This tutorial guides how to insert a page break in Excel with Node.js. It contains the details to set the development environment, a list of steps to write the application, and a runnable sample code to change page break in Excel with Node.js. You will learn to add horizontal and vertical page breaks using different overload methods in the respective collection classes.
Steps to Set Page Break in Excel with Node.js
- Set the IDE to use Aspose.Cells for Node.js via Java to add page breaks
- Load the target spreadsheet into the Workbook class object
- Access the worksheet where page breaks are to be added in different cells
- Access the collection of the horizontal page breaks and add a new page break
- Access the collection of the vertical page breaks and add a new page break
- Save the resultant workbook with manual page breaks
These steps present how to break page in Excel with Node.js. Commence the process by loading the spreadsheet into the Workbook class followed by accessing the horizontal or vertical page breaks collection in the target sheet. This collection class provides an add() method to insert manual page breaks along with the default automatic page breaks added by Excel.
Code to Change Page Breaks in Excel with Node.js
This code sample demonstrates how to set page break in Excel with Node.js. It uses the HorizontalPageBreakCollection and VerticalPageBreakCollection classes for adding the page breaks using the add() method that requires the cell reference in terms of a cell name as a string, the row number, the column number, or row and column number. Perform the page breaks management using the above-mentioned ‘collection classes’ like deleting page breaks, searching page breaks, or checking the existence of page breaks before adding them.
In this topic, we have learned to insert additional page breaks in an Excel file along with the existing page breaks added by MS Excel. To adjust the row height, refer to the article on how to adjust row height in Excel using Node.js.