diff options
-rw-r--r-- | poi-ooxml/src/test/java/org/apache/poi/xssf/usermodel/TestXSSFWorkbook.java | 16 | ||||
-rw-r--r-- | test-data/spreadsheet/github-321.xlsx | bin | 0 -> 8122 bytes |
2 files changed, 16 insertions, 0 deletions
diff --git a/poi-ooxml/src/test/java/org/apache/poi/xssf/usermodel/TestXSSFWorkbook.java b/poi-ooxml/src/test/java/org/apache/poi/xssf/usermodel/TestXSSFWorkbook.java index 235d16116a..3a7fa17d30 100644 --- a/poi-ooxml/src/test/java/org/apache/poi/xssf/usermodel/TestXSSFWorkbook.java +++ b/poi-ooxml/src/test/java/org/apache/poi/xssf/usermodel/TestXSSFWorkbook.java @@ -43,6 +43,7 @@ import org.apache.poi.ss.usermodel.Comment; import org.apache.poi.ss.usermodel.DataFormatter; import org.apache.poi.ss.usermodel.Font; import org.apache.poi.ss.usermodel.FormulaError; +import org.apache.poi.ss.usermodel.FormulaEvaluator; import org.apache.poi.ss.usermodel.RichTextString; import org.apache.poi.ss.usermodel.Row; import org.apache.poi.ss.usermodel.Row.MissingCellPolicy; @@ -1398,6 +1399,21 @@ public final class TestXSSFWorkbook extends BaseTestXWorkbook { } } + @Test + void testGithub321() throws Exception { + try (XSSFWorkbook wb = openSampleWorkbook("github-321.xlsx")) { + XSSFSheet xssfSheet = wb.getSheetAt(0); + DataFormatter dataFormatter = new DataFormatter(); + FormulaEvaluator formulaEvaluator = wb.getCreationHelper().createFormulaEvaluator(); + XSSFCell a3 = xssfSheet.getRow(2).getCell(0); + assertEquals("2.05", dataFormatter.formatCellValue(a3)); + assertEquals("2.05", dataFormatter.formatCellValue(a3, formulaEvaluator)); + XSSFCell a4 = xssfSheet.getRow(3).getCell(0); + assertEquals("2.1", dataFormatter.formatCellValue(a4)); + assertEquals("2.1", dataFormatter.formatCellValue(a4, formulaEvaluator)); + } + } + private static void expectFormattedContent(Cell cell, String value) { assertEquals(value, new DataFormatter().formatCellValue(cell), "Cell " + ref(cell) + " has wrong formatted content."); diff --git a/test-data/spreadsheet/github-321.xlsx b/test-data/spreadsheet/github-321.xlsx Binary files differnew file mode 100644 index 0000000000..0b517e9eaa --- /dev/null +++ b/test-data/spreadsheet/github-321.xlsx |