How to Copy Excel Sheet to Another Workbook using Node.js

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

  1. Set the environment to use Aspose.Cells for Node.js via Java to copy a sheet
  2. Load the input and output Excel files using the Workbook objects
  3. Access the collection of the sheets from the output workbook
  4. Call the copy() method of the output Worksheet object
  5. Pass the target sheet from the input workbook as an argument to the copy() method
  6. 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.

 English