I want to set the paper size print option to A6 or a custom user size template with openpyxl
, the code would be as follows:
workbook = Workbook()
ws = workbook.active
ws.page_setup.paperSize = ws.PAPERSIZE_CUSTOM
unfortunately, from the docs, it seems the only enumerated sizes available are:
PAPERSIZE_LETTER = '1'
PAPERSIZE_LETTER_SMALL = '2'
PAPERSIZE_TABLOID = '3'
PAPERSIZE_LEDGER = '4'
PAPERSIZE_LEGAL = '5'
PAPERSIZE_STATEMENT = '6'
PAPERSIZE_EXECUTIVE = '7'
PAPERSIZE_A3 = '8'
PAPERSIZE_A4 = '9'
PAPERSIZE_A4_SMALL = '10'
PAPERSIZE_A5 = '11'
I've tried setting the paper height and paper width to my custom properties as such:
#ws.page_setup.paperSize = ws.PAPERSIZE_A6
ws.page_setup.paperHeight = '105mm'
ws.page_setup.paperWidth = '148mm'
however, when printing thru excel, I still have to use the drop down dialog to select 'A6' before I can print to the correct paper size.
Is there a way I can do this? or achieve a similar effect? I'm on Mac OS if that matters.