Reputation: 17
I want to add some object to my excel sheet, I'm using openpyxl, In excel you do it by: Insert->Object
Is there a way to do it thru openpyxl or any other excel tool that working with python?
Upvotes: 0
Views: 2227
Reputation: 19537
While this is not currently possible with openpyxl I suspect it would be fairly straightforward to add the relevant functionality using the add_image()
method as a starting place.
Upvotes: 1
Reputation: 143
import openpyxl
wb = openpyxl.Workbook()
ws = wb.worksheets[0]
picture = openpyxl.drawing.Image('/path/to/picture')
picture.anchor(ws.cell('cell to put the image'))
ws.add_image(picture)
wb.save('whatever you want to save the workbook as')
This code of course refers to creating a new workbook and adding the image into it. To add the image to your preexisting workbook you would obviously just load that workbook using load_workbook
.
Upvotes: 0