views:

108

answers:

1

Hello could someone please help me with the following, I try 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 info what could be wrong. Or must I use another approach? Thank you very much for your help.

A: 

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);
The_Fox
Works like a charm, thank you very much!
addelichtman