Get Started
Usage API

AddDefName

AddDefName(sName, sRef, isHidden) → { Error | true }

Defines a new name for a range of cells.

Parameters:

Name Type Description
sName string
sRef string

Must contain the sheet name, followed sign ! , followed by a range of cells. Example: "Sheet1!$A$1:$B$2".

isHidden bool

Returns:

Type
Error | true

Example

Copy code
builder.CreateFile("xlsx");
oWorksheet = Api.GetActiveSheet();
oWorksheet.GetRange("A1").SetValue("1");
oWorksheet.GetRange("B1").SetValue("2");
Api.AddDefName("numbers", "Sheet1!$A$1:$B$1");
oWorksheet.GetRange("A3").SetValue("We defined a name 'numbers' for a range of cells A1:B1.");
builder.SaveFile("xlsx", "AddDefName.xlsx");
builder.CloseFile();

Resulting document