[]
        
(Showing Draft Content)

Configure Page Settings

In GcExcel .NET, you can use the properties of the IPageSetup interface in order to configure page settings.

Configuring page settings involves the following tasks:

  1. Configure Page Margins

  2. Configure Page Orientation

  3. Configure Page Order

  4. Configure Page Center

  5. Configure First Page Number

Configure Page Margins

You can use the TopMargin propertyRightMargin property and BottomMargin property of the IPageSetup interface in order to configure margins for a page.

//Set page margins, in points.
worksheet.PageSetup.TopMargin = 36;
worksheet.PageSetup.BottomMargin = 36;
worksheet.PageSetup.RightMargin = 72;
            

Note: While you set margins for your page, it is necessary to ensure that it should not be less than Zero.

Configure Page Orientation

You can use the Orientation property of the IPageSetup interface in order to set the orientation for a page to Portrait or Landscape as per your preferences.

//Set page orientation.
            
worksheet.PageSetup.Orientation = PageOrientation.Landscape;

Configure Page Order

You can use the Order property of the IPageSetup interface in order to configure the order of the page as per your choice.

//Set page order. The default value is DownThenOver.
           
 worksheet.PageSetup.Order = Order.OverThenDown;
           

Configure Page Center

You can use the CenterHorizontally property and the CenterVertically property of the IPageSetup interface in order to configure the center of your page according to your preferences.

//Set center. The default value is false.
            
worksheet.PageSetup.CenterHorizontally = true;
worksheet.PageSetup.CenterVertically = true;
            

Configure First Page Number

You can use the FirstPageNumber property of the IPageSetup interface in order to configure the number for your first page as per your choice.

//Set first page number. The default value is p1.
            
worksheet.PageSetup.FirstPageNumber = 3;
            

You can also use IsAutoFirstPageNumber property of the IPageSetup interface to set the first page number to “Auto”.

// Set first page number to auto.
worksheet2.PageSetup.IsAutoFirstPageNumber = true;