I am using Apache Poi for writing of data Into the Excel Sheet. I have a requirement to merge cells and set background for the merged Cells. I have a code for merged cell but I don't know how to set background or foreground for the Cell.
// This code is the I used for merging cells and setting border for the cells
CellRangeAddress cellRangeAddress = new CellRangeAddress(rowNum,rowNum,colNum,colNum);
sheet.addMergedRegion(cellRangeAddress);
RegionUtil.setBorderTop(CellStyle.BORDER_MEDIUM, mergedCell, sheet, workBook);
RegionUtil.setBorderBottom(CellStyle.BORDER_MEDIUM, mergedCell,sheet, workBook);
RegionUtil.setBorderLeft(CellStyle.BORDER_MEDIUM, mergedCell, sheet, workBook);
RegionUtil.setBorderRight(CellStyle.BORDER_MEDIUM, mergedCell,sheet, workBook);
I want to have background for the merged cells . Please help me with a code for setting background or foreground for the merged cells.