如何将 LibreOffice 功能使用到 Basic 中?
How to use LibreOffice functions into Basic?
我已经 asked here 了解了这样做的好方法。
现在我正在尝试以下代码 found here,但出现了一些意外错误。
我想我没有以正确的方式使用它。有什么想法吗?
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
需要一个方阵。
并且 ZTEST
仅当范围内有值时才有效。
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
我已经 asked here 了解了这样做的好方法。
现在我正在尝试以下代码 found here,但出现了一些意外错误。
我想我没有以正确的方式使用它。有什么想法吗?
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
需要一个方阵。
并且 ZTEST
仅当范围内有值时才有效。
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