How to get excel cell color in java
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
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
}
精彩评论