Formatting a simple cell

Questions and answers on how to use XLSReadWriteII 5.
Post Reply
thefreecat
Posts: 12
Joined: Mon Sep 12, 2005 10:52 pm

Formatting a simple cell

Post 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,
larsa
Site Admin
Posts: 926
Joined: Mon Jun 27, 2005 9:30 pm

Re: Formatting a simple cell

Post 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.
Lars Arvidsson, Axolot Data
thefreecat
Posts: 12
Joined: Mon Sep 12, 2005 10:52 pm

Re: Formatting a simple cell

Post by thefreecat »

Thanks. Upgrading to latest version also helped.
Post Reply