I wrote a programm in pascal to read data from a spreadsheet with Calc. So I can read ".ods" and ".xls" files. Now I want to save changes in ".xls" files. But I think although it has the ".xls" extension it is stored as ".ods".
I open the spreadsheet:
Code: Select all
function T_OO.OpenCalc: Boolean;
var
Path : String;
Par : OLEVariant;
begin
Result := false;
if FileExists( oFilNam ) then
begin
Progress( 'SetCap', 0,0, 'Öffne Datei "' + oFilNam + '"' );
try
oAge := FileAge( oFilNam ) ;
Par := VarArrayCreate([0, 0], varVariant); // [lowest index, highest index]
oOpenOffice := CreateOleObject('com.sun.star.ServiceManager') ;
Par[0] := oOpenOffice.Bridge_GetStruct('com.sun.star.beans.PropertyValue') ;
Par[0].Name := 'Hidden' ;
Par[0].Value := True ;
oStarDesktop := oOpenOffice.createInstance('com.sun.star.frame.Desktop') ;
oFCP := oOpenOffice.createInstance('com.sun.star.ucb.FileContentProvider');
Path := oFCP.getFileURLFromSystemPath('', oFilNam) ;
oFil := oStarDesktop.loadComponentFromURL( Path, '_blank', 0, Par ) ;
oTab := oFil.Sheets.getByName( oShNam ) ;
Result := true ;
except
Code: Select all
procedure T_OO.SaveCalc;
var
Par : OLEVariant; S : String;
begin
Par := VarArrayCreate([0, 0], varVariant) ;
Par[0] := oOpenOffice.Bridge_GetStruct('com.sun.star.beans.PropertyValue');
Par[0].Name := 'Hidden' ;
Par[0].Value := True ;
try
oFil.storeAsURL( oFil.Url, Par );
except
Greetings from the north sea with wite borders
Peter