我正在尝试创建一个python程序(使用pyUNO)在OpenOffice计算表上进行一些更改.
我已经在"接受"模式下启动了以前的OpenOffice,以便能够从外部程序进行连接.显然,应该像以下一样简单:
import uno
# get the uno component context from the PyUNO runtime
localContext = uno.getComponentContext()
# create the UnoUrlResolver
resolver = localContext.ServiceManager.createInstanceWithContext(
"com.sun.star.bridge.UnoUrlResolver", localContext)
# connect to the running office
ctx = resolver.resolve("uno:socket,host=localhost,port=2002;"
"urp;StarOffice.ComponentContext")
smgr = ctx.ServiceManager
# get the central desktop object
DESKTOP =smgr.createInstanceWithContext("com.sun.star.frame.Desktop", ctx)
#The calling it's not exactly this way, just to simplify the code
DESKTOP.loadComponentFromURL('file.ods')
Run Code Online (Sandbox Code Playgroud)
但是AttributeError当我尝试访问时,我得到了一个loadComponentFromURL.如果我做了dir(DESKTOP),我只看到以下属性/方法:
['ActiveFrame', 'DispatchRecorderSupplier', 'ImplementationId', 'ImplementationName',
'IsPlugged', 'PropertySetInfo', 'SupportedServiceNames', 'SuspendQuickstartVeto',
'Title', 'Types', 'addEventListener', 'addPropertyChangeListener',
'addVetoableChangeListener', 'dispose', 'disposing', 'getImplementationId',
'getImplementationName', 'getPropertySetInfo', 'getPropertyValue',
'getSupportedServiceNames', 'getTypes', 'handle', 'queryInterface',
'removeEventListener', 'removePropertyChangeListener', 'removeVetoableChangeListener',
'setPropertyValue', 'supportsService']
Run Code Online (Sandbox Code Playgroud)
我已经读过有一个bug在做同样的事情,但在OpenOffice 3.0上(我在Red Hat5.3上使用的是OpenOffice 3.1).我试图使用此处所述的解决方法,但它们似乎没有起作用.
有任何想法吗?