0

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?

1

2 Answers 2

1

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.

Sign up to request clarification or add additional context in comments.

Comments

0
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.

1 Comment

I don't want to add image, I would like to add some "pdf" or "word" file

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.