Setting RGB Colors with XSSFColor
The getIndexed()
method in XSSFColor
has Javadocs that state that it's for backwards compatibility. Basically, XSSF has no pallette, so it's useless to set an index of color in a CellStyle
.
However, XSSF has its own method of setting the foreground color in a style -- using the colors directly. Use the overload of setFillBackgroundColor
that directly takes a XSSFColor
. It only exists in XSSFCellStyle
, not the interface CellStyle
, so cast it as a XSSFCellStyle
first.
((XSSFCellStyle) style).setFillForegroundColor(color);