如何将LibreOffice函数用于Basic? [英] How to use LibreOffice functions into Basic?
本文介绍了如何将LibreOffice函数用于Basic?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经在这里问有关好的方法为此.
I've asked here about the good way to do so.
现在我正在尝试以下代码找到了这里,并得到一些意外错误.
Now I'm trying the following code found here, and get some unexpected errors.
我想我没有正确使用它.有什么主意吗?
I suppose I'm not using it the correct way. Any idea ?
Sub Main
Dim aResult
Dim aFunc
Dim oRange
aFunc = GetProcessServiceManager().createInstance("com.sun.star.sheet.FunctionAccess")
aResult = aFunc.callFunction("SUM", Array(1, 2, 3))
' ---- Works OK
Print aResult
aResult = aFunc.callFunction("MDETERM", Array(2, 5, 8))
' ---- IllegalArgumentException
Print aResult
oRange = ThisComponent.sheets(0).getcellrangebyname("B4:B6")
aResult = aFunc.callFunction("ZTEST", Array(oRange, 2.5, 1.0))
' ---- IllegalArgumentException
Print aResult
End Sub
推荐答案
MDETERM
需要一个正方形数组.
MDETERM
needs a square array.
ZTEST
仅在范围内有值的情况下有效.
And ZTEST
works only if there are values in the range.
Sub Main
Dim oFunc as Object
Dim vResult as Variant
Dim oRange as Object
Dim bDoZTEST as Boolean
Dim aSubArray as Variant
Dim vValue as Variant
oFunc = GetProcessServiceManager().createInstance("com.sun.star.sheet.FunctionAccess")
vResult = oFunc.callFunction("SUM", Array(1, 2, 3))
Print vResult
vResult = oFunc.callFunction("MDETERM", Array(Array(Array(2, 5, 8), Array(1, 4, 3), Array(9, 7, 6))))
Print vResult
oRange = ThisComponent.sheets(0).getCellRangeByName("B4:B6")
bDoZTEST = true
vResult = Empty
for each aSubArray in oRange.DataArray
for each vValue in aSubArray
if not isNumeric(vValue) then bDoZTEST = false
next
next
if bDoZTEST then vResult = oFunc.callFunction("ZTEST", Array(oRange, 2.5, 1.0))
Print vResult
End Sub
这篇关于如何将LibreOffice函数用于Basic?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文