Managing Page Breaks

Aspose.Cells & Page Breaks

Aspose.Cells provides a class, Workbook that represents an Excel file. The Workbook class contains a WorksheetCollection that allows access to each worksheet in the Excel file.

A worksheet is represented by the Worksheet class which provides a wide range of properties and methods for managing worksheets. To add the page breaks, use the Worksheet class' HorizontalPageBreaks and VerticalPageBreaks properties.

The HorizontalPageBreaks and VerticalPageBreaks properties are in fact collections that may contain several page breaks. Each collection contains several methods for managing horizontal and vertical page breaks. How these methods are used is discussed below.

Adding Page Breaks

To add a page break in a worksheet, insert vertical and horizontal page breaks at the specified cell by calling the HorizontalPageBreaks and VerticalPageBreaks collections' Add methods. Each Add method takes the cell name where the page break is to be added.

Clearing All Page Breaks

To clear all page breaks in a worksheet, call the HorizontalPageBreakCollection and VerticalPageBreakCollection collections' Clear methods.

Removing Specific Page Break

To remove a specific page break in the worksheet, call the HorizontalPageBreakCollection and VerticalPageBreakCollection collections' removeAt methods. Each removeAt method will take the index of the page break to be removed.