API 参考

FBoardTable

本 API 页面目前提供英文正文。代码签名与标识符不随界面语言变化。

Facade for one Board table element and its table resource.

Instances are returned by FBoard table mixin methods. Do not construct this class directly because it needs the active Board model, table resource service, and command service.

Access

Access through:

Setup

Register @univerjs-pro/boards-table or a preset that includes it. In plugin mode, import @univerjs-pro/boards-table/facade. Additional methods below require their listed plugin packages. See Facade setup.

@univerjs-pro/boards-table

FBoardTable.deleteColumns

Deletes an inclusive column range.

TypeScript
deleteColumns(startColumn: number, endColumn: number): boolean

Parameters

  • startColumn — Required. First zero-based column to delete.
  • endColumn — Required. Last zero-based column to delete.

Returns

true when the command succeeds.

Examples

TypeScript
const board = univerAPI.getActiveBoard()if (!board) throw new Error('No active board')const table = board.insertTable({ left: 80, top: 80, rows: 3, columns: 4 })if (!table || !table.deleteColumns(1, 2)) throw new Error('Cannot delete columns')

Package: @univerjs-pro/boards-table · Type definitions

FBoardTable.deleteRows

Deletes an inclusive row range.

TypeScript
deleteRows(startRow: number, endRow: number): boolean

Parameters

  • startRow — Required. First zero-based row to delete.
  • endRow — Required. Last zero-based row to delete.

Returns

true when the command succeeds.

Examples

TypeScript
const board = univerAPI.getActiveBoard()if (!board) throw new Error('No active board')const table = board.insertTable({ left: 80, top: 80, rows: 4, columns: 3 })if (!table || !table.deleteRows(1, 2)) throw new Error('Cannot delete rows')

Package: @univerjs-pro/boards-table · Type definitions

FBoardTable.getCellInfo

Gets plain text, rich text, style, and merge information for one cell.

TypeScript
getCellInfo(row: number, column: number): IBoardTableFacadeCellInfo | null

Parameters

  • row — Required. Zero-based row index.
  • column — Required. Zero-based column index.

Returns

Detached cell information, or null when the coordinates or table resource are invalid.

Examples

TypeScript
const board = univerAPI.getActiveBoard()if (!board) throw new Error('No active board')const table = board.insertTable({ left: 80, top: 80, rows: 3, columns: 3 })if (!table) throw new Error('Cannot insert table')console.log(table.getCellInfo(0, 0))

Types: IBoardTableFacadeCellInfo

Package: @univerjs-pro/boards-table · Type definitions

FBoardTable.getCellRichText

Gets one cell as a detached rich-text value.

The returned value can be copied or transformed safely before calling setCellRichText(). It never exposes the mutable table resource snapshot.

TypeScript
getCellRichText(row: number, column: number): RichTextValue | null

Parameters

  • row — Required. Zero-based row index.
  • column — Required. Zero-based column index.

Returns

Detached rich-text value, or null when the table or cell does not exist.

Examples

TypeScript
const board = univerAPI.getActiveBoard()if (!board) throw new Error('No active board')const table = board.insertTable({ left: 80, top: 80, rows: 3, columns: 3 })if (!table) throw new Error('Cannot insert table')console.log(table.getCellRichText(0, 0)?.getData())

Types: RichTextValue

Package: @univerjs-pro/boards-table · Type definitions

FBoardTable.getCellStyle

Gets a detached style snapshot for one cell.

TypeScript
getCellStyle(row: number, column: number): ISlideTableCellStyle | null

Parameters

  • row — Required. Zero-based row index.
  • column — Required. Zero-based column index.

Returns

A cloned style object, or null when the cell has no explicit style or does not exist.

Examples

TypeScript
const board = univerAPI.getActiveBoard()if (!board) throw new Error('No active board')const table = board.insertTable({ left: 80, top: 80, rows: 3, columns: 3 })if (!table) throw new Error('Cannot insert table')console.log(table.getCellStyle(0, 0))

Types: ISlideTableCellStyle

Package: @univerjs-pro/boards-table · Type definitions

FBoardTable.getData

Gets a clone of the raw table resource snapshot.

Agent scripts normally prefer getValues() and explicit mutation methods rather than depending on table internals.

TypeScript
getData(): ISlideTableSnapshot | null

Returns

Table resource data, or null when it is unavailable.

