summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPJ Fanning <fanningpj@apache.org>2021-12-08 19:27:09 +0000
committerPJ Fanning <fanningpj@apache.org>2021-12-08 19:27:09 +0000
commita24820e629dc37b3f3b78aa69602fc7a99ccf1bd (patch)
treefd6199fc9601cce671a0becda141643ac85b85a9
parentea9883af5500f5f92f3c3b3d056f82fc52b2ff16 (diff)
downloadpoi-a24820e629dc37b3f3b78aa69602fc7a99ccf1bd.tar.gz
poi-a24820e629dc37b3f3b78aa69602fc7a99ccf1bd.zip
add data-formatter test
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1895706 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--poi-ooxml/src/test/java/org/apache/poi/xssf/usermodel/TestXSSFDataFormat.java13
-rw-r--r--test-data/spreadsheet/formula-eval.xlsxbin0 -> 8369 bytes
2 files changed, 13 insertions, 0 deletions
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
--- /dev/null
+++ b/test-data/spreadsheet/formula-eval.xlsx
Binary files differ