|Summary:||XSSFColor.getRgb() always returns null|
|Component:||XSSF||Assignee:||POI Developers List <dev>|
|OS:||Mac OS X 10.4|
|Attachments:||Example file with font and background colors|
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)