问题描述
我正在创建一个小程序,该程序使用python-docx-template库将报告生成为.docx文件。在此程序中,我有一个函数可以使用不同的值和图片(放置在虚拟徽标占位符中)生成此报告。
我首先想到了生成报告并将其与预期报告进行比较,但是我仍然不确定如何进行此检查。
这是有问题的功能:
def generate_report(name,logo):
doc = DocxTemplate("templates/template.docx")
context = { 'name' : name,'stat1': "955$",'stat2': "800$"
}
with Image.open(logo) as logo:
padded_logo = pad_logo(logo)
buffered_logo = image_to_bytes_buffer(padded_logo)
doc.replace_pic('dummy',buffered_logo)
doc.render(context)
doc.save("output/generated_doc.docx")
padded_logo.close()
buffered_logo.close()
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)