# Set Pagination

## Content

The pagination feature is available in the ReportSheet. This feature allows customization of pagination settings in the template sheet to meet diverse report layout requirements. To enable pagination, configure the pagination settings using the `setPaginationSetting` method of the [GC.Spread.Report.TemplateSheet](/spreadjs/api/v17/classes/GC.Spread.Report.TemplateSheet) class.
To paginate the report, the ReportSheet combines the pagination settings of the template sheet, the pagination settings of the template cell, and the paper size in the print information into a final pagination setting.

> **Note**: Pagination settings take effect only in the [PaginatedPreview ](/spreadjs/docs/v17/)render mode.

The pagination feature in ReportSheet offers customizable layouts for reports. You can paginate by rows or by paper size.

## Row Pagination

You can enable row-based pagination using the `RowPagination` property of the [IPaginationSetting](/spreadjs/api/v17/interfaces/GC.Spread.Report.IPaginationSetting) interface. This mode is beneficial when displaying a fixed number of rows on each page.
You can use the following code sample to set the row-based pagination setting:

```auto
// Set row pagination.
templateSheet.setPaginationSetting({    
   rowPagination: {       
        paginationDataCell: 'A2',        
        rowCountPerPage: 20,
   },    
   titleRow: {
        start: 0,
        end: 0,
   },
});
```

## Paper Size Pagination

You can enable paper size-based pagination using the `PaperSizePagination` member of the [IPaginationSetting ](/spreadjs/api/v17/interfaces/GC.Spread.Report.IPaginationSetting)interface. This mode is ideal for printing reports, allowing customization based on paper size.
You can use the following code sample to set the paper-size pagination setting:

```auto
// Set paper size pagination.
templateSheet.setPaginationSetting({ 
        paperSizePagination: true,
        titleRow: {
                 start: 0,
                 end: 0,
       },
       titleCol: {
                 start: 0,
                 end: 0,
       },
       paginationOrder: 'OverThenDown',   // 'DownThenOver' | 'OverThenDown'
});
```

## Cell Pagination Setting

ReportSheet supports various cell pagination settings to control the behavior of pagination in reports. You need to set the value of the required pagination properties to true in a specific row/column paging setting in the [setTemplateCell](/spreadjs/api/v17/classes/GC.Spread.Report.TemplateSheet) method. The available pagination properties are given below:

* `paginateBeforeRow`
* `paginateAfterRow`
* `paginateBeforeColumn`
* `paginateAfterColumn`
* `canBreakWhenPaging`
* `repeatContentWhenPaging`

The following code sample shows the use of the `paginateAfterRow` property to design a report in which each order is displayed on a separate page.

```auto
templateSheet.setTemplateCell(3, 0, {
       type: 'Static',
       context: {
            vertical: "A3"
       },
       paginateAfterRow: true, 
});

// Switch to the PaginatedPreview to view the report.
reportSheet.renderMode('PaginatedPreview');
reportSheet.refresh();
```

Here is another code sample where the `canBreakWhenPaging` and `repeatContentWhenPaging` properties are set to true. In this case, when the cell extends to the last row of the current page, it may break due to paging. The row is not displayed completely on the first page and is repeated on the next page.

```auto
templateSheet.setTemplateCell(3, 0, {
      type: 'Static',
      context: {
            vertical: "A3"
      },
      canBreakWhenPaging: true, 
      repeatContentWhenPaging: true 
});

// Switch to the PaginatedPreview to view the report.
reportSheet.renderMode('PaginatedPreview');
reportSheet.refresh();
```

## Using Designer

Follow the below steps to set pagination settings for ReportSheet:

1. Go to the **REPORT SHEET DESIGN** tab and select **Pagination Setting**.
    The **Pagination Setting** dialog appears.
    ![image](https://gcdocumentsitekrblob.blob.core.windows.net/document-site-files/images/d37fbce1-6a37-43ce-b728-dd79fba68421/image.4618ec.png)
2. Select **Pagination Type** from the **Type** dropdown list.
    The available options are **PaperSize Pagination** and **Row Pagination**.
3. Set **Titles And Ends** for title/end of rows/columns.
4. Under the **Page Order** section, select **Down, then over** or **Over, then down**.
    The direction of each option is displayed in the preview box.

Additionally, you can repeat the Title/End of Rows/Columns on every report. To repeat the title or end columns, select **Set** **Repeat Title Columns** or **Set** **Repeat End Columns** in the contextMenu.

![image](https://gcdocumentsitekrblob.blob.core.windows.net/document-site-files/images/d37fbce1-6a37-43ce-b728-dd79fba68421/image.48fd78.png?width=320)