在 OpenOffice Calc 中创建图表

发布于 2024-09-26 18:45:48 字数 1621 浏览 0 评论 0原文

我正在尝试使用 OOoTools.pas 界面创建 OpenOffice Calc 图表。代码是这样的:

/////////////////////////////// CODE //////////////////////////////////

procedure TForm1.ProcessChart(aFilename : String);
Var
                  oTheFile, oAllSheets, oMySheet, oCharts,
                  oCellRangeAddress, oRectangle, oSize : Variant;
begin
 ConnectOpenOffice;
   oTheFile := OpenSheet(aFilename, True);
   oAllSheets:= oTheFile.Sheets;

   oMySheet:= oAllSheets.getByIndex(0);  // first sheet of the spreadsheet

   oCharts := oMySheet.getCharts;

   oCellRangeAddress := oTheFile.Bridge_getStruct('com.sun.star.table.CellRangeAddress');
   oCellRangeAddress.Sheet       := 0;// '1ere feuille du graphique
   oCellRangeAddress.StartColumn := 0;// 'Ligne 1
   oCellRangeAddress.StartRow    := 0;// 'Colonne A
   oCellRangeAddress.EndColumn   := 3;// 'Colonne D
   oCellRangeAddress.EndRow      := 29;// 'Ligne 30

   oRectangle := oTheFile.Bridge_GetStruct('com.sun.star.awt.Rectangle');
   oRectangle := oMySheet.Bridge_GetStruct('com.sun.star.awt.Rectangle');
   oRectangle.X      := 8000;
   oRectangle.Y      := 1000;
   oRectangle.Width  := 5000;
   oRectangle.Height := 5000;

   // Type Error Mismatch error on this call:       
   oCharts.addNewByName('LogData',
                        oRectangle,
                        oCellRangeAddress,
                        true,
                        true);

 DisconnectOpenOffice;
End;

/////////////////////////////// END CODE //////////////////////////////////

oCharts.addNewByName 调用中,我收到“类型不匹配”错误,并且没有进一步的信息可能出现错误。

或者我必须使用另一种方法?

I am trying to create an OpenOffice Calc chart using the OOoTools.pas interface. The code is this:

/////////////////////////////// CODE //////////////////////////////////

procedure TForm1.ProcessChart(aFilename : String);
Var
                  oTheFile, oAllSheets, oMySheet, oCharts,
                  oCellRangeAddress, oRectangle, oSize : Variant;
begin
 ConnectOpenOffice;
   oTheFile := OpenSheet(aFilename, True);
   oAllSheets:= oTheFile.Sheets;

   oMySheet:= oAllSheets.getByIndex(0);  // first sheet of the spreadsheet

   oCharts := oMySheet.getCharts;

   oCellRangeAddress := oTheFile.Bridge_getStruct('com.sun.star.table.CellRangeAddress');
   oCellRangeAddress.Sheet       := 0;// '1ere feuille du graphique
   oCellRangeAddress.StartColumn := 0;// 'Ligne 1
   oCellRangeAddress.StartRow    := 0;// 'Colonne A
   oCellRangeAddress.EndColumn   := 3;// 'Colonne D
   oCellRangeAddress.EndRow      := 29;// 'Ligne 30

   oRectangle := oTheFile.Bridge_GetStruct('com.sun.star.awt.Rectangle');
   oRectangle := oMySheet.Bridge_GetStruct('com.sun.star.awt.Rectangle');
   oRectangle.X      := 8000;
   oRectangle.Y      := 1000;
   oRectangle.Width  := 5000;
   oRectangle.Height := 5000;

   // Type Error Mismatch error on this call:       
   oCharts.addNewByName('LogData',
                        oRectangle,
                        oCellRangeAddress,
                        true,
                        true);

 DisconnectOpenOffice;
End;

/////////////////////////////// END CODE //////////////////////////////////

In the oCharts.addNewByName call I get a "Type Mismatch" error and have no further information what could be wrong.

Or must I use another approach?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

迷你仙 2024-10-03 18:45:48

addNewByName 需要一个 com.sun.star.table.CellRangeAddress 并且您没有给出 CellRangeAddress 结构序列,而是给出结构本身。

试试这个:

oCharts.addNewByName('LogData',
                        oRectangle,
                        VarArrayOf(oCellRangeAddress),
                        true,
                        true);

The aRanges parameter of addNewByName expects a sequence of com.sun.star.table.CellRangeAddress and you are not giving a sequence of CellRangeAddress structs, but the struct itself.

Try this:

oCharts.addNewByName('LogData',
                        oRectangle,
                        VarArrayOf(oCellRangeAddress),
                        true,
                        true);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文