How to Convert Excel to JPG using Node.js

This quick tutorial guides on how to convert Excel to JPG using Node.js. It has all the details to set the development environment, a list of steps, and a runnable sample code to export Excel to JPG using Node.js. You will also learn different options to customize the output images as per the requirements and save them to disk or print them directly to a printer.

Steps to Convert XLSX to JPG using Node.js

  1. Set the IDE to use Aspose.Cells for Node.js via Java to transform Excel to JPG
  2. Load a workbook and create an object of ImageOrPrintOptions to set output image properties
  3. Set the image type and the flag to auto-fit the cells according to the contents
  4. Render the sheet using the ImageOrPrintOptions object
  5. Loop through all the pages in the rendered sheet and save as a separate JPG

These steps explain the process to convert Excel file to JPG using Node.js. The process requires the loading of the workbook and creation of the ImageOrPrintOptions class object to customize the rendering process for instance adjusting the cell size according to the contents, and setting the image type. The rendering process may create multiple pages that require to be parsed through for saving each image in a separate file.

Code to Convert Excel to JPG using Node.js

The sample code above demonstrates the transformation of Excel to JPG using Node.js. You may set the image type to any other type, for instance, EMF, PICT, PNG, BMP, GIF, and SVG. The SheetRender.toImage() method saves the rendered sheet as separate images and toPrinter() prints the images directly.

This article has guided us on how to convert Excel sheet to image using Node.js. If you want to learn the process to convert a sheet to SVG, refer to the article on how to convert Excel to SVG in Node.js.

 English