XlPageMargins Class
Represents the object that specifies page margins for a worksheet.
Namespace: DevExpress.Export.Xl
Assembly: DevExpress.Printing.v24.2.Core.dll
Declaration
Related API Members
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
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;