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 2015/10/02 12:57:16 UTC

[Bug 58471] New: [PATCH] Format numbers more like Excel

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

            Bug ID: 58471
           Summary: [PATCH] Format numbers more like Excel
           Product: POI
           Version: unspecified
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: SS Common
          Assignee: dev@poi.apache.org
          Reporter: cmb-apache@corefiling.co.uk

Created attachment 33155
  --> https://bz.apache.org/bugzilla/attachment.cgi?id=33155&action=edit
Patch to format numbers more like Excel

The current DataFormatter differs slightly from Excel's formatting, which is
documented at https://support.microsoft.com/en-us/kb/65903 (Summary, 3rd
sentence onward) regarding when to use scientific notation and counting the
decimal point towards the character limit. It also differs on rounding mode,
which in Excel appears to be HALF_UP (this does not appear to be documented).

I attach a patch adding and using a new ExcelGeneralNumberFormat which matches
Excel in a variety of test cases. This is useful for users who want to
construct an error message quoting the cell value as it would be shown in
Excel.

Note that this all matches the longest string Excel will display given a
sufficiently wide cell. In the default cell width, it uses a smaller number of
characters, and I don't know if that number and/or the cell width vary with
display settings/DPI, accessibility settings, available fonts, etc., so the
wide-cell value seemed the best thing to target.

-- 
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 58471] [PATCH] Format numbers more like Excel

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

--- Comment #1 from Chris Boyle <cm...@corefiling.co.uk> ---
I've belatedly noticed that POI does already use HALF_UP in at least some
circumstances, but I think the rest stands.

-- 
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 58471] [PATCH] Format numbers more like Excel

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

Chris Boyle <cm...@corefiling.co.uk> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
  Attachment #33155|0                           |1
        is obsolete|                            |

--- Comment #3 from Chris Boyle <cm...@corefiling.co.uk> ---
Created attachment 33165
  --> https://bz.apache.org/bugzilla/attachment.cgi?id=33165&action=edit
Format numbers more like Excel does, v2

Replacement patch attached. Compared to the previous patch, it:

* Adds @Test so the new test actually gets run.
* Chooses better test decimals that are representable as ending in 5 as
intended not 49999[...].
* Adds missing invocation of DataFormatter.setExcelStyleRoundingMode() on the
new formatter's child DecimalFormats.

-- 
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 58471] [PATCH] Format numbers more like Excel

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

--- Comment #2 from Chris Boyle <cm...@corefiling.co.uk> ---
Hold fire on this, my forward-port and tidying-up missed that test methods now
need the @Test annotation, so TestDataFormatter.testLargeNumbersAndENotation()
will not actually get run in the currently attached patch, and it fails. I will
supply a replacement patch shortly.

-- 
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 58471] [PATCH] Format numbers more like Excel

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

David North <dt...@corefiling.co.uk> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
             Status|NEW                         |RESOLVED

--- Comment #4 from David North <dt...@corefiling.co.uk> ---
Looks like an improvement to me

Committed in r1706971, release notes in r1706972

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