NameCollection

NameCollection class

Represents a collection of all the Name objects in the spreadsheet.

class NameCollection;

Methods

MethodDescription
get(number)Gets the Name element at the specified index.
get(string)Gets the Name element with the specified name.
add(string)Defines a new name.
filter(NameScopeType, number)Gets all defined name by scope.
remove(string[])Remove an array of name
remove(string)Remove the name.
removeAt(number)Remove the name at the specific index.
clear()Remove all defined names which are not referenced by the formulas and data source. If the defined name is referred, we only set Name.ReferTo as null and hide them.
removeDuplicateNames()Remove the duplicate defined names
sort()Sorts defined names.
getCount()Gets the number of elements contained in.
isNull()Checks whether the implementation object is null.

get(number)

Gets the Name element at the specified index.

get(index: number) : Name;

Parameters:

ParameterTypeDescription
indexnumberThe zero based index of the element.

Returns

The element at the specified index.

get(string)

Gets the Name element with the specified name.

get(text: string) : Name;

Parameters:

ParameterTypeDescription
textstringName text.

Returns

The element with the specified name.

add(string)

Defines a new name.

add(text: string) : number;

Parameters:

ParameterTypeDescription
textstringThe text to use as the name.

Returns

Name object index.

Remarks

Name cannot include spaces and cannot look like cell references.

filter(NameScopeType, number)

Gets all defined name by scope.

filter(type: NameScopeType, sheetIndex: number) : Name[];

Parameters:

ParameterTypeDescription
typeNameScopeTypeThe scope type.
sheetIndexnumberThe sheet index. /// Only effects when scope type is NameScopeType.Worksheet

Returns

Name[]

remove(string[])

Remove an array of name

remove(names: string[]) : void;

Parameters:

ParameterTypeDescription
namesstring[]The names’ text.

remove(string)

Remove the name.

remove(text: string) : void;

Parameters:

ParameterTypeDescription
textstringThe name text.

removeAt(number)

Remove the name at the specific index.

removeAt(index: number) : void;

Parameters:

ParameterTypeDescription
indexnumberindex of the Name to be removed.

Remarks

Please make sure that the name is not referred by the other formulas before calling the method. And if the name is referred, setting Name.RefersTo as null is better.

clear()

Remove all defined names which are not referenced by the formulas and data source. If the defined name is referred, we only set Name.ReferTo as null and hide them.

clear() : void;

removeDuplicateNames()

Remove the duplicate defined names

removeDuplicateNames() : void;

sort()

Sorts defined names.

sort() : void;

Remarks

If you create a large amount of named ranges in the Excel file, please call this method after all named ranges are created and before saving

getCount()

Gets the number of elements contained in.

getCount() : number;

isNull()

Checks whether the implementation object is null.

isNull() : boolean;