BackGroundColor usage

I am trying to change the background color using the styles using the following code.

excel = new Excel();
styles = excel.Styles;
//Set CategoryName style
styleIndex = styles.Add();
styleCategoryName = styles[styleIndex];
styleCategoryName.BackgroundColor = Color.Yellow;
styleCategoryName.ForegroundColor = Color.Black;
styleCategoryName.Font.Size = 14;
styleCategoryName.Font.IsBold = true;
cells[“A1”].Style = styleCategoryName;

While the text in cell A1 does have the correct font, the background isn’t yellow. Am I implementing this incorrectly?

I forgot to mention that I tried searching the forum for “BackgroundColor” and recieved an error page.

Hi,

Please post the detailed info of the error page when you search the fourm.

Thanks for your cooperation.

Hi,

In default state, the pattern of a style is BackGroupType.None. In this pattern, only foreground color will take effect. You can set the foreground color to yellow. Then the cell color will be yellow.