Skip to Content
ClassesFRangeProtectionRule

类: FRangeProtectionRule

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

访问器

id

Getter 签名

get id(): string

Get the rule ID.

示例
const worksheet = univerAPI.getActiveWorkbook()?.getActiveSheet(); const permission = worksheet?.getWorksheetPermission(); const rules = await permission?.listRangeProtectionRules(); const ruleId = rules?.[0]?.id; console.log(ruleId);
返回

string

The unique identifier of this protection rule.


options

Getter 签名

get options(): IRangeProtectionOptions

Get the protection options.

示例
const worksheet = univerAPI.getActiveWorkbook()?.getActiveSheet(); const permission = worksheet?.getWorksheetPermission(); const rules = await permission?.listRangeProtectionRules(); const options = rules?.[0]?.options; console.log(options);
返回

IRangeProtectionOptions

Copy of the protection options.


ranges

Getter 签名

get ranges(): FRange[]

Get the protected ranges.

示例
const worksheet = univerAPI.getActiveWorkbook()?.getActiveSheet(); const permission = worksheet?.getWorksheetPermission(); const rules = await permission?.listRangeProtectionRules(); const ranges = rules?.[0]?.ranges; console.log(ranges);
返回

FRange[]

Array of protected ranges.

方法

remove()

remove(): Promise<void>

Delete the current protection rule.

返回

Promise<void>

A promise that resolves when the rule is removed.

示例

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.

参数

参数类型描述
rangesFRange[]New ranges to protect.

返回

Promise<void>

A promise that resolves when the ranges are updated.

示例

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')]);