Bug 57202 - Upgrading from POI 3.9 to 3.10.1 giving invalid fraction value in csv
Summary: Upgrading from POI 3.9 to 3.10.1 giving invalid fraction value in csv
Alias: None
Product: POI
Classification: Unclassified
Component: SS Common (show other bugs)
Version: 3.10-FINAL
Hardware: PC All
: P2 regression (vote)
Target Milestone: ---
Assignee: POI Developers List
Depends on:
Reported: 2014-11-12 11:25 UTC by Kushal
Modified: 2016-08-13 20:47 UTC (History)
1 user (show)


Note You need to log in before you can comment on or make changes to this bug.
Description Kushal 2014-11-12 11:25:09 UTC
We are trying to upgrade our POI implementation from 3.9 version to 3.10.1, when doing so we encountered the below problem. 

Excel fraction value getting converted incorrectly in csv file. Sample input 

Cell format in Excel : Fraction - Up to one digit (1/4)
Cell value in Excel : 44022813230178
Displayed value in Excel : 44022813230178

In Apache POI 3.9 version converted csv file for the about input file is

POI 3.9 csv file value : 44022813230178

Where as in POI 3.10-FINAL and 3.10.1 versions the output is incorrect

POI 3.10.1 and 3.10-FINAL csv value : 2147483647

Java code used 
formatter = new DataFormatter(true);

When i debug into the code of org.apache.poi.ss.usermodel.FractionFormat class, in the method format(Number num) I see a possible bug. The double value is getting converted into 'int'. 

In the line number 123, sb.append(Integer.toString((int)wholePart));  there are multiple palaces where its converted to 'int'.
Comment 1 Nick Burch 2014-11-12 11:42:29 UTC
Can you retry with 3.11 beta 3?

(Should be on all popular mirrors + maven central within the next 12 hours)

Also, it'd be helpful to know what POI thinks the format string is that applies to the problematic cell
Comment 2 Kushal 2014-11-12 12:06:59 UTC
I even tried with 3.11-beta2 (as that's the latest maven available), still getting the same result as 3.10-FINAL. 

The format string POI applies to that cell is : # ?/?

Will wait for 3.11-beta3 version and update the same.
Comment 3 Tim Allison 2014-11-12 16:16:43 UTC
Thank you for submitting this issue.  Y, we should switch to long, and we may need to convert the fraction calculation to BigDecimal, iirc.  I should have a patch by the end of the week.
Comment 4 Dominik Stadler 2016-03-26 12:54:13 UTC
Please state if this is still a problem on 3.14 or latest trunk.
Comment 5 Dominik Stadler 2016-08-13 20:47:13 UTC
No update for several months, thus I am closing this as WORKSFORME for now, please reopen this bug if there is still a problem with a current version of POI.