Bug 45492 - HSSFCellStyle.getFillBackgroundColor() does always return 64
Summary: HSSFCellStyle.getFillBackgroundColor() does always return 64
Alias: None
Product: POI
Classification: Unclassified
Component: HSSF (show other bugs)
Version: unspecified
Hardware: PC Windows XP
: P2 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
Depends on:
Reported: 2008-07-28 06:09 UTC by Vojtech Minarik
Modified: 2008-09-21 11:57 UTC (History)
0 users

Test workbook (13.50 KB, application/vnd.ms-excel)
2008-07-28 06:09 UTC, Vojtech Minarik

Note You need to log in before you can comment on or make changes to this bug.
Description Vojtech Minarik 2008-07-28 06:09:02 UTC
Created attachment 22323 [details]
Test workbook

Version: 3.1-FINAL-20080629 (not in the version listbox)

After upgrading POI library to version 3.1 FINAL in my project I have found that there is a bug in retrieving fill background color. It returns value 64 for any cell in the worksheet.

I attach sample Excel file (created in Excel 2000 if it does matter), on which the following code fails.

    HSSFSheet sheet = workBook.getSheet( "Sheet1" );
    HSSFRow row = sheet.getRow( sheet.getFirstRowNum() );
    StringBuilder sb = new StringBuilder( "Background color test:\n");
    boolean flag = false;
    for( short colIx = row.getFirstCellNum(); colIx < row.getLastCellNum(); colIx++ )
      HSSFCell cell = row.getCell( colIx );
      if( cell == null )
      short bgColor = cell.getCellStyle().getFillBackgroundColor();
      if( bgColor != 64 )
        flag = true;
      sb.append( "Column " ).append( colIx ).append( " has background color index " )
          .append( bgColor ).append( "\n" );
    System.out.println( sb.toString() );
    assertTrue( flag );
Comment 1 Nick Burch 2008-09-21 11:57:37 UTC
This is as expected. You've setup your cells with a foreground colour fill, and not a background one. If you check the foreground fill colour, it'll have the values you want.