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

Free Support Forum - aspose.com

Can't set a backgroundcolor


I try to apply a backgroundcolor to some cells by using the solid pattern, but the result is always the same, no color is applied. It’s possible to to apply one of the other patterns but there’s no chance to use the solid pattern.

I use this code snippet:

cell = worksheet.Cells[0, 0];
cell.Style.BackgroundColor = Color.Red;
cell.Style.Pattern = BackgroundType.Solid;

I’ve installed the latest hotfix and use Excel 2007.

After I’ve executed the code and opened the cell format dialog in Excel I can see the pattern format is solid and the pattern color is red but the backgroundcolor ist set to no color.
The assignment of all other patterns is working well except for the solid pattern.

What I’m doing wrong?



Please change your code to:

cell = worksheet.Cells[0, 0];
cell.Style.ForegroundColor = Color.Red;
cell.Style.Pattern = BackgroundType.Solid;

For further reference, please check the following:



Thank you.

Now it works fine.
Why didn’t I try that?

Thank you.