2010-10-14 85 views
0

请帮助我: 我想使用OOoTools.pas 界面确定开放式办公室计算列中的最大值。 以此为FAS,因为我来了:OpenOffice Automation Delphi如何使用callfunction

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:”。为什么? 谢谢

回答

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; 

我不得不说我发现documentation有点不清楚。

当你对我的上述样品中的callFunction方法错误,尝试:上oResult发生

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

错误:= oFuncService.callFunction( 'MAX',VarArrayOf([oCellRange])); – addelichtman 2010-10-14 15:06:40

+0

Hello The_Fox,然后出现“Type Mismatch”错误 – addelichtman 2010-10-14 15:11:11

+0

@addelichtman:K8:K10范围内可能有无效值吗?文字而不是数值? – 2010-10-14 15:53:28