Hello Everyone,
I output report to an Excel file and I need to set background color for the cells. But no matter how hard I try, I can't do anything - background color remains white. I ask you to help me with advice on how to solve this problem? Here is a fragment of my code:
.....
var orderCellStyle = oO.createCellStyle(orderFont, 0, 0, 0, 0, 0, 0, 0, 0, Constants.ALIGN_LEFT, Constants.ALIGN_CENTER, 0, 0, Constants.NO_FILL);
orderCellStyle.setVerticalAlignment(Constants.VERTICAL_TOP);
orderCellStyle.setWrapText(true);
orderCellStyle.setBorderBottom(Constants.BORDER_THIN);
orderCellStyle.setBorderTop(Constants.BORDER_THIN);
orderCellStyle.setBorderLeft(Constants.BORDER_THIN);
orderCellStyle.setBorderRight(Constants.BORDER_THIN);
orderCellStyle.setFillBackgroundColor(10); //10 - for example
......
sheet1.cell(0,0).setCellValue("Example");
sheet1.cell(0,0).setCellStyle(orderCellStyle);
All cell appearance settings are applied except for the background color :( I've also tried changing the parameters in oO.createCellStyle(....), but that doesn't work either.
I hope for your help.
Robert Goldenbaum on
Hi,
you have to create a cell style and then set it to the cell:
oStyle = _oWorkbook.createCellStyle(_fStyle, lTopBorder, lRightBorder, lBottomBorder, lLeftBorder, lTopBorderColor, lRightBorderColor, lBottomBorderColor, lLeftBorderColor, lHorizontalAlignment, lVerticalAlignment, lBackgroundColor, lForegroundColor, lFillPattern)
oCell = _oOutSheet.cell(i, j);
oCell.setCellValue("blabla");
oCell.setCellStyle(oStyle);
BR Robert