]> source.dussan.org Git - poi.git/commitdiff
[github-321] add test case
authorPJ Fanning <fanningpj@apache.org>
Fri, 8 Apr 2022 13:08:10 +0000 (13:08 +0000)
committerPJ Fanning <fanningpj@apache.org>
Fri, 8 Apr 2022 13:08:10 +0000 (13:08 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1899667 13f79535-47bb-0310-9956-ffa450edef68

poi-ooxml/src/test/java/org/apache/poi/xssf/usermodel/TestXSSFWorkbook.java
test-data/spreadsheet/github-321.xlsx [new file with mode: 0644]

index 235d16116a1624f59b370f98a41d1d84142ce6d7..3a7fa17d30f1219879de9d16eb8947c822e18fdb 100644 (file)
@@ -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
new file mode 100644 (file)
index 0000000..0b517e9
Binary files /dev/null and b/test-data/spreadsheet/github-321.xlsx differ