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. |
enter |
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. |
get |
Gets the worksheet's currently active sheet view. |
get |
Gets the number of sheet views in this worksheet. Includes the temporary sheet view if it exists. |
get |
Gets a sheet view using its name. |
get |
Gets a sheet view by its index in the collection. |
get |
Gets a sheet view using its name. If the sheet view object does not exist, then this method returns an object with its |
load(options) | Queues up a command to load the specified properties of the object. You must call |
load(property |
Queues up a command to load the specified properties of the object. You must call |
load(property |
Queues up a command to load the specified properties of the object. You must call |
toJSON() | Overrides the JavaScript |
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
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
exit()
Exits the currently active sheet view.
exit(): void;
Returns
void
Remarks
getActive()
Gets the worksheet's currently active sheet view.
getActive(): Excel.NamedSheetView;
Returns
The currently active sheet view for this worksheet.
Remarks
getCount()
Gets the number of sheet views in this worksheet. Includes the temporary sheet view if it exists.
getCount(): OfficeExtension.ClientResult<number>;
Returns
OfficeExtension.ClientResult<number>
Remarks
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
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
getItemOrNullObject(key)
Note
This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.
Gets a sheet view using its name. If the sheet view object does not exist, then this method returns an object with its isNullObject
property set to true
. For further information, see *OrNullObject methods and properties.
getItemOrNullObject(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.
Remarks
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
Office Add-ins