导出列表的OpenOffice Calc的德尔福 [英] Exporting a list to OpenOffice Calc from Delphi

查看:180
本文介绍了导出列表的OpenOffice Calc的德尔福的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在使用Delphi 7,我想从我的计划,以OpenOffice的Calc中使用自动化列表的内容输出,而不是使用的文件。

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.

我已经发现了一些code,但它并不完整,我希望有人有一些例如code准备完成这个非常简单的任务。它可以在几个小时救了我的努力。

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.

在此先感谢!

编辑:我想自动OpenOffice的计算才能达到我上面写的。谢谢!

I'd like to automate OpenOffice Calc to achieve what I wrote above. Thanks!

推荐答案

最简单的办法是写CSV文件输出,并打开OpenOffice中。

The easiest solution is to write CSV file output, and open that in OpenOffice.

也有图书馆写.xls文件其中两个OpenOffice的计算器和Excel可以读取。 CSV就是这么简单,我不知道你需要的例子。创建一个的TStringList,并添加字符串到它,以逗号分隔的格式。保存到文件中。

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.

所谓的纲领性的方法包括OLE自动化。

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)
   ...

这篇关于导出列表的OpenOffice Calc的德尔福的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