Excel 报告中的图像

С. *_*цэг 1 image report xlsx odoo

求助,如何打印图像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))
Run Code Online (Sandbox Code Playgroud)

错误是:

warn("Image file '%s' not found." % force_unicode(filename))
Run Code Online (Sandbox Code Playgroud)

怎么解决?我的目标是在 odoo 中打印产品图像。

jmc*_*ara 7

像下面这样的东西应该有效:

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})
Run Code Online (Sandbox Code Playgroud)

请参阅XlsxWriter 文档的insert_image()部分以及将图像从字节流插入工作表的示例。io.BytesIO