Page 1 of 1

FontColor doesn't seem to work

Posted: Sat Jun 04, 2011 10:04 pm
by BlueKnight
I have used the following (C++) code to assign a value to a cell and format it:

xlSht->AsString[0][0] = "Report for " + dtMthStart.FormatString("mmmm yyyy");
TCell* cl = xlSht->Cell[0][0];
cl->FontName = "Arial Black";
cl->FontStyle = TXFontStyles() << xfsBold;
cl->FontSize = 20;
cl->FontColor = xcRed;

All of this works fine apart from FontColor - no matter what I enter it always stays as the default colour (black).

Re: FontColor doesn't seem to work

Posted: Sun Jun 05, 2011 12:17 am
by BlueKnight
Further investigation has revealed that FontColor should be specified as RGB, rather than one of the Excel colours.

I then tried "cl->FontColor = XColorToRGB(xcGray50)", but that gave me R=128, G=128, B=0!

For now I have worked around this by assigning "cl->FontColor = 0x7f7f7f", as defined in Excel.

Lars, can you please check/fix the code for XColorToRGB?