Reputation: 2715
In Apache POI 4.0 I want to set an Excel cell background color like this :
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);
.. but all I get are black cells. I've tried many things, but result is always the same.
How can I set the background color of an Excel cell in Apache POI 4.0 ?
Upvotes: 1
Views: 1474
Reputation: 768
Try to use below code for background style
style.setFillForegroundColor(IndexedColors.YELLOW.getIndex());
Upvotes: 1