Bug 50784 - XSSFFont.getXSSFColor().getRgb() returns null for theme colors
Summary: XSSFFont.getXSSFColor().getRgb() returns null for theme colors
Status: RESOLVED FIXED
Alias: None
Product: POI
Classification: Unclassified
Component: XSSF (show other bugs)
Version: 3.7-FINAL
Hardware: PC Windows XP
: P2 major (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-02-15 10:31 UTC by andrei
Modified: 2011-03-04 10:05 UTC (History)
0 users



Attachments
FontColorTest.xlsx (12.05 KB, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet)
2011-02-16 08:49 UTC, andrei
Details
FontColorTest.java (1.56 KB, application/octet-stream)
2011-02-16 08:49 UTC, andrei
Details

Note You need to log in before you can comment on or make changes to this bug.
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.