Cannot set ForegroundColor

hi
cannot set ForegroundColor to Color.LightSkyBlue


cells[0, i].Style.Pattern = BackgroundType.Solid;
cells[0, i].Style.ForegroundColor = Color.LightSkyBlue;


This message was posted using Email2Forum by ShL77.

Hi,

Thanks for considering Aspose.

Well, the color (LightSkyBlue) your are applying might not be present in the Standard Color Palette, so you have to add it first into the palette before setting it as a fill color of the 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.

Please add a line of code to update the color palette as following:

Workbook workbook = new Workbook();

.............

// Add light sky blue color to the palette at its last index.

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

.

.

.

cells[0, i].Style.Pattern = BackgroundType.Solid;
cells[0, i].Style.ForegroundColor = Color.LightSkyBlue;

..........

For further reference, please check the doc: http://www.aspose.com/documentation/file-format-components/aspose.cells-for-.net-and-java/colors-and-palette.html

Thank you.