Convert Excel to PDF in Node.js

Excel spreadsheets are commonly used to store and analyze data in the form of rows and columns. However, in various cases, you need to convert the Excel files to PDF before sharing them over the internet. In order to automate Excel to PDF conversion, this article shows how to convert Excel files to PDF programmatically using Node.js. Furthermore, advanced options to customize the Excel to PDF conversion are also discussed.

Node.js Excel to PDF Conversion API

For converting the Excel XLSX/XLS files to PDF, we will use Aspose.Cells for Node.js via Java. It is a spreadsheet manipulation API that lets you create, read, modify, and convert Excel workbooks seamlessly. You can either download the API’s package or install it use the following NPM command.

> npm install aspose.cells

Convert Excel XLSX to PDF in Node.js

The following are the steps to convert Excel XLSX or XLS files to PDF.

The following code sample shows how to convert an Excel XLSX file to PDF.

Excel File

Node.js Excel to PDF

Converted PDF

Excel to PDF

Excel XLSX/XLS to PDF - Advanced Options

Aspose.Cells also allows you to control the Excel to PDF conversion using different options. For example, you can set PDF compliance, compression, gridlines style, number of pages per sheet, etc. To customize the conversion, the API provides PdfSaveOptions class.

The following are the steps to convert an Excel file to PDF with advanced options.

The following code sample shows how to convert Excel to PDF using advanced options.

Get a Free API License

In order to use the API without evaluation limitations, you can request a free temporary license.

Conclusion

In this article, you have learned how to convert Excel files to PDF within Node.js applications. Furthermore, you have seen how to control Excel to PDF conversion using advanced options. You can explore more about the Node.js Excel API using the documentation. Furthermore, you can contact us via our forum in case of any query.

See Also