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

    In DsExcel Java, you can use the methods 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 setTopMargin method, setHeaderMargin method, setFooterMargin method, setRightMargin method, setLeftMargin method and  the setBottomMargin method of the IPageSetup interface to configure margins for a page.

    Java
    Copy Code
    // Set margins, in points.
    worksheet.getPageSetup().setTopMargin(36);
    worksheet.getPageSetup().setBottomMargin(36);
    worksheet.getPageSetup().setLeftMargin(28.8);
    worksheet.getPageSetup().setRightMargin(72);
    worksheet.getPageSetup().setHeaderMargin(0);
    worksheet.getPageSetup().setFooterMargin(93.6);
    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 setOrientation method of the IPageSetup interface in order to set the orientation for a page to Portrait or Landscape as per custom preferences.

    Java
    Copy Code
    // Set page orientation, default is portrait.
    worksheet.getPageSetup().setOrientation(PageOrientation.Landscape);

    Configure Page Order

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

    Java
    Copy Code
    // Set page order. The default value is DownThenOver.
    worksheet.getPageSetup().setOrder(Order.OverThenDown);

    Configure Page Center

    You can use the setCenterHorizontally method and the setCenterVertically method of the IPageSetup interface in order to configure the center of the page according to your custom preferences.

    Java
    Copy Code
    // Set page center. The default value is false.
    worksheet.getPageSetup().setCenterHorizontally(true);
    worksheet.getPageSetup().setCenterVertically(true);

    Configure First Page Number

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

    Java
    Copy Code
    // Set first page number, default is p1.
    worksheet.getPageSetup().setFirstPageNumber(3);

    You can also use setIsAutoFirstPageNumber method of the IPageSetup interface to set the first page number to ¡°Auto¡±.

    Java
    Copy Code
    // Set first page number to Auto.
    worksheet.getPageSetup().setIsAutoFirstPageNumber(true);