如何用POI取得Excel单元格的背景颜色?

oksonic 2006-12-11 03:33:24
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
...全文
441 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
wy158457 2006-12-11
  • 打赏
  • 举报
回复
jf

62,614

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