How to convert Excel XLSX to CSV Files in Node.js

The first step is to add a reference to the library we will need to use to the package.json file for this project:

"dependencies": {
"cloudmersive-convert-api-client": "^1.2.7"

Now, all we have to do is make a call to the appropriate function, convertDocumentXlsxToCsv to perform the conversion:

var CloudmersiveConvertApiClient = require('cloudmersive-convert-api-client');
var defaultClient = CloudmersiveConvertApiClient.ApiClient.instance;
// Configure API key authorization: Apikey
var Apikey = defaultClient.authentications['Apikey'];
Apikey.apiKey = 'YOUR API KEY';
var apiInstance = new CloudmersiveConvertApiClient.ConvertDocumentApi();var inputFile = Buffer.from(fs.readFileSync("C:\\temp\\inputfile").buffer); // File | Input file to perform the operation on.var callback = function(error, data, response) {
if (error) {
} else {
console.log('API called successfully. Returned data: ' + data);
apiInstance.convertDocumentXlsxToCsv(inputFile, callback);

From here, we are done — it was that easy. This will convert the Excel Spreadsheet into a CSV file. Note that we can also use the function convertDocumentCsvToXlsx to perform the conversion in the other direction.

Many other functions are also available, for example to convert to JSON, and other data formats.

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