'Declaration
Public Class Margins Inherits WorksheetElement
'Usage
Dim instance As Margins
public class Margins : WorksheetElement
'Declaration
Public Class Margins Inherits WorksheetElement
'Usage
Dim 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
Target Platforms: Windows 11, Windows 10, Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2