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

Free Support Forum - aspose.com

Color Question

How can I set the backcolour of a cell to light blue?

I’m using the following

styleindex = styles.Add
style = styles(styleindex)
style.Font.Size = 7
style.Font.IsBold = False
style.ForegroundColor = Color.LightBlue
style.Pattern = BackgroundType.Solid
style.Name = "SmallTableLightBlue"

but it just comes out black. Using blue and red are OK, but as soon as I use a non-standard colour it appears black.

Hi, Andy.

If you want to use a non-standard color. Please use Excel.ChangePalette to change color palette first.

excel.ChangePalette(Color.LightBlue, 55);

Then you can use your code to change foreground color.

Aspose.Excel is discontinued now and is replaced with more advanced version Aspose.Cells which not only contains support for all the versions of MS Excel including the latest one but also is efficient and feature-rich. This new product also supports formatting the cells as follows:

Workbook wb = new Workbook(@“Test.xlsx”);
var style = wb.Worksheets[0].Cells[“A2”].GetStyle();
style.Pattern = BackgroundType.Solid;
style.ForegroundColor = System.Drawing.Color.LightBlue;

For more information on formatting the cells, please follow the link below:
Cells Formatting

For the latest version of Aspose.Cells for .NET, follow the link below:
Aspose.Cells for .NET (Latest Version)

Latest demos are available here.