Examples

TypeScript
const board = univerAPI.getActiveBoard()if (!board) throw new Error('No active board')const table = board.insertTable({ left: 80, top: 80, rows: 3, columns: 3 })if (!table) throw new Error('Cannot insert table')console.log(table.getData())

Types: ISlideTableSnapshot

Package: @univerjs-pro/boards-table · Type definitions

FBoardTable.getId

Gets the generated Board element id.

Prefer getId() for agent references; this id is only useful for integration event payloads.

TypeScript
getId(): string

Returns

Generated table host element id.

Examples

TypeScript
const board = univerAPI.getActiveBoard()if (!board) throw new Error('No active board')const table = board.insertTable({ left: 80, top: 80, rows: 3, columns: 3 })if (!table) throw new Error('Cannot insert table')console.log(table.getId())

Package: @univerjs-pro/boards-table · Type definitions

FBoardTable.getRichTextValues

Gets a rectangular matrix of detached rich-text cell values.

Omit range to read the complete table. The returned values are independent of the resource snapshot and can be transformed before being written with setRichTextValues().

TypeScript
getRichTextValues(range?: ISlideTableCellRange): RichTextValue[][]

Parameters

  • range — Optional. Optional inclusive zero-based range.

Returns

A rectangular rich-text matrix, or an empty array when the table or range is invalid.

Examples

TypeScript
const board = univerAPI.getActiveBoard()if (!board) throw new Error('No active board')const table = board.insertTable({ left: 80, top: 80, rows: 3, columns: 3 })if (!table) throw new Error('Cannot insert table')console.log(table.getRichTextValues({ startRow: 0, endRow: 1, startColumn: 0, endColumn: 1 }))

Types: RichTextValue · ISlideTableCellRange

Package: @univerjs-pro/boards-table · Type definitions

FBoardTable.getStructure

Gets a detached structural summary of this table.

TypeScript
getStructure(): IBoardTableFacadeStructure | null

Returns

Row/column counts, sizes, and merged ranges, or null when the table resource is unavailable.

Examples

TypeScript
const board = univerAPI.getActiveBoard()if (!board) throw new Error('No active board')const table = board.insertTable({ left: 80, top: 80, rows: 3, columns: 3 })if (!table) throw new Error('Cannot insert table')console.log(table.getStructure())

Types: IBoardTableFacadeStructure

Package: @univerjs-pro/boards-table · Type definitions

FBoardTable.getTableId

Gets the table resource id.

TypeScript
getTableId(): string | null

Returns

Generated table resource id, or null when the host table no longer exists.

Examples

TypeScript
const board = univerAPI.getActiveBoard()if (!board) throw new Error('No active board')const table = board.insertTable({ left: 80, top: 80, rows: 3, columns: 3 })if (!table) throw new Error('Cannot insert table')console.log(table.getTableId())

Package: @univerjs-pro/boards-table · Type definitions

FBoardTable.getValues

Gets the current plain-text values in row and column order.

TypeScript
getValues(): string[][]

Returns

A rectangular matrix. Empty cells are returned as empty strings.

Examples

TypeScript
const board = univerAPI.getActiveBoard()if (!board) throw new Error('No active board')const table = board.insertTable({ left: 80, top: 80, rows: 3, columns: 3 })if (!table) throw new Error('Cannot insert table')console.log(table.getValues())

Package: @univerjs-pro/boards-table · Type definitions

FBoardTable.insertColumns

Inserts columns and grows the Board host element in the same undoable command.

TypeScript
insertColumns(columnIndex: number, count?: number, width?: number): boolean

Parameters

  • columnIndex — Required. Zero-based insertion index.
  • count — Optional. Default: 1. Number of columns to insert. Defaults to 1.
  • width — Optional. Optional width in board units for each new column.

Returns

true when the command succeeds.

Examples

TypeScript
const board = univerAPI.getActiveBoard()if (!board) throw new Error('No active board')const table = board.insertTable({ left: 80, top: 80, rows: 3, columns: 3 })if (!table || !table.insertColumns(1, 2)) throw new Error('Cannot insert columns')

Package: @univerjs-pro/boards-table · Type definitions

FBoardTable.insertRows

Inserts rows and grows the Board host element in the same undoable command.

TypeScript
insertRows(rowIndex: number, count?: number, height?: number): boolean

