4

I am trying to get font color of cell of a XLSX file. I am using the apache poi. I am able to get the cell color but not the font color. Any kind of suggestion will be appreciated.

thanks

user3284156
  • 43
  • 1
  • 3

1 Answers1

9

From an XSSFCellStyle you can get the XSSFFont. From that, you can get the XSSFColor. Finally, from the XSSFColor, you can get the colour information as ARGB Hex, RGB with Tint etc.

Your code would look something like:

XSSFCellStyle style = cell.getCellStyle();
XSSFFont font = style.getFont();
XSSFColor colour = font.getXSSFColour();
System.out.println("The colour is " + colour.getARGBHex());
Gagravarr
  • 47,320
  • 10
  • 111
  • 156
  • I'm getting null back as color when I call font.getXSSFColour(). I can call getColor() and get a pallete index number (8 if that is significant). The cell has no empty string content. Any ideas how I can get a rgb from the pallete index? – Tony Eastwood Oct 26 '16 at 13:07