IRONSOFTWAREHOME
Excel Print Setup
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")
pip install ironxl
Excel Print Setup

Excel Print Setup

The Excel Print Setup feature in IronXL allows Python developers to configure print settings for Excel worksheets before printing or saving them as PDFs. This is particularly useful when generating reports, invoices, or documents that require specific formatting for print output. Developers can set custom headers and footers with dynamic content such as page numbers and titles, ensuring a professional result. The PrintSetup options also allow fine-tuning of margins, paper size, and orientation, making it possible to adapt the document for various printers and paper types.

IronXL provides full control over the printed layout, including paper sizes such as B4, A4, and letter, as well as portrait and landscape orientation. The option to enable black-and-white printing adds flexibility for cost-effective printing scenarios. This feature streamlines the process of preparing Excel files for high-quality printed output directly from Python.

Learn More About Managing Excel Worksheets in Python

Ready to Get Started?

Version:2026.9just released

Key in blue circle

Get your free 30-day Trial Key instantly.

Your trial license will be sent to your email address

No limitations. 100% unlocked. No credit card.

bullet_checkedNo credit card or account creation requiredNo limitations. 100% unlocked. No credit card.
  • Logo Aetna
  • Logo NASA
  • Logo GE
  • Logo Porsche
  • Logo USDA
  • Logo Qatar
Join Millions of Engineers who’ve tried IronPDF
Book your free Live Demo
Booking Badge

Trusted by Millions of Engineers Worldwide

Iron Software's customer logos
Get Your No-Obligation Consult
Complete the form below or email sales@ironsoftware.com
Your details will always be kept confidential.
Trusted by Millions of Engineers Worldwide
Iron Software's customer logos
Get your free 30-day Trial Key instantly.
No credit card or account creation required