Convert Excel to PDF in Node.js

Excel workbooks are widely used for data storage and analysis, yet many business scenarios demand a PDF version for secure sharing or printing. This article provides a complete, code‑first tutorial on converting Excel (XLSX or XLS) files to PDF with Node.js, and explains how to fine‑tune the output using Aspose.Cells advanced settings.

Node.js Excel to PDF Conversion API

To transform Excel workbooks into PDF documents, we use Aspose.Cells for Node.js via Java – a powerful spreadsheet manipulation library. It supports creating, reading, editing, and converting Excel files without requiring Microsoft Office. Install the package directly from npm:

> npm install aspose.cells

You can also download the full library from the official site if you prefer a manual setup.

Convert Excel XLSX to PDF in Node.js

Follow these steps to convert an Excel workbook (XLSX or XLS) to a PDF file:

  1. Load the workbook with the Workbook class.
  2. Call Workbook.save(string, SaveFormat.PDF) to generate the PDF.

Below is a minimal example that reads an Excel file and saves it as PDF:

Excel File

Node.js Excel to PDF

Converted PDF

Excel to PDF

Excel XLSX/XLS to PDF - Advanced Options

Aspose.Cells lets you control the PDF output with a rich set of parameters, such as PDF/A compliance, image compression, gridline visibility, and page layout. These settings are exposed through the PdfSaveOptions class.

To apply custom options:

  1. Load the workbook using Workbook.
  2. Instantiate PdfSaveOptions.
  3. Configure desired properties, for example PdfOptions.setCompliance(PdfCompliance) for PDF/A.
  4. Save the workbook with Workbook.save(string, PdfSaveOptions).

The sample below demonstrates how to convert an Excel file to PDF while specifying advanced options:

Get a Free API License

To remove evaluation limits and unlock full functionality, request a free temporary license from Aspose:

request a free temporary license

Conclusion

This guide showed you how to convert Excel files to PDF in Node.js applications, both with basic conversion and with fine‑grained PDF settings. Explore the full capabilities of the Node.js Excel API in the official documentation and join the community on the forum for additional support.

See Also