Can't Set Fill Color Apache POI Excel Workbook

后端 未结 1 525
庸人自扰
庸人自扰 2020-12-03 13:14

I have scanned this forum over and over and tried every method mentioned on here and still can\'t get Apache POI to change to fill background color of my excel document.

相关标签:
1条回答
  • 2020-12-03 14:01

    Use foreground color instead of Background color.

     errorOccured = true;
     XSSFCellStyle style = workbook.createCellStyle();
     style.setFillForegroundColor(IndexedColors.RED.getIndex());
     style.setFillPattern(FillPatternType.SOLID_FOREGROUND);
     row.getCell(0).setCellStyle(style);
    

    this will fill the cell background color with RED.

    0 讨论(0)
提交回复
热议问题