Get Started
Usage API
More information

SetName

SetName(sName) → { Error | true }

Set a String value representing the object name.

Parameters:

Name Type Description
sName string

New name for range.

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("name", "Sheet1!$A$1:$B$1");
oDefName = Api.GetDefName("name");
oDefName.SetName("new_name");
oNewDefName = Api.GetDefName("new_name");
oWorksheet.GetRange("A3").SetValue("The new name of the range: " + oNewDefName.GetName());
builder.SaveFile("xlsx", "SetName.xlsx");
builder.CloseFile();

Resulting document