FontColor doesn't seem to work

Questions and answers on how to use XLSReadWriteII 3/4/5.
Post Reply
BlueKnight
Posts: 8
Joined: Sun Jun 20, 2004 1:40 pm
Location: New Zealand
Contact:

FontColor doesn't seem to work

Post 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).
BlueKnight
Posts: 8
Joined: Sun Jun 20, 2004 1:40 pm
Location: New Zealand
Contact:

Re: FontColor doesn't seem to work

Post 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?
Post Reply