I have:
CellStyle style = sheet.getWorkbook().createCellStyle();
HSSFCell cell = row.createCell((short)number);
cell.setCellValue(text)
cell.setCellStyle(style);
I would like the background to be gray, for example
I have:
CellStyle style = sheet.getWorkbook().createCellStyle();
HSSFCell cell = row.createCell((short)number);
cell.setCellValue(text)
cell.setCellStyle(style);
I would like the background to be gray, for example
What you have to do is:
CellStyle style = sheet.getWorkbook().createCellStyle();
//cambiar el fondo
style.setFillForegroundColor(HSSFColor.GREY_25_PERCENT.index);
style.setFillPattern(CellStyle.SOLID_FOREGROUND);
HSSFCell cell = row.createCell((short)number);
cell.setCellValue(text)
cell.setCellStyle(style);
With this method you can add the color.
protected CellStyle setCellBackground(CellStyle cellStyle, Short color) {
cellStyle.setFillForegroundColor(color);
cellStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);
return cellStyle;
}
For the gray color it is:
HSSFColor.GREY_25_PERCENT.index