Bug 48779

Summary: XSSFCellStyle.getFillForegroundColor dosn't return the right value
Product: POI Reporter: Andrej <AndrejRW>
Component: XSSFAssignee: POI Developers List <dev>
Severity: normal    
Priority: P2    
Version: 3.6-FINAL   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Attachments: test file

Description Andrej 2010-02-19 15:04:24 UTC
If you try to get a color from a cell which has a non-empty color, you always get black color independently of what is the right color of the cell. This bug can be reproduced only for Excel 2007 formats. For '.xls' files it's not reproducible. 

So if you run the following code for the attached files:
	public static void main(String[] args) {
		Workbook workbook = null;
		try {
			workbook = new XSSFWorkbook("C:/Test.xlsx");
			System.out.println("Cell color in Excel 2007: " + 
		} catch (IOException e) {

		try {
			workbook = new HSSFWorkbook(new FileInputStream("C:/Test.xls"));
			System.out.println("Cell color in Excel 2003: " + 
		} catch (IOException e) {

you will see the following output:
Cell color in Excel 2007: 0
Cell color in Excel 2003: 10

Comment 1 Andrej 2010-02-19 15:05:28 UTC
Created attachment 25024 [details]
test file
Comment 2 Nick Burch 2010-05-26 13:48:22 UTC
The problem is that XSSF does some colours differently to HSSF. HSSF only ever had indexed colours, while XSSF has a mixture of indexed colours and inline defined colours

I'd suggest you try the new getFillForegroundColorColor() and getFillBackgroundColorColor() methods on a CellStyle, which'll always get you the underlying Color object no matter if they're inline or indexed

Please give feedback on the mailing list about the new ss.usermodel.Color class, as at the moment it's a stub, but if we can decide what's generic between XSSFColor and HSSFColor we can add in methods to it

(You'll need a svn checkout of r948511 of later)