TRY NEW VERSION

SHEETS

SHEETS(arg1) → { number | string | boolean }

Returns the number of sheets in a reference.

Parameters:

Name Type Description
arg1 ApiRange

Is a reference for which you want to know the number of sheets it contains. If omitted the number of sheets in the workbook containing the function is returned.

Returns:

Type
number | string | boolean

Example

Copy code
builder.CreateFile("xlsx");

// Add more sheets
Api.AddSheet("Sheet2")
Api.AddSheet("Sheet3")

// Get the number of sheets
var oFunction = Api.GetWorksheetFunction();
var result = oFunction.SHEETS();
const oWorksheet = Api.GetActiveSheet();
oWorksheet.GetRange("C3").SetValue(result);

builder.SaveFile("xlsx", "SHEETS.xlsx");
builder.CloseFile();

Resulting document