Merge Multiple Excel Files into One using REST API in Node.js

Merge Multiple Excel Files into One using REST API in Node.js

You can easily combine two or more Excel files into a single file programmatically on the cloud. You may need to generate reports based on the data available in multiple files, so you can merge them into a single file in your Node.js applications. In this article, you will learn how to merge multiple Excel files into one file using a REST API in Node.js.

The following topics shall be covered in this article:

File Merger REST API and Node.js SDK

For merging multiple XLSX files, I will be using the Node.js SDK of GroupDocs.Merger Cloud API. It allows you to combine, split, remove and rearrange a single page or a collection of pages from supported document formats such as Word, Excel, PowerPoint, Visio drawings, PDF, and HTML.

You can install GroupDocs.Merger Cloud to your Node.js application using the following command in the console:

npm install groupdocs-merger-cloud

Please get your Client ID and Secret from the dashboard before following the mentioned steps. Once you have your ID and secret, add in the code as shown below:

Merge Multiple Excel Files using REST API in Node.js

You can combine two or more Excel files programmatically on the cloud by following the simple steps mentioned below:

  • Upload the Excel files to the Cloud
  • Merge Multiple Excel files using Node.js
  • Download the merged file

Upload the Excel Files

Firstly, upload the Excel files to the Cloud using the code example given below:

As a result, the uploaded XLSX files will be available in the files section of your dashboard on the cloud.

Merge Multiple Excel Files using Node.js

You can easily merge multiple Excel files into a single file programmatically by following the steps mentioned below:

  • Create an instance of the DocumentApi
  • Create the first JoinItem
  • Provide the input file path for first JoinItem in the FileInfo
  • Create the second JoinItem
  • Provide the input file path for second JoinItem in the FileInfo
  • Create the JoinOptions
  • Add comma seperated list of created join items
  • Set the output file path
  • Create JoinRequest with JoinOptions
  • Get results by calling the join() method of the DocumentAPI

The following code snippet shows how to merge multiple Excel files using a REST API in Node.js.

Merge Multiple Excel Files using a REST API in Node.js
Merge Multiple Excel Files using a REST API in Node.js

Download the Merged File

The above code sample will save the merged Excel file on the cloud. You can download it using the following code sample:

Merge Specific Excel Sheets using Node.js

You can easily merge specific Excel sheets of multiple Excel files into a single file programmatically by following the steps mentioned below:

  • Create an instance of the DocumentApi
  • Create the first JoinItem
  • Provide the input file path for first JoinItem in the FileInfo
  • Create the second JoinItem
  • Provide the input file path for second JoinItem in the FileInfo
  • Create the JoinOptions
  • Define start sheet number and end sheet number
  • Set the output file path
  • Create JoinRequest with JoinOptions
  • Get results by calling the join() method of the DocumentAPI

The following code snippet shows how to merge specific Excel sheets from multiple files using a REST API in Node.js.

Merge Specific Excel Sheets using a REST API in Node.js
Merge Specific Excel Sheets using a REST API in Node.js

Try Online

Please try the following free online XLSX merging tool, which is developed using the above API. https://products.groupdocs.app/merger/xlsx

Conclusion

In this article, you have learned how to merge multiple Excel files on the cloud. You have also learned how to merge specific Excel sheets into one file using a REST API in Node.js. Moreover, you have learned how to programmatically upload XLSX files on the cloud and then download the merged file from the Cloud. The API also enables you to reorder or replace document pages, change page orientation, manage document passwords and perform other manipulations easily for any supported file format. It also provides .NET, Java, PHP, Ruby, Android, and Python SDKs as its document merger family members for the Cloud API. You can learn more about GroupDocs.Merge Cloud API using the documentation. We also provide an API Reference section that lets you visualize and interact with our APIs directly through the browser. In case of any ambiguity, please feel free to contact us on the forum.

See Also