'Declaration
Public Sub SetAll( _ ByVal left As Single, _ ByVal right As Single, _ ByVal top As Single, _ ByVal bottom As Single, _ ByVal header As Single, _ ByVal footer As Single _ )
'Declaration
Public Sub SetAll( _ ByVal left As Single, _ ByVal right As Single, _ ByVal top As Single, _ ByVal bottom As Single, _ ByVal header As Single, _ ByVal footer As Single _ )
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 all margins using custom values worksheet.PageLayout.Margins.SetAll( 0.7f, 0.7f, 0.5f, 0.5f, 0.4f, 0.4f ); // Saves workbook to disk. workbook.Save(); Console.WriteLine( "/tCreated:PageMarginsAndBreaks.xlsx/n" ); } }
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