From a24820e629dc37b3f3b78aa69602fc7a99ccf1bd Mon Sep 17 00:00:00 2001 From: PJ Fanning Date: Wed, 8 Dec 2021 19:27:09 +0000 Subject: [PATCH] add data-formatter test git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1895706 13f79535-47bb-0310-9956-ffa450edef68 --- .../poi/xssf/usermodel/TestXSSFDataFormat.java | 13 +++++++++++++ test-data/spreadsheet/formula-eval.xlsx | Bin 0 -> 8369 bytes 2 files changed, 13 insertions(+) create mode 100644 test-data/spreadsheet/formula-eval.xlsx 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 0000000000000000000000000000000000000000..198c6b5e0724f31303f489160deb6d9aaded97b1 GIT binary patch literal 8369 zcmeHMgx(b?ZtA?&F%sQ$bq{h^^`458t}I7?TLAPI&ztmQBy}d@6q8voq=*N;O`Pw0&gc_^ zj+?JLh!k<%@kN690IxwaUpXXJZd7$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