का उपयोग कर ओपनऑफिस पर एक दस्तावेज़ लोड करना मैं ओपनऑफिस कैल्क शीट पर कुछ बदलाव करने के लिए एक पायथन प्रोग्राम (पायुनो का उपयोग करके) बनाने की कोशिश कर रहा हूं।बाहरी पायथन प्रोग्राम
मैंने बाहरी प्रोग्राम से कनेक्ट करने में सक्षम होने के लिए पहले "ओपनऑफिस" ओपनऑफिस लॉन्च किया है। जाहिर है, के रूप में के रूप में आसान होना चाहिए:
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')
लेकिन मैं एक 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']
मैं कहाँ एक बग एक ही कर देखते हैं कि पढ़ा है, लेकिन OpenOffice 3.0 पर (मैं OpenOffice 3.1 से अधिक उपयोग कर रहा हूँ लाल Hat5.3)। मैंने here बताए गए वर्कअराउंड का उपयोग करने की कोशिश की है, लेकिन ऐसा लगता है कि वे काम नहीं कर रहे हैं।
कोई विचार?
विधि नहीं, पाया जाता है के रूप में मैं विधि itsef प्राप्त करने की कोशिश कर रहा है, इंटरैक्टिव खोल से पैरामीटर के बिना बुला: - (मैंने इसे चार पैरामीटर के साथ कॉल करने का भी प्रयास किया है, मैंने इसे जानबूझकर सरल बना दिया है। – Khelben