Hi,
Thanks for your posting and using Aspose.Cells.
The background color is actually a Fill Color and foreground color is actually a Font Color.
Please use these methods/properties to get the Fill Color and Font Color of the cells.
- Style.getForegroundColor()
- Style.getFont().getColor())
Please see the following sample code, its
input Excel file as well as console output for more help.
Java
Workbook wb = new Workbook(dirPath + “Color.xlsx”);
Worksheet ws = wb.getWorksheets().get(0);
Cell a1 = ws.getCells().get(“A1”);
Cell b1 = ws.getCells().get(“B1”);
Style a1St = a1.getStyle();
Style b1St = b1.getStyle();
System.out.println("Fill Color of A1: " + a1St.getForegroundColor());
System.out.println("Font Color of A1: " + a1St.getFont().getColor());
System.out.println();
System.out.println("Fill Color of B1: " + b1St.getForegroundColor());
System.out.println("Font Color of B1: " + b1St.getFont().getColor());
Console Output
Fill Color of A1: com.aspose.cells.Color@ffffff00
Font Color of A1: com.aspose.cells.Color@ffff0000
Fill Color of B1: com.aspose.cells.Color@ff00b0f0
Font Color of B1: com.aspose.cells.Color@ff7030a0