Free Support Forum - aspose.com

Unable to set background color to the particular cell with Evaluation version

Hi,

we are evaluating the ASPOSE.Cells for using one of our project. we are checking for the option to set the background color of the cell.

we are facing some issue regarding setting the background color to a particular cell.

But it is not setting any color. The following is the syntax used.

sheet1.Cells["A4"].Style.BackgroundColor=Color.Lime;

Coulc you please help somebody whats the problem with this code. Is this limation of using with Evaluation version?.

Prompt reply will help us further.

Thanks.

Hi,

Thanks for considering Aspose.

Well, MS Excel (97-2003) color palette only supports 56 (0-55 indexed) colors. The palette does not have the color by default, so you have to add it to the color palette using Workbook.ChangePalette() method.

I think you may try the following code:

Workbook workbook = new Workbook();
//Add the color to the Excel palette
workbook.ChangePalette(System.Drawing.Color.Lime,55);
Worksheet sheet1 = workbook.Worksheets[0];
sheet1.Cells["A4"].Style.ForegroundColor = Color.Lime;
sheet1.Cells["A4"].Style.Pattern = BackgroundType.Solid;
workbook.Save("d:\\test\\out_book.xls");

Please check the following thread to know more about how to set the foreground , background, font colors etc.

<A href="</A></P> <P>Thank you.</P> <P> </P> <P> </P>

Hi Thanks,

Its working fine now....