How to Print an Excel File in Node.js

How to Print an Excel File in Node.js

Printing documents programmatically gives your business a competitive edge. Automating this common task saves time and effort for your team. In this post we install the JS Excel library in a Node.js project to manipulate Excel files and show how to print an Excel file in Node.js.

We will cover the following points in this blog post:

JS Excel library installation

Visit this link for the installation steps of this enterprise‑level library. You can either download the API package or install it with these commands:

npm install java
npm install aspose.cells

How to print an Excel file in Node.js

Once installation is completed, you can start writing the source code and explore the methods to configure your API calls.

The steps are:

  1. Create an instance of the WorkBook class and load the source Excel file.
  2. Instantiate an object for ImageOptions class that allows specifying options when rendering worksheets to images, and printing worksheets.
  3. Get the first worksheet by invoking the get method.
  4. Create a SheetRender object with respect to your desired sheet which can render worksheet to various images.
  5. Print the worksheet by calling the toPrinter method.

Copy & paste the following code into your main file:

The output can be seen in the image below:

printing software

Get a Free License

You can avail a free temporary license to try the API without evaluation limitations.

Summing up

We conclude this post hoping you now know how to print an Excel file in Node.js. You can customize the snippet for your business needs and explore the documentation of this JS Excel library for more methods.

Moreover, we suggest you follow our Getting Started guide.

Stay tuned to conholdate.com for new blog posts and regular updates.

Ask a question

You can let us know about your questions or queries on our forum.

FAQs

How do I get Excel to print automatically?

Follow this link to get the code snippet that prints Excel files programmatically.

See Also