2011-09-23 88 views
1

我正在使用OpenERP和一個名爲report_openoffice的模塊。該模塊需要安裝python-uno軟件包。問題是我有2個版本的Python(2.6和2.7)。當我安裝軟件包時,Python2.7可以使用軟件包python-uno,但python2.6不能。我需要在python2.6中使用它。有沒有辦法爲python 2.6安裝這個軟件包?安裝了python2.6和python2.7的Python-uno軟件包問題

PS:我在Ubuntu 11.04

非常感謝您

回答

2

我軟鏈接從2.7 uno.pyunohelper.py到2.6,並且似乎工作。 作爲根做(或者與sudo):

$> cd /usr/lib/python2.6/dist-packages 
$> ln -s /usr/lib/python2.7/dist-packages/uno.py 
$> ln -s /usr/lib/python2.7/dist-packages/unohelper.py 
1

蟒-UNO常被用於驅動的​​OpenOffice/LibreOffice的。但是,如果你只是想創建ODT或pdf文件的報告,你可以使用PyQt4的

一個簡單的例子來說明如何寫一個ODT文件:

>>>from pyqt4 import QtGui 
# Create a document object 
>>>doc = QtGui.QTextDocument() 
# Create a cursor pointing to the beginning of the document 
>>>cursor = QtGui.QTextCursor(doc) 
# Insert some text 
>>>cursor.insertText('Hello world') 
# Create a writer to save the document 
>>>writer = QtGui.QTextDocumentWriter() 
>>>writer.supportedDocumentFormats() 
[PyQt4.QtCore.QByteArray(b'HTML'), PyQt4.QtCore.QByteArray(b'ODF'), PyQt4.QtCore.QByteArray(b'plaintext')] 
>>>odf_format = writer.supportedDocumentFormats()[1] 
>>>writer.setFormat(odf_format) 
>>>writer.setFileName('hello_world.odt') 
>>>writer.write(doc) # Return True if successful 
True 

QTextCursor還可以插入表格,框架,塊,圖像。更多信息。的更多信息: http://qt-project.org/doc/qt-4.8/qtextcursor.html

-1

uno包在python 2.7安裝,然後運行下面的命令:

sudo apt-get install libreoffice python-genshi python-cairo python-lxml python-setuptools 
sudo apt-get install libreoffice-script-provider-python 

easy_install uno