如何用POI取得Excel单元格的背景颜色?
public String getCellBackColor(int iRow, int iCol) throws Exception{
if (null == this.sheet){
throw new Exception("can't read any data:sheet is not exist!!!");
}
HSSFPalette palette = workBook.getCustomPalette();
HSSFCell cell = this.getCell(iRow, iCol);
HSSFColor hc = palette.getColor(cell.getCellStyle().getFillBackgroundColor());
return hc.getHexString();
}
我这样写,hc 对像却总是为null,得到的颜色值为64或65