How to Fix Excel Printing and Scaling in C# Interop Workbooks
Question details
The user needs to configure an Excel workbook generated via C# Interop to print on a single page instead of spanning across multiple pages.

- Product
- Microsoft Excel (C# Interop)
- Device & OS
- not provided
- Scenario
- Generating an Excel workbook programmatically using C# and attempting to print or export it to PDF.
- Observed behavior
- The generated workbook prints across two or more pages, failing to automatically scale row heights, font sizes, or layout to fit on one page.
Ensure you have added the appropriate Microsoft.Office.Interop.Excel reference to your C# project and that your target machine has Excel installed for the Interop to function.
Configure PageSetup Properties for Fit to Page in C#
Use the Excel Interop PageSetup object in your C# code to force the worksheet to scale and fit on a single printed page.
When automating Excel via C#, the default print settings will print at 100% scale. To force the content to fit on one page, you must explicitly disable the Zoom property and define the FitToPagesWide and FitToPagesTall properties.
In your C# code, reference the worksheet's PageSetup property: `Excel.PageSetup pageSetup = worksheet.PageSetup;`
Set the zoom to false so Excel allows the fit-to-page settings to take effect: `pageSetup.Zoom = false;`
Force the worksheet to fit exactly one page wide: `pageSetup.FitToPagesWide = 1;`
Force the worksheet to fit exactly one page tall (or set it to false if you only want to constrain width): `pageSetup.FitToPagesTall = 1;`

Manually Adjust Scaling via the Excel UI
If you are unable to modify the C# code immediately, you can adjust the scaling manually inside the generated Excel file before printing.
Try WPS Office for Lightweight Spreadsheet Management
If you frequently work with Excel files and need a fast, reliable, and free alternative, WPS Office provides excellent compatibility with Microsoft Office formats, including robust print layout controls and API automation capabilities.

Frequently Asked Questions
Why is my Excel Interop PageSetup.FitToPagesWide code being ignored?
The FitToPagesWide and FitToPagesTall properties will be completely ignored by Excel unless you explicitly set the Zoom property of the PageSetup object to false (`pageSetup.Zoom = false;`).
Can I use C# Interop to auto-fit row heights and column widths before printing?
Yes, you can optimize the cell sizes before setting the print scaling. Call `worksheet.Columns.AutoFit();` and `worksheet.Rows.AutoFit();` on your target range in your C# code before applying the PageSetup commands.
Does WPS Office support COM Interop automation like Microsoft Excel?
WPS Office offers its own COM API that is highly structurally compatible with Microsoft Excel's VBA and Interop models. Developers can often port their automation scripts to WPS Office with minimal code adjustments.




