Having problem of setting style background color


#1

Hi,

I’m facing a problem of setting style’s background color. When exported to Excel, the background color is black eventhough I had set it to other color.

Here’s my code:

styleIndex = excel.Styles.Add();
style = excel.Styles[styleIndex];
excel.ChangePalette(Color.Blue, 55);
style.BackgroundColor = Color.Blue;
style.Pattern = BackgroundType.Solid;
style.Name = “Header5”;


#2

Hi, thanks for your consideration.

When the fill pattern is solid, background color will not take effect. Please change your code as following and have a try:

styleIndex = excel.Styles.Add();
style = excel.Styles[styleIndex];
style.ForegroundColor = Color.Blue;
style.Pattern = BackgroundType.Solid;
style.Name = “Header5”;


#3

Thanks Laurence! It works now.