Excel.NamedSheetViewCollection class

Represents the collection of sheet views in the worksheet.

Extends

Remarks

[ API set: ExcelApiOnline 1.1 ]

Properties

context

The request context associated with the object. This connects the add-in's process to the Office host application's process.

items

Gets the loaded child items in this collection.

Methods

add(name)

Creates a new sheet view with the given name.

enterTemporary()

Creates and activates a new temporary sheet view. Temporary views are removed when closing the application, exiting the temporary view with the exit method, or switching to another sheet view. The temporary sheet view can also be accessed with the empty string (""), if the temporary view exists.

exit()

Exits the currently active sheet view.

getActive()

Gets the worksheet's currently active sheet view.

getCount()

Gets the number of sheet views in this worksheet. Includes the temporary sheet view if it exists.

getItem(key)

Gets a sheet view using its name.

getItemAt(index)

Gets a sheet view by its index in the collection.

load(options)

Queues up a command to load the specified properties of the object. You must call context.sync() before reading the properties.

load(propertyNames)

Queues up a command to load the specified properties of the object. You must call context.sync() before reading the properties.

load(propertyNamesAndPaths)

Queues up a command to load the specified properties of the object. You must call context.sync() before reading the properties.

toJSON()

Overrides the JavaScript toJSON() method in order to provide more useful output when an API object is passed to JSON.stringify(). (JSON.stringify, in turn, calls the toJSON method of the object that is passed to it.) Whereas the original Excel.NamedSheetViewCollection object is an API object, the toJSON method returns a plain JavaScript object (typed as Excel.Interfaces.NamedSheetViewCollectionData) that contains an "items" array with shallow copies of any loaded properties from the collection's items.

Property Details

context

The request context associated with the object. This connects the add-in's process to the Office host application's process.

context: RequestContext;

Property Value

items

Gets the loaded child items in this collection.

readonly items: Excel.NamedSheetView[];

Property Value

Method Details

add(name)

Creates a new sheet view with the given name.

add(name: string): Excel.NamedSheetView;

Parameters

name

string

The name of the sheet view to be created. Throws an error when the provided name already exists, is empty, or is a name reserved by the worksheet.

Returns

The newly created sheet view object.

Remarks

[ API set: ExcelApiOnline 1.1 ]

enterTemporary()

Creates and activates a new temporary sheet view. Temporary views are removed when closing the application, exiting the temporary view with the exit method, or switching to another sheet view. The temporary sheet view can also be accessed with the empty string (""), if the temporary view exists.

enterTemporary(): Excel.NamedSheetView;

Returns

The newly created sheet view object.

Remarks

[ API set: ExcelApiOnline 1.1 ]

exit()

Exits the currently active sheet view.

exit(): void;

Returns

void

Remarks

[ API set: ExcelApiOnline 1.1 ]

getActive()

Gets the worksheet's currently active sheet view.

getActive(): Excel.NamedSheetView;

Returns

The currently active sheet view for this worksheet.

Remarks

[ API set: ExcelApiOnline 1.1 ]

getCount()

Gets the number of sheet views in this worksheet. Includes the temporary sheet view if it exists.

getCount(): OfficeExtension.ClientResult<number>;

Returns

Remarks

[ API set: ExcelApiOnline 1.1 ]

getItem(key)

Gets a sheet view using its name.

getItem(key: string): Excel.NamedSheetView;

Parameters

key

string

The case-sensitive name of the sheet view. Use the empty string ("") to get the temporary sheet view, if the temporary view exists.

Returns

The sheet view with the given name, or the temporary view if an empty string was provided. If there is no current temporary view and an empty string was provided, then an ItemNotFound error is thrown.

Remarks

[ API set: ExcelApiOnline 1.1 ]

getItemAt(index)

Gets a sheet view by its index in the collection.

getItemAt(index: number): Excel.NamedSheetView;

Parameters

index

number

The index of the sheet view object in the collection.

Returns

The sheet view at the given index.

Remarks

[ API set: ExcelApiOnline 1.1 ]

load(options)

Queues up a command to load the specified properties of the object. You must call context.sync() before reading the properties.

load(options?: Excel.Interfaces.NamedSheetViewCollectionLoadOptions & Excel.Interfaces.CollectionLoadOptions): Excel.NamedSheetViewCollection;

Parameters

options

Excel.Interfaces.NamedSheetViewCollectionLoadOptions & Excel.Interfaces.CollectionLoadOptions

Provides options for which properties of the object to load.

Returns

load(propertyNames)

Queues up a command to load the specified properties of the object. You must call context.sync() before reading the properties.

load(propertyNames?: string | string[]): Excel.NamedSheetViewCollection;

Parameters

propertyNames

string | string[]

A comma-delimited string or an array of strings that specify the properties to load.

Returns

load(propertyNamesAndPaths)

Queues up a command to load the specified properties of the object. You must call context.sync() before reading the properties.

load(propertyNamesAndPaths?: OfficeExtension.LoadOption): Excel.NamedSheetViewCollection;

Parameters

propertyNamesAndPaths
OfficeExtension.LoadOption

propertyNamesAndPaths.select is a comma-delimited string that specifies the properties to load, and propertyNamesAndPaths.expand is a comma-delimited string that specifies the navigation properties to load.

Returns

toJSON()

Overrides the JavaScript toJSON() method in order to provide more useful output when an API object is passed to JSON.stringify(). (JSON.stringify, in turn, calls the toJSON method of the object that is passed to it.) Whereas the original Excel.NamedSheetViewCollection object is an API object, the toJSON method returns a plain JavaScript object (typed as Excel.Interfaces.NamedSheetViewCollectionData) that contains an "items" array with shallow copies of any loaded properties from the collection's items.

toJSON(): Excel.Interfaces.NamedSheetViewCollectionData;

Returns