Delete page break in Excel using Java by following the steps shared in this article. This article provides all the necessary details to set the development environment, a list of steps to understand the tasks in the application, and a sample code demonstrating how to remove the page break in Excel using Java. You will get information to delete all or selected page breaks from the Excel file added manually.
Steps to Delete Page Break in Excel using Java
- Set the IDE to process the page breaks using Aspose.Cells for Java
- Instantiate the Workbook class object with the target spreadsheet and access a sheet in it
- Get the collection of horizontal page breaks and clear all the page breaks in it
- Access the collection of vertical page breaks and remove all the page breaks
- Save the spreadsheet after removing all the page breaks
These steps guide you through how to delete page break in Excel using Java. Initiate the process by accessing the target sheet from the loaded workbook and getting a reference to the collection of horizontal and vertical page breaks in the sheet. Finally, call the clear() method in both collections to delete all the items in the list.
Code to Remove Page Break in Excel using Java
This code demonstrates how to eliminate page breaks in Excel using Java. Other than deleting all the page breaks, you may search for a page break and delete it using the RemoveAt() method. If you want to delete all the horizontal manual page breaks, search for the page breaks with starting column 0 and ending at column 255, whereas for deleting all the manual vertical page breaks, find the page breaks with starting row 0 and ending row 65535.
This article has taught us how to reset page breaks in Excel using Java, as it deletes all the manual page breaks. If you want to add more manual page breaks, refer to the article Insert a page break in Excel using Java.