Bug 53859 - DataFormatter Numeric cell value extra digits
Summary: DataFormatter Numeric cell value extra digits
Status: RESOLVED FIXED
Alias: None
Product: POI
Classification: Unclassified
Component: XSSF (show other bugs)
Version: 3.8-FINAL
Hardware: PC Windows Vista
: P2 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-09-12 12:10 UTC by Sebas
Modified: 2016-01-22 05:09 UTC (History)
0 users



Attachments
Contains the described formula (7.14 KB, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet)
2012-09-18 14:56 UTC, Sebas
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Sebas 2012-09-12 12:10:37 UTC
Type 1612.44/3600 in a cell, Excel displays 0.4479, the stored value is 

<f>1612.44/3600</f>
<v>0.44790000000000002</v>

DataFormatter will show 0.44790000000000002 instead of 0.4479

To verify that it was not a problem in my code I have run the example org.apache.poi.xssf.eventusermodel.XLSX2CSV, the behavior is the same.

The problem seems to be that when the cell doesn't have any format string associated, DataFormatter doesn't apply the General formatter.
To test that I added some code at the end of XLSX2CSV.MyXSSFSheetHandler.startElement

[code]
public void startElement(String uri, String localName, String name,
                         Attributes attributes) throws SAXException {
   ...
   else if ("c".equals(name)) {
   ...
      else if (cellStyleStr == null){
         this.formatString="General";
      }
   } 
}
[/code]

With that modification the output is 0.4479
Comment 1 Sebas 2012-09-18 14:56:14 UTC
Created attachment 29382 [details]
Contains the described formula
Comment 2 Javen O'Neal 2016-01-22 05:09:20 UTC
Fixed by bug 57951.

See Bug 58883 comment 6 for an explanation.