Bug 65644 - [PATCH] Improved regex for Excel accounting formats
Summary: [PATCH] Improved regex for Excel accounting formats
Status: RESOLVED FIXED
Alias: None
Product: POI
Classification: Unclassified
Component: SS Common (show other bugs)
Version: 4.1.2-FINAL
Hardware: PC All
: P2 major (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-10-19 18:04 UTC by Adam DeSapio
Modified: 2021-10-19 23:34 UTC (History)
0 users



Attachments
Patch file for CellFormatPart.java and TestCellFormatter.java (5.03 KB, patch)
2021-10-19 18:04 UTC, Adam DeSapio
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Adam DeSapio 2021-10-19 18:04:52 UTC
Created attachment 38074 [details]
Patch file for CellFormatPart.java and TestCellFormatter.java

Excel uses the following format codes under Format Cells > Number > Accounting

R English (South Africa) (0 decimal places)
"_-[$R-1C09]* #,##0_-;\-[$R-1C09]* #,##0_-;_-[$R-1C09]* "-"??_-;_-@_-"

USD (0 decimal places)
"_([$USD]\ * #,##0_);_([$USD]\ * \(#,##0\);_([$USD]\ * "-"_);_(@_)"

POI handles [$x-xxx] but not [$x-xxxx] or [$xxx].

The provided .patch file 
1. Improves upon the regex used by handling these 2 different formats.
2. Extends accounting test case to include these scenarios.

Found in version 4.2.1; affects latest.
Comment 1 PJ Fanning 2021-10-19 18:16:08 UTC
Why did you create a patch against an out of date POI directory structure? We only accept patches for the latest code and directory structure.
Comment 2 Adam DeSapio 2021-10-19 18:24:30 UTC
My apologies, I referenced http://poi.apache.org/devel/guidelines.html#SubmittingPatches
for the right way to do things and must have missed that. I was looking into solving a problem in the version I used and was unaware

I can provide a .patch for the poi trunk branch instead
Comment 3 PJ Fanning 2021-10-19 18:26:32 UTC
I think I sorted out the merge issues manually. Applied r1894386