Permission Control

Use a workbook mode to control editing and commenting across a spreadsheet. To let selected collaborators edit a sheet or a range, protect that sheet or range. In a collaborative deployment, the server must also authorize reads, session joins, and document changes. See Identity and authorization.

Common tasks

Make a workbook read-only or allow comments

The viewer mode allows viewing and printing. Use 'commenter' instead to allow comments while keeping cells read-only. A mode sets several permission points at once. To change one person’s role, use the collaborator APIs.

TypeScript
const fWorkbook = univerAPI.getActiveWorkbook()if (!fWorkbook) throw new Error('No active workbook')const permission = fWorkbook.getWorkbookPermission()await permission.setMode('viewer')

To change a single point, call setPoint. For example, await permission.setPoint(univerAPI.Enum.WorkbookPermissionPoint.Edit, false) turns off workbook editing. When the value changes, the SDK calls IAuthzIoService.update with the policy role Editor for true or Owner for false. To keep the policy when the document reopens, connect an authorization service.

Let selected collaborators edit a worksheet

Replace user1 and user2 with IDs of existing workbook collaborators. Create the protection rule with protect() before setting individual worksheet permission points. Call worksheetPermission.unprotect() to remove worksheet protection.

TypeScript
const fWorkbook = univerAPI.getActiveWorkbook()if (!fWorkbook) throw new Error('No active workbook')const fWorksheet = fWorkbook.getActiveSheet()const worksheetPermission = fWorksheet.getWorksheetPermission()await worksheetPermission.protect({  allowedUsers: ['user1', 'user2'],  name: 'My Worksheet Protection',})

Restrict viewing and editing of A1:B2 to selected collaborators

allowedUsers identifies the collaborators who can edit the range. Set allowViewByOthers: false to also restrict who can see it. Call rule.remove() on the returned rule to remove just that protection.

TypeScript
const fWorkbook = univerAPI.getActiveWorkbook()if (!fWorkbook) throw new Error('No active workbook')const fWorksheet = fWorkbook.getActiveSheet()const fRange = fWorksheet.getRange('A1:B2')const rangePermission = fRange.getRangePermission()const rule = await rangePermission.protect({  name: 'My protected range',  allowViewByOthers: false,  allowedUsers: ['user1', 'user2'],})

Call rangePermission.listRules() to list the rules intersecting the range. rangePermission.unprotect() removes all intersecting rules.

Manage protected ranges

TypeScript
const fWorkbook = univerAPI.getActiveWorkbook()if (!fWorkbook) throw new Error('No active workbook')const fWorksheet = fWorkbook.getActiveSheet()const permission = fWorksheet.getWorksheetPermission()const createdRules = await permission.protectRanges([  {    ranges: [fWorksheet.getRange('D1:D4')],    options: { name: 'Public area', allowViewByOthers: true },  },  {    ranges: [fWorksheet.getRange('E1:E4')],    options: { name: 'Private area', allowViewByOthers: false, allowedUsers: ['user1'] },  },])await createdRules[0].updateRanges([fWorksheet.getRange('D1:D5')])

Diagnose why a value cannot be entered in A1

The example shows the permissions required to enter a plain cell value. Any false value blocks the edit. debugCellPermission(0, 0) returns the protection rule covering A1, or undefined if none applies.

TypeScript
const fWorkbook = univerAPI.getActiveWorkbook()if (!fWorkbook) throw new Error('No active workbook')const worksheet = fWorkbook.getActiveSheet().getWorksheetPermission()const rule = await worksheet.debugCellPermission(0, 0)console.table({  workbookEdit: fWorkbook.getWorkbookPermission().canEdit(),  worksheetEdit: worksheet.canEdit(),  setCellValue: worksheet.getPoint(univerAPI.Enum.WorksheetPermissionPoint.SetCellValue),  rangeEdit: rule?.canEdit() ?? true,})

List of permission points

Worksheet actions and their points

Each operation checks its own points. A workbook point always applies alongside the worksheet or range points listed in the same row. When a row includes a range point, every protected range the operation touches must also allow the edit. Hiding a row or column widens the check to the whole row or column.

