Bug 62753 - Background color is always black for a merged cell
Summary: Background color is always black for a merged cell
Status: RESOLVED INVALID
Alias: None
Product: POI
Classification: Unclassified
Component: POI Overall (show other bugs)
Version: 3.17-FINAL
Hardware: PC Linux
: P2 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-09-21 14:34 UTC by apulbere
Modified: 2018-09-25 08:44 UTC (History)
0 users



Attachments
example of problem (4.24 KB, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet)
2018-09-21 14:34 UTC, apulbere
Details

Note You need to log in before you can comment on or make changes to this bug.
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