API Reference

FRangePermission

Packages@univerjs/sheets

Implementation class for RangePermission Manages range-level permissions

This class should not be instantiated directly. Use factory methods on univerAPI instead.

Overview

@univerjs/sheets

MethodDescription
isProtectedCheck if the current range is protected
listRulesList all protection rules that intersect with the current range
protectProtect the current range
unprotectCancel all protection rules that intersect with the current range

APIs

Getters & Queries

isProtected

Check if the current range is protected.

Signature

TypeScript
isProtected(): boolean

Returns

  • boolean — True if the range is protected, false otherwise.

Examples

TypeScript
const fWorkbook = univerAPI.getActiveWorkbook();const fWorksheet = fWorkbook.getActiveSheet();const fRange = fWorksheet.getRange('A1:B2');// Check if the A1:B2 range is protectedconst isProtected = fRange.getRangePermission().isProtected();console.log(isProtected);
Source: @univerjs/sheets

listRules

List all protection rules that intersect with the current range.

Signature

TypeScript
async listRules(options?: {            ignoreCollaborators?: boolean; // Option to ignore fetching collaborators for performance        }): Promise<FRangeProtectionRule[]>

Parameters

  • options { ignoreCollaborators?: boolean; } (optional)No description

Returns

  • Promise<FRangeProtectionRule[]> — Array of protection rules.

Examples

TypeScript
const fWorkbook = univerAPI.getActiveWorkbook();const fWorksheet = fWorkbook.getActiveSheet();const fRange = fWorksheet.getRange('A1:B2');const rules = await fRange.getRangePermission().listRules();console.log(rules);
Source: @univerjs/sheets

Miscellaneous

protect

Protect the current range.

Signature

TypeScript
async protect(options?: IRangeProtectionOptions): Promise<FRangeProtectionRule>

Parameters

  • options IRangeProtectionOptions (optional)No description

Returns

  • Promise<FRangeProtectionRule> — The created protection rule.

Examples

TypeScript
const fWorkbook = univerAPI.getActiveWorkbook();const fWorksheet = fWorkbook.getActiveSheet();const fRange = fWorksheet.getRange('A1:B2');const rule = await fRange.getRangePermission().protect({  name: 'My protected range',  allowedUsers: ['user1', 'user2'],  allowViewByOthers: false,});console.log(rule);
Source: @univerjs/sheets

unprotect

Remove all protection rules that intersect with the current range.

Signature

TypeScript
async unprotect(): Promise<boolean>

Returns

  • Promise<boolean> — True if all rules were successfully removed, false otherwise.

Examples

TypeScript
const fWorkbook = univerAPI.getActiveWorkbook();const fWorksheet = fWorkbook.getActiveSheet();const fRange = fWorksheet.getRange('A1:B2');const result = await fRange.getRangePermission().unprotect();console.log(result);
Source: @univerjs/sheets

How is this guide?

© 2026 DreamNum Co., Ltd.