Cannot set Background/Foreground color for a cell

Hello,

I am using Aspose.Excel (3.6.2.0) and the background/foreground color of a cell cannot be set. I have also tried the evaluation version of 4.0.0.3 and it didn't work either.

Here is the code:

this.Worksheets[0].Cells[10,0].PutValue("Test");

this.Worksheets[0].Cells[10,0].Style.BackgroundColor = Color.Yellow;

Before I set the background color, the colors have already been added to the palette.

Thanks!

Miao

Hi Miao,

Thanks for considering Aspose.

Please try the following sample codes for your tasks.

For Background color:

this.Worksheets[0].Cells[10,0].Style.ForegroundColor = Color.Yellow;

this.Worksheets[0].Cells[10,0].Style.Pattern = BackgroundType.Solid;

For Foreground color:

this.Worksheets[0].Cells[10,0].Style.Font.Color=Color.Red;

Regards

Amjad Sahi

Aspose Nanjing Team

Hi Amjad,

I just tried and it worked perfectly. Thanks for your help!

Miao