AddDefName

function AddDefName(sName: string = null, sRef: string = null, isHidden: boolean = null): boolean

Description

Adds a new name to the current worksheet.

Parameters

sNamestringdefault: null

The range name.

sRefstringdefault: null

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

isHiddenbooleandefault: null

Defines if the range name is hidden or not.

Returns

boolean

Try It

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

Get Help

  • If you have any questions about ONLYOFFICE Docs, try the FAQ section first.
  • You can request a feature or report a bug by posting an issue on GitHub.
  • You can also ask our developers on ONLYOFFICE forum (registration required).