This article explains how to merge cells in Excel using Node.js. It has the instructions to create the development environment, a list of steps for application development, and a running sample code showing how to combine cells in Excel using Node.js. You will also learn the process of combining multiple rows and columns along with the option to resolve conflicts with other merged cells.
Steps to Merge Columns in Excel using Node.js
- Set the IDE to use Aspose.Cells for Node.js via Java to merge cells
- Create a workbook class object or load an existing workbook for combining cells
- Access the Cells collection from the selected sheet of the loaded workbook
- Call the merge() method in the Cells class by providing the necessary arguments
- Put some sample text value in the first cell of the merged area
- Save the output workbook
These steps summarize the process of how to combine two columns in Excel using Node.js. The process is commenced by creating or loading an existing workbook and accessing the cells collection of a particular sheet. The Cells class contains multiple overloaded methods of merge() to combine the cells. The effect of this operation is tested by setting a sample text in the top-left cell of the merged area before saving the resultant workbook.
Code to Combine Columns in Excel using Node.js
The code mentioned above demonstrates how to merge two columns in Excel using Node.js. The merge method requires the row and column number of the starting cell followed by the total number of rows and columns to be merged for instance, one row and two columns are merged in this sample code. You may also use other overloaded methods where setting the mergeConflict flag to true removes the other merged cells if a conflict occurs with the current merging.
This article has taught us how to combine two cells in Excel using Node.js. If you want to remove formulas but keep data in an Excel file, refer to the article on how to remove formula but keep data in Excel using Nodejs.