https://issues.apache.org/bugzilla/show_bug.cgi?id=53150
Bug #: 53150
Summary: DataFormatter Fractions for Whole Numbers
Product: POI
Version: 3.8
Platform: PC
OS/Version: Windows XP
Status: NEW
Severity: normal
Priority: P2
Component: POI Overall
AssignedTo: [email protected]
ReportedBy: [email protected]
Classification: Unclassified
There are two issues with formatting fractions with a numerator value of 0 -
For example, format 1.0 as a fraction yields with 1 digit numerator and
denominators yields "1 1/9".
1.
This junit patch (to TestDataFormatter.java:testFractions) demonstrates the
issue:
assertEquals("1 0/9", dfUS.formatRawCellContents(1.0, -1, "# #/#"));
I believe the solution to the following is:
In org.apache.poi.ss.usermodel.DataFormatter$FractionFormat, near line 1009:
for(int i2 = (int)(Math.pow(10, fractParts[1].length())- 1d); i2 > 0; i2--){
That loop's test should be i2 >= 0.
Was numerator meant to be abbreviated as num, instead of neum?
2. In Excel 2003, 1.0 with a format of "# #/#" gets written as "1 " (the
fraction's digits are replaced by spaces and no / is written). I would expect
some kind of emulateCsv support to handle this if it's decided that the
solution to step #1 above is to print fractions as 0/d.
--
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]