This quick tutorial guides on how to copy Excel sheet to another workbook using Node.js. It has detailed information to set the environment for developing and executing the application, and a runnable sample code demonstrating how to make a copy of an Excel sheet using Node.js. This process can be executed in any platform supporting Node.js and Java and does not require any other third-party tools.
Steps to Copy Excel Worksheet using Node.js
- Set the environment to use Aspose.Cells for Node.js via Java to copy a sheet
- Load the input and output Excel files using the Workbook objects
- Access the collection of the sheets from the output workbook
- Call the copy() method of the output Worksheet object
- Pass the target sheet from the input workbook as an argument to the copy() method
- Save the output workbook after copying the sheet
These steps explain the process to perform Excel sheet copy using Node.js. The process is accomplished by using the copy() method in the Worksheet class that takes the input sheet and is called by using the reference to a particular sheet in the output workbook where contents are to be copied. You may either save the resultant workbook with the same name or save it with a different name and even save it to some memory stream.
Code to Copy Worksheet to Another Workbook using Node.js
This code presents how to copy a sheet in Excel using Node.js. In this process, if the destination sheet contains any contents, those are overwritten and replaced by the contents of the source input sheet. You may use any of the overloaded copy methods of the Worksheet class for instance one overload requires only the source sheet whereas the other overload method requires CopyOptions also supporting different options.
This article has taught us how to copy Excel sheet to another sheet using Node.js. If you want to learn the process of applying validation in a worksheet, refer to the article on how to make a dropdown list in Excel using Node.js.