Default format example not working

Questions and answers on how to use XLSReadWriteII 5.
Post Reply
rjvanvliet
Posts: 17
Joined: Fri Feb 01, 2013 8:24 pm

Default format example not working

Post by rjvanvliet »

I try to implement the fastest method to format cells, but the example 'formatcells' shows only the format that is created al last. I moved 'F3' to the front and all the cells are not yellow anymore but red. So it donot listen to the if statements. That is a pitty because this method looks really good!!
larsa
Site Admin
Posts: 926
Joined: Mon Jun 27, 2005 9:30 pm

Re: Default format example not working

Post by larsa »

Hello

Can you please show me a complete code sample?
Lars Arvidsson, Axolot Data
rjvanvliet
Posts: 17
Joined: Fri Feb 01, 2013 8:24 pm

Re: Default format example not working

Post by rjvanvliet »

It is just your example. I excepted to see 3 formats in the excelfile, but I only see the green color format[color=$10F040][/color]:

// Create first default format.
// The sheet parameter of BeginFormat is Nil, as it's not assigned to any
// particular woeksheet.
XLS.CmdFormat.BeginEdit(Nil);
XLS.CmdFormat.Fill.BackgroundColor.RGB := $7F7F10;
XLS.CmdFormat.Font.Name := 'Courier new';
XLS.CmdFormat.AddAsDefault('F1');

// Create second default format.
XLS.CmdFormat.BeginEdit(Nil);
XLS.CmdFormat.Fill.BackgroundColor.RGB := $FF1010;
XLS.CmdFormat.Font.Name := 'Ariel Black';
XLS.CmdFormat.AddAsDefault('F2');

// Create third default format.
XLS.CmdFormat.BeginEdit(Nil);
XLS.CmdFormat.Fill.BackgroundColor.RGB := $10F040;
XLS.CmdFormat.Font.Name := 'Times New Roman';
XLS.CmdFormat.Font.Style := [xfsBold,xfsItalic];
DefFmt_F3 := XLS.CmdFormat.AddAsDefault('F3');

// The default formats are in the XLS.CmdFormat.Defaults property.

for R := 2 to 100 do begin
if (R mod 4) = 0 then
// Assign format by name.
XLS.DefaultFormat := XLS.CmdFormat.Defaults.Find('F2')
else if (R mod 7) = 0 then
// Assign format by variable.
XLS.DefaultFormat := DefFmt_F3
else
// Assign format by index. We know that format 'F1' has index #0 as the
// list was empty.
XLS.DefaultFormat := XLS.CmdFormat.Defaults[0];
XLS[0].AsFloat[2,R] := 525;
end;

// Reset the default format.
XLS.DefaultFormat := Nil;
larsa
Site Admin
Posts: 926
Joined: Mon Jun 27, 2005 9:30 pm

Re: Default format example not working

Post by larsa »

Hello

This is fixed in 5.10.03
Lars Arvidsson, Axolot Data
rjvanvliet
Posts: 17
Joined: Fri Feb 01, 2013 8:24 pm

Re: Default format example not working

Post by rjvanvliet »

Great!! :-D
Post Reply