You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@poi.apache.org by bu...@apache.org on 2016/11/08 17:03:20 UTC

[Bug 60354] New: DataFormatter rounding issues

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

            Bug ID: 60354
           Summary: DataFormatter rounding issues
           Product: POI
           Version: 3.15-FINAL
          Hardware: PC
                OS: Mac OS X 10.1
            Status: NEW
          Severity: normal
          Priority: P2
         Component: SL Common
          Assignee: dev@poi.apache.org
          Reporter: fanningpj@yahoo.com
  Target Milestone: ---

I've run into some issues where converting numbers into Double leads to
rounding issues. I would like to subclass
org.apache.poi.ss.usermodel.DataFormatter to avoid converting numbers to
Double. A lot of DataFormatter functionality is private. Would it be possible
to change some methods to be protected? getFormattedDateString and
getFormattedNumberString are examples of methods that it would be nice to have
as protected so that I don't have to copy/paste the code into my subclass.

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


[Bug 60354] DataFormatter rounding issues

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=60354

--- Comment #2 from PJ Fanning <fa...@yahoo.com> ---
This issue may be down to my own confusion. We used to have a streaming parser
based on the FromHowTo sample in POI and this code ran into rounding problems.
This appears to be because the worksheet XML actually has the numeric data
already stored as a badly rounded value.
This code does not use the DataFormatter.
For a cell that my workbook displays 9.20 for, the XML in the worksheet has:
<c r="C1" s="2"><v>9.1999999999999993</v></c>

We have now switched to an approach more like the XLSX2CSV POI sample but I've
been wary about equivalent rounding issues and this is why I was interested in
writing a custom DataFormatter to avoid using floating point precision. But it
would appear that the Double logic is actually necessary to handle the fact
that the Excel sheet data doesn't have the actual '9.20' value but an
approximation of it.

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


[Bug 60354] DataFormatter rounding issues

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=60354

PJ Fanning <fa...@yahoo.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |INVALID
             Status|NEEDINFO                    |RESOLVED

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


[Bug 60354] DataFormatter rounding issues

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=60354

Nick Burch <ap...@gagravarr.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |NEEDINFO

--- Comment #1 from Nick Burch <ap...@gagravarr.org> ---
If DataFormatter is rounding things incorrectly compared to Excel, it'd be
better to fix the bug, rather than requiring everyone to subclass it to do
their own fixes!

Can you produce a small sample file and junit unit test, where DataFormatter
formats a cell with different rounding to what Excel does?

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org