How to Convert Excel (97–2003) XLS to CSV in JavaScript
While the majority of folks have moved over to the most recent XLSX version of Excel, there are still a solid portion of people who still use the 97–2003 XLS version. If you encounter this issue, converting them to a more compatible and useful format is the best move; the CSV format is popular among developers, and is a great alternative. Since the manual conversion process isn’t the easiest task to perform, we will be demonstrating how you can use an API in JavaScript to automate the conversion from XLS to CSV.
To begin the set up, we will run this command to install jQuery:
bower install jquery
Now, we simply need to input the outdated Excel file and our API key into the following code:
var form = new FormData();
form.append("inputFile", fileInput.files[0], "file");var settings = {
"url": "https://api.cloudmersive.com/convert/xls/to/csv",
"method": "POST",
"timeout": 0,
"headers": {
"Content-Type": "multipart/form-data",
"Apikey": "YOUR-API-KEY-HERE"
},
"processData": false,
"mimeType": "multipart/form-data",
"contentType": false,
"data": form
};$.ajax(settings).done(function (response) {
console.log(response);
});
The operation will be complete in seconds flat, enabling a better working experience with the file.