openoffice再次使用delphi进行计算

时间:2012-02-14 09:16:35

标签: delphi delphi-7 openoffice.org ole openoffice-calc

我使用的是搜索引擎而不仅仅是在这里,并且厌倦了它;只想要一个简单的答案(或链接)来解决一个简单的问题:

如何打开计算表并从Delphi(7)代码中将123写入单元格A1? (或任何问题的世界?)

2 个答案:

答案 0 :(得分:3)

你可以看看这个演示: http://sourceforge.net/projects/ooomacros/files/Delphi%20OOo/Version%201.2/Delphi_OOo_v12en.zip/download

我在一个月前测试了文档部分(有效),而且我在examples.pas中也有一些电子表格代码。

答案 1 :(得分:3)

好的,经过一些研究并使用上述信息后,我非常感谢,这里有一个简单的答案:

使用部分

Uses ComObj, OOoMessages, OOoTools, OOoConstants, OOoXray;

主要代码

打开空白文档,将'hello 123'文本写入a1,然后将其保存在桌面上

procedure HelloWorldExample;
var
  mentesiOpciok,oSheet,oSheets,myCalc : Variant;
begin
  ConnectOpenOffice;
  myCalc:=StarDesktop.loadComponentFromURL('private:factory/scalc', '_blank', 0, dummyArray);
  oSheets:=myCalc.getSheets;
  oSheet:=oSheets.getByIndex(0);
  //oSheet.getCellByPosition(0, 0).SetValue(123);
  oSheet.getCellByPosition(0, 0).SetFormula('hello 123!');

  mentesiOpciok:=CreateProperties(['FilterName', 'MS Excel 97']);
  myCalc.storeToURL('file:///C:/Documents and Settings/Zéiksz/Asztal/calcdoc.xls', mentesiOpciok);
  showMessage('kész :)');
  myCalc.close(true);
  DisconnectOpenOffice();
end;

使用getcellbyposition(...)。setvalue来设置数值,或者设置字符串(不太确定,但是LOL中有一个字符串)。

彼得

编辑:我在互联网上找到的最有用的信息都在这个论坛中: http://www.oooforum.org/forum/viewtopic.phtml?t=4996

相关问题