Python – How to fill Excel cell with image, using python

If you have ever dreamed that it will be possible to fill out an Excel cell with a picture, using Python, then you should probably reevaluate your dreams. Seriously, who dreams of something like that?

Filling Excel cell with a picture is not scary.

Without further dreaming, the code below will return a file named export.xlsx with my logo on it on cell B2:

Like this:

It is not a coincidence, that the left upper part of the picture is around cell B2, see the code above.

Abd if you want to upload the picture from your PC, then uncomment this line and run it again – img = openpyxl.drawing.image.Image('printing_a_picture.png').

That’s all folks!