0
votes

I've been searching for this but I couldn't find a solution.

I have a workbook and I have to check if a cell has the Excel Gold color as background.

something like:

if(cell.getCellStyle().getFillForegroundColorColor().equals(gold) ){ then do something

I tried with HSSF and RGB colors but I can't get it work.

I really apreciate some help.

THanks!

2
Did you try printing out the colour that POI finds for the cell in question? - Gagravarr
Yes, but only as a short color. but I can't have the equals() working with short - Danyelous
What happens if you then look that short up in the palette, what colour does that give you? - Gagravarr

2 Answers

0
votes

You can use

 if(cell.getCellStyle().getFillForegroundColor()==HSSFColor.GOLD.index){
   //do whatever you want
 }
0
votes

this should work:

if(cell.getCellStyle().getFillForegroundColor().equals(HSSFColor.GOLD) ) 
{   
}