How to convert Excel XLSX to PDF in Node.js

The first step is to add a reference to our package.json for the document processing library:

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

Now, all we have to do is call convertDocumentXlsxToPdf to convert our Excel Document (XLSX) format file into a PDF file:

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

That’s all there is to it, and it is free.

Note that this function is specifically for XLSX. Other functions are available for XLS, as well as auto-detection of the document type and generalized conversion into PDF.

You can also use this library to convert XLSX files into JSON, and even enumerate and manipulate the contents of the XLSX file, for example to add or remove a header, watermark, row of data, etc.

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