Page 1 of 1

Formatting a simple cell

Posted: Tue Oct 29, 2013 2:01 pm
by thefreecat
Hello,
I'm trying to change the font color of one cell to red. I have given up trying to do it with Cell[y,x].fontcolor : I don't know how to specify the color and it messed up my original XLS file.
So I'm now trying, using the example and "Default" formats (I guess this horror is due to Excel's file format) :

Code: Select all

      XLS.CmdFormat.BeginEdit(Nil);
      XLS.CmdFormat.Font.Color.IndexColor:=xcDarkRed;
      XLS.CmdFormat.Font.Style := [xfsBold];
      fmt:=XLS.CmdFormat.AddAsDefault('F3');
Now how do I apply this default F3 (why F3 ?) to one cell ?

And what if I reopen the same xls file and want to apply the same red/bold to another cell ? Do I have to first search in the stored formats if one suits my needs then reuse it or create a new one ?

Is there a documentation somewhere explaining this ? All I found was a reference manual in html and the SampleFormatCells example. None of these 2 explain the concept. What did I miss ?

Thanks,

Re: Formatting a simple cell

Posted: Fri Nov 01, 2013 8:02 am
by larsa
Hello

Here is an example on how to set the font color:

Code: Select all

XLS.CmdFormat.BeginEdit(FXSS.XLS[0]);
XLS.CmdFormat.Font.Color.RGB := $FF0000;
XLS.CmdFormat.Apply(0,0,0,9); // Apply format on cells A1:A10

XLS[0].AsString[0,2] := 'Hello'; // Test it
For more info regarding cell formatting, please study the FormatCells sample.

Re: Formatting a simple cell

Posted: Mon Nov 04, 2013 9:35 am
by thefreecat
Thanks. Upgrading to latest version also helped.