ActionRequired points
Enter a cell value (excluding formulas)WorkbookEditablePermission, WorksheetEditPermission, WorksheetSetCellValuePermission, RangeProtectionPermissionEditPoint
Insert a worksheetWorkbookEditablePermission, WorkbookCreateSheetPermission
Copy a worksheetWorkbookEditablePermission, WorkbookCopySheetPermission
Move a worksheetWorkbookEditablePermission, WorkbookMoveSheetPermission
Rename a worksheetWorkbookEditablePermission, WorkbookRenameSheetPermission
Hide or show a worksheetWorkbookEditablePermission, WorkbookHideSheetPermission
Delete a worksheetWorkbookEditablePermission, WorkbookDeleteSheetPermission
Hide or show rows or columnsWorkbookEditablePermission, WorksheetEditPermission, WorksheetSetRowStylePermission or WorksheetSetColumnStylePermission, and the edit point of each intersecting protected range
Resize rows or columns, or fit them to their contentWorksheetSetRowStylePermission or WorksheetSetColumnStylePermission
Merge or unmerge cellsWorkbookEditablePermission, WorksheetEditPermission, WorksheetSetCellValuePermission, WorksheetSetCellStylePermission, and the edit point of each intersecting protected range
Sort a rangeWorkbookEditablePermission, WorksheetEditPermission, WorksheetSortPermission, and the edit point of each intersecting protected range
Freeze or unfreeze panesWorkbookEditablePermission, WorksheetEditPermission
Show or hide gridlines, or change their colorWorkbookEditablePermission, WorksheetEditPermission
Add, update, or delete an annotationWorkbookEditablePermission, WorksheetEditPermission, and the edit point of each protected range that contains the cell
Group or ungroup rows or columnsWorkbookEditablePermission, WorksheetEditPermission, WorksheetSetRowStylePermission or WorksheetSetColumnStylePermission, and the edit point of each intersecting protected range
Create a protection ruleWorkbookCreateProtectPermission
Manage the collaborators of a protection ruleWorksheetManageCollaboratorPermission or RangeProtectionPermissionManageCollaPoint
Delete a protection ruleWorksheetDeleteProtectionPermission or RangeProtectionPermissionDeleteProtectionPoint

When a required point is false, the command is rejected before it changes the document.

Annotations follow the cell edit points. Reading an annotation is not permission-checked.

Comment permissions

Reading a Sheets comment requires workbook View. Posting requires workbook Comment. Both require worksheet View. For a comment anchored to a cell, each protection rule covering that cell must also allow viewing. Authors can update or delete their own comments.

Workbook permissions

API EnumCorresponding Permission Point ClassDescription
univerAPI.Enum.WorkbookPermissionPoint.EditWorkbookEditablePermissionCan edit
univerAPI.Enum.WorkbookPermissionPoint.ViewWorkbookViewPermissionCan view
univerAPI.Enum.WorkbookPermissionPoint.PrintWorkbookPrintPermissionCan print
univerAPI.Enum.WorkbookPermissionPoint.ExportWorkbookExportPermissionCan export
univerAPI.Enum.WorkbookPermissionPoint.ShareWorkbookSharePermissionCan share
univerAPI.Enum.WorkbookPermissionPoint.CopyContentWorkbookCopyPermissionCan copy
univerAPI.Enum.WorkbookPermissionPoint.DuplicateFileWorkbookDuplicatePermissionCan duplicate
univerAPI.Enum.WorkbookPermissionPoint.CommentWorkbookCommentPermissionCan comment
univerAPI.Enum.WorkbookPermissionPoint.ManageCollaboratorWorkbookManageCollaboratorPermissionCan manage collaborators
univerAPI.Enum.WorkbookPermissionPoint.CreateSheetWorkbookCreateSheetPermissionCan create worksheets
univerAPI.Enum.WorkbookPermissionPoint.DeleteSheetWorkbookDeleteSheetPermissionCan delete worksheets
univerAPI.Enum.WorkbookPermissionPoint.RenameSheetWorkbookRenameSheetPermissionCan rename worksheets
univerAPI.Enum.WorkbookPermissionPoint.MoveSheetWorkbookMoveSheetPermissionCan move worksheets
univerAPI.Enum.WorkbookPermissionPoint.HideSheetWorkbookHideSheetPermissionCan hide worksheets
univerAPI.Enum.WorkbookPermissionPoint.CopySheetWorkbookCopySheetPermissionCan copy worksheets
univerAPI.Enum.WorkbookPermissionPoint.ViewHistoryWorkbookViewHistoryPermissionCan view history
univerAPI.Enum.WorkbookPermissionPoint.RecoverHistoryWorkbookRecoverHistoryPermissionCan recover history
univerAPI.Enum.WorkbookPermissionPoint.CreateProtectionWorkbookCreateProtectPermissionCan create protection
univerAPI.Enum.WorkbookPermissionPoint.InsertRowWorkbookInsertRowPermissionCan insert rows
univerAPI.Enum.WorkbookPermissionPoint.InsertColumnWorkbookInsertColumnPermissionCan insert columns
univerAPI.Enum.WorkbookPermissionPoint.DeleteRowWorkbookDeleteRowPermissionCan delete rows
univerAPI.Enum.WorkbookPermissionPoint.DeleteColumnWorkbookDeleteColumnPermissionCan delete columns

