Are the POI color values ​​for IndexedColors?

I am trying to set the colors of Excel cells using Apache POI in Java. I played in Excel itself and chose the colors that I need, but I cannot figure out how to use these colors with the POI. I am using the font.setColor method, which takes a short that color index ... Which seems to indicate that I am limited by constants in IndexedColors . Is there a way to set the cell to a hex color value? Or can I use only predefined constants?

+4
source share
2 answers

You can use the HSSFPalette class to query for specific colors and define your own colors (using setColorAtIndex() ).

+5
source

I work with HWPF, not HSSF, and I'm too lazy to search, but do the cell / character class classes you work with have an attribute named "ico24" or something similar? In HWPF, an int representation of a 24-bit (A) RGB color specification that can be used to indicate any color that you like.

0
source

Source: https://habr.com/ru/post/1302058/


All Articles