How to convert Legacy XLS to CSV in Node.JS

Today we are going to convert our deprecated XLS files into handy CSVs instead, generally making life easier. For Node.JS users, your usual option for accomplishing this would involve several hours of coding and possibly a nice fat headache. Instead of that, how about we wrap this up in under 5 minutes? Let’s dive in.

Npm install can be used to set up our client, requiring this command.

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

Now call convertDocumentXlsToCsv, as you see below.

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.convertDocumentXlsToCsv(inputFile, callback);

Well look at that, we’re done. All that you needs do now is input your XLS files. Not too shabby.

Image for post
Image for post

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