How to use LibreOffice functions into Basic?

夙愿已清 提交于 2019-12-01 21:38:17

MDETERM needs a square array.

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
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!