We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Cell background colors?

I need to specify the background colors of a range of cells however there seems to be a conflict between the colorindex values used in excel and the colorindex values used in XlsIO.

For example, the color index value of 36 should return a light yellow, however I seem to be getting a purple color instead.

I'm referring to the following page for excel color index values:
http://www.mvps.org/dmcritchie/excel/colors.htm
If you scroll down to "Color 36", you'll notice it's the light yellow color I'm looking for.

Here's the code I'm using to try to set the color to light yellow:
ExcelKnownColors knownEnm = (ExcelKnownColors)36;
range.CellStyle.ColorIndex = knownEnm;

What code should I be using so the color index values do in fact follow excel's color pallette?

Thanks.

-Ryan

1 Reply

MW Melba Winshia Syncfusion Team January 3, 2007 01:41 PM UTC

Hi Ryan,

I was able to reproduce the problem. However our custom color starts from 0 and excel color starts from 1. So excel color index value of 36 is equivalent to XlsIO color index value of 35. Use the following code snippets to set light yellow for the cell background.

[C#]

sheet.Range["A1"].CellStyle.ColorIndex=ExcelKnownColors.Custom35;

Please take a look and let me know if you have any other questions.

Thanks,
Melba

Loader.
Live Chat Icon For mobile
Up arrow icon