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?
I’m trying to set Excel cell colors using Apache POI in Java. I played
Share
You can use the
HSSFPaletteclass to query the defined colors and define your own colors as well (usingsetColorAtIndex()).