Worksheet permissions

API EnumCorresponding Permission Point ClassDescription
univerAPI.Enum.WorksheetPermissionPoint.EditWorksheetEditPermissionCan edit
univerAPI.Enum.WorksheetPermissionPoint.ViewWorksheetViewPermissionCan view
univerAPI.Enum.WorksheetPermissionPoint.CopyWorksheetCopyPermissionCan copy
univerAPI.Enum.WorksheetPermissionPoint.SetCellValueWorksheetSetCellValuePermissionCan edit cell values
univerAPI.Enum.WorksheetPermissionPoint.SetCellStyleWorksheetSetCellStylePermissionCan edit cell styles
univerAPI.Enum.WorksheetPermissionPoint.SetRowStyleWorksheetSetRowStylePermissionCan set row styles
univerAPI.Enum.WorksheetPermissionPoint.SetColumnStyleWorksheetSetColumnStylePermissionCan set column styles
univerAPI.Enum.WorksheetPermissionPoint.InsertRowWorksheetInsertRowPermissionCan insert rows
univerAPI.Enum.WorksheetPermissionPoint.InsertColumnWorksheetInsertColumnPermissionCan insert columns
univerAPI.Enum.WorksheetPermissionPoint.DeleteRowWorksheetDeleteRowPermissionCan delete rows
univerAPI.Enum.WorksheetPermissionPoint.DeleteColumnWorksheetDeleteColumnPermissionCan delete columns
univerAPI.Enum.WorksheetPermissionPoint.SortWorksheetSortPermissionCan sort
univerAPI.Enum.WorksheetPermissionPoint.FilterWorksheetFilterPermissionCan filter
univerAPI.Enum.WorksheetPermissionPoint.PivotTableWorksheetPivotTablePermissionCan use pivot tables
univerAPI.Enum.WorksheetPermissionPoint.InsertHyperlinkWorksheetInsertHyperlinkPermissionCan use hyperlinks
univerAPI.Enum.WorksheetPermissionPoint.ManageCollaboratorWorksheetManageCollaboratorPermissionCan manage collaborators
univerAPI.Enum.WorksheetPermissionPoint.DeleteProtectionWorksheetDeleteProtectionPermissionCan delete protection
univerAPI.Enum.WorksheetPermissionPoint.EditExtraObjectWorksheetEditExtraObjectPermissionCan edit extra objects
univerAPI.Enum.WorksheetPermissionPoint.SelectProtectedCellsWorksheetSelectProtectedCellsPermissionCan select protected cells
univerAPI.Enum.WorksheetPermissionPoint.SelectUnProtectedCellsWorksheetSelectUnProtectedCellsPermissionCan select unprotected cells

Range protection

API EnumCorresponding Permission Point ClassDescription
univerAPI.Enum.RangePermissionPoint.EditRangeProtectionPermissionEditPointCan edit protected ranges
univerAPI.Enum.RangePermissionPoint.ViewRangeProtectionPermissionViewPointCan view content of protected ranges
univerAPI.Enum.RangePermissionPoint.DeleteRangeProtectionPermissionDeleteProtectionPointCan delete protected ranges
univerAPI.Enum.RangePermissionPoint.ManageCollaboratorRangeProtectionPermissionManageCollaPointCan manage collaborators for protected ranges

Plugin configuration

UniverSheetsUIPlugin

  • protectedRangeShadow
    boolean | 'always' | 'non-editable' | 'non-viewable' | 'none'Default: true
    Which protected ranges show a shadow.
  • protectedRangeUserSelector
    object
    Customize the picker used for choosing users of a protected range.
    • component
      ComponentType<IPermissionDetailUserPartProps>
      Component that picks users.
    • framework
      string
      Framework the component uses, for example react.

