Free Support Forum - aspose.com

Workbook.ChangePalette

HI,

I have problems in setting the background color of a header in the excel. The code I used was working previously but now it does not work... no color comes. The color that i am trying to set is an HTML color ( #cad8ea ) . the code is as follows -

//background colors

itemStyle.BackgroundColor.Source = "#cad8ea "

if (itemStyle.BackgroundColor != null)

{

//If the color is not a known color, set the palette with the color before using it

workbook.ChangePalette(System.Drawing.ColorTranslator.FromHtml(itemStyle.BackgroundColor.Source), 53);

//cell.Style.Pattern = BackgroundType.Gray6;

//cell.Style.BackgroundColor = System.Drawing.ColorTranslator.FromHtml(itemStyle.BackgroundColor.Source);

cell.Style.BackgroundColor = System.Drawing.ColorTranslator.FromHtml(itemStyle.BackgroundColor.Source);

cell.Style.Pattern = BackgroundType.Gray6;

}

I think its the porblem with the palette, but not sure. I get the color When i debug the code to see it the cell has the background after it has been set. But on the excel its blank. HOwever i tried some system color like blue and red , they do appear... could you plese tell me how i can correc this ?

Yes. This problem may be caused by the palette.

Since there are only 56 differenct colors in an Excel palette, please change the palette very carefully.

1. Please change palette at the very start of you program. Otherwise it may disorder previous set colors.

2. Please avoid change more than once for a color palette index.