[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
This commit is contained in:
PJ Fanning 2021-10-11 10:45:59 +00:00
parent cdbbbb6726
commit 700ecc461f
8 changed files with 39 additions and 0 deletions

View File

@ -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());
}
}
}
}
}

Binary file not shown.