Preset configuration

UniverSheetsCorePreset

  • sheets
    object
    Options for the selected feature.
    • protectedRangeShadow
      boolean | 'always' | 'non-editable' | 'non-viewable' | 'none'Default: true
      Which protected ranges show a shadow.
    • protectedRangeUserSelector
      object
      Customize the picker used for choosing users of a protected range.
      • component
        ComponentType<IPermissionDetailUserPartProps>
        Component that picks users.
      • framework
        string
        Framework the component uses, for example react.

Protected range shadow strategy

Use non-editable to distinguish the protected areas the current user can edit from those they cannot. Editable areas receive no shadow, areas with editing disabled keep their shadow, and non-viewable ranges stay masked.

The setting affects only how range and worksheet protection is displayed. It does not create protection rules, does not change edit or view permissions, and does not add shadows to unprotected areas. Configure the protection rules and the current user’s permissions first, as described above.

StrategyDisplay behavior
true / 'always'Show shadows for all protected areas (default).
'non-editable'Hide shadows on editable protected areas; keep them on non-editable areas.
'non-viewable'Show shadows only on non-viewable protected areas.
false / 'none'Hide all protection shadows; permission checks still apply.

Protection shadow preview

Compare the same areas under different strategies for the current user.

Unprotected

A1:B3

No shadow

Protected · editable

D1:E3

No shadow

Protected · read-only

G1:H3

Shadow shown

Protected · not viewable

J1:K3

Shadow shown

protectedRangeShadow: 'non-editable'

Illustration only: changing the shadow does not change permissions. Hidden content stays hidden, even with none.

Set the strategy during initialization:

TypeScript
univer.registerPlugin(UniverSheetsUIPlugin, {  protectedRangeShadow: 'non-editable',})

Custom user component

The built-in user selector covers a limited set of cases. When your requirements exceed it, provide a custom component:

For details on building one, see Custom Components.

TypeScript
univer.registerPlugin(UniverSheetsUIPlugin, {  protectedRangeUserSelector: {    /**     * Custom component; must implement the `IPermissionDetailUserPartProps` interface.     */    component: CustomPermissionDetailUserPart,    /**     * The framework of the component. Must be passed correctly.     */    framework: 'react',  },})

Update permission UI with the Facade API

Protected range shadow strategy

The Facade API below changes existing workbooks in the current Univer instance. In plugin mode, import @univerjs/sheets-ui/facade first; the Sheets Core preset already includes that module.

TypeScript
// Set to only show shadows for non-editable rangesuniverAPI.setProtectedRangeShadowStrategy('non-editable')// Get the current protected range shadow display strategyconsole.log(univerAPI.getProtectedRangeShadowStrategy())// Subscribe to changes in the protected range shadow strategyconst subscription = univerAPI.getProtectedRangeShadowStrategy$().subscribe((strategy) => {  console.log('Global strategy changed to:', strategy)  // Update UI or perform other actions})// Later, unsubscribe to clean upsubscription.unsubscribe()

Custom user component

Call setSelectUserList() from the change handler of your user picker. The React example below clears the selection. useDependency runs inside the component, and the service is updated only after a click. Build the remaining parts of the picker against IPermissionDetailUserPartProps.

TSX
import type { IPermissionDetailUserPartProps } from '@univerjs/sheets-ui'import type { FC } from 'react'import { SheetPermissionUserManagerService } from '@univerjs/sheets-ui'import { useDependency } from '@univerjs/ui'export const CustomPermissionDetailUserPart: FC<IPermissionDetailUserPartProps> = () => {  const service = useDependency(SheetPermissionUserManagerService)  const clearSelection = () => service.setSelectUserList([])  return <button type="button" onClick={clearSelection}>Clear selected users</button>}

Hide the permission dialog

TypeScript
univerAPI.setPermissionDialogVisible(false)

Permission service integration

Integrating a third-party authorization service (advanced)

Register your IAuthzIoService implementation before creating the workbook. The service must save protection rules and collaborator changes, return permissions for the current user, and propagate request failures to the caller.

TypeScript
import { IAuthzIoService, Univer } from '@univerjs/core'import { YourAuthzService } from './authorization-service'const univer = new Univer({  override: [[IAuthzIoService, { useClass: YourAuthzService }]],})

Collaborator management

  • Get the collaborator list
