我正在使用OpenERP和一个名为report_openoffice的模块。该模块需要安装python-uno包。问题是我有两个版本的python(2.6和2.7)。当我安装这个包时,Python2.7可以使用包python-uno,但是python2.6不能,我需要在python2.6中使用它。有没有办法为python2.6安装这个包?
PS:我在Ubuntu 11.04上
非常感谢
发布于 2011-10-20 04:16:39
我将uno.py和unohelper.py从2.7版本软链接到了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发布于 2012-10-04 22:40:28
python-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
TrueQTextCursor还可以插入表、帧、块和图像。更多信息。有关更多信息,请访问:http://qt-project.org/doc/qt-4.8/qtextcursor.html
发布于 2016-10-14 19:27:44
在Python2.7中安装uno包,然后运行以下命令:
sudo apt-get install libreoffice python-genshi python-cairo python-lxml python-setuptools
sudo apt-get install libreoffice-script-provider-python
easy_install unohttps://stackoverflow.com/questions/7526773
复制相似问题