]> source.dussan.org Git - poi.git/commitdiff
Bug 57236: Add reproducer, although I am not sure if we should and how to fix this...
authorDominik Stadler <centic@apache.org>
Mon, 22 Dec 2014 07:57:03 +0000 (07:57 +0000)
committerDominik Stadler <centic@apache.org>
Mon, 22 Dec 2014 07:57:03 +0000 (07:57 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1647254 13f79535-47bb-0310-9956-ffa450edef68

src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestUnfixedBugs.java
test-data/spreadsheet/57236.xlsx [new file with mode: 0644]

index 2d91e8400dd5e67c74f4fd973d3555c412cfa3a7..96f42f554cabd6e1f5115cca82462711455a9cc3 100644 (file)
@@ -25,6 +25,7 @@ import junit.framework.TestCase;
 \r
 import org.apache.poi.hssf.HSSFTestDataSamples;\r
 import org.apache.poi.ss.usermodel.Cell;\r
+import org.apache.poi.ss.usermodel.DataFormatter;\r
 import org.apache.poi.ss.usermodel.Row;\r
 import org.apache.poi.ss.usermodel.Sheet;\r
 import org.apache.poi.ss.usermodel.Workbook;\r
@@ -104,4 +105,33 @@ public final class TestUnfixedBugs extends TestCase {
             }\r
         }\r
     }\r
+\r
+\r
+    public void test57236() {\r
+        // Having very small numbers leads to different formatting, Excel uses the scientific notation, but POI leads to "0"\r
+        \r
+        /*\r
+        DecimalFormat format = new DecimalFormat("#.##########", new DecimalFormatSymbols(Locale.getDefault()));\r
+        double d = 3.0E-104;\r
+        assertEquals("3.0E-104", format.format(d));\r
+         */\r
+        \r
+        DataFormatter formatter = new DataFormatter(true);\r
+\r
+        XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("57236.xlsx");\r
+        for(int sheetNum = 0;sheetNum < wb.getNumberOfSheets();sheetNum++) {\r
+            Sheet sheet = wb.getSheetAt(sheetNum);\r
+            for(int rowNum = sheet.getFirstRowNum();rowNum < sheet.getLastRowNum();rowNum++) {\r
+                Row row = sheet.getRow(rowNum);\r
+                for(int cellNum = row.getFirstCellNum();cellNum < row.getLastCellNum();cellNum++) {\r
+                    Cell cell = row.getCell(cellNum);\r
+                    String fmtCellValue = formatter.formatCellValue(cell);\r
+                    \r
+                    System.out.println("Cell: " + fmtCellValue);\r
+                    assertNotNull(fmtCellValue);\r
+                    assertFalse(fmtCellValue.equals("0"));\r
+                }\r
+            }\r
+        }\r
+    }\r
 }\r
diff --git a/test-data/spreadsheet/57236.xlsx b/test-data/spreadsheet/57236.xlsx
new file mode 100644 (file)
index 0000000..6568847
Binary files /dev/null and b/test-data/spreadsheet/57236.xlsx differ