TypeScript
const fWorkbook = univerAPI.getActiveWorkbook()if (!fWorkbook) throw new Error('No active workbook')const workbookPermission = fWorkbook.getWorkbookPermission()const collaborators = await workbookPermission.listCollaborators()console.log(collaborators)
  • Add collaborators

Use addCollaborator to add one person. setCollaborators replaces the entire list, so include everyone who should retain access.

TypeScript
const fWorkbook = univerAPI.getActiveWorkbook()if (!fWorkbook) throw new Error('No active workbook')const workbookPermission = fWorkbook.getWorkbookPermission()await workbookPermission.addCollaborator(  { userID: 'user1', name: 'John Doe', avatar: '' },  univerAPI.Enum.UnitRole.Editor,)
  • Replace the collaborator list
TypeScript
const fWorkbook = univerAPI.getActiveWorkbook()if (!fWorkbook) throw new Error('No active workbook')const workbookPermission = fWorkbook.getWorkbookPermission()await workbookPermission.setCollaborators([  {    user: { userID: 'user1', name: 'John Doe', avatar: '' },    role: univerAPI.Enum.UnitRole.Editor,  },  {    user: { userID: 'user2', name: 'Jane Smith', avatar: '' },    role: univerAPI.Enum.UnitRole.Reader,  },])
  • Update collaborator roles
TypeScript
const fWorkbook = univerAPI.getActiveWorkbook()if (!fWorkbook) throw new Error('No active workbook')const workbookPermission = fWorkbook.getWorkbookPermission()await workbookPermission.updateCollaborator(  { userID: 'user1', name: 'John Doe Updated', avatar: '' },  univerAPI.Enum.UnitRole.Reader,)
  • Remove collaborators
TypeScript
const fWorkbook = univerAPI.getActiveWorkbook()if (!fWorkbook) throw new Error('No active workbook')const workbookPermission = fWorkbook.getWorkbookPermission()await workbookPermission.removeCollaborators(['user1', 'user2'])

Extend permissions in a plugin

Extended usage

To check permissions inside your own plugin, work with the permission points directly.

The example below uses WorkbookEditablePermission. Other permission points follow the same pattern.

TypeScript
import { IPermissionService } from '@univerjs/core'import { WorkbookEditablePermission } from '@univerjs/sheets'class YourService {  constructor(@IPermissionService private _permissionService: IPermissionService) {  }  setWorkbookNotEditable() {    this._permissionService.updatePermissionPoint(new WorkbookEditablePermission('unitId').id, false)  }  setWorkbookEditable() {    this._permissionService.updatePermissionPoint(new WorkbookEditablePermission('unitId').id, true)  }}

List of permission points

SheetPermissionCheckController.permissionCheckByPoints(points) checks an explicit list of permission points and returns false when any of them is disabled. Use it when a command already knows the points it needs, such as the points of a specific protection rule.

How to extend permission points

For custom permission points, implement IPermissionPoint and register it with the permission service:

TypeScript
import type { IPermissionPoint } from '@univerjs/core'import { IPermissionService, PermissionStatus } from '@univerjs/core'import { UnitAction, UnitObject } from '@univerjs/protocol'export class CustomPermissionPoint implements IPermissionPoint {  type = UnitObject.Unkonwn // your type  subType = UnitAction.View // your subType  status = PermissionStatus.INIT  value = true // Default value  id: string  constructor(unitId: string, subUnitId: string, customId: string) {    // The id must be unique within `IPermissionService`.    this.id = `${unitId}.${subUnitId}.${customId}`  }}class YourService {  constructor(@IPermissionService private _permissionService: IPermissionService) {    this._init()  }  _init() {    this._permissionService.addPermissionPoint(new CustomPermissionPoint('unitId', 'subUnitId', 'my-id'))  }}// How to use it elsewhereclass ConsumeService {  constructor(@IPermissionService private _permissionService: IPermissionService) {  }  doSomething() {    const point = this._permissionService.getPermissionPoint(new CustomPermissionPoint('unitId', 'subUnitId', 'my-id').id)    console.log(point?.value)  }  bindEvent() {    // This returns an RxJS observable that lets you listen for permission changes    const point$ = this._permissionService.getPermissionPoint$(new CustomPermissionPoint('unitId', 'subUnitId', 'my-id').id)    console.log(point$)  }}

Reference

How is this guide?

© 2026 DreamNum Co., Ltd.