Class: FRangeProtectionRule
Implementation class for range protection rules Encapsulates operations on a single protection rule
Accessors
id
Get Signature
get id(): stringGet 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(): IRangeProtectionOptionsGet 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
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
| Parameter | Type | Description |
|---|---|---|
ranges | FRange[] | 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')]);