2

I have an XSLX sheet in which few cells are having background color Green, few Red and rest are default(white).

How to identify the cell color ? based on the cell color, i have to process the text in the cell. I am using apache poi.

Cell cell = row.getCell(6);
CellStyle style = cell.getCellStyle();
Color cellColor = (cell.getCellStyle().getFillBackgroundColorColor());

if the cellColor will hold the background color of the cell, how can the color name be retrevied from it.

Please Help

thanks Ramm

user301016
  • 2,207
  • 7
  • 36
  • 50

1 Answers1

2

Don't base it on text value. You're almost there.

Color cellColor = (cell.getCellStyle().getFillBackgroundColorColor());

Now just do:

if(cellColor.equals(Color.GREEN)) {
  //do whatever
}
Chris Matthews
  • 382
  • 4
  • 19