How to Convert Excel to JPG in Node.js

How to Convert Excel to JPG in Node.js

Automation of Excel to JPG conversion provides great help when it comes to giving a business presentation. In most scenarios, you can’t attach huge Excel files with your PowerPoint presentations. Therefore, you can convert Excel to JPG by writing a few lines of source code in JavaScript. In this blog post, you will learn how to convert Excel to JPG in Node.js programmatically. We will install this XLSX JS library in our Node.js project to build an Excel to JPG converter.

In this blog post, the following points will be covered:

XLSX JS library installation

The installation process of this JavaScript library is developer-friendly. So, it lets you either download the API package or install it by running the following commands:

npm install java
npm install aspose.cells

How to Convert Excel to JPG in Node.js

There is a huge stack of features offered by this rich-featured library. Now, you can start writing code to build an Excel to JPG converter programmatically.

Please follow the steps given below:

  1. Initialize an instance of the Workbook class and load the source file.
  2. Create an object of the ImageOrPrintOptions class to access specific image creation options.
  3. Call the setImageType method to set the image type.
  4. The get(index) method will access the first worksheet in the workbook.
  5. Initialize the constructor of the SheetRender class for the target sheet.
  6. Loop through the pages and invoke the toImage method to create images for the sheets.

Copy & paste the following code into your main file:

The output can be seen in the image below:

Excel to JPG converter

Get a Free License

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

Summing up

To sum up, you have learned how to convert Excel to JPG in Node.js programmatically. This article will surely help you if you are looking to develop an Excel to JPG conversion module using this XLSX JS library. Moreover, you may visit the documentation to explore other features.

Moreover, we suggest you follow our Getting Started guide.

Finally, conholdate.com is writing new blog posts. So, please stay in touch for regular updates.

Ask a question

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

FAQs

How do I convert Excel to image?

You may follow this link to know the code snippet and the steps to convert Excel to JPG/JPEG programmatically.

See Also