Parameters

  • rowIndex — Required. Zero-based insertion index.
  • count — Optional. Default: 1. Number of rows to insert. Defaults to 1.
  • height — Optional. Optional height in board units for each new row.

Returns

true when the command succeeds.

Examples

TypeScript
const board = univerAPI.getActiveBoard()if (!board) throw new Error('No active board')const table = board.insertTable({ left: 80, top: 80, rows: 3, columns: 3 })if (!table || !table.insertRows(1, 2)) throw new Error('Cannot insert rows')

Package: @univerjs-pro/boards-table · Type definitions

FBoardTable.mergeCells

Merges a supplied inclusive cell range.

TypeScript
mergeCells(range: ISlideTableCellRange): boolean

Parameters

  • range — Required. Inclusive zero-based range to merge.

Returns

true when the command succeeds or the range is already merged.

Examples

TypeScript
const board = univerAPI.getActiveBoard()if (!board) throw new Error('No active board')const table = board.insertTable({ left: 80, top: 80, rows: 3, columns: 3 })if (!table || !table.mergeCells({ startRow: 0, endRow: 0, startColumn: 0, endColumn: 1 })) {  throw new Error('Cannot merge cells')}

Types: ISlideTableCellRange

Package: @univerjs-pro/boards-table · Type definitions

FBoardTable.moveColumns

Moves an inclusive column range before or after a target column.

Cell content, rich text, style, merges, and column width move together through the shared table command.

TypeScript
moveColumns(startColumn: number, endColumn: number, targetColumn: number, position: SlideTableMovePosition): boolean

Parameters

  • startColumn — Required. First zero-based column to move.
  • endColumn — Required. Last zero-based column to move.
  • targetColumn — Required. Zero-based reference column.
  • position — Required. Insert the moved columns before or after the reference column.

Returns

true when the move succeeds or is already in the requested position.

Examples

TypeScript
const board = univerAPI.getActiveBoard()if (!board) throw new Error('No active board')const table = board.insertTable({ left: 80, top: 80, rows: 3, columns: 4 })if (!table || !table.moveColumns(0, 0, 2, 'after')) throw new Error('Cannot move column')

Types: SlideTableMovePosition

Package: @univerjs-pro/boards-table · Type definitions

FBoardTable.moveRows

Moves an inclusive row range before or after a target row.

Cell content, rich text, style, merges, and row height move together. Invalid overlaps are rejected by the shared table layout command, while an equivalent update returns true without creating history.

TypeScript
moveRows(startRow: number, endRow: number, targetRow: number, position: SlideTableMovePosition): boolean

Parameters

  • startRow — Required. First zero-based row to move.
  • endRow — Required. Last zero-based row to move.
  • targetRow — Required. Zero-based reference row.
  • position — Required. Insert the moved rows before or after the reference row.

Returns

true when the move succeeds or is already in the requested position.

Examples

TypeScript
const board = univerAPI.getActiveBoard()if (!board) throw new Error('No active board')const table = board.insertTable({ left: 80, top: 80, rows: 4, columns: 3 })if (!table || !table.moveRows(0, 0, 2, 'after')) throw new Error('Cannot move row')

Types: SlideTableMovePosition

Package: @univerjs-pro/boards-table · Type definitions

FBoardTable.remove

Removes the Board table host element and its table resource.

TypeScript
remove(): boolean

Returns

true when the removal command succeeds.

Examples

TypeScript
const board = univerAPI.getActiveBoard()if (!board) throw new Error('No active board')const table = board.insertTable({ left: 80, top: 80, rows: 3, columns: 3 })if (!table || !table.remove()) throw new Error('Cannot remove table')

Package: @univerjs-pro/boards-table · Type definitions

FBoardTable.resizeColumns

Resizes an inclusive column range.

TypeScript
resizeColumns(startColumn: number, endColumn: number, width: number): boolean

Parameters

  • startColumn — Required. First zero-based column to resize.
  • endColumn — Required. Last zero-based column to resize.
  • width — Required. New column width in board units.

Returns

true when the command succeeds or the columns already have this width.

Examples

TypeScript
const board = univerAPI.getActiveBoard()if (!board) throw new Error('No active board')const table = board.insertTable({ left: 80, top: 80, rows: 3, columns: 3 })if (!table || !table.resizeColumns(0, 1, 160)) throw new Error('Cannot resize columns')

