Document Solutions for Excel, .NET Edition | Document Solutions
Features / Print / Page Setup / Configure Page Settings
In This Topic
    Configure Page Settings
    In This Topic

    In DsExcel .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.

    C#
    Copy Code
    // 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.

    C#
    Copy Code
    // 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.

    C#
    Copy Code
    // 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.

    C#
    Copy Code
    // 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.

    C#
    Copy Code
    // 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”.

    C#
    Copy Code
    // Set first page number to auto.
    worksheet2.PageSetup.IsAutoFirstPageNumber = true;