How to convert Excel XLSX to CSV Files in Javascript
1 min readMar 10, 2020
By the end of this tutorial, we will have you up to speed on how to set up format conversion between Excel files and CSV. Total time, about 5 minutes.
We begin with importing our API client via this script tag, which can be added to your HTML file or between the head tags of your page.
<script src="https://cdn.cloudmersive.com/jsclient/cloudmersive-document-convert-client.js"></script>
Next step, call our 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.convertDocumentXlsToCsv(inputFile, callback);
Well that about covers it. The API will take care of the format conversion on its own. If you have use for additional format conversion, we have other functions that support other popular document types, such as PDF, DOCX, etc.