Bug 57236 - DataFormatter, invalid conversion of General String value
Summary: DataFormatter, invalid conversion of General String value
Alias: None
Product: POI
Classification: Unclassified
Component: SS Common (show other bugs)
Version: 3.10-FINAL
Hardware: PC All
: P2 major (vote)
Target Milestone: ---
Assignee: POI Developers List
Depends on:
Reported: 2014-11-19 10:33 UTC by Kushal
Modified: 2016-01-02 21:16 UTC (History)
1 user (show)

Input FIles (8.66 KB, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet)
2014-11-19 10:33 UTC, Kushal

Note You need to log in before you can comment on or make changes to this bug.
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

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
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.