Cell background color is always white


I noticed that I don’t get back the correct background color of cells and the font color also doesn’t seem to change!?

Colors.zip (5.9 KB)


var workbook = new Workbook("Colors.xlsx");
var sheet = workbook.Worksheets[0];

Cell cell = sheet.Cells.GetCell(0, 1); // Just for the sake of simplicity, I explicitly declare a cell
Style style = cell.GetStyle(); // Background color is "{Name=White, ARGB=(255, 255, 255, 255)}" instead red


Thanks for using Aspose APIs.

Please use the Style.ForegroundColor property. It will return the following color which is correct. Please remember, the background color is actually a fill color of the cell. When fill color type is solid, the foreground color property returns the fill color of the cell.

Console Output

Color [A=255, R=255, G=0, B=0]

But I want to know the color from the background like in my sample image (2.0 KB). My expectation was that I would get the color the user used to fill.

Oh, I think I misunderstood you. By this property I get the value back, thank you! But what happens if I change the color of the text? How do I get the color between cell and font?


Good to know that you are able to get the cell’s shading color via Style.ForegroundColor property.

Please try to use style.Font.Color attribute to get the font/text color.