How to convert Legacy XLS (97–03) Spreadsheet to PDF in Node.js
1 min readApr 12, 2020
Legacy files, such as Excel’s old XLS format, are a source of many headaches, which you no doubt already know. There are a few ways to deal with outdated formats, including updating them to their modern counterpart (covered in a separate tutorial), or in the case of today, by turning them into lovely PDF files. Today we will be covering the method behind the latter approach.
We can begin with a simple client installation:
npm install cloudmersive-convert-api-client --save
Following that, 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.convertDocumentXlsToPdf(inputFile, callback);
Now any XLS files that you drop into convertDocumentXlsToPdf will be repackaged nicely by the API as PDF files. How easy was that?