Summary: | BackGround color not working | ||
---|---|---|---|
Product: | POI | Reporter: | Rama Krishna G <bcaramu> |
Component: | HSSF | Assignee: | POI Developers List <dev> |
Status: | RESOLVED WONTFIX | ||
Severity: | major | CC: | bcaramu, wobblycogs |
Priority: | P1 | ||
Version: | 3.2-FINAL | ||
Target Milestone: | --- | ||
Hardware: | PC | ||
OS: | Windows XP |
Description
Rama Krishna G
2009-01-08 05:19:12 UTC
post sample code to reproduce the problem. Also, see the Quick Guide: http://poi.apache.org/spreadsheet/quick-guide.html#FillsAndFrills Yegor I don't know about version 3.2 but in 3.5 beta 4 the following code (with suitable code around it to create a workbook and save it etc) doesn't create a cell with a light blue background - the background is white. This functionality worked in 3.5 beta 3 (but setting the font as bold didn't work). Font font = wb.createFont(); font.setBoldweight( Font.BOLDWEIGHT_BOLD ); CellStyle style = wb.createCellStyle(); style.setFillBackgroundColor( IndexedColors.LIGHT_BLUE.getIndex() ); style.setFont( font ); Cell cell = row.createCell( 0 ); cell.setCellStyle( style ); cell.setCellValue( "foo" ); You need to set the type of fill pattern. The following snippet of code works fine to me: CellStyle style = wb.createCellStyle(); style.setFillForegroundColor( IndexedColors.LIGHT_BLUE.getIndex() ); style.setFillPattern(CellStyle.SOLID_FOREGROUND); style.setFont( font ); Cell cell = row.createCell( 0 ); cell.setCellStyle( style ); cell.setCellValue( "foo" ); See the quick guide: http://poi.apache.org/spreadsheet/quick-guide.html Yegor |