Free Support Forum - aspose.com

Issue with changing foreground color in Excel Cells when using strange RGB configuration

Hi,

I am using Aspose.Cells. v4.2 as all our software is based on this version. I am having issues with changing the foreground and background colors to any strange RGB configuration except for the basic colors such as green, yellow, red, etc. If I use a config like this:

Style stHeaderStyle = wbExcelExport.Styles[intIndex];

stHeaderStyle.Font.IsBold = true;

Color clrScenarioColorTitle = Color.FromArgb(188, 44, 37);

stHeaderStyle.ForegroundColor = clrScenarioColorTitle;

stHeaderStyle.BackgroundColor = clrScenarioColorTitle;

stHeaderStyle.Pattern = BackgroundType.Solid;

stHeaderStyle.Font.Color = Color.White;

stHeaderStyle.Font.Size = 14;

This RGB color is a reddish color, however when I use this configuration I just get a black background color.

I have to use this version as all our software is based on it and I have to keep the versions consistent. If however, this bug is fixed in a newer version, I'd push the request through to upgrade.

Thanks,

Hi,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for considering Aspose.

Well, the rgb colors your are applying might not be present in the Standard Color Palette, so you have to add it first into the palette using Workbook.ChangePalette() method before setting it as a fill color of the cell: http://www.aspose.com/documentation/file-format-components/aspose.cells-for-.net-and-java/colors-and-palette.html Since the MS Excel (97-2003) 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.

For complete ref, please check the following:

http://www.aspose.com/community/forums/thread/74700.aspx

http://www.aspose.com/documentation/file-format-components/aspose.cells-for-.net-and-java/colors-background-patterns.html

Thank you.