Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OpenPyXL - How to set print area for a worksheet

I am trying to use OpenPyXL to create invoices. I have a worksheet with an area to be printed and some notes outside of that range. I have most everything working but I am unable to find anything in the API for one function. Is there a way to set the print area on a worksheet?

I am able to find lots of print settings, but not the print area.

Thanks!

like image 633
Len Wanger Avatar asked Oct 27 '25 14:10

Len Wanger


1 Answers

In the current version of openpyxl (2.5.4 at time of writing), this is done using:

Worksheet.print_area = "A1:L25"

Docs are here.

like image 127
Jamie Bull Avatar answered Oct 30 '25 07:10

Jamie Bull



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!