Reputation: 83133
I'm trying to set Excel cell colors using Apache POI in Java. I played around in Excel itself and chose the colors I wanted - but I can't figure out how to use those colors with POI. I'm using the font.setColor
method, which takes a short that's the index of a color... Which seems to indicate that I'm limited to the constants in IndexedColors
. Is there any way to set a cell to a hex color value? Or can I only use the predefined constants?
Upvotes: 4
Views: 6903
Reputation: 67790
I'm working with HWPF, not HSSF and I'm too lazy to go looking, but do the cell/character format classes you're working with have an attribute named "ico24" or something similar? In HWPF, that's the int
representation of a 24 bit (A)RGB color spec which can be used to specify any color you like.
Upvotes: -1
Reputation: 308159
You can use the HSSFPalette
class to query the defined colors and define your own colors as well (using setColorAtIndex()
).
Upvotes: 5