Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- unit libreofficeexport;
- {$IFDEF FPC}
- {$MODE Delphi}
- {$ELSE}
- {$APPTYPE CONSOLE}
- {$ENDIF}
- interface
- uses SysUtils, Variants, ComObj;
- procedure createDocument;
- procedure writeCellValue(col,row:integer;value:longint);
- procedure writeCellString(col,row:integer;str:widestring);
- implementation
- var Server : Variant;
- Desktop : Variant;
- Document : Variant;
- procedure createDocument;
- begin;
- Desktop := Server.CreateInstance('com.sun.star.frame.Desktop');
- Document := Desktop.LoadComponentFromURL('private:factory/scalc', '_blank', 0, VarArrayCreate([0, -1], varVariant));
- end;
- procedure writeCellValue(col,row:integer;value:longint);
- var Cell,Sheet:Variant;
- begin
- Sheet := Document.getSheets.getByIndex(0);
- Cell := Sheet.GetCellByPosition(col,row);
- Cell.setValue(value);
- end;
- procedure writeCellString(col,row:integer;str:widestring);
- var Cell,Sheet:Variant;
- begin
- Sheet := Document.getSheets.getByIndex(0);
- Cell := Sheet.GetCellByPosition(col,row);
- Cell.setString(str);
- end;
- initialization
- begin
- if Assigned(InitProc) then
- TProcedure(InitProc);
- try
- Server := CreateOleObject('com.sun.star.ServiceManager');
- except
- WriteLn('Unable to start OO.');
- Exit;
- end;
- end;
- end.
Add Comment
Please, Sign In to add comment