Setting foreground color for HSSFCellStyle is always coming out black

后端 未结 3 633
旧时难觅i
旧时难觅i 2020-12-05 04:09

I am using POI to create an Excel spreadsheet in Java. I have the following code used for creating a header row:

HSSFWorkbook wb = new HSSFWorkbook();
HSSFSh         


        
3条回答
  •  抹茶落季
    2020-12-05 04:51

    I got this to work. I had to set the foreground color to make the background color work (??).

    So I changed:

    cellStyle.setFillBackgroundColor(HSSFColor.GREY_25_PERCENT.index);
    

    to:

    cellStyle.setFillForegroundColor(HSSFColor.GREY_25_PERCENT.index);
    

    and it worked!

提交回复
热议问题