Insert Shapes in Excel using Node.js

Insert Shapes in Excel using Node.js

This JavaScript API for Excel enables you to add multiple shapes in Worksheets programmatically. Shapes such as stars, lines, rectangles, arrows, and many others. This library offers a wide range of methods to automate this whole process. In addition, you may fill the shapes with colors and configure their sizes depending upon your requirements. In this blog post, we will write the code snippets to insert shapes in Excel using Node.js Excel library.

The following points will be covered in this guide:

Insert shapes in Excel using Node.js - API installation

The installation process of this library is simple. You can either download the API package or install it by running the following commands into the terminal:

npm install java
npm install aspose.cells

Insert a Line shape into Worksheet

You may follow the steps and the code snippet to add a line shape into an Excel file programmatically:

  1. Instantiate an instance of the Workbook class.
  2. Access the first worksheet from the collection by calling the get(index) method.
  3. Invoke the addShape method to add the line to the worksheet.
  4. Call the save method to save the file.

Copy & paste the following code into your main file:

You may see the output in the image below:

line shape

Add Rectangle in an Excel file

Similarly, we can add a rectangle shape by following the code snippet:

You may see the output in the image below:

rectangle shape

Insert a Star shape into Worksheet

Follow the code snippet to add a star sign using this JavaScript API for Excel:

You may see the output in the image below:

star shape

Add multiplication sign

Follow the code snippet to add a star sign using this JavaScript API for Excel:

You may see the output in the image below:

multiplication shape

Get a Free License

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

Summing up

This brings us to the end of this blog post. You have gone through how to insert shapes in Excel using Node.js Excel library. In addition, you have gone through some prominent features of this JavaScript API for Excel. Moreover, this blog post will really help you if you are looking to automate this process programmatically. However, do not forget to visit the documentation to know other features.

Moreover, we suggest you follow our Getting Started guide.

Finally, conholdate.com is writing new blog posts. Therefore, 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 insert multiple shapes into Excel?

Please follow this link to know the code snippet that helps you add various shapes in Excel files programmatically.

See Also