Aspose.cells forground color limitation

Hi,

I need to use diffrent color as cell forground color. But I can use only Red, Green, Blue etc.

Is there any limitation for this. I can’t use all System.Color.

Thanks

Hi,

Thanks for considering Aspose.

Well, there is no limitation for setting colors. I think the color your are applying might not be present in the Excel Standard Color Palette, so you have to add it first into the palette before setting it as a fill color of a cell. Since the Excel color palette has only 56 colors (0-55 indexed) on it, so if a color is not there, you will add the color to the palette replacing any existing color on a specified index position using Workbook.ChangePalette() method.

Here is a sample code for your need:

//Instantiating a Workbook object

Workbook workbook = new Workbook();

// Add sky blue color to the palette.

workbook.ChangePalette(System.Drawing.Color.SkyBlue, 55);

//Obtaining the first worksheet by passing its sheet index

Worksheet worksheet = workbook.Worksheets[0];

//Now setting the foreground color of the "A1" cell to sky blue

worksheet.Cells["A1"].Style.ForegroundColor = Color.SkyBlue;

//Setting the background pattern of the "A1" cell to solid

worksheet.Cells["A1"].Style.Pattern = BackgroundType.Solid;

//Saving the Excel file

workbook.Save("d:\\test\\fillcolors.xls",FileFormatType.Default);

For further ref, please check the following:

http://www.aspose.com/Wiki/default.aspx/Aspose.Cells/ColorAndPalette.html

Thank you.