Excel报告中的图像 [英] image in excel report
本文介绍了Excel报告中的图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
帮助,如何打印图像Excel报告? 请帮我? 我使用xlsxwriter. xlsxwriter的示例 这是我的代码:
product_image = product_product.product_tmpl_id.image
imgdata = base64.b64decode(product_image)
image = Image.open(io.BytesIO(imgdata))
# imgdata = base64.b64decode(product_image)
# image = io.BytesIO(imgdata)
print type(image)
sheet.insert_image(rowx, 12, str(image))
错误是:
warn("Image file '%s' not found." % force_unicode(filename))
如何解决? 我的目标是在odoo中打印产品图片.
解决方案
类似以下的方法应该起作用:
product_image = product_product.product_tmpl_id.image
imgdata = base64.b64decode(product_image)
image = io.BytesIO(imgdata)
worksheet.insert_image('B5', 'myimage.png', {'image_data': image})
请参阅XlsxWriter文档的 insert_image()部分和此示例,它是将io.BytesIO
字节流中的图像插入到工作表中.>
Help, How can i print image excel report? Please, help me? I use xlsxwriter. Example of xlsxwriter This is my code:
product_image = product_product.product_tmpl_id.image
imgdata = base64.b64decode(product_image)
image = Image.open(io.BytesIO(imgdata))
# imgdata = base64.b64decode(product_image)
# image = io.BytesIO(imgdata)
print type(image)
sheet.insert_image(rowx, 12, str(image))
The error is:
warn("Image file '%s' not found." % force_unicode(filename))
How to solve? My goal is print product image in odoo.
解决方案
Something like the following should work:
product_image = product_product.product_tmpl_id.image
imgdata = base64.b64decode(product_image)
image = io.BytesIO(imgdata)
worksheet.insert_image('B5', 'myimage.png', {'image_data': image})
See the insert_image() section of the XlsxWriter docs and this example of inserting images from an io.BytesIO
byte stream into a worksheet.
这篇关于Excel报告中的图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文