Unhide Sheets in Excel using Node.js

Unhide Sheets in Excel using Node.js

You perform a number of business-related tasks using Microsoft Excel files. These files contain a huge amount of data and complex formulas are being applied to compile the results. In such scenarios, you only need working sheets to be shown to keep clarity in place while hiding the unwanted sheets. In this blog post, we will use this WorkSheet library to learn how to unhide Sheets in Excel using Node.js programmatically.

We will cover the following points:

Worksheet library installation

The installation process of this rich-featured library is quite easy. Therefore, it lets you download the API package or install it by running the following commands:

npm install java
npm install aspose.cells

Unhide Sheets in Excel using Node.js

Let’s write the code snippet that unhides the Excel WorkSheet using a few lines of source code programmatically.

The steps are:

  1. Create an object of the Workbook class and load the source Excel file.
  2. Get the reference of the first workSheet of the Excel file by calling the getWorkSheets method.
  3. Obtain the WorkSheet element at the specified index by calling the get method.
  4. Unhiding the first workSheet of the Excel file by setting the value of the setVisible method to true.
  5. Invoke the save method to save the modified Excel file.

Copy & paste the following code into your main file:

Similarly, it will hide the first WorkSheet if you set the value of the setVisible method to false.

The output can be seen in the image below where the first WorkSheet is hidden:

Unhide Sheets in Excel

Show/Hide tabs in Excel programmatically

Likewise, this WorkSheet library offers methods to show or hide tabs in an Excel file programmatically. You can follow the following steps to hide the tabs:

  1. Initialize the constructor of the Workbook class with an Excel file.
  2. Now, get the WorkSheet element at the specified index.
  3. Invoke the setShowTabs method to hide the tabs of the Excel file. Set the value to false/true to hide/show the tabs.
  4. Call the save method to save the updated Excel file.

You can see the output in the image below:

hide tabs in Excel

Hide headers in WorkSheet

In addition, you can hide the rows/columns headers programmatically. Please follow the following steps and the code snippet to hide the rows and columns headers:

  1. Instantiate an instance of the Workbook class and load an Excel file.
  2. get the WorkSheet element at the specified index.
  3. Call the setRowColumnHeadersVisible method to hide the Row/Column Headers of the Excel file.
  4. save the updated Excel file.

You can see the output in the image below:

Hide headers in Worksheet

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 this WorkSheet library that offers a wide range of features to manipulate and process Excel files programmatically. Further, you have seen how to unhide sheets in Excel using Node.js. Moreover, you can do a lot more such as hiding tabs, rows/colomns headers, and more. 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 automatically unhide sheets in Excel?

Please follow the link to know the code snippet that hides/unhides sheets in Excel programmatically.

See Also