Skip to Content
ClassesFRangeProtectionRule

Class: FRangeProtectionRule

Implementation class for range protection rules Encapsulates operations on a single protection rule

Accessors

id

Get Signature

get id(): string

Get the rule ID.

Example
const worksheet = univerAPI.getActiveWorkbook()?.getActiveSheet(); const permission = worksheet?.getWorksheetPermission(); const rules = await permission?.listRangeProtectionRules(); const ruleId = rules?.[0]?.id; console.log(ruleId);
Returns

string

The unique identifier of this protection rule.


options

Get Signature

get options(): IRangeProtectionOptions

Get the protection options.

Example
const worksheet = univerAPI.getActiveWorkbook()?.getActiveSheet(); const permission = worksheet?.getWorksheetPermission(); const rules = await permission?.listRangeProtectionRules(); const options = rules?.[0]?.options; console.log(options);
Returns

IRangeProtectionOptions

Copy of the protection options.


ranges

Get Signature

get ranges(): FRange[]

Get the protected ranges.

Example
const worksheet = univerAPI.getActiveWorkbook()?.getActiveSheet(); const permission = worksheet?.getWorksheetPermission(); const rules = await permission?.listRangeProtectionRules(); const ranges = rules?.[0]?.ranges; console.log(ranges);
Returns

FRange[]

Array of protected ranges.

Methods

remove()

remove(): Promise<void>

Delete the current protection rule.

Returns

Promise<void>

A promise that resolves when the rule is removed.

Example

const worksheet = univerAPI.getActiveWorkbook()?.getActiveSheet(); const permission = worksheet?.getWorksheetPermission(); const rules = await permission?.listRangeProtectionRules(); const rule = rules?.[0]; await rule?.remove();

updateRanges()

updateRanges(ranges): Promise<void>

Update the protected ranges.

Parameters

ParameterTypeDescription
rangesFRange[]New ranges to protect.

Returns

Promise<void>

A promise that resolves when the ranges are updated.

Example

const worksheet = univerAPI.getActiveWorkbook()?.getActiveSheet(); const permission = worksheet?.getWorksheetPermission(); const rules = await permission?.listRangeProtectionRules(); const rule = rules?.[0]; await rule?.updateRanges([worksheet.getRange('A1:C3')]);