excel 报告中的图片

image in excel report

求助,如何打印图像 excel 报告? 请帮我? 我使用 xlsxwriter。 Example of 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})

查看 insert_image() section of the XlsxWriter docs and this example 将图像从 io.BytesIO 字节流插入工作表。