Spreadsheet cell background color

Hi everyone,

Is it possible to set the background of the spreadsheet cell with hex color code?

Till now I have found something like this where the color name i,e “ORANGE” is used.
CellStyle style = cloneStyle(cell);
style.setFillBackgroundColor(IndexedColors.ORANGE.getIndex());
style.setFillBackgroundColor(0);
style.setFont(font);
cell.setCellStyle(style);

Instead of name, I want to use code like “#2f0a04”.

Any help is highly appreciated.

CellStyle class comes from POI and is used as is without modifications in Spreadsheet. The Java API is here


https://poi.apache.org/apidocs/org/apache/poi/ss/usermodel/CellStyle.html

So the parameter is index, so you need to do some conversion, here is some info that could be useful.


https://stackoverflow.com/questions/10912578/apache-poi-xssfcolor-from-hex-code