Package: @univerjs-pro/boards-table · Type definitions

FBoardTable.resizeRows

Resizes an inclusive row range.

TypeScript
resizeRows(startRow: number, endRow: number, height: number): boolean

Parameters

  • startRow — Required. First zero-based row to resize.
  • endRow — Required. Last zero-based row to resize.
  • height — Required. New row height in board units.

Returns

true when the command succeeds or the rows already have this height.

Examples

TypeScript
const board = univerAPI.getActiveBoard()if (!board) throw new Error('No active board')const table = board.insertTable({ left: 80, top: 80, rows: 3, columns: 3 })if (!table || !table.resizeRows(0, 1, 48)) throw new Error('Cannot resize rows')

Package: @univerjs-pro/boards-table · Type definitions

FBoardTable.setBorderPreset

Applies a border preset to a cell range.

TypeScript
setBorderPreset(range: ISlideTableCellRange, preset: SlideTableBorderPresetEnum, border?: ISlideTableBorder): boolean

Parameters

  • range — Required. Inclusive zero-based target range.
  • preset — Required. Border preset enum value.
  • border — Optional. Optional border appearance.

Returns

true when the command succeeds or the border is unchanged.

Examples

TypeScript
const board = univerAPI.getActiveBoard()if (!board) throw new Error('No active board')const table = board.insertTable({ left: 80, top: 80, rows: 3, columns: 3 })if (  !table ||  !table.setBorderPreset(    { startRow: 0, endRow: 2, startColumn: 0, endColumn: 2 },    univerAPI.Enum.BoardTableBorderPresetEnum.All,    { color: '#64748b', width: 1 },  ))  throw new Error('Cannot set borders')

Types: ISlideTableCellRange · SlideTableBorderPresetEnum · ISlideTableBorder

Package: @univerjs-pro/boards-table · Type definitions

FBoardTable.setCellRichText

Replaces one cell with rich text built by univerAPI.newRichText().

The builder data is cloned before dispatch, so later changes to the builder do not mutate the table snapshot. Use setCellText() for plain strings. Raw document data is reserved for advanced integrations.

TypeScript
setCellRichText(row: number, column: number, richText: RichTextValue): boolean

Parameters

  • row — Required. Zero-based row index.
  • column — Required. Zero-based column index.
  • richText — Required. Rich text value returned by univerAPI.newRichText().

Returns

true when the command succeeds or the requested rich text is unchanged.

Examples

TypeScript
const board = univerAPI.getActiveBoard()if (!board) throw new Error('No active board')const table = board.insertTable({ left: 80, top: 80, rows: 3, columns: 3 })const value = univerAPI.newRichText().bold('Approved')if (!table || !table.setCellRichText(0, 0, value)) throw new Error('Cannot set rich text')

Types: RichTextValue

Package: @univerjs-pro/boards-table · Type definitions

FBoardTable.setCellStyle

Merges a style patch into a cell range.

TypeScript
setCellStyle(range: ISlideTableCellRange, style: ISlideTableCellStyle): boolean

Parameters

  • range — Required. Inclusive zero-based target range.
  • style — Required. Cell style patch.

Returns

true when the command succeeds or the style is unchanged.

Examples

TypeScript
const board = univerAPI.getActiveBoard()if (!board) throw new Error('No active board')const table = board.insertTable({ left: 80, top: 80, rows: 3, columns: 3 })if (  !table ||  !table.setCellStyle(    { startRow: 0, endRow: 0, startColumn: 0, endColumn: 2 },    { fill: { type: univerAPI.Enum.BoardTableFillTypeEnum.Solid, color: '#e0e7ff', alpha: 1 } },  ))  throw new Error('Cannot style cells')

Types: ISlideTableCellRange · ISlideTableCellStyle

Package: @univerjs-pro/boards-table · Type definitions

FBoardTable.setCellText

Replaces one cell with plain text.

TypeScript
setCellText(row: number, column: number, text: string): boolean

Parameters

  • row — Required. Zero-based row index.
  • column — Required. Zero-based column index.
  • text — Required. New plain text.

Returns

true when the command succeeds or the text is unchanged.

Examples

TypeScript
const board = univerAPI.getActiveBoard()if (!board) throw new Error('No active board')const table = board.insertTable({ left: 80, top: 80, rows: 3, columns: 3 })if (!table || !table.setCellText(0, 0, 'Approved')) throw new Error('Cannot set cell text')

