0

请帮我解决以下问题:我想使用 OOoTools.pas 界面确定开放办公室计算列中的最大值。这是我来的时候:

Procedure FindMaximum(oMySheet : Variant);
Var
            oFuncService : Variant;
Begin
  oFuncService := CreateUnoService('com.sun.star.sheet.FunctionAccess');
  ShowMessage(oFuncService.callFunction('MAX', VarArrayOf([10,20,50])));
End;

这有效

当然,我想填写一列的值,例如:

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

我收到消息“com.star.lang.IllegalArgumentException:。” 为什么?谢谢

4

1 回答 1

0

我又来了。

callFunction给出这个错误的方法还是getCellRangeByName方法?

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;

我不得不说我发现文档有点不清楚。

当您callFunction在上述示例中的方法出现错误时,请尝试以下操作:

//CellRange not wrapped in a VariantArray
oResult := oFuncService.callFunction('MAX', oCellRange);
于 2010-10-14T14:55:52.183 回答