IXlSheet.PageMargins Property
Gets or sets page margins used to align the worksheet content on a printed page.
Namespace: DevExpress.Export.Xl
Assembly: DevExpress.Printing.v24.1.Core.dll
NuGet Package: DevExpress.Printing.Core
Declaration
Property Value
Type | Description |
---|---|
XlPageMargins | An XlPageMargins object that controls the worksheet’s margin settings. |
Remarks
Use the PageMargins property to set page margins, which determine the space between the worksheet content and page edges. The XlPageMargins object contains all margin settings and allows you to specify the top (XlPageMargins.Top), bottom (XlPageMargins.Bottom), left (XlPageMargins.Left), right (XlPageMargins.Right), header (XlPageMargins.Header) and footer (XlPageMargins.Footer) margins. To control the unit of margin measurement, use the XlPageMargins.PageUnits property. By default, inches are utilized to specify the width of page margins. For an example on how to adjust margin settings, 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
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;
Related GitHub Examples
The following code snippets (auto-collected from DevExpress Examples) contain references to the PageMargins 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.