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: " + workbook.getSheetAt(0).getRow(0).getCell(0) .getCellStyle().getFillForegroundColor()); } catch (IOException e) { e.printStackTrace(); } try { workbook = new HSSFWorkbook(new FileInputStream("C:/Test.xls")); System.out.println("Cell color in Excel 2003: " + workbook.getSheetAt(0).getRow(0).getCell(0) .getCellStyle().getFillForegroundColor()); } catch (IOException e) { e.printStackTrace(); } } you will see the following output: Cell color in Excel 2007: 0 Cell color in Excel 2003: 10 Thanks, Andrej
Created attachment 25024 [details] test file
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)