我正在尝试使Excel文件背景为一排白色和其他浅绿色。但是由于某种原因,无论我做什么,颜色总是变为黑色。
private void writeTable(Table table, Row row, CellStyle style){
if(row.getRowNum() % 2 == 0) {
style.setFillBackgroundColor(IndexedColors.AQUA.getIndex());
style.setFillPattern(CellStyle.SOLID_FOREGROUND);
}
style.setWrapText(true);
Cell cell = row.createCell(0);
cell.setCellValue(table.index);
cell.setCellStyle(style);
//And it continues with other cells
}
即使我尝试将GREY_25_PERCENT完全变黑,它也不会改变我所做的任何事情。这是我的Excel文件的图片
似乎违反直觉,但使用
style.setFillPattern(CellStyle.SOLID_FOREGROUND);
与...结合
style.setFillForegroundColor(IndexedColors.AQUA.getIndex());
设置单元格的背景色。
单元背景本身也可能由两层组成:前景和背景。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句