问题
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.
回答1:
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.
来源:https://stackoverflow.com/questions/52148963/image-in-excel-report