Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to get font color of a XSSF CELLSTYLE?

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

like image 342
user3284156 Avatar asked Jan 11 '23 06:01

user3284156


1 Answers

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());
like image 63
Gagravarr Avatar answered Apr 29 '23 20:04

Gagravarr