Hi,
It's my first time to use the POI API,
I'm trying to change the background color of a cell but it won't change,
although all other features in the HSSFCellStyle I used like borders and alignment worked perfectly, here's the code:
HSSFCellStyle titleStyle = xls_workbook.createCellStyle();
titleStyle.setFillBackgroundColor(HSSFColor.GREY_2 5_PERCENT.index);
titleStyle.setAlignment(CellStyle.ALIGN_CENTER);
titleStyle.setBorderBottom(CellStyle.BORDER_MEDIUM );
titleStyle.setBorderLeft(CellStyle.BORDER_MEDIUM);
titleStyle.setBorderRight(CellStyle.BORDER_MEDIUM) ;
titleStyle.setBorderTop(CellStyle.BORDER_MEDIUM);
Font titleFont = xls_workbook.createFont();
titleFont.setBoldweight(Font.BOLDWEIGHT_BOLD);
titleStyle.setFont(titleFont);
/***********************************/
HSSFRow row = xls_sheet1.createRow((short)0);
HSSFCell cells[]=new HSSFCell[columns];
for(int i=0;i<columns;i++)
{
cells[i]=row.createCell(i);
cells[i].setCellStyle(titleStyle);
}
cells[0].setCellValue("Time Relative");
cells[1].setCellValue("I/O");
cells[2].setCellValue("Signal Name");
cells[3].setCellValue("Value to be set/checked");
cells[4].setCellValue("Time Tolerance");
cells[5].setCellValue("Comparison Type");
cells[6].setCellValue("Comment");
for(int i=0;i<columns;i++)
{
xls_sheet1.autoSizeColumn((short)i);
}
xls_workbook.write(xlsFileOut);
xlsFileOut.close();