Java (Apache POI) Detect cell bakground gold color

喜你入骨 提交于 2019-12-25 16:42:49

问题


I've been searching for this but I couldn't find a solution.

I have a workbook and I have to check if a cell has the Excel Gold color as background.

something like:

if(cell.getCellStyle().getFillForegroundColorColor().equals(gold) ){ then do something

I tried with HSSF and RGB colors but I can't get it work.

I really apreciate some help.

THanks!


回答1:


You can use

 if(cell.getCellStyle().getFillForegroundColor()==HSSFColor.GOLD.index){
   //do whatever you want
 }



回答2:


this should work:

if(cell.getCellStyle().getFillForegroundColor().equals(HSSFColor.GOLD) ) 
{   
}


来源:https://stackoverflow.com/questions/17221082/java-apache-poi-detect-cell-bakground-gold-color

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!