Bug 50784

Summary: XSSFFont.getXSSFColor().getRgb() returns null for theme colors
Product: POI Reporter: andrei <andrei.astrouski>
Component: XSSFAssignee: POI Developers List <dev>
Status: RESOLVED FIXED    
Severity: major    
Priority: P2    
Version: 3.7-FINAL   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Attachments: FontColorTest.xlsx
FontColorTest.java

Description andrei 2011-02-15 10:31:37 UTC
Steps:
1. Create Excel doc.
2. Set font color with the theme color.
3. Call from POI
XSSFFont font = (XSSFFont) workbook.getFontAt(cell.getCellStyle().getFontIndex());
byte[] rgb = font.getXSSFColor().getRgb();

Actual result: null
Expected: rgb
Comment 1 Nick Burch 2011-02-15 11:50:36 UTC
I guess we'll need to pass the theme details into XSSFColor, and have it check those if needed

Any chance you could create a simple document that shows this, along with a failing unit test? And ideally a patch too if you can :)
Comment 2 andrei 2011-02-16 08:49:09 UTC
Created attachment 26666 [details]
FontColorTest.xlsx
Comment 3 andrei 2011-02-16 08:49:35 UTC
Created attachment 26667 [details]
FontColorTest.java
Comment 4 Nick Burch 2011-02-18 10:47:09 UTC
Thanks for this. I've added a disabled unit test in r1072027.

It looks like we need to give XSSFColor a way to load themes from the theme table. Then, we need it to spot when something isn't set on the colour itself, and in that instance go check the parent theme. If you could work up a patch for that it'd be wonderful!
Comment 5 Nick Burch 2011-02-25 16:19:46 UTC
In XSSFCellStyle there is extractColorFromTheme, which does the appropriate work for theme based cell style colours

I think we need the same thing for XSSFFont, but it'll need some work because XSSFFont doesn't currently have access to the themes table. If you can work up a patch that solves this that'd be great!
Comment 6 Nick Burch 2011-03-04 10:05:44 UTC
Thanks for the unit test. Fixed in r1077986.