Bug 62753

Summary: Background color is always black for a merged cell
Product: POI Reporter: apulbere
Component: POI OverallAssignee: POI Developers List <dev>
Status: RESOLVED INVALID    
Severity: normal    
Priority: P2    
Version: 3.17-FINAL   
Target Milestone: ---   
Hardware: PC   
OS: Linux   
Attachments: example of problem

Description apulbere 2018-09-21 14:34:16 UTC
Created attachment 36159 [details]
example of problem

I'm using the following code to set the background color for cells:

XSSFCellStyle cellStyle = (XSSFCellStyle) excelStyle.getCellStyle();
cellStyle.setFillForegroundColor(new XSSFColor(new byte[]{(byte) 14, (byte) 173, (byte) 108}, new DefaultIndexedColorMap()));
cellStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);

But I'm always getting black background for a merged cell.
Also, I've tried this way:

cellStyle.setFillForegroundColor(new XSSFColor(java.awt.Color.decode("#0ead6c")));

but this same result.
It works only if I'm using IndexedColors like:

cellStyle.setFillForegroundColor(IndexedColors.CORAL.index);


Additional info:
SXSSFWorkbook
poi:3.17
poi-ooxml:3.17
Comment 1 apulbere 2018-09-21 15:46:39 UTC
seems that problem is in 
org.apache.poi.ss.util.RegionUtil#setBorderTop

if I apply style in this order, then it's ok:
1. merge cells
2. set border for merge region
3. set background color for merged cell