The following inserts the image into cell A1. Adjust the location of the image according to your needs or process the creation of the PIL image yourself and pass it Image()
import openpyxl wb = openpyxl.Workbook() ws = wb.worksheets[0] img = openpyxl.drawing.image.Image('test.jpg') img.anchor = 'A1' ws.add_image(img) wb.save('out.xlsx')
In older versions of openpyxl, the following works:
import openpyxl wb = openpyxl.Workbook() ws = wb.worksheets[0] img = openpyxl.drawing.Image('test.jpg') img.anchor(ws.cell('A1')) ws.add_image(img) wb.save('out.xlsx')
Anthon
source share