https://bz.apache.org/bugzilla/show_bug.cgi?id=57738

            Bug ID: 57738
           Summary: XSSFSheetXmlHandler returns incorrect values for
                    numeric cells
           Product: POI
           Version: 3.11-FINAL
          Hardware: Macintosh
                OS: Mac OS X 10.4
            Status: NEW
          Severity: normal
          Priority: P2
         Component: XSSF
          Assignee: [email protected]
          Reporter: [email protected]

When reading a spreadsheet containing certain numbers (for example 8.2), the
XSSFSheetXmlHandler will output the incorrect value. 

I believe this is due to an error in the NUMBER case of the method endElement,
where formatted cells are parsed as doubles, but unformatted cells simply
return the internal value, which for reasons I don't understand, is 8.1999...
rather than 8.2. It appears that simply converting these into Doubles will
return the correct value. 

We don't currently have a work around - since this needs to happen only when
the value is a number, in order to distinguish strings like '012' from numbers
like '12' we can't simply attempt to parse all strings passed to output.cell. 

I'm unfamiliar with how to use SVN and create patches, but the following code
seems to fix the problem:

case NUMBER:
    String n = value.toString();
if (this.formatString != null) {
    thisStr = formatter.formatRawCellContents(Double.parseDouble(n),
this.formatIndex, this.formatString);
} else {
    DecimalFormat df = new DecimalFormat("0");
    df.setMaximumFractionDigits(340);
    thisStr = df.format(Double.parseDouble(n));
}

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

Reply via email to