Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Insert PDF into Excel, Python

Tags:

python

excel

pdf

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?

like image 283
Mike Avatar asked Nov 07 '25 02:11

Mike


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

like image 98
John Y Avatar answered Nov 09 '25 19:11

John Y



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!