2011-09-21 303 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 
} 
相關問題