我想用Python生成OpenERP中的Ms Word报告,所以我尝试使用python-docx。我在我的界面中的按钮调用的函数中编写了以下代码,以了解执行的结果:
import docx
from docx import Document
from docx.shared import Inches
def fct_imprimer_rapportword(self, cr, uid, ids, context=None):
doc = docx.Document()
doc.add_paragraph('Hello world!')
paraObj1 = doc.add_paragraph('This is a second paragraph.')
paraObj2 = doc.add_paragraph('This is a yet another paragraph.')
paraObj1.add_run(' This text is being added to the second paragraph.')
doc.save('multipleParagraphs.docx')
print 'document===>>>>',doc
return doc
代码执行时没有任何错误,但我没有任何结果!我搜索了文件multipleParagraphs.docx,但我找不到它,似乎还没有创建这个文件。请帮忙吗?