from ironxl import *
# Load the Excel workbook
workbook = WorkBook.Load("sample.xlsx")
worksheet = workbook.DefaultWorkSheet
# Set the print header and footer of the worksheet
worksheet.Header.Center = "My document"
worksheet.Footer.Center = "Page &P of &N"
# Set the header margin
worksheet.PrintSetup.HeaderMargin = 2.33
# Set the size of the paper
# Paper size enum represents different sizes of paper
worksheet.PrintSetup.PaperSize = PaperSize.B4
# Set the print orientation of the worksheet
worksheet.PrintSetup.PrintOrientation = PrintOrientation.Portrait
# Set black and white printing
worksheet.PrintSetup.NoColor = True
workbook.SaveAs("PrintSetup.xlsx")