【发布时间】:2018-10-29 19:59:28
【问题描述】:
在 Apache POI 4.0 中,我想像这样设置 Excel 单元格背景颜色:
IndexedColorMap colorMap = workbook.getStylesSource().getIndexedColors();
style.setFillForegroundColor(new XSSFColor(java.awt.Color.BLUE, colorMap).getIndex());
style.setFillPattern(FillPatternType.SOLID_FOREGROUND);
Row header = sheet.createRow(0);
header.createCell(0).setCellValue("Title");
header.getCell(0).setCellStyle(style);
.. 但我得到的只是黑色细胞。我尝试了很多东西,但结果总是一样。
如何在 Apache POI 4.0 中设置 Excel 单元格的背景颜色?
【问题讨论】:
-
你有没有想过如何为十六进制或 rgb 值执行此操作?
-
不,我停止寻找它。我使用了@Vasif 的答案。
标签: java excel apache-poi