Exporting a list to OpenOffice Calc from Delphi

只谈情不闲聊 提交于 2019-12-06 01:46:01

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!