Bug 57236

Summary: DataFormatter, invalid conversion of General String value
Product: POI Reporter: Kushal <Kushal.j1987>
Component: SS CommonAssignee: POI Developers List <dev>
Status: RESOLVED WORKSFORME    
Severity: major CC: Kushal.j1987
Priority: P2    
Version: 3.10-FINAL   
Target Milestone: ---   
Hardware: PC   
OS: All   
Attachments: Input FIles

Description Kushal 2014-11-19 10:33:33 UTC
Created attachment 32214 [details]
Input FIles

We are facing a issue when we are trying to convert an excel file with below values to csv file.

Cell value : 3E-104
5E-104
5E-106

All the above values are getting converted to 0 , in a csv . Cell format in MS Excel is 'General'

Java code used for the conversion

DataFormatter formatter = new DataFormatter(true);
String fmtCellValue = formatter.formatCellValue(cell);

I am attaching the sample of excel file.

Versions tested : POI - 3.9, 3.10-Final, 3.10.1, 3.11-beta3
Comment 1 Kushal 2014-11-26 05:58:15 UTC
Hi,
Any update on this issue?
Comment 2 Dominik Stadler 2014-12-19 14:48:36 UTC
Can you post your code? Preferrably as simple unit-test, so we can reproduce. I tried quickly, but could not reproduce your problem with the sample file given.
Comment 3 Dominik Stadler 2014-12-22 08:00:32 UTC
I could reproduce it now, FYI, POI internally does the following, which fails for such small numbers:

        DecimalFormat format = new DecimalFormat("#.##########", new DecimalFormatSymbols(Locale.getDefault()));
        double d = 3.0E-104;
        
        assertEquals("3.0E-104", format.format(d));
Comment 4 Dominik Stadler 2016-01-02 21:16:38 UTC
This seems to have been fixed with some previous change, maybe changes for bug 58471 made it work. I have enabled the previously disabled unit test via r1722666 to verify that it works now.