Package: @univerjs-pro/boards-table · Type definitions

FBoardTable.setCellTextData

Replaces one cell with raw Univer document data.

This is an advanced integration escape hatch. Application and agent code should prefer setCellRichText().

TypeScript
setCellTextData(row: number, column: number, textData: IDocumentData | null): boolean

Parameters

  • row — Required. Zero-based row index.
  • column — Required. Zero-based column index.
  • textData — Required. Document data, or null to clear the cell.

Returns

true when the command succeeds or the requested data is unchanged.

Examples

TypeScript
const board = univerAPI.getActiveBoard()if (!board) throw new Error('No active board')const table = board.insertTable({ left: 80, top: 80, rows: 2, columns: 2 })if (!table || !table.setCellRichText(0, 0, univerAPI.newRichText().bold('Risk'))) {  throw new Error('Cannot prepare source cell')}const importedTextData = table.getCellRichText(0, 0)?.getData()if (!importedTextData) throw new Error('Source cell is empty')if (!table.setCellTextData(1, 0, importedTextData)) throw new Error('Cannot restore raw cell data')

Types: IDocumentData

Package: @univerjs-pro/boards-table · Type definitions

FBoardTable.setRichTextValues

Replaces a rectangular range with rich text in one table update command.

The matrix must be rectangular and fit inside the current table. Every builder is cloned before dispatch, and an unchanged matrix succeeds without creating undo or collaboration traffic.

TypeScript
setRichTextValues(values: RichTextValue[][], startRow?: number, startColumn?: number): boolean

Parameters

  • values — Required. Rich-text matrix built with univerAPI.newRichText().
  • startRow — Optional. Default: 0. Zero-based start row. Defaults to 0.
  • startColumn — Optional. Default: 0. Zero-based start column. Defaults to 0.

Returns

true when the batch succeeds or all requested cells are already current.

Examples

TypeScript
const board = univerAPI.getActiveBoard()if (!board) throw new Error('No active board')const table = board.insertTable({ left: 80, top: 80, rows: 2, columns: 2 })const title = univerAPI.newRichText().bold('Status')const value = univerAPI.newRichText().text('Approved')if (!table || !table.setRichTextValues([[title, value]])) throw new Error('Cannot set rich text')

Types: RichTextValue

Package: @univerjs-pro/boards-table · Type definitions

FBoardTable.setValues

Replaces a rectangular range of cells with plain text in one table update command.

Unchanged cells do not generate a mutation. The values matrix must fit inside the current table bounds; use row or column insertion methods first when an agent needs to grow the table.

TypeScript
setValues(values: string[][], startRow?: number, startColumn?: number): boolean

Parameters

  • values — Required. Plain-text matrix to write.
  • startRow — Optional. Default: 0. Zero-based start row. Defaults to 0.
  • startColumn — Optional. Default: 0. Zero-based start column. Defaults to 0.

Returns

true when the update succeeds or the requested values are already present.

Examples

TypeScript
const board = univerAPI.getActiveBoard()if (!board) throw new Error('No active board')const table = board.insertTable({ left: 80, top: 80, rows: 3, columns: 3 })if (  !table ||  !table.setValues([    ['Task', 'Owner'],    ['Review', 'Alex'],  ]))  throw new Error('Cannot set values')

Package: @univerjs-pro/boards-table · Type definitions

FBoardTable.unmergeCell

Unmerges the merged range containing one cell.

TypeScript
unmergeCell(row: number, column: number): boolean

Parameters

  • row — Required. Zero-based row inside the merged range.
  • column — Required. Zero-based column inside the merged range.

Returns

true when the command succeeds or the cell is already unmerged.

Examples

TypeScript
const board = univerAPI.getActiveBoard()if (!board) throw new Error('No active board')const table = board.insertTable({ left: 80, top: 80, rows: 3, columns: 3 })if (  !table ||  !table.mergeCells({ startRow: 0, endRow: 0, startColumn: 0, endColumn: 1 }) ||  !table.unmergeCell(0, 0))  throw new Error('Cannot unmerge cells')

Package: @univerjs-pro/boards-table · Type definitions

你觉得这篇文档如何?

© 2026 DreamNum Co., Ltd.