Skip to main content

add()

Description

Adds a new empty sheet to the spreadsheet and returns the unique identifier of the newly created sheet

If no name is provided, a default name will be generated automatically (e.g. "Sheet 2", "Sheet 3", etc.).

info

To apply this method, you need to enable the multiSheets configuration option.

Usage

add: (name?: string) => Id;

Parameters

  • name - (string) optional, the displayed name for the new sheet tab. If omitted, a default name is assigned.

Returns

  • Id - (string | number) the unique identifier of the newly created sheet.

Example

const spreadsheet = new dhx.Spreadsheet("spreadsheet_container", {
multiSheets: true
});
spreadsheet.parse(data);

// Add a sheet with a custom name
const newSheetId = spreadsheet.sheets.add("Q4 Report");
console.log(newSheetId); // e.g. "sheet_2"

// Add a sheet with an auto-generated name
const anotherSheetId = spreadsheet.sheets.add();

Change log: Added in v6.0

Related articles: Working with sheets