Page 1 of 1

How to save in Excel97-Format

Posted: Tue Jun 17, 2014 9:15 am
by Emil1957
Hello,

internally I use a TXLSReadWriteII5 object with version set to xvExcel2007. But I want my users give the possibility to store the data also in Excel97 format. How can I do that? I tried the following

procedure SwitchToOldXLSVersion;
var
strm: TMemoryStream;
begin
strm := TMemoryStream.Create;
try
xlsRW.SaveToStream( strm );
strm.Seek( soFromBeginning, 0 );
xlsRW.Clear;
xlsRW.Version := xvExcel97;
xlsRW.LoadFromStream( strm );
xlsRW.Filename := 'test.xls';
xlsRW.Write;
finally
FreeAndNil( strm );
end;
end;

But when I want to open the xls file with Excel2000 I get an error that the file cannot be read. When I change the extension to xlsx I can open the file with Excel2010. Obviously the file is in Excel2007 format.

Re: How to save in Excel97-Format

Posted: Tue Jun 17, 2014 1:30 pm
by larsa
Hello

You must set the version before you write the stream, not before you read it. Also, you can't change the file version on an existing file.