Annotations

Headless supported

An annotation attaches a comment to a cell, so additional information or context remains next to the data it describes. This page explains how to read, create, update, and delete annotations through the Facade API, and lists the events they emit.

Plugin mode

Installation

Shell
pnpm add @univerjs/sheets-note @univerjs/sheets-note-ui

Usage

TypeScript
import { LocaleType, mergeLocales, Univer } from '@univerjs/core'import { UniverSheetsNotePlugin } from '@univerjs/sheets-note'import { UniverSheetsNoteUIPlugin } from '@univerjs/sheets-note-ui'import SheetsNoteEnUS from '@univerjs/sheets-note/locale/en-US'import SheetsNoteUIEnUS from '@univerjs/sheets-note-ui/locale/en-US'import '@univerjs/sheets-note-ui/lib/index.css'import '@univerjs/sheets-note/facade'const univer = new Univer({  locale: LocaleType.EN_US,  locales: {    [LocaleType.EN_US]: mergeLocales(      SheetsNoteEnUS,       SheetsNoteUIEnUS,     ),  },})univer.registerPlugin(UniverSheetsNotePlugin)univer.registerPlugin(UniverSheetsNoteUIPlugin)

Preset mode

Installation

Shell
pnpm add @univerjs/preset-sheets-note

Usage

TypeScript
import { UniverSheetsCorePreset } from '@univerjs/preset-sheets-core'import UniverPresetSheetsCoreEnUS from '@univerjs/preset-sheets-core/locales/en-US'import { UniverSheetsNotePreset } from '@univerjs/preset-sheets-note'import UniverPresetSheetsNoteEnUS from '@univerjs/preset-sheets-note/locales/en-US'import { createUniver, LocaleType, mergeLocales } from '@univerjs/presets'import '@univerjs/preset-sheets-core/lib/index.css'import '@univerjs/preset-sheets-note/lib/index.css'const { univerAPI } = createUniver({  locale: LocaleType.EN_US,  locales: {    [LocaleType.EN_US]: mergeLocales(      UniverPresetSheetsCoreEnUS,      UniverPresetSheetsNoteEnUS,     ),  },  presets: [    UniverSheetsCorePreset(),    UniverSheetsNotePreset(),   ],})

Facade API

The complete Facade API type definitions are in the FacadeAPI.

Importing

Plugin mode note

The Facade package is imported manually only in plugin mode. Preset mode already includes the corresponding package.

TypeScript
import '@univerjs/sheets-note/facade'

Get annotations

FWorksheet.getNotes returns every annotation in the worksheet.

TypeScript
const fWorkbook = univerAPI.getActiveWorkbook()const fWorksheet = fWorkbook.getActiveSheet()const notes = fWorksheet.getNotes()notes.forEach((item) => {  const { row, col, note } = item  console.log(`Cell ${fWorksheet.getRange(row, col).getA1Notation()} has note: ${note}`)})

FRange.getNote returns the annotation on the top-left cell of the range.

TypeScript
const fWorkbook = univerAPI.getActiveWorkbook()const fWorksheet = fWorkbook.getActiveSheet()const fRange = fWorksheet.getRange('A1:D10')const note = fRange.getNote()

Add or update annotations

FRange.createOrUpdateNote creates or updates the annotation on the top-left cell of the range.

TypeScript
const fWorkbook = univerAPI.getActiveWorkbook()const fWorksheet = fWorkbook.getActiveSheet()const fRange = fWorksheet.getRange('A1')fRange.createOrUpdateNote({  note: 'This is an annotation',  width: 160,  height: 100,  show: true,})

Remove annotations

FRange.deleteNote removes the annotation on the top-left cell of the range.

TypeScript
const fWorkbook = univerAPI.getActiveWorkbook()const fWorksheet = fWorkbook.getActiveSheet()const notes = fWorksheet.getNotes()if (notes.length > 0) {  // Remove the first annotation in the worksheet  const { row, col } = notes[0]  fWorksheet.getRange(row, col).deleteNote()}// Remove the annotation in cell C1const fRange = fWorksheet.getRange('C1')fRange.deleteNote()

Event listeners

The complete event type definitions are in the Events.

Event NameDescription
SheetNoteAddFires after an annotation is added
SheetNoteDeleteFires after an annotation is deleted
SheetNoteUpdateFires after an annotation is updated
SheetNoteShowFires when an annotation is shown
SheetNoteHideFires when an annotation is hidden
BeforeSheetNoteAddFires before an annotation is added
BeforeSheetNoteDeleteFires before an annotation is deleted
BeforeSheetNoteUpdateFires before an annotation is updated
BeforeSheetNoteShowFires before an annotation is shown
BeforeSheetNoteHideFires before an annotation is hidden
Event Listener Examples
TypeScript
// Triggered after adding an annotationconst disposable = univerAPI.addEvent(univerAPI.Event.SheetNoteAdd, (params) => {  const { workbook, worksheet, row, col, note } = params})// Remove event listener using `disposable.dispose()`
TypeScript
// Triggered before removing an annotation, can be canceledconst disposable = univerAPI.addEvent(univerAPI.Event.BeforeSheetNoteDelete, (params) => {  const { workbook, worksheet, row, col, oldNote } = params  // Cancel the annotation deletion operation  params.cancel = true})// Remove event listener using `disposable.dispose()`

How is this guide?

© 2026 DreamNum Co., Ltd.