Home » excel » Insert PDF into Excel, Python

Insert PDF into Excel, Python

Posted by: admin April 23, 2020 Leave a comment


I wrote a python script that I use to create a spreasheet with various calculations. I want to further insert a pdf into the spreadhseet (pdf is desireable, but a jpeg is useable). I’ve been flipping through xlwt and can’t find anything. Can anyone suggest a way to accomplish this?

How to&Answers:

To actually insert a PDF, you may need to just use Excel. The most convenient way to automate a running instance of Excel is probably VBA or VBScript, but you can still use Python with pywin32 or pywinauto.

If it’s important to stick with Python and it’s acceptable to generate .xlsx instead of .xls, your best bet is XlsxWriter, which lets you import JPEG or PNG (in addition to BMP). Here’s documentation and an example for inserting images with XlsxWriter.