AutoWidthCols produces large xls files.
Posted: Tue Nov 26, 2013 8:06 am
Hi!
The sample below creates an xls file with only one 'test' string in it. The FOR-loop simulates that a user writes to the same xls file several times
adding new sheets to the file. If i use the procedure AutoWitdhCols to adjust the first column with the 'test' strings the file will become unusually large the more often
I save the file (appears to grow exponentially).
In the sample below the file size is ~ 530kb with AutoWidthCols enabled. Opening the file in Excel an saving it again without changin something will result in a smaller file of only 30kb!
If I do not use the AutoWidthCols in the code below, this code produces a file of only 20kb.
Please help.
The sample below creates an xls file with only one 'test' string in it. The FOR-loop simulates that a user writes to the same xls file several times
adding new sheets to the file. If i use the procedure AutoWitdhCols to adjust the first column with the 'test' strings the file will become unusually large the more often
I save the file (appears to grow exponentially).
In the sample below the file size is ~ 530kb with AutoWidthCols enabled. Opening the file in Excel an saving it again without changin something will result in a smaller file of only 30kb!
If I do not use the AutoWidthCols in the code below, this code produces a file of only 20kb.
Please help.
Code: Select all
var
ExcelFile5 : TXLSReadWriteII5;
lstring: String;
i: Integer;
begin
ExcelFile5 := TXLSReadWriteII5.Create(nil);
ExcelFile5.Filename := 'C:\test.xls';
ExcelFile5.Version := xvExcel97;
ExcelFile5.Sheets[0].AsString[0,0] := 'test';
ExcelFile5.Write;
for i := 1 to 15 do begin
ExcelFile5.Read;
ExcelFile5.Add;
ExcelFile5.Sheets[i].AsString[0,0] := 'test';
ExcelFile5.Sheets[i].AutoWidthCols(0,0);
ExcelFile5.Write;
end;