https://issues.apache.org/bugzilla/show_bug.cgi?id=57074

            Bug ID: 57074
           Summary: HSSFCell.getCellStyle().getFillForegroundColorColor()
                    returns incorrect color for xls file created using
                    Microsoft Excel 2007
           Product: POI
           Version: 3.9-FINAL
          Hardware: PC
            Status: NEW
          Severity: critical
          Priority: P2
         Component: HSSF
          Assignee: [email protected]
          Reporter: [email protected]

Created attachment 32100
  --> https://issues.apache.org/bugzilla/attachment.cgi?id=32100&action=edit
MS Excel 2007 created .xls file

I have created an .xls file using Microsoft Excel 2007. The file contains a
cell with:

Background color: RGB(215, 228, 188)
Font color: RGB(0, 128, 128)

as can be seen in the Custom Colors dialog in the Excel. I tried to read the
background and foreground colors as shown below:

public class ColorTest2007 {

    public static void main(String arg[]) throws Exception
    {
        File f = new File("david2.xls");
        FileInputStream fis = new FileInputStream(f);
        HSSFWorkbook workbook = new HSSFWorkbook(fis);

        HSSFSheet sheet = workbook.getSheet("Sheet1");
        HSSFRow row = sheet.getRow(0);
        HSSFCell cell = row.getCell(0);

        HSSFColor bgColor = cell.getCellStyle().getFillBackgroundColorColor();
        System.out.println(bgColor.getTriplet()[0]+",
"+bgColor.getTriplet()[1]+", "+bgColor.getTriplet()[2]);

        HSSFColor fontColor =
cell.getCellStyle().getFillForegroundColorColor();
        System.out.println(fontColor.getTriplet()[0]+",
"+fontColor.getTriplet()[1]+", "+fontColor.getTriplet()[2]);
    }
}

which resulted in:

0, 0, 0
247, 244, 239

I have also tried to use the cell.getCellStyle().getFillBackgroundColor() and
tried to retrieve the color from the custom color palette. But that also did
not return the colors seen in Excel.

I am attaching the david2.xls file. This definitely looks like a bug unless the
reading of the color from xls file created using MS Excel 2007 is unsupported.
Please let me know if there is any other way to retrieve the correct color
values.

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to