Excel.AllowEditRangeCollection class
Represents the set of AllowEditRange
objects found in a worksheet. AllowEditRange
objects work with worksheet protection properties. When worksheet protection is enabled, an AllowEditRange
object can be used to allow editing of a specific range, while maintaining protection on the rest of 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(title, range |
Adds an |
get |
Returns the number of |
get |
Gets the |
get |
Returns an |
get |
Gets the |
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 |
pause |
Pauses worksheet protection for all |
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.AllowEditRange[];
Property Value
Method Details
add(title, rangeAddress, options)
Adds an AllowEditRange
object to the worksheet. Worksheet protection must be disabled or paused for this method to work properly. If worksheet protection is enabled and not paused, then this method throws an AccessDenied
error and the add operation fails.
add(title: string, rangeAddress: string, options?: Excel.AllowEditRangeOptions): void;
Parameters
- title
-
string
The title string of the AllowEditRange
object to be added.
- rangeAddress
-
string
The range address of the AllowEditRange
object to be added.
- options
- Excel.AllowEditRangeOptions
Additional options to be added to the AllowEditRange
object, such as the password.
Returns
void
Remarks
getCount()
Returns the number of AllowEditRange
objects in the collection.
getCount(): OfficeExtension.ClientResult<number>;
Returns
OfficeExtension.ClientResult<number>
Remarks
getItem(key)
Gets the AllowEditRange
object by its title.
getItem(key: string): Excel.AllowEditRange;
Parameters
- key
-
string
The title of the AllowEditRange
.
Returns
The AllowEditRange
with the title. If there is no AllowEditRange
with the given title, then an ItemNotFound
error is thrown.
Remarks
getItemAt(index)
Returns an AllowEditRange
object by its index in the collection.
getItemAt(index: number): Excel.AllowEditRange;
Parameters
- index
-
number
The index of the AllowEditRange
object in the collection.
Returns
The AllowEditRange
at the given index.
Remarks
getItemOrNullObject(key)
Gets the AllowEditRange
object by its title.
getItemOrNullObject(key: string): Excel.AllowEditRange;
Parameters
- key
-
string
The title of the AllowEditRange
.
Returns
The AllowEditRange
with the title. If there is no AllowEditRange
with the given title, then this method returns an object with its isNullObject
property set to true
. For further information, see *OrNullObject methods and properties.
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.AllowEditRangeCollectionLoadOptions & Excel.Interfaces.CollectionLoadOptions): Excel.AllowEditRangeCollection;
Parameters
- options
-
Excel.Interfaces.AllowEditRangeCollectionLoadOptions & 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.AllowEditRangeCollection;
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.AllowEditRangeCollection;
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
pauseProtection(password)
Pauses worksheet protection for all AllowEditRange
objects found in this worksheet that have the given password for the user in the current session. This method does nothing if worksheet protection isn't enabled or is paused. If worksheet protection cannot be paused, this method throws an UnsupportedOperation
error and fails to pause protection for the range. If the password does not match any AllowEditRange
objects in the collection, then this method throws a BadPassword
error and fails to pause protection for any range in the collection.
pauseProtection(password: string): void;
Parameters
- password
-
string
The password to pause protection on the AllowEditRange
objects.
Returns
void
Remarks
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.AllowEditRangeCollection
object is an API object, the toJSON
method returns a plain JavaScript object (typed as Excel.Interfaces.AllowEditRangeCollectionData
) that contains an "items" array with shallow copies of any loaded properties from the collection's items.
toJSON(): Excel.Interfaces.AllowEditRangeCollectionData;
Returns
Office Add-ins