# FRangeProtectionRule

> Language fallback: requested `ko-KR`; content is `en-US`.

- Human documentation: [https://docs.univer.ai/ko-KR/reference/facade/range-protection-rule](https://docs.univer.ai/ko-KR/reference/facade/range-protection-rule)

- Agent Markdown: [https://docs.univer.ai/ko-KR/reference/facade/range-protection-rule.md](https://docs.univer.ai/ko-KR/reference/facade/range-protection-rule.md)

- Requested language: `ko-KR`

- Content language: `en-US`

- Documentation version: `1.0.4`

- Source: [facade/range-protection-rule.mdx](https://github.com/dream-num/documentation/blob/dev/content/reference/facade/range-protection-rule.mdx)

---

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

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

## Access

Access through:

* [`FRangePermission.protect()`](https://docs.univer.ai/ko-KR/reference/facade/range-permission.md#protect)
* [`FRangePermission.listRules()`](https://docs.univer.ai/ko-KR/reference/facade/range-permission.md#listrules)
* [`FWorksheetPermission.protectRanges()`](https://docs.univer.ai/ko-KR/reference/facade/worksheet-permission.md#protectranges)
* [`FWorksheetPermission.listRangeProtectionRules()`](https://docs.univer.ai/ko-KR/reference/facade/worksheet-permission.md#listrangeprotectionrules)
* [`FWorksheetPermission.debugCellPermission()`](https://docs.univer.ai/ko-KR/reference/facade/worksheet-permission.md#debugcellpermission)

## Setup

Register [`@univerjs/sheets`](https://docs.univer.ai/ko-KR/reference/packages/plugins/univerjs/sheets.md) or a preset that includes it. In plugin mode, import `@univerjs/sheets/facade`. Additional methods below require their listed plugin packages. See [Facade setup](https://docs.univer.ai/ko-KR/guides/sheets/getting-started/facade.md).

## `@univerjs/sheets`

### `FRangeProtectionRule.canDelete`

Check if the current user can delete this protection rule.

```typescript
canDelete(): boolean
```

**Returns**

true if can delete rule, false otherwise.

**Examples**

```ts
const fWorkbook = univerAPI.getActiveWorkbook()
const fWorksheet = fWorkbook.getSheetByName('Sheet1')
if (!fWorksheet) throw new Error('fWorksheet is not available')
const rules = await fWorksheet.getWorksheetPermission().listRangeProtectionRules()
// Check if the first rule allows deleting the rule
const rule = rules[0]
if (rule?.canDelete()) {
  console.log(
    `You can delete this protection rule for this range ${rule.ranges.map((r) => r.getA1Notation()).join(', ')}`,
  )
}
```

**Package:** [`@univerjs/sheets`](https://docs.univer.ai/ko-KR/reference/packages/plugins/univerjs/sheets.md) · [Type definitions](https://unpkg.com/@univerjs/sheets/lib/types/facade/permission/f-range-protection-rule.d.ts)

### `FRangeProtectionRule.canEdit`

Check if the current user can edit this range.

```typescript
canEdit(): boolean
```

**Returns**

true if editable, false otherwise.

**Examples**

```ts
const fWorkbook = univerAPI.getActiveWorkbook()
const fWorksheet = fWorkbook.getSheetByName('Sheet1')
if (!fWorksheet) throw new Error('fWorksheet is not available')
const rules = await fWorksheet.getWorksheetPermission().listRangeProtectionRules()
// Check if the first rule allows editing
const rule = rules[0]
if (rule?.canEdit()) {
  console.log(`You can edit this range ${rule.ranges.map((r) => r.getA1Notation()).join(', ')}`)
}
```

**Package:** [`@univerjs/sheets`](https://docs.univer.ai/ko-KR/reference/packages/plugins/univerjs/sheets.md) · [Type definitions](https://unpkg.com/@univerjs/sheets/lib/types/facade/permission/f-range-protection-rule.d.ts)

### `FRangeProtectionRule.canManageCollaborator`

Check if the current user can manage collaborators for this range.

```typescript
canManageCollaborator(): boolean
```

**Returns**

true if can manage collaborators, false otherwise.

**Examples**

```ts
const fWorkbook = univerAPI.getActiveWorkbook()
const fWorksheet = fWorkbook.getSheetByName('Sheet1')
if (!fWorksheet) throw new Error('fWorksheet is not available')
const rules = await fWorksheet.getWorksheetPermission().listRangeProtectionRules()
// Check if the first rule allows managing collaborators
const rule = rules[0]
if (rule?.canManageCollaborator()) {
  console.log(
    `You can manage collaborators for this range ${rule.ranges.map((r) => r.getA1Notation()).join(', ')}`,
  )
}
```

**Package:** [`@univerjs/sheets`](https://docs.univer.ai/ko-KR/reference/packages/plugins/univerjs/sheets.md) · [Type definitions](https://unpkg.com/@univerjs/sheets/lib/types/facade/permission/f-range-protection-rule.d.ts)

### `FRangeProtectionRule.canView`

Check if the current user can view this range.

```typescript
canView(): boolean
```

**Returns**

true if viewable, false otherwise.

**Examples**

```ts
const fWorkbook = univerAPI.getActiveWorkbook()
const fWorksheet = fWorkbook.getSheetByName('Sheet1')
if (!fWorksheet) throw new Error('fWorksheet is not available')
const rules = await fWorksheet.getWorksheetPermission().listRangeProtectionRules()
// Check if the first rule allows viewing
const rule = rules[0]
if (rule?.canView()) {
  console.log(`You can view this range ${rule.ranges.map((r) => r.getA1Notation()).join(', ')}`)
}
```

**Package:** [`@univerjs/sheets`](https://docs.univer.ai/ko-KR/reference/packages/plugins/univerjs/sheets.md) · [Type definitions](https://unpkg.com/@univerjs/sheets/lib/types/facade/permission/f-range-protection-rule.d.ts)

### `FRangeProtectionRule.getPoint`

Get the value of a specific permission point.

```typescript
getPoint(point: RangePermissionPoint): boolean
```

**Parameters**

* `point` — Required. The range permission point to query.

**Returns**

true if allowed, false if denied.

**Examples**

```ts
const fWorkbook = univerAPI.getActiveWorkbook()
const fWorksheet = fWorkbook.getSheetByName('Sheet1')
if (!fWorksheet) throw new Error('fWorksheet is not available')
const rules = await fWorksheet.getWorksheetPermission().listRangeProtectionRules()
// Check if the first rule allows editing
if (rules.length > 0) {
  const rule = rules[0]
  const canEdit = rule.getPoint(univerAPI.Enum.RangePermissionPoint.Edit)
  console.log(canEdit)
}
```

**Types:** [`RangePermissionPoint`](https://unpkg.com/@univerjs/sheets/lib/types/facade/permission/permission-types.d.ts)

**Package:** [`@univerjs/sheets`](https://docs.univer.ai/ko-KR/reference/packages/plugins/univerjs/sheets.md) · [Type definitions](https://unpkg.com/@univerjs/sheets/lib/types/facade/permission/f-range-protection-rule.d.ts)

### `FRangeProtectionRule.getSnapshot`

Get the current permission snapshot.

```typescript
getSnapshot(): RangePermissionSnapshot
```

**Returns**

Snapshot of all permission points.

**Examples**

```ts
const fWorkbook = univerAPI.getActiveWorkbook()
const fWorksheet = fWorkbook.getSheetByName('Sheet1')
if (!fWorksheet) throw new Error('fWorksheet is not available')
const rules = await fWorksheet.getWorksheetPermission().listRangeProtectionRules()
// Get the permission snapshot of the first rule
if (rules.length > 0) {
  const rule = rules[0]
  const snapshot = rule.getSnapshot()
  console.log(snapshot)
}
```

**Types:** [`RangePermissionSnapshot`](https://unpkg.com/@univerjs/sheets/lib/types/facade/permission/permission-types.d.ts)

**Package:** [`@univerjs/sheets`](https://docs.univer.ai/ko-KR/reference/packages/plugins/univerjs/sheets.md) · [Type definitions](https://unpkg.com/@univerjs/sheets/lib/types/facade/permission/f-range-protection-rule.d.ts)

### `FRangeProtectionRule.id`

Get the rule ID.

```typescript
readonly id: string
```

**Package:** [`@univerjs/sheets`](https://docs.univer.ai/ko-KR/reference/packages/plugins/univerjs/sheets.md) · [Type definitions](https://unpkg.com/@univerjs/sheets/lib/types/facade/permission/f-range-protection-rule.d.ts)

### `FRangeProtectionRule.options`

Get the protection options.

```typescript
readonly options: IRangeProtectionOptions
```

**Types:** [`IRangeProtectionOptions`](https://unpkg.com/@univerjs/sheets/lib/types/facade/permission/permission-types.d.ts)

**Package:** [`@univerjs/sheets`](https://docs.univer.ai/ko-KR/reference/packages/plugins/univerjs/sheets.md) · [Type definitions](https://unpkg.com/@univerjs/sheets/lib/types/facade/permission/f-range-protection-rule.d.ts)

### `FRangeProtectionRule.permissionId`

Get the permission ID associated with this rule.

```typescript
readonly permissionId: string
```

**Package:** [`@univerjs/sheets`](https://docs.univer.ai/ko-KR/reference/packages/plugins/univerjs/sheets.md) · [Type definitions](https://unpkg.com/@univerjs/sheets/lib/types/facade/permission/f-range-protection-rule.d.ts)

### `FRangeProtectionRule.ranges`

Get the protected ranges.

```typescript
readonly ranges: FRange[]
```

**Types:** [`FRange`](https://docs.univer.ai/ko-KR/reference/facade/range.md)

**Package:** [`@univerjs/sheets`](https://docs.univer.ai/ko-KR/reference/packages/plugins/univerjs/sheets.md) · [Type definitions](https://unpkg.com/@univerjs/sheets/lib/types/facade/permission/f-range-protection-rule.d.ts)

### `FRangeProtectionRule.remove`

Delete the current protection rule.

```typescript
remove(): Promise<boolean>
```

**Returns**

A promise resolving to whether the rule was removed.

**Examples**

```ts
const fWorkbook = univerAPI.getActiveWorkbook()
const fWorksheet = fWorkbook.getSheetByName('Sheet1')
if (!fWorksheet) throw new Error('fWorksheet is not available')
const rules = await fWorksheet.getWorksheetPermission().listRangeProtectionRules()
// Remove the first protection rule
if (rules.length > 0) {
  const rule = rules[0]
  const result = await rule.remove()
  console.log(result)
}
```

**Types:** [`Promise`](https://unpkg.com/@typescript/typescript-darwin-arm64/lib/lib.es5.d.ts)

**Package:** [`@univerjs/sheets`](https://docs.univer.ai/ko-KR/reference/packages/plugins/univerjs/sheets.md) · [Type definitions](https://unpkg.com/@univerjs/sheets/lib/types/facade/permission/f-range-protection-rule.d.ts)

### `FRangeProtectionRule.setPoint`

Set a specific permission point for the range rule (low-level API).

**Important:** This method only updates the permission point value for an existing protection rule.
It does NOT create permission checks that will block actual editing operations.
You must call `protect()` first to create a protection rule before using this method.

This method is useful for:

* Fine-tuning permissions after creating a protection rule with `protect()`
* Dynamically adjusting permissions based on runtime conditions
* Advanced permission management scenarios

```typescript
setPoint(point: RangePermissionPoint, value: boolean): Promise<void>
```

**Parameters**

* `point` — Required. The permission point to set.
* `value` — Required. The value to set (true = allowed, false = denied).

**Returns**

A promise that resolves when the point is set.

**Throws**

If no protection rule exists for this range.

**Examples**

```ts
const fWorkbook = univerAPI.getActiveWorkbook()
const fWorksheet = fWorkbook.getSheetByName('Sheet1')
if (!fWorksheet) throw new Error('fWorksheet is not available')
const fRange = fWorksheet.getRange('A1:B2')
// First, create a protection rule
const rule = await fRange.getRangePermission().protect({ name: 'My Range', allowEdit: true })
// Then you can dynamically update permission points
await rule.setPoint(univerAPI.Enum.RangePermissionPoint.Edit, false) // Now disable edit
await rule.setPoint(univerAPI.Enum.RangePermissionPoint.View, true) // Ensure view is enabled
```

**Types:** [`Promise`](https://unpkg.com/@typescript/typescript-darwin-arm64/lib/lib.es5.d.ts) · [`RangePermissionPoint`](https://unpkg.com/@univerjs/sheets/lib/types/facade/permission/permission-types.d.ts)

**Package:** [`@univerjs/sheets`](https://docs.univer.ai/ko-KR/reference/packages/plugins/univerjs/sheets.md) · [Type definitions](https://unpkg.com/@univerjs/sheets/lib/types/facade/permission/f-range-protection-rule.d.ts)

### `FRangeProtectionRule.updateRanges`

Update the protected ranges.

```typescript
updateRanges(ranges: FRange[]): Promise<boolean>
```

**Parameters**

* `ranges` — Required. New ranges to protect.

**Returns**

A promise resolving to whether the protected ranges were updated.

**Examples**

```ts
const fWorkbook = univerAPI.getActiveWorkbook()
const fWorksheet = fWorkbook.getSheetByName('Sheet1')
if (!fWorksheet) throw new Error('fWorksheet is not available')
const rules = await fWorksheet.getWorksheetPermission().listRangeProtectionRules()
// Update the ranges to A1:C3 for the first rule
if (rules.length > 0) {
  const rule = rules[0]
  const result = await rule.updateRanges([fWorksheet.getRange('A1:C3')])
  console.log(result)
}
```

**Types:** [`Promise`](https://unpkg.com/@typescript/typescript-darwin-arm64/lib/lib.es5.d.ts) · [`FRange`](https://docs.univer.ai/ko-KR/reference/facade/range.md)

**Package:** [`@univerjs/sheets`](https://docs.univer.ai/ko-KR/reference/packages/plugins/univerjs/sheets.md) · [Type definitions](https://unpkg.com/@univerjs/sheets/lib/types/facade/permission/f-range-protection-rule.d.ts)
