How to convert CSV to Excel XLSX Spreadsheet in Node.JS

Today’s tutorial will cover how to convert a CSV file into an Excel spreadsheet. No, this won’t be a time-consuming slog through the lovely affair that is file format conversion coding. Instead it will be a lightning-fast sprint through an API.

Our first task is that of client installation using npm install. This command will take care of that.

npm install cloudmersive-convert-api-client --save

After installation has finished, 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.ConvertDocumentApi();var inputFile = "/path/to/file"; // File | Input file to perform the operation on.var callback = function(error, data, response) {if (error) {console.error(error);} else {console.log('API called successfully. Returned data: ' + data);}};apiInstance.convertDocumentCsvToXlsx(inputFile, callback);

Done! Yup, pretty easy. This same API offers an absolute plethora of useful functions, allowing you to speed through everything from document editing to merging 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