Home » excel » java – POI's HSSF dataformat – what colors are supported?

java – POI's HSSF dataformat – what colors are supported?

Posted by: admin May 14, 2020 Leave a comment

Questions:

When colorizing numbers (black for positive numbers, red for negative numbers), I usually use this snippet:

style.setDataFormat(format.getFormat("[Green]#,##0;[Red]#,##0"));

Ive seen some variation like this one below but Im not sure what COLOR 5 means.

"[BLACK]0.00;[COLOR 5]##.##"

What I would like to know is, what colors are suported for these color descriptors and if it is possible to provide a hex value instead? (Ive tried it, didnt work so maybe Im doing it incorrectly).

How to&Answers:

I believe at least values listed in org.apache.poi.ss.usermodel.IndexedColors should be supported. They also should be backward compatible with older versions of Excel.