https://bugs.freedesktop.org/show_bug.cgi?id=60158

          Priority: medium
            Bug ID: 60158
          Assignee: libreoffice-bugs@lists.freedesktop.org
           Summary: python cannot invoke  LO cacle built-in functions
          Severity: normal
    Classification: Unclassified
                OS: Linux (All)
          Reporter: jmx...@qq.com
          Hardware: x86 (IA32)
            Status: UNCONFIRMED
           Version: 4.0.0.2 rc
         Component: BASIC
           Product: LibreOffice

Created attachment 74049
  --> https://bugs.freedesktop.org/attachment.cgi?id=74049&action=edit
This document is embedded python script.

Trying with python to invoke cacle built-in functions,
However, it seems the cacle built-in functions can only accept python tuple,
it can not accept python list.
If the built-in functions with multiple parameters, I do not know how to pass
parameters?

The following invokeSUM function run successfully, error while invokeCOUNTIF.

# python code list
# -*- encoding: UTF-8 -*-

import uno
import unohelper
from com.sun.star.script.provider import XScriptProviderFactory
from com.sun.star.script.provider import XScriptProvider
from com.sun.star.script.provider import XScriptContext

def invokeSUM(*args):
    # get the doc from the scripting context which is made available to all
scripts
    oDoc = XSCRIPTCONTEXT.getDocument()
    # retrieve the active sheet
    oSheet = oDoc.getSheets().getByName("sheet1")
    uurl = 'com.sun.star.sheet.FunctionAccess'
    FP = uno.getComponentContext().ServiceManager.createInstance(uurl)
    oRange = oSheet.getCellRangeByName("A1:A4")
    aData = oRange.getDataArray()
    aA = ()
    for n in aData:
        aA = aA + (n[0],)
    jj = FP.callFunction("SUM", aA)
    oSheet.getCellRangeByName("B1").ssetString("SUM(A1:A4)=")
    oSheet.getCellRangeByName("B2").setString(jj)
    return None

def invokeCOUNTIF(*args):
    # get the doc from the scripting context which is made available to all
scripts
    oDoc = XSCRIPTCONTEXT.getDocument()
    # retrieve the active sheet
    oSheet = oDoc.getSheets().getByName("sheet1")
    uurl = 'com.sun.star.sheet.FunctionAccess'
    FP = uno.getComponentContext().ServiceManager.createInstance(uurl)
    oRange = oSheet.getCellRangeByName("A1:A4")
    aData = oRange.getDataArray()
    aA = ()
    for n in aData:
        aA = aA + (n[0],)
    bB = ("<3",)
    cC = (aA,bB)
    kk = FP.callFunction("COUNTIF",cC)
    oSheet.getCellRangeByName("C1").setString("COUNTIF(A1:A4,<3)=")
    oSheet.getCellRangeByName("C2").setString(kk)
    return None

-- 
You are receiving this mail because:
You are the assignee for the bug.
_______________________________________________
Libreoffice-bugs mailing list
Libreoffice-bugs@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-bugs

Reply via email to