Cells(1- 1).Style.BackgroundColor.ToString


#1

Hi,

when I use this

Cells(r, 2).Style.BackgroundColor.ToString to obtain the backgroundColor of the cell, it always return Black color, even though it was yallow.

Benny.


#2

Please try Style.ForegroundColor.


#3

We get the same result. Although I cannot see how using the foreground property to get the background color could help. Is te Forground property used to set the Font Color, or the cell background?


#4

Note: When the color is set from within Aspose, it works. but if we are using a template that was created in Excel, and we try to access those properties, we always get the color black.


#5

Please try the following code:

Excel excel = new Excel();
excel.Open(“d:\book1.xls”);
Console.WriteLine(excel.Worksheets[0].Cells[“b2”].Style.ForegroundColor.ToString());

The output is:
Color [A=255, R=255, G=255, B=0]

You can use Font.Color to set font color. When the cell background pattern is solid, only foreground color will take effect. If you change the background pattern to other values, foreground color and background color will all take effect.