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

            Bug ID: 62865
           Summary: Dot in user-defined number format is removed
           Product: POI
           Version: 4.0.0-FINAL
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: SS Common
          Assignee: dev@poi.apache.org
          Reporter: p...@table2web.de
  Target Milestone: ---

Created attachment 36222
  --> https://bz.apache.org/bugzilla/attachment.cgi?id=36222&action=edit
File with user-defined formats

When I format a numeric cell in Excel 365 or in LibreOffice 6.1.2.1 (the
behavior is in both the same) with user-defined format code
"ca. "0
(the whole line is the format code, not just that between the quotes), then
Excel and LibreOffice show for example "ca. 5" as a result in that cell.

POI's behavior is that "new DataFormatter(Locale.US).formatCellValue(cell,
formulaEvaluator)" returns "ca5.0".

It seems to me that java.text.DecimalFormat.applyPattern(String, boolean)
removes that dot, because it thinks to be in phase 1 (digits-phase), instead of
being in phase 0 (prefix-phase).

I think that
org.apache.poi.ss.usermodel.DataFormatter.createNumberFormat(String, double)
should not remove the quote-signs from formatStr, so that the call of "new
InternalDecimalFormatWithScale(format, symbols)" still contains information
about the prefix-phase.


Attached is a file with three cells:
- one user-formatted with no dot ("ca "0 -- POI formats that ok as "ca 5")
- one user-formatted with one dot ("ca. "0 -- POI formats that nok as "ca5.0")
- one user-formatted with two dots ("ca.. "0 -- POI formats that nok as "5" --
and java.text.DecimalFormat.applyPattern(String, boolean) throws an
IllegalArgumentException("Multiple decimal separators in pattern \"" + pattern
+ '"'))

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

Reply via email to