开发者

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
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