From: PJ Fanning Date: Mon, 11 Oct 2021 10:45:59 +0000 (+0000) Subject: [bug-62215] add test case for sxssf formulas - issue was already fixed X-Git-Tag: REL_5_2_0~400 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=700ecc461f2fa00aac5655ac31b163d584fc9ad1;p=poi.git [bug-62215] add test case for sxssf formulas - issue was already fixed git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1894128 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/poi-ooxml-full/src/main/java9/module-info.class b/poi-ooxml-full/src/main/java9/module-info.class index 34e3970b88..e922419617 100644 Binary files a/poi-ooxml-full/src/main/java9/module-info.class and b/poi-ooxml-full/src/main/java9/module-info.class differ diff --git a/poi-ooxml-lite-agent/src/main/java9/module-info.class b/poi-ooxml-lite-agent/src/main/java9/module-info.class index 7839f4047c..8b45606400 100644 Binary files a/poi-ooxml-lite-agent/src/main/java9/module-info.class and b/poi-ooxml-lite-agent/src/main/java9/module-info.class differ diff --git a/poi-ooxml/src/main/java9/module-info.class b/poi-ooxml/src/main/java9/module-info.class index fd29b43f37..f4db29c614 100644 Binary files a/poi-ooxml/src/main/java9/module-info.class and b/poi-ooxml/src/main/java9/module-info.class differ diff --git a/poi-ooxml/src/test/java/org/apache/poi/xssf/usermodel/TestSXSSFBugs.java b/poi-ooxml/src/test/java/org/apache/poi/xssf/usermodel/TestSXSSFBugs.java index 432444f044..a9dbe077ec 100644 --- a/poi-ooxml/src/test/java/org/apache/poi/xssf/usermodel/TestSXSSFBugs.java +++ b/poi-ooxml/src/test/java/org/apache/poi/xssf/usermodel/TestSXSSFBugs.java @@ -274,4 +274,43 @@ public final class TestSXSSFBugs extends BaseTestBugzillaIssues { } } } + + @Test + public void test62215() throws IOException { + String sheetName = "1"; + int rowIndex = 0; + int colIndex = 0; + String formula = "1"; + String value = "yes"; + CellType valueType = CellType.STRING; + + try (Workbook wb = new SXSSFWorkbook()) { + Sheet sheet = wb.createSheet(sheetName); + Row row = sheet.createRow(rowIndex); + Cell cell = row.createCell(colIndex); + + // this order ensures that value will not be overwritten by setting the formula + cell.setCellFormula(formula); + cell.setCellValue(value); + + assertEquals(CellType.FORMULA, cell.getCellType()); + assertEquals(formula, cell.getCellFormula()); + assertEquals(valueType, cell.getCachedFormulaResultType()); + assertEquals(value, cell.getStringCellValue()); + // so far so good + + try (UnsynchronizedByteArrayOutputStream bos = new UnsynchronizedByteArrayOutputStream()){ + wb.write(bos); + + try (XSSFWorkbook testWb = new XSSFWorkbook(bos.toInputStream())) { + Cell testCell = testWb.getSheet(sheetName).getRow(rowIndex).getCell(colIndex); + assertEquals(CellType.FORMULA, testCell.getCellType()); + assertEquals(formula, testCell.getCellFormula()); + + assertEquals(CellType.STRING, testCell.getCachedFormulaResultType()); + assertEquals(value, testCell.getStringCellValue()); + } + } + } + } } diff --git a/poi-ooxml/src/test/java9/module-info.class b/poi-ooxml/src/test/java9/module-info.class index 012028ad0b..2cd55eb942 100644 Binary files a/poi-ooxml/src/test/java9/module-info.class and b/poi-ooxml/src/test/java9/module-info.class differ diff --git a/poi-scratchpad/src/main/java9/module-info.class b/poi-scratchpad/src/main/java9/module-info.class index 53efc695f7..72189ac318 100644 Binary files a/poi-scratchpad/src/main/java9/module-info.class and b/poi-scratchpad/src/main/java9/module-info.class differ diff --git a/poi-scratchpad/src/test/java9/module-info.class b/poi-scratchpad/src/test/java9/module-info.class index e4d2abd3d2..f5349bb241 100644 Binary files a/poi-scratchpad/src/test/java9/module-info.class and b/poi-scratchpad/src/test/java9/module-info.class differ diff --git a/poi/src/test/java9/module-info.class b/poi/src/test/java9/module-info.class index b145aa3bb7..028b943d0a 100644 Binary files a/poi/src/test/java9/module-info.class and b/poi/src/test/java9/module-info.class differ