https://bz.apache.org/bugzilla/show_bug.cgi?id=60898
Bug ID: 60898
Summary: XSSFColor's getARGB() mehtod returns a wrong color
value when a workbook has a custom indexed colors
Product: POI
Version: 3.15-FINAL
Hardware: PC
Status: NEW
Severity: normal
Priority: P2
Component: XSSF
Assignee: [email protected]
Reporter: [email protected]
Target Milestone: ---
Created attachment 34861
--> https://bz.apache.org/bugzilla/attachment.cgi?id=34861&action=edit
wrong_color.xlsx
If a workbook has a custom indexed colors defined instead of the fixed color
array (see the styles.xml file attached), the XSSFColor's getARGB() mehtod
calls the 'getRGBOrARGB()' defined in 'ExtendedColor.java'. This mehtod simply
referrs to a constant color array.
But if a workbook has custom(modified) indexed colors (i.e. if an
<indexedColors> element is defined inside the styles.xml part of the workbook),
the indexed colors should refer to the color array defined in the styles.xml
file.
I have attached a sample .xlsx file here, and added a test to
TestXSSFColor.java to show the problem(patch attached).
Possible solutions.
This problem could be solved by overriding the getRGBOrARGB() in XSSFColor.java
in a way that custom indexed colors (if any) are looked up from the CTcolors.
Unfortunately, the XSSFColor dosen't have an access to the CTcolors, so either
a CTcolors field should be added to XSSFColor (hence also a new constructor
will be added) or the indexed color can be obtained from the Dom Elelement.
Solution 1 (Probably this is not a clean solution and more error prone):
Get the Dom element from the 'ctColor' field, get the styleSheet
element, and then get the indexed color. (see the attached
XSSFColor.java.patch):
Solution 2:
add a CTcolors field to XSSFColor, and a constructor that takes bothe
CTcolors and CTcolor. Consequently, change (probably all or most of) the calls
to the "XSSFColor(CTcolor)" constructor with a call to "XSSFColor(CTcolor,
CTcolors)". (see attached XSSFColor1.java.patch)
--
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]