Skip to main content
All docs
V23.2
Row

SheetView.SetCustomPaperSize(Single, Single) Method

Specifies custom paper size for a worksheet or chart sheet.

Namespace: DevExpress.Spreadsheet

Assembly: DevExpress.Spreadsheet.v23.2.Core.dll

NuGet Package: DevExpress.Spreadsheet.Core

Declaration

void SetCustomPaperSize(
    float width,
    float height
)

Parameters

Name Type Description
width Single

The paper width in measurement units defined by the Unit property.

height Single

The paper height in measurement units defined by the Unit property.

Exceptions

Type Description
ArgumentException

Occurs if the paper width or height is less than or equal to 0.

Remarks

When you call the SetCustomPaperSize method to define paper size, the PaperKind property value changes to Custom. Custom paper dimensions are saved to a file only if you export a workbook to Microsoft Office Open XML formats (XLSX, XLSM, XLTX, and XLTM). Custom size values are lost when you open and resave the document in Microsoft® Excel®.

If PaperKind is Custom for a loaded workbook, but the document does not contain custom paper dimensions, the Spreadsheet attempts to retrieve paper size from the printerSettings binary files stored in the workbook. If printer settings are not found, the Spreadsheet uses the Letter paper size (8.5 inches by 11 inches) to print the document or export it to PDF.

Define Custom Paper Size

The following example specifies custom paper size for the first worksheet in the document:

using DevExpress.Office;
using DevExpress.Spreadsheet;
// ...

// Set measurement unit to inches.
workbook.Unit = DocumentUnit.Inch;

// Specify custom paper size (10 inches by 12 inches).
workbook.Worksheets[0].ActiveView.SetCustomPaperSize(10, 12);

Reset Custom Paper Size

Assign a PaperKind enumeration member to the SheetView.PaperKind property to use one of the standard paper sizes (Letter, Legal, Tabloid, and so on) to print a worksheet or chart sheet.

// Use standard paper size.
workbook.Worksheets[0].ActiveView.PaperKind = DevExpress.Drawing.Printing.DXPaperKind.Letter;
See Also