Bug 53371

Summary: XSSFColor not correctly created from hex code
Product: POI Reporter: adinamita
Component: XSSFAssignee: POI Developers List <dev>
Severity: major    
Priority: P2    
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: All   

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.