How to Print Excel as Fitted Pages Wide and Tall with Python.NET
Contents
[
Hide
]
Introduction
The fit_to_pages_wide and fit_to_pages_tall settings control spreadsheet scaling during printing. These settings ensure printed output fits within specified page dimensions:
- fit_to_pages_wide: Specifies horizontal page count for printing
- fit_to_pages_tall: Specifies vertical page count for printing
Why Use FitToPagesWide and FitToPagesTall
Key benefits include:
- Precise print layout control
- Consistent multi-sheet formatting
- Professional document presentation
How to Print File as Fitted Pages Wide and Tall in Excel
To configure in Microsoft Excel:
- Open workbook and select worksheet
- Navigate to Page Layout → Page Setup dialog
- In Page tab under Scaling:
- Select “Fit to”
- Specify pages wide (horizontal) and tall (vertical)

How to Print Excel as Fitted Pages Wide and Tall Using Aspose.Cells
To configure programmatically:
- Load sample file
- Access worksheet’s page_setup object
- Set fit_to_pages_tall and fit_to_pages_wide properties
from aspose.cells import Workbook
# Instantiating a Workbook object
workbook = Workbook("input.xlsx")
# Accessing the first worksheet in the Excel file
worksheet = workbook.worksheets[0]
# Setting the number of pages to which the length of the worksheet will be spanned
worksheet.page_setup.fit_to_pages_tall = 1
# Setting the number of pages to which the width of the worksheet will be spanned
worksheet.page_setup.fit_to_pages_wide = 1
# Save the workbook
workbook.save("out_net.pdf")
Output result:
How to Print Worksheet as One Page
To force single-page output:
- Use PdfSaveOptions
- Set one_page_per_sheet property
from aspose.cells import Workbook, PdfSaveOptions
# Instantiating a Workbook object
workbook = Workbook("sample.xlsx")
options = PdfSaveOptions()
# Setting OnePagePerSheet option
options.one_page_per_sheet = True
# Save the workbook with options
workbook.save("OnePagePerSheet.pdf", options)
Output result:
How to Print All Columns in One Page
To consolidate columns horizontally:
- Configure PdfSaveOptions
- Enable all_columns_in_one_page_per_sheet property
from aspose.cells import Workbook, PdfSaveOptions
# Instantiating a Workbook object
workbook = Workbook("sample.xlsx")
options = PdfSaveOptions()
# Setting all columns in one page per sheet
options.all_columns_in_one_page_per_sheet = True
# Save the workbook
workbook.save("AllColumnsInOnePagePerSheet.pdf", options)
Output result: