How to merge two Excel XLSX files together in Node.JS

Setting up spreadsheet merging in Node.JS is nobody’s idea of a fun afternoon, especially when it takes longer than that. Don’t you worry, though, we have a quick way to get this done.

So we are going to start by installing our client via this reference in your package.json file.

"dependencies": {
"cloudmersive-convert-api-client": "^2.1.6"
}

Now call this function:

var CloudmersiveConvertApiClient = require('cloudmersive-convert-api-client');var defaultClient = CloudmersiveConvertApiClient.ApiClient.instance;// Configure API key authorization: Apikeyvar Apikey = defaultClient.authentications['Apikey'];Apikey.apiKey = 'YOUR API KEY';// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)//Apikey.apiKeyPrefix = 'Token';var apiInstance = new CloudmersiveConvertApiClient.MergeDocumentApi();var inputFile1 = "/path/to/file"; // File | First input file to perform the operation on.var inputFile2 = "/path/to/file"; // File | Second input file to perform the operation on (more than 2 can be supplied).var callback = function(error, data, response) {if (error) {console.error(error);} else {console.log('API called successfully. Returned data: ' + data);}};apiInstance.mergeDocumentXlsx(inputFile1, inputFile2, callback);

Select your two files and they will be returned to you as a single merged file. Not bad! The file order will be maintained if you repeat the process using additional files.

Image for post
Image for post

Written by

There’s an API for that. Cloudmersive is a leader in Highly Scalable Cloud APIs.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store