# Configure Page Settings

Work with DsExcel to configure the page margins, page orientation, page order, page center, and first page number.

## Content

In DsExcel Java, you can use the methods of the [IPageSetup](/document-solutions/java-excel-api/api/online/com/grapecity/documents/excel/IPageSetup.html) interface in order to configure page settings.
Configuring page settings involves the following tasks:

1. [Configure Page Margins](/document-solutions/java-excel-api/docs/online/Features/ConfigurePrintSettingsviaPageSetup/ConfigurePageSettings#configure-page-margins)
2. [Configure Page Orientation](/document-solutions/java-excel-api/docs/online/Features/ConfigurePrintSettingsviaPageSetup/ConfigurePageSettings#configure-page-orientation)
3. [Configure Page Order](/document-solutions/java-excel-api/docs/online/Features/ConfigurePrintSettingsviaPageSetup/ConfigurePageSettings#configure-page-order)
4. [Configure Page Center](/document-solutions/java-excel-api/docs/online/Features/ConfigurePrintSettingsviaPageSetup/ConfigurePageSettings#configure-page-center)
5. [Configure First Page Number](/document-solutions/java-excel-api/docs/online/Features/ConfigurePrintSettingsviaPageSetup/ConfigurePageSettings#configure-first-page-number)

## Configure Page Margins

You can use the [setTopMargin](/document-solutions/java-excel-api/api/online/com/grapecity/documents/excel/IPageSetup.html#setTopMargin) method, [setHeaderMargin](/document-solutions/java-excel-api/api/online/com/grapecity/documents/excel/IPageSetup.html#setHeaderMargin) method, [setFooterMargin](/document-solutions/java-excel-api/api/online/com/grapecity/documents/excel/IPageSetup.html#setFooterMargin) method, [setRightMargin](/document-solutions/java-excel-api/api/online/com/grapecity/documents/excel/IPageSetup.html#setRightMargin) method, [setLeftMargin](/document-solutions/java-excel-api/api/online/com/grapecity/documents/excel/IPageSetup.html#setLeftMargin) method and the [setBottomMargin](/document-solutions/java-excel-api/api/online/com/grapecity/documents/excel/IPageSetup.html#setBottomMargin) method of the IPageSetup interface to configure margins for a page.

```Java
// 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);
```

> !type=note
> **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](/document-solutions/java-excel-api/api/online/com/grapecity/documents/excel/IPageSetup.html#setOrientation) method of the IPageSetup interface in order to set the orientation for a page to Portrait or Landscape as per custom preferences.

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

## Configure Page Order

You can use the [setOrder](/document-solutions/java-excel-api/api/online/com/grapecity/documents/excel/IPageSetup.html#setOrder) method of the IPageSetup interface in order to configure the order of the page as per your choice.

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

## Configure Page Center

You can use the [setCenterHorizontally](/document-solutions/java-excel-api/api/online/com/grapecity/documents/excel/IPageSetup.html#setCenterHorizontally) method and the [setCenterVertically](/document-solutions/java-excel-api/api/online/com/grapecity/documents/excel/IPageSetup.html#setCenterVertically) method of the IPageSetup interface in order to configure the center of the page according to your custom preferences.

```Java
// 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](/document-solutions/java-excel-api/api/online/com/grapecity/documents/excel/IPageSetup.html#setFirstPageNumber) method of the IPageSetup interface in order to configure the number for your first page as per your choice.

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

You can also use [setIsAutoFirstPageNumber](/document-solutions/java-excel-api/api/online/com/grapecity/documents/excel/IPageSetup.html#setIsAutoFirstPageNumber) method of the IPageSetup interface to set the first page number to <span style="color: rgb(33, 37, 41); font-family: Montserrat, 'Gotham SSm A', 'Gotham SSm B', 'Open Sans', 'Segoe UI', 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial; display: inline !important; float: none;">"</span>Auto".

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