How to save in Excel97-Format
Posted: Tue Jun 17, 2014 9:15 am
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.
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.