2011-09-21 40 views
2

我有一个XSLX表单,其中几个单元格具有背景颜色绿色,少量红色,其余为默认(白色)。如何在java中获得excel单元格颜色

如何识别细胞颜色?基于单元格颜色,我必须处理单元格中的文本。我正在使用Apache poi。

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

如果cellColor将保存单元格的背景颜色,那么颜色名称如何从中撤消。

请帮助

感谢 拉姆

回答

2

不要将它基于文本的价值。你快到了。

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

现在只是做:

if(cellColor.equals(Color.GREEN)) { 
    //do whatever 
} 
相关问题