Skip to main content

XlPageSetup.FitToWidth Property

Gets or sets the number of pages wide the worksheet should fit on when printed.

Namespace: DevExpress.Export.Xl

Assembly: DevExpress.Printing.v24.1.Core.dll

NuGet Package: DevExpress.Printing.Core

Declaration

public int FitToWidth { get; set; }

Property Value

Type Description
Int32

A positive integer value that specifies the number of pages that the worksheet should fit on.

This value must be between 0 and 32767; otherwise, a System.ArgumentOutOfRangeException will be thrown.

Remarks

To scale the content to fit on a specific number of pages wide, set the XlPageSetup.FitToPage property to true and specify the desired number of pages using the FitToWidth property. For more information on how to adjust page formatting options, refer to the How to: Specify Print Settings article.

Example

Note

A complete sample project is available at https://github.com/DevExpress-Examples/excel-export-api-examples

// Specify page settings for the worksheet.
sheet.PageSetup = new XlPageSetup();
// Select the paper size.
sheet.PageSetup.PaperKind = System.Drawing.Printing.PaperKind.A4;
// Set the page orientation to Landscape.
sheet.PageSetup.PageOrientation = XlPageOrientation.Landscape;
//  Scale the print area to fit to one page wide.
sheet.PageSetup.FitToPage = true;
sheet.PageSetup.FitToWidth = 1;
sheet.PageSetup.FitToHeight = 0;
//  Print in black and white.
sheet.PageSetup.BlackAndWhite = true;
// Specify the number of copies.
sheet.PageSetup.Copies = 2;

The following code snippets (auto-collected from DevExpress Examples) contain references to the FitToWidth property.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

See Also