How to Create Hyperlinks in Excel using Node.js

How to Create Hyperlinks in Excel using Node.js

Accessing and manipulating Excel files programmatically is not a more difficult task. There are a number of routine chores that are time-consuming and sometimes become a hassle. However, automating such repetitive tasks always provides a competitive edge for the business application. Therefore, we will use this XLSX Javascript library to implement how to create Hyperlinks in Excel using Node.js programmatically.

The following points will be covered:

XLSX JavaScript library installation

This library offers a rich stack of methods along with comprehensive documentation. There are two ways to install this library, you can install it by downloading the API package or running the following commands in the terminal/CMD.

npm install java
npm install aspose.cells

Let’s write the code snippet and the steps to achieve the desired functionality programmatically.

The following are the steps:

  1. Initialize an instance of the Workbook class.
  2. Obtain the reference of the first worksheet by calling the getWorksheets method.
  3. get the Worksheet element at the specified index.
  4. Get the HyperlinkCollection collection by calling the getHyperlinks method and assigning it to the HyperlinkCollection.
  5. Invoke the add method to add a hyperlink to a URL at “A1” cell.
  6. Save the Excel file by invoking the save method.

Copy & paste the following code into your main file:

You can see the output in the image below:

How to Create Hyperlinks in Excel

Likewise, you can explore many other features exposed by this XLSX Javascript library. It lets you configure your API calls to meet your business requirements.

Please follow the following steps:

  1. Create an object of the Workbook class.
  2. get the Worksheet element at the specified index.
  3. Call the getCells method to get the Cells collection.
  4. get the Cell element at the specified cell name.
  5. Set the value of the range by calling the setValue method.
  6. Setting the font color of the cell to Blue by calling the setColor method.
  7. Now, get the HyperlinkCollection collection by calling the getHyperlinks method and assign it to the HyperlinkCollection.
  8. Add a hyperlink to a URL at “A1” cell by calling the add method.
  9. Invoke the save method to save the Excel file.

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. We can safely say that you have gone through and learned how to create Hyperlinks in Excel using Node.js. In addition, you also have explored some advanced methods exposed by this XLSX JavaScript library. Moreover, do not skip 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 create multiple Hyperlinks in Excel?

Please visit this link to get the code snippet that demonstrates how to create Hyperlinks in an Excel file using the XLSX JavaScript library.

See Also