Is it possible to insert an image (jpeg, png, etc) using openpyxl?
Basically I want to place a generated image with a chart below it.
I don't see anything in the documentation, which seems to be a little lacking compared to the maturity of the code.
The following inserts an image in cell A1. Adjust the image location to your needs or handle the creation of the PIL image yourself and hand that to
Image()
Providing a full update on how to do this. This solution uses openpyxl version 2.4.5.
I downloaded an image to my local directory, opened an existing workbook and saved with the image inserted.
Results:
This code worked for me:
In current versions of openpyxl (up to 2.4.5 at least) you have to call Image like this:
img = openpyxl.drawing.image.Image('test.jpg')
Using Anthon's example: