FRangeProtectionRule
| packages | @univerjs/sheets |
|---|
Implementation class for range protection rules Encapsulates operations on a single protection rule
APIs
id
Get the rule ID.
Signature
get id(): stringReturns
- (
string) — The unique identifier of this protection rule.
Examples
const worksheet = univerAPI.getActiveWorkbook()?.getActiveSheet()
const permission = worksheet?.getWorksheetPermission()
const rules = await permission?.listRangeProtectionRules()
const ruleId = rules?.[0]?.id
console.log(ruleId)options
Get the protection options.
Signature
get options(): IRangeProtectionOptionsReturns
- (
IRangeProtectionOptions) — Copy of the protection options.
Examples
const worksheet = univerAPI.getActiveWorkbook()?.getActiveSheet()
const permission = worksheet?.getWorksheetPermission()
const rules = await permission?.listRangeProtectionRules()
const options = rules?.[0]?.options
console.log(options)ranges
Get the protected ranges.
Signature
get ranges(): FRange[]Returns
- (
FRange[]) — Array of protected ranges.
Examples
const worksheet = univerAPI.getActiveWorkbook()?.getActiveSheet()
const permission = worksheet?.getWorksheetPermission()
const rules = await permission?.listRangeProtectionRules()
const ranges = rules?.[0]?.ranges
console.log(ranges)remove
Delete the current protection rule.
Signature
remove(): Promise<void>Returns
- (
Promise<void>) — A promise that resolves when the rule is removed.
Examples
const worksheet = univerAPI.getActiveWorkbook()?.getActiveSheet()
const permission = worksheet?.getWorksheetPermission()
const rules = await permission?.listRangeProtectionRules()
const rule = rules?.[0]
await rule?.remove()updateRanges
Update the protected ranges.
Signature
updateRanges(ranges: FRange[]): Promise<void>Parameters
ranges(FRange[]) — New ranges to protect.
Returns
- (
Promise<void>) — A promise that resolves when the ranges are updated.
Examples
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')])