This short guide is about how to insert image in Excel using Node.js. It assists in setting the development environment, shares a list of steps to be performed in the code, and a runnable sample code to insert picture in Excel using Node.js. You will also learn different options to add an image from the disk or a steam in a sheet using different parameters.
Steps to Insert Picture in Excel Cell using Node.js
- Set the development environment to use Aspose.Cells for Node.js via Java to insert an image
- Create a new Workbook and access a sheet where the image is to be added
- Access the picture collection from the selected sheet
- Call the add() method in the PictureCollection class to add the image
- Provide the cell reference and the image file
- Save the resultant workbook with an image in it
These steps describe the process to insert image into Excel cell using Node.js. Firstly, the pictures collection is obtained from the selected sheet in the loaded workbook and then the add() method is called to insert an image at the defined cell. At the end, the resultant workbook is saved on the disk however you may save it to a stream or HTTP response if required.
Code to Add Image in Excel using Node.js
This code sample demonstrates the process of how to insert picture in Excel using Node.js. There are multiple overloaded methods available to add an image in a cell where different parameters can be set like adding a picture from a stream, adding a picture by providing cell area within which a picture is to be added, or just setting the starting cell and allow expanding the picture according to its original size. You may also remove a picture, check the presence of a picture, or get the total picture count if required.
This article has taught us how to insert photo in Excel using Node.js. If you want to add a chart to a sheet, refer to the article on how to create chart in Excel using Node.js.