2010-10-14 81 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