Xceed Workbooks for .NET v3.0 Documentation
Xceed.Workbooks.NET Assembly / Xceed.Workbooks.NET Namespace / Margins Class
Members Example


In This Topic
    Margins Class
    In This Topic
    Represents the Worksheet's margins. 
    Syntax
    'Declaration
     
    
    Public Class Margins 
       Inherits WorksheetElement
    'Usage
     
    
    Dim instance As Margins
    public class Margins : WorksheetElement 
    Remarks

    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. 

    Example
    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" );
        }
    }
    Inheritance Hierarchy

    System.Object
       Xceed.Workbooks.NET.WorkbookElement
          Xceed.Workbooks.NET.WorksheetElement
             Xceed.Workbooks.NET.Margins

    Public Constructors
     NameDescription
    Public Constructor  
    Top
    Public Properties
     NameDescription
    Public PropertyGets or sets the margin located at the bottom of the Worksheet.  
    Public PropertyGets or sets the height of the Footer area.  
    Public PropertyGets or sets the height of the Header area.  
    Public PropertyGets or sets the margin located at the left of the Worksheet.  
    Public PropertyGets or sets the margin located at the right of the Worksheet.  
    Public PropertyGets or sets the margin located at the top of the Worksheet.  
    Top
    Public Methods
     NameDescription
    Public Method  
    Public MethodOverloaded.   
    Public Method  
    Public MethodSets all of the Worksheet's Margins at the same time.  
    Public MethodSets the MarginPreset.  
    Top
    Requirements

    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

    See Also