I'm using Delphi 7 and I'd like to export the contents of a list from my program to OpenOffice Calc using automation, instead of using files.
The task is simple: create new document, iterate through rows/columns and change cell data.
I've found some code but it's not complete, and I was hoping someone has some example code ready to accomplish this very simple task. It could save me a few hours of trying.
Thanks in advance!
Edit: I'd like to automate OpenOffice Calc to achieve what I wrote above. Thanks!
The easiest solution is to write CSV file output, and open that in OpenOffice.
There are also libraries to write .XLS files which both OpenOffice Calc and Excel can read. CSV is so simple, I wonder that you need an example. Create a TStringList, and add strings to it, in comma separated format. Save to file.
The so called "programmatic" method involves OLE automation.
uses
OleAuto;
var
mgr,calc,sheets,sheet1,dt,args:Variant;
begin
args = VarArrayCreate(...);
mgr := CreateOleObject('com.sun.star.ServiceManager');
dt := mgr.createInstance('com.sun.star.frame.Desktop')
calc = dt.loadComponentFromURL('private:factory/scalc', '_blank', 0, args)
sheets = calc.getSheets()
sheet1 = sheets.getByIndex(0)
...
Open Office supports Automation
see: http://udk.openoffice.org/common/man/tutorial/office_automation.html
Open Office info for Delphi can be found at:
http://development.openoffice.org/#OLE
The site ooomacros.org seems to be down, luckily the wayback machine still has a copy:
http://replay.web.archive.org/20090608051118/http://www.ooomacros.org/dev.php
Good luck.