Back to Devexpress

XlPageMargins Class

corelibraries-devexpress-dot-export-dot-xl-e1077e5a.md

latest3.4 KB
Original Source

XlPageMargins Class

Represents the object that specifies page margins for a worksheet.

Namespace : DevExpress.Export.Xl

Assembly : DevExpress.Printing.v25.2.Core.dll

NuGet Package : DevExpress.Printing.Core

Declaration

csharp
public class XlPageMargins
vb
Public Class XlPageMargins

The following members return XlPageMargins objects:

Remarks

Use the properties of the XlPageMargins object to control the space between the worksheet content and page edges (XlPageMargins.Top, XlPageMargins.Bottom, XlPageMargins.Left and XlPageMargins.Right) and define the distance between a header/footer and the top/bottom edge of a page (XlPageMargins.Header and XlPageMargins.Footer). By default, the margin size is set in inches. To change the unit of margin measurement, use the XlPageMargins.PageUnits property.

To specify margin sizes for a particular worksheet, set the IXlSheet.PageMargins property to the instance of the XlPageMargins class. For an example, refer to the How to: Set Page Margins topic.

Example

Note

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

csharp
sheet.PageMargins = new XlPageMargins();
// Set the unit of margin measurement.
sheet.PageMargins.PageUnits = XlPageUnits.Centimeters;
// Specify page margins.
sheet.PageMargins.Left = 2.0;
sheet.PageMargins.Right = 1.0;
sheet.PageMargins.Top = 1.25;
sheet.PageMargins.Bottom = 1.25;
// Specify header and footer margins.
sheet.PageMargins.Header = 0.7;
sheet.PageMargins.Footer = 0.7;
vb
sheet.PageMargins = New XlPageMargins()
' Set the unit of margin measurement.
sheet.PageMargins.PageUnits = XlPageUnits.Centimeters
' Specify page margins.
sheet.PageMargins.Left = 2.0
sheet.PageMargins.Right = 1.0
sheet.PageMargins.Top = 1.25
sheet.PageMargins.Bottom = 1.25
' Specify header and footer margins.
sheet.PageMargins.Header = 0.7
sheet.PageMargins.Footer = 0.7

Inheritance

Object XlPageMargins

See Also

XlPageMargins Members

Use the Excel Export API to Set Page Margins

DevExpress.Export.Xl Namespace