Bug 46493 - BackGround color not working
Summary: BackGround color not working
Status: RESOLVED WONTFIX
Alias: None
Product: POI
Classification: Unclassified
Component: HSSF (show other bugs)
Version: 3.2-FINAL
Hardware: PC Windows XP
: P1 major (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-01-08 05:19 UTC by Rama Krishna G
Modified: 2009-01-29 08:19 UTC (History)
2 users (show)



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Rama Krishna G 2009-01-08 05:19:12 UTC
HSSFCellStyle.setFillBackgroundColor not working
Comment 1 Yegor Kozlov 2009-01-08 07:10:04 UTC
post sample code to reproduce the problem.
Also, see the Quick Guide:
http://poi.apache.org/spreadsheet/quick-guide.html#FillsAndFrills

Yegor
Comment 2 Graham Smith 2009-01-21 11:15:05 UTC
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" );
Comment 3 Yegor Kozlov 2009-01-29 08:19:18 UTC
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