Skip to main content

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

Use the Excel Export API to Insert Page Breaks in a Worksheet

The following example demonstrates how to insert a page break on a worksheet to start a new page. Page breaks in a worksheet are contained in two separate IXlPageBreaks collections: one for the horizontal (row) page breaks and one for the vertical (column) page breaks. To get access to these collections, use the IXlSheet.RowPageBreaks and IXlSheet.ColumnPageBreaks properties, respectively. To add a new page break, use the IXlPageBreaks.Add method and pass an index of the row or column after which a page break should be inserted. To remove a single page break from a worksheet, use the IXlPageBreaks.Remove or IXlPageBreaks.RemoveAt method. To clear all page breaks at once, use the IXlPageBreaks.Clear method.

View Example

// Insert a page break after the column "B".
sheet.ColumnPageBreaks.Add(2);
// Insert a page break after the tenth row.
sheet.RowPageBreaks.Add(10);

The image below illustrates the result (the workbook is opened in Microsoft® Excel®).

XlExport_Printing_PageBreaks