From: PJ Fanning Date: Wed, 8 Dec 2021 19:27:09 +0000 (+0000) Subject: add data-formatter test X-Git-Tag: REL_5_2_0~99 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=a24820e629dc37b3f3b78aa69602fc7a99ccf1bd;p=poi.git add data-formatter test git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1895706 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/poi-ooxml/src/test/java/org/apache/poi/xssf/usermodel/TestXSSFDataFormat.java b/poi-ooxml/src/test/java/org/apache/poi/xssf/usermodel/TestXSSFDataFormat.java index 5147e1f843..fe4aa0a00a 100644 --- a/poi-ooxml/src/test/java/org/apache/poi/xssf/usermodel/TestXSSFDataFormat.java +++ b/poi-ooxml/src/test/java/org/apache/poi/xssf/usermodel/TestXSSFDataFormat.java @@ -107,4 +107,17 @@ public final class TestXSSFDataFormat extends BaseTestDataFormat { assertEquals("1000", formatter.formatCellValue(cell, evaluator)); } } + + @Test + void testSetUseCachedValuesForFormulaCells() throws Exception { + try (XSSFWorkbook wb = openSampleWorkbook("formula-eval.xlsx")) { + final DataFormatter formatter = new DataFormatter(); + XSSFSheet sheet = wb.getSheetAt(0); + XSSFRow row = sheet.getRow(0); + XSSFCell d1 = row.getCell(3); + assertEquals("SUM(A1:C1)", formatter.formatCellValue(d1)); + formatter.setUseCachedValuesForFormulaCells(true); + assertEquals("6.75", formatter.formatCellValue(d1)); + } + } } diff --git a/test-data/spreadsheet/formula-eval.xlsx b/test-data/spreadsheet/formula-eval.xlsx new file mode 100644 index 0000000000..198c6b5e07 Binary files /dev/null and b/test-data/spreadsheet/formula-eval.xlsx differ