开发者

OpenOffice Automation Delphi how use a callfunction

开发者 https://www.devze.com 2023-01-19 20:20 出处:网络
please help me with the following: I want to determine the maximum value in an open office calc column using the OOoTools.pas

please help me with the following: I want to determine the maximum value in an open office calc column using the OOoTools.pas interface. This as fas as I come:

Procedure FindMaximum(oMySheet : Variant);
Var
            oFuncService : Variant;
Begin
  oFuncService := CreateUnoService('com.sun.star.sheet.FunctionAccess');
  ShowMessage(oFuncService.callF开发者_如何学Cunction('MAX', VarArrayOf([10,20,50])));
End;

This works

Of course I want to fill in the values of a column like:

ShowMessage(oFuncService.callFunction('MAX', VarArrayOf([oMySheet.getCellRangeByName('K8:K10')])));

I get the message "com.star.lang.IllegalArgumentException:." why? Thanks


Here I am again.

Is it the callFunction method that gives this error or the getCellRangeByName method?

procedure FindMaximum(oMySheet : Variant);
var
  oFuncService : Variant;
  oCellRange: Variant;
  oResult: Variant;
begin
  oFuncService := CreateUnoService('com.sun.star.sheet.FunctionAccess');

  //error here?
  oCellRange := oMySheet.getCellRangeByName('K8:K10');

  //or error here?
  oResult := oFuncService.callFunction('MAX', VarArrayOf([oCellRange]));

  ShowMessage(oResult);
end;

I have to say that I find the documentation a bit unclear.

When you have the error on the callFunction method in my above sample, try this:

//CellRange not wrapped in a VariantArray
oResult := oFuncService.callFunction('MAX', oCellRange);
0

精彩评论

暂无评论...
验证码 换一张
取 消