I've found the following question which is similar but not exactly the same:
Setting foreground color for HSSFCellStyle is always coming out black
So I'm creating an XSSFCellStyle for the headers of my table, and giving them a Foreground color with the following:
wb = new XSSFWorkbook();
headerStyle = wb.createCellStyle();
XSSFColor headerBackgroundColor = new XSSFColor(new java.awt.Color(187,187,187));
headerStyle.setFillForegroundColor( headerBackgroundColor);
headerStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);
Then I apply it to a cell using the setCellStyle.
Everything there works fine until I try adding a border around that/those cells.
I'm using propertyTemplate.drawBorders(range, borderType, color, extent);
CellRangeAddress range = new CellRangeAddress(startRow, endRow, startColumn, endColumn);
BorderStyle borderType = BorderStyle.MEDIUM;
short color = IndexedColors.BLACK.getIndex();
BorderExtent extent = BorderExtent.ALL;
propertyTemplate.drawBorders(range, borderType, color, extent);
When I apply this and generate my sheet, the cells that were styled with the headerStyle are completely black. I can change the text color to white and I can see all the data is still there.
When I comment out the setFillPattern in the headerStyle, I can see the borders properly, but then the foreground color is white as though the setFillForegroundColor was no set (even though it is).
I've tried using setFillBackgroundColor as well but I get the same results.
Does anyone have any idea where I might be going wrong or is this a known (or unknown?) bug?
Thank you!
Alex