Remove Page Break in Excel using C#

This article guides how to remove page break in Excel using C#. It has the details to set the development environment, a list of steps depicting the program logic, and a ready-to-run sample code demonstrating how to delete page break in Excel using C#. You will learn to search the page breaks using different criteria and delete the selected page breaks if required.

Steps to Delete Page Break in Excel using C#

  1. Set the IDE to work with page breaks using Aspose.Cells for .NET
  2. Load the spreadsheet into the Workbook class object and access the sheet for deleting page breaks
  3. Access the HorizontalPageBreaksCollection object and call the clear() method to delete all page breaks
  4. Repeat the above steps for vertical page breaks
  5. Save the output Excel after removing the manual page breaks

The above steps define how to change page breaks in Excel using C#. Initialize the process by accessing the target sheet from the loaded workbook and accessing the horizontal and vertical collections of page breaks. Call the clear() method in each collection class to remove all the page breaks.

Code to Remove Page Break in Excel using C#

This code demonstrates how to remove the page break in Excel using C#. If you want to delete the horizontal page breaks only, you may search for all the horizontal page breaks with starting column 0 and ending column 255. For removing the vertical page breaks, search the page breaks with starting row 0 and ending row 65535.

This article has taught us to eliminate the page breaks from an Excel file. To add a page break in an Excel file refer to the article insert a page break in Excel using C#.

 English