Hi!
I got an EAccessViolation in function TXc12XF.GetFont when changing the FontColor for multiple cells (XLSReadWriteII 5.10.02).
I am not sure but it seems that this error only occurs if I am using the old xls format.
Sample code:
var
ExcelFile5 : TXLSReadWriteII5;
lindex :Integer;
begin
ExcelFile5 := TXLSReadWriteII5.Create(nil);
ExcelFile5.Version := Xc12Utils5.xvExcel97; <---- using old xls format
ExcelFile5.Filename := 'D:\output.xls';
for lIndex := 0 to 1000 do begin
ExcelFile5[0].AsString[0,lIndex] := 'test';
ExcelFile5[0].Cell[0,lindex].FontColor := $5050FF; <------- this results in an EAccessViolation
end;
ExcelFile5.Write;
end;
Any help would be appreciated.
Thank you.
EAccessViolation when changing FontColor for multiple cells
Re: EAccessViolation when changing FontColor for multiple cells
Hello
Don't use the Cell object for formatting several cells. It's only usefull for just formatting a few cells, or read the format of cells.
Use CmdFormat instead. Example:
Don't use the Cell object for formatting several cells. It's only usefull for just formatting a few cells, or read the format of cells.
Use CmdFormat instead. Example:
Code: Select all
for i := 0 to 1000 do
XLS[0].AsString[1,i] := 'Test';
XLS.CmdFormat.BeginEdit(XLS[0]);
XLS.CmdFormat.Font.Color.RGB := $5050FF;
XLS.CmdFormat.Apply(1,0,1,1000);
Lars Arvidsson, Axolot Data
Re: EAccessViolation when changing FontColor for multiple cells
Hi!
Thank you! Works great.
Unfortunately I have a similar problem when trying to convert multiple cells into date format. I get the same EAccessViolation.
I know, I should not access the cells directly for formatting multiple cells but I don't find a function similar to the cmdformat which converts the cells into date format:
Sample
var
ExcelFile5 : TXLSReadWriteII5;
lindex :Integer;
begin
ExcelFile5 := TXLSReadWriteII5.Create(nil);
ExcelFile5.Version := Xc12Utils5.xvExcel97;
ExcelFile5.Filename := 'D:\output.xls';
for lIndex := 0 to 1000 do begin
ExcelFile5[0].AsDateTime[0,lindex] := date; <- EAccessViolation
end;
ExcelFile5.Write;
end.
Is there a function (similar to the cmdformat) which can be used for this?
Thank you.
Thank you! Works great.
Unfortunately I have a similar problem when trying to convert multiple cells into date format. I get the same EAccessViolation.
I know, I should not access the cells directly for formatting multiple cells but I don't find a function similar to the cmdformat which converts the cells into date format:
Sample
var
ExcelFile5 : TXLSReadWriteII5;
lindex :Integer;
begin
ExcelFile5 := TXLSReadWriteII5.Create(nil);
ExcelFile5.Version := Xc12Utils5.xvExcel97;
ExcelFile5.Filename := 'D:\output.xls';
for lIndex := 0 to 1000 do begin
ExcelFile5[0].AsDateTime[0,lindex] := date; <- EAccessViolation
end;
ExcelFile5.Write;
end.
Is there a function (similar to the cmdformat) which can be used for this?
Thank you.
Re: EAccessViolation when changing FontColor for multiple cells
Hello
This is fixed in update 5.10.06
This is fixed in update 5.10.06
Lars Arvidsson, Axolot Data
Re: EAccessViolation when changing FontColor for multiple cells
Thank you.
The EAccessViolation issue seems to be fixed. But now I got a corrupted xls file with the code above.
Opening the created xls file in Excel results in the following message: Protected view - 'Office has detected a problem with the file. Editing it may harm your computer. Click more for details'.
The EAccessViolation issue seems to be fixed. But now I got a corrupted xls file with the code above.
Opening the created xls file in Excel results in the following message: Protected view - 'Office has detected a problem with the file. Editing it may harm your computer. Click more for details'.
Re: EAccessViolation when changing FontColor for multiple cells
Hello
FIxed in update 5.10.07
FIxed in update 5.10.07
Lars Arvidsson, Axolot Data