From: Dominik Stadler
To change the style of a cell without affecting other cells that use the same style, - * use {@link org.apache.poi.ss.util.CellUtil#setCellStyleProperties(org.apache.poi.ss.usermodel.Cell, Map)}
+ * use {@link org.apache.poi.ss.util.CellUtil#setCellStyleProperties(org.apache.poi.ss.usermodel.Cell, java.util.Map)} * * @param style reference contained in the workbook * @see org.apache.poi.hssf.usermodel.HSSFWorkbook#createCellStyle() diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java b/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java index 078008a899..7cc9b4ea59 100644 --- a/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java +++ b/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java @@ -2977,4 +2977,28 @@ public final class TestBugs extends BaseTestBugzillaIssues { wb.close(); } + + @Test + public void test55668() throws IOException { + Workbook wb = HSSFTestDataSamples.openSampleWorkbook("55668.xls"); + + Sheet sheet = wb.getSheetAt(0); + Row row = sheet.getRow(0); + Cell cell = row.getCell(0); + assertEquals(Cell.CELL_TYPE_FORMULA, cell.getCellType()); + assertEquals("IF(TRUE,\"\",\"\")", cell.getCellFormula()); + assertEquals("", cell.getStringCellValue()); + cell.setCellType(Cell.CELL_TYPE_STRING); + + assertEquals(Cell.CELL_TYPE_BLANK, cell.getCellType()); + try { + assertNull(cell.getCellFormula()); + fail("Should throw an exception here"); + } catch (IllegalStateException e) { + // expected here + } + assertEquals("", cell.getStringCellValue()); + + wb.close(); + } } diff --git a/test-data/spreadsheet/55668.xls b/test-data/spreadsheet/55668.xls new file mode 100644 index 0000000000..8aa8f50427 Binary files /dev/null and b/test-data/spreadsheet/55668.xls differ