Python-uno package issue with python2.6 and python2.7 installed
我正在使用 OpenERP 和一个名为 report_openoffice 的模块。该模块需要安装包 python-uno。问题是我有 2 个版本的 python(2.6 和 2.7)。当我安装包时,Python2.7 可以使用包 python-uno 但 python2.6 不能。我需要在python2.6中使用它。有没有办法为 python 2.6 安装这个包?
PS:我在 Ubuntu 11.04
非常感谢
我将 uno.py 和 unohelper.py 从 2.7 软链接到 2.6,这似乎可行。
以 root 身份(或使用 sudo ):
| 1 2 3 |
$ > 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 |
python-uno 常用于驱动 OpenOffice/LibreOffice。但是,如果您只想在 odt 或 pdf 文件中创建报告,则可以使用 PyQt4
显示如何写入 odt 文件的简单示例:
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
>>> 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
uno 在 python 2.7 中安装包,然后运行以下命令:
| 1 2 3 4 |
sudo apt-get install libreoffice python-genshi python-cairo python-lxml python-setuptools sudo apt-get install libreoffice-script-provider-python easy_install uno |
声明:本站(华域联盟www.cnhackhy.com)所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。

评论(0)