AutoWidthCols produces large xls files.

Questions and answers on how to use XLSReadWriteII 5.
Post Reply
d3nton
Posts: 133
Joined: Thu Oct 25, 2012 9:48 am

AutoWidthCols produces large xls files.

Post by d3nton »

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.

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

Re: AutoWidthCols produces large xls files.

Post by larsa »

Hello

This is fixed in update 5.20.09
Lars Arvidsson, Axolot Data
Post Reply