Skip to main content

Work with sheets

Starting from v4.1, the library allows working with multiple sheets in the spreadsheet.

In this article we'll discuss the details on how to implement such operations as adding a new sheet into the spreadsheet, removing the unnecessary sheet, getting all sheets, or getting the currently active sheet via using API methods. Besides, we'll explain how to load multiple sheets into the spreadsheet at once.


To learn how to interact with multiple sheets via the user interface, check our User Guide.

Loading multiple sheets

To load several sheets into the spreadsheet, you should prepare data with the desired number of sheets and their configuration and pass them to the parse() method as a parameter. The data should be an object. Check the list of attributes the object can include.


In case the multiSheets configuration option is set to false, only one sheet will be created.

Adding a new sheet

To add a new sheet into the spreadsheet, use the addSheet() method and pass the name of the new sheet as a parameter:

spreadsheet.addSheet("New Sheet");
// -> "u1614669331209"

The method returns the id of the created sheet.

Removing a sheet

You can remove a sheet from the spreadsheet by its id via the removeSheet() method:


Note, that a sheet won't be deleted if the number of sheets in the spreadsheet is less than 2.

Setting active sheet

To change the active sheet dynamically after initialization of the spreadsheet, use the setActiveSheet() method. It takes the id of a sheet as a parameter:


Related sample: Spreadsheet. Set active sheet

Getting active sheet

It is possible to get the sheet that is currently active by applying the getActiveSheet() method:

// -> {name: "sheet", id: "u1614675531904"}

The method returns an object with the name and id attributes of the currently active sheet.

Getting sheets

The getSheets() method allows you to get all sheets of the spreadsheet. The method returns an array with a set of sheet objects:

// -> [{name: "sheet1", id: "u1614669331194"}, …]

Clearing sheets

There is the ability to clear the data of the specified sheet by its id via the clearSheet() method:


Related sample: Spreadsheet. Clear

To clear the currently active sheet, call the clearSheet() method without the parameter:


If you need to clear the whole spreadsheet at once, use the clear() method.