Bug 48962 - XSSFColor.getRgb() always returns null
Summary: XSSFColor.getRgb() always returns null
Status: RESOLVED WORKSFORME
Alias: None
Product: POI
Classification: Unclassified
Component: XSSF (show other bugs)
Version: 3.6-FINAL
Hardware: Macintosh Mac OS X 10.4
: P2 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-03-22 22:25 UTC by mkbitbucket
Modified: 2015-08-24 09:34 UTC (History)
0 users



Attachments
Example file with font and background colors (49.08 KB, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet)
2010-03-22 22:25 UTC, mkbitbucket
Details

Note You need to log in before you can comment on or make changes to this bug.
Description mkbitbucket 2010-03-22 22:25:10 UTC
Created attachment 25167 [details]
Example file with font and background colors

When examining an XLSX file created with Microsoft Excel that has both font colors and background colors in it, those colors cannot be extracted because the XSSFColor method always returns null.

1) Open the attached XLSX file (or any XLSX file that has a font color or fill color)
2) Navigate the sheet to one of the cells with color
3) Get that cell's style and font and notice that the getXSSFColor() method returns non-null XSSFColor
4) Call getRgb() on the XSSFColor and receive null value in return

An array with the RGB values should be returned.

To make this bug more painful, I have been unable to find any workaround.
Comment 1 Petr.Udalau 2010-03-31 13:04:06 UTC
You can see this:
https://issues.apache.org/bugzilla/show_bug.cgi?id=48432
Comment 2 longxibo 2010-05-19 04:50:35 UTC
(In reply to comment #1)
> You can see this:
> https://issues.apache.org/bugzilla/show_bug.cgi?id=48432

But org.openxmlformats.schemas.drawingml.x2006.main.CTColorScheme and ThemeDocument can not found in poi-ooxml-schemas-3.6-20091214.jar
Comment 3 Nick Burch 2010-05-19 05:25:23 UTC
I'd suggest you try un-zipping the problem file, and taking a look at the XML that makes it up. See if you can spot where the colour details are being recorded, then compare that with what POI is doing to spot where the issue comes from
Comment 4 longxibo 2010-05-19 22:03:55 UTC
(In reply to comment #3)
> I'd suggest you try un-zipping the problem file, and taking a look at the XML
> that makes it up. See if you can spot where the colour details are being
> recorded, then compare that with what POI is doing to spot where the issue
> comes from

Ok,Where I can download poi-ooxml-schemas-3.6-20091214.jar corresponding source code? So I add new ThemeDocument and CTColorScheme Class into poi-ooxml-schemas-3.6 project.Thank you very much!
Comment 5 Nick Burch 2010-05-20 04:48:27 UTC
It's an auto-generated jar, based on the microsoft XSDs. See the list archive for many discussions on how to get the generated source.
Comment 6 Dominik Stadler 2015-08-23 19:04:54 UTC
I think this is on-purpose because the color is "indexed", i.e. one of a predefined set provided by Excel. See methods isRGB() and getIndex() in XSSFColor, if isRGB() returns false, getRGB() will return null.
Comment 7 Nick Burch 2015-08-24 09:34:46 UTC
Also note that if you want the hex value, whether indexed or normal, then there's https://poi.apache.org/apidocs/org/apache/poi/ss/usermodel/ExtendedColor.html#getARGBHex%28%29 (works for XSSFColor amongst others)