From 766300e0338a383984058bff44ab6a24eaa897ea Mon Sep 17 00:00:00 2001 From: Dominik Stadler Date: Mon, 22 Dec 2014 07:57:03 +0000 Subject: [PATCH] Bug 57236: Add reproducer, although I am not sure if we should and how to fix this... git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1647254 13f79535-47bb-0310-9956-ffa450edef68 --- .../poi/xssf/usermodel/TestUnfixedBugs.java | 30 ++++++++++++++++++ test-data/spreadsheet/57236.xlsx | Bin 0 -> 8870 bytes 2 files changed, 30 insertions(+) create mode 100644 test-data/spreadsheet/57236.xlsx diff --git a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestUnfixedBugs.java b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestUnfixedBugs.java index 2d91e8400d..96f42f554c 100644 --- a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestUnfixedBugs.java +++ b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestUnfixedBugs.java @@ -25,6 +25,7 @@ import junit.framework.TestCase; import org.apache.poi.hssf.HSSFTestDataSamples; import org.apache.poi.ss.usermodel.Cell; +import org.apache.poi.ss.usermodel.DataFormatter; import org.apache.poi.ss.usermodel.Row; import org.apache.poi.ss.usermodel.Sheet; import org.apache.poi.ss.usermodel.Workbook; @@ -104,4 +105,33 @@ public final class TestUnfixedBugs extends TestCase { } } } + + + public void test57236() { + // Having very small numbers leads to different formatting, Excel uses the scientific notation, but POI leads to "0" + + /* + DecimalFormat format = new DecimalFormat("#.##########", new DecimalFormatSymbols(Locale.getDefault())); + double d = 3.0E-104; + assertEquals("3.0E-104", format.format(d)); + */ + + DataFormatter formatter = new DataFormatter(true); + + XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("57236.xlsx"); + for(int sheetNum = 0;sheetNum < wb.getNumberOfSheets();sheetNum++) { + Sheet sheet = wb.getSheetAt(sheetNum); + for(int rowNum = sheet.getFirstRowNum();rowNum < sheet.getLastRowNum();rowNum++) { + Row row = sheet.getRow(rowNum); + for(int cellNum = row.getFirstCellNum();cellNum < row.getLastCellNum();cellNum++) { + Cell cell = row.getCell(cellNum); + String fmtCellValue = formatter.formatCellValue(cell); + + System.out.println("Cell: " + fmtCellValue); + assertNotNull(fmtCellValue); + assertFalse(fmtCellValue.equals("0")); + } + } + } + } } diff --git a/test-data/spreadsheet/57236.xlsx b/test-data/spreadsheet/57236.xlsx new file mode 100644 index 0000000000000000000000000000000000000000..656884784e36f0883ea135390805128ec1b4efe9 GIT binary patch literal 8870 zcmeHMWmJ^w+Mc1iLxz?H=>btfLKGMp>2T=oPNh2?x}-!}r6nAM0YN||rTZJ* zXCK{c&syL5etdtE2vQbS>{1)C57n>jqr+X3DeZ--vmwapNKM6yv$4N%f^HV zCgaA&?13yg2VHn988BMsW7)G~p{8{D_`)CwNft_0i+HY+7DjAng85-)=hO@6xNiZ3 zD)PaNvXhl0M_Lj0XP}q0yuix017ORhy``Sgo}99CXYv!Yxx;{&?a%$xMJ zu?5VMhX*03K?SiW2$M28^x7o=`nE{{Z_W9@b8$ z$}Kk8VS|O~i&-jhB6eI=4_0#Y;$87KNmY)K%pnyW^!OxWfm<>%`#eK>P(GM^H*12p z|Ma>kY7Q&hKxOZ;PQ>{-Byv=4VOIDp=jcr|<{FlL$Yh*V=dDrsIu>MqN6?K;xgl|^JxNq(8q-c1Wbkj?l zDWf27J@T+{p0EHMyx9Gu^QDXf8Wn8bO;e6uPk4CNoXHOE@BHjm*tnMw(kh&hewGkv z8b}NJ)plak2ay~jYGK+TOxb!@avD@B&w>_VL_|^~p6NBA%)0?7e(m6 zV#kUSI%}33jTNzK8?WYubsak_Y^a}@*!}!E=R5yVnAKue!2_U~0-Fe&B7mmhS(_uQ zXJd|?N-brd^&xGdYQ(*8A-HI@sgd8?;~E(cH9NAJi&OQRNnKi0*0Zo-k$b*kDobeS zHO{q~0x&tD=FC0Ik*6N!5vfUW*@mONfSq)m$jHt4Ce`qxqNXNk)S2eS&YrU63e%&| z6-ujhU+^WVc$1_lqQF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