Bug 53371 - XSSFColor not correctly created from hex code
Summary: XSSFColor not correctly created from hex code
Alias: None
Product: POI
Classification: Unclassified
Component: XSSF (show other bugs)
Version: unspecified
Hardware: PC All
: P2 major with 1 vote (vote)
Target Milestone: ---
Assignee: POI Developers List
Depends on:
Reported: 2012-06-06 09:26 UTC by adinamita
Modified: 2015-09-03 21:05 UTC (History)
0 users


Note You need to log in before you can comment on or make changes to this bug.
Description adinamita 2012-06-06 09:26:32 UTC
I want to set the foreground color of a cell to a given color in hex code. For example, when I try to set it to red:

style.setFillForegroundColor(new XSSFColor(Color.decode("#FF0000")).getIndexed());

No matter what Hex value I set in the parameter for the decode function, the getIndexed function will always return the black color.
Comment 1 Dominik Stadler 2015-09-03 21:05:07 UTC
If you construct a color with a color-value, it is not indexed, POI does currently not try to map known colors to indexes. Thus getIndexed() returns 0 by design in this case. Use isIndexed() to check if the color is actually indexed. And if not, use getRGB() to get the color value.