Hi guys
I am trying to set RGB background colors on cells and in addition set
borders on regions using RegionUtil. When doing this, all the cells with
borders end up completely black.

It seems that using XSSFColor on XSSFCellStyle causes problems with the way
CellUtil.setCellStyleProperties works. CellUtil is used by RegionUtil.

This is a minimal test to reproduce the problem:

    XSSFWorkbook workbook = new XSSFWorkbook();
    XSSFSheet sheet = workbook.createSheet();

    Cell cell = CellUtil.getCell(CellUtil.getRow(0, sheet), 0);

    XSSFColor color = new XSSFColor(Color.RED);
    XSSFCellStyle style = workbook.createCellStyle();
    style.setFillForegroundColor(color);
    style.setFillPattern(XSSFCellStyle.SOLID_FOREGROUND);
    cell.setCellStyle(style);

    // Everything is fine at this point, cell is red

    Map<String, Object> properties = new HashMap<>();
    properties.put(CellUtil.BORDER_BOTTOM, CellStyle.BORDER_THIN);
    CellUtil.setCellStyleProperties(cell, properties);

    // Now the cell is all black

Does anybody know if this is supposed to work? Any suggestions on
workarounds? It is of course possible to avoid the CellUtil methods, but
they contain some clever logic to avoid creating new styles for every cell
and eventually hit a threshold in Excel.

All help will be very appreciated!

Thanks, Anders

Reply via email to