We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Background patterns and colors

Can you please help me with following issue:

1) I need to read a background color for this cell
2) I need to support “transparent” cells (cells, that have no background color)

Now i have used:
1) style.getPattern() == BackgroundType.NONE for detection transparent cells;
2) style.getForegroundColor for detection a background color

But it not worked for case, when i have a cell, that had fill-pattern, but now i have removed it:

Excel shows, that cell had no fill style, but my methods returns black.

public void bgTest() throws Exception {
Workbook wb = new Workbook(“D://1.xlsx”);

Cells cells = wb.getWorksheets().get(0).getCells();

Style style = cells.getCellStyle(2, 2);
TestCase.assertEquals(BackgroundType.NONE, style.getPattern());

style = cells.getCellStyle(4, 2);
TestCase.assertEquals(BackgroundType.SOLID, style.getPattern());

style = cells.getCellStyle(6, 2);
TestCase.assertEquals(BackgroundType.GRAY_75, style.getPattern());

style = cells.getCellStyle(8, 2);
TestCase.assertEquals(BackgroundType.NONE, style.getPattern());

Hi Alexey,

Thanks for your sample file, sample code and using Aspose.Cells.

We were able to observe this issue after running your code with the latest version: Aspose.Cells for Java 8.1.1.

The background pattern of cell C9 should be detected as BackgroundType.NONE but it is detected as BackgroundType.SOLID and its foreground color is detected as Black while it should be detected as White or No-Fill.

We have logged this issue in our database for investigation. We will look into it and fix this issue. Once, the issue is resolved or we have some other update for you, we will let you know asap.

This issue has been logged as

  • CELLSJAVA-40881 - Wrong detection of cell background pattern and color


We have evaluated your issue further. Please open the file in MS Excel, the cell C9 is not transparent, Right-click on the cell C9 ==> Format Cells==>Fill==>Background color : No Color is
selected, Click “Pattern Style”, “Solid” is selected.


In Aspose.Cells, Color.isEmpty() is used to check whether there is no color set.

See following codes:

Sample code:

style = cells.getCellStyle(8, 2);

TestCase.assertEquals(BackgroundType.NONE, style.getPattern());


Thank you.

Thanks, Amjad Sahi. It is very helpfull.