

'DeclarationPublic Class Margins Inherits WorksheetElement
'UsageDim instance As Margins
public class Margins : WorksheetElement
The values of the various margins must stay between 0 & 2.1; these values correpond to inches.
If needed, it is also possible to set these values using various presets, which are available through the MarginPreset enumeration.
public static void PageMarginsAndPageBreaks() { using( var workbook = Workbook.Create( PageLayoutSample.PageLayoutSampleOutputDirectory + @"PageMarginsAndBreaks.xlsx" )) { // Gets the first worksheet; a workbook always contains at least 1 worksheet. var worksheet = workbook.Worksheets[0]; // Adds a title. worksheet.Cells["B1"].Value = "Page Margins and Breaks"; worksheet.Cells["B1"].Style.Font = new Font() {Bold = true, Size = 15.5d}; // Sets values for specific margins. worksheet.PageLayout.Margins.Right = 0.3f; worksheet.PageLayout.Margins.Left = 0.3f; worksheet.PageLayout.Margins.Top = 0.2f; worksheet.PageLayout.Margins.Footer = 0.1f; // Saves workbook to disk. workbook.Save(); Console.WriteLine( "/tCreated:PageMarginsAndBreaks.xlsx/n" ); } }
System.Object
Xceed.Workbooks.NET.WorkbookElement
Xceed.Workbooks.NET.WorksheetElement
Xceed.Workbooks.NET.Margins
| Name | Description | |
|---|---|---|
![]() | Margins Constructor |
| Name | Description | |
|---|---|---|
![]() | Bottom | Gets or sets the margin located at the bottom of the Worksheet. |
![]() | Footer | Gets or sets the height of the Footer area. |
![]() | Header | Gets or sets the height of the Header area. |
![]() | Left | Gets or sets the margin located at the left of the Worksheet. |
![]() | Right | Gets or sets the margin located at the right of the Worksheet. |
![]() | Top | Gets or sets the margin located at the top of the Worksheet. |
| Name | Description | |
|---|---|---|
![]() | Clone | |
![]() | Equals | Overloaded. |
![]() | GetHashCode | |
![]() | SetAll | Sets all of the Worksheet's Margins at the same time. |
![]() | SetPreset | Sets the MarginPreset. |
.NET: net5.0, net5.0-windows, net6.0, net6.0-macos, net6.0-windows, net7.0, net7.0-macos, net7.0-windows, net8.0, net8.0-browser, net8.0-macos, net8.0-windows, net9.0, net9.0-browser, net9.0-macos, net9.0-windows, net10.0, net10.0-browser, net10.0-macos, net10.0-windows.
.NET Framework: net40, net403, net45, net451, net452, net46, net461, net462, net463, net47, net471, net472, net48, net481.