FDocumentTable
Facade object for a single enhanced docs table.
All mutating methods execute synchronously through the Univer command service and return
true when the underlying document mutation succeeds.
Access
Access through:
FDocument.getTables()FDocument.getTable()FDocument.getTableAt()FDocument.getTableAtSelection()FDocument.findTableByText()FDocument.findTables()FDocument.insertTable()FDocument.insertTableFromData()
Example
const fDocument = univerAPI.getActiveDocument()const table = fDocument?.findTableByText('Status')console.log(table?.describe())table?.setCellText(1, 1, 'Done')table?.setTableBorder({ color: '#3367D6', width: 1 })Setup
Register @univerjs-pro/docs-table or a preset that includes it. In plugin mode, import @univerjs-pro/docs-table/facade. Additional methods below require their listed plugin packages. See Facade setup.
@univerjs-pro/docs-table
FDocumentTable.appendColumn
Appends a new column at the end of the table.
appendColumn(): booleanReturns
true if the column was successfully appended.
Examples
const fDocument = univerAPI.getActiveDocument()const table = fDocument?.findTableByText('Status')table?.appendColumn() // Appends a new column at the end of the tablePackage: @univerjs-pro/docs-table · Type definitions
FDocumentTable.appendRow
Appends a new row at the end of the table.
appendRow(): booleanReturns
true if the row was successfully appended.
Examples
const fDocument = univerAPI.getActiveDocument()const table = fDocument?.findTableByText('Status')table?.appendRow() // Appends a new row at the end of the tablePackage: @univerjs-pro/docs-table · Type definitions
FDocumentTable.deleteColumn
Deletes a single column at the specified column index.
deleteColumn(column: number): booleanParameters
column— Required. The zero-based column index to delete.
Returns
true if the column was successfully deleted.
Examples
const fDocument = univerAPI.getActiveDocument()const table = fDocument?.findTableByText('Status')table?.deleteColumn(1) // Deletes column 1Package: @univerjs-pro/docs-table · Type definitions
FDocumentTable.deleteColumns
Deletes multiple columns starting from the specified column index.
deleteColumns(startColumn: number, count?: number): booleanParameters
startColumn— Required. The zero-based starting column index to delete.count— Optional. Default:1. The number of columns to delete.
Returns
true if the columns were successfully deleted.
Examples
const fDocument = univerAPI.getActiveDocument()const table = fDocument?.findTableByText('Status')table?.deleteColumns(1, 2) // Deletes columns 1 and 2Package: @univerjs-pro/docs-table · Type definitions
FDocumentTable.deleteRow
Deletes a single row at the specified row index.
deleteRow(row: number): booleanParameters
row— Required. The zero-based row index to delete.
Returns
true if the row was successfully deleted.
Examples
const fDocument = univerAPI.getActiveDocument()const table = fDocument?.findTableByText('Status')table?.deleteRow(1) // Deletes row 1Package: @univerjs-pro/docs-table · Type definitions
FDocumentTable.deleteRows
Deletes multiple rows starting from the specified row index.
deleteRows(startRow: number, count?: number): booleanParameters
startRow— Required. The zero-based starting row index to delete.count— Optional. Default:1. The number of rows to delete.
Returns
true if the rows were successfully deleted.
Examples
const fDocument = univerAPI.getActiveDocument()const table = fDocument?.findTableByText('Status')table?.deleteRows(1, 2) // Deletes rows 1 and 2Package: @univerjs-pro/docs-table · Type definitions
FDocumentTable.deleteTable
Deletes the entire table.
deleteTable(): booleanReturns
true if the table was successfully deleted.
Examples
const fDocument = univerAPI.getActiveDocument()const table = fDocument?.findTableByText('Status')table?.deleteTable() // Deletes the entire tablePackage: @univerjs-pro/docs-table · Type definitions
FDocumentTable.describe
Returns a human-readable table summary with sample rows.
describe(): IDocsTableDescriptionReturns
A compact description suitable for agents or logs.
Examples
const fDocument = univerAPI.getActiveDocument()const table = fDocument?.findTableByText('Status')console.log(table?.describe())Types: IDocsTableDescription
Package: @univerjs-pro/docs-table · Type definitions
FDocumentTable.distributeColumns
Distributes the width of columns evenly across a specified range of columns in the table.
distributeColumns(startColumn?: number, count?: number): booleanParameters
startColumn— Optional. Default:0. The zero-based starting column index to distribute from.count— Optional. Default:this.getColumnCount(). The number of columns to distribute. If not provided, it will distribute all columns starting from thestartColumnto the end of the table.
Returns
true if the column widths were successfully distributed.
Examples
const fDocument = univerAPI.getActiveDocument()const table = fDocument?.findTableByText('Status')table?.distributeColumns(1, 3) // Distributes the width of columns 1 to 3 evenlyPackage: @univerjs-pro/docs-table · Type definitions
FDocumentTable.distributeRows
Distributes the height of rows evenly across a specified range of rows in the table.
distributeRows(startRow?: number, count?: number): booleanParameters
startRow— Optional. Default:0. The zero-based starting row index to distribute from.count— Optional. Default:this.getRowCount(). The number of rows to distribute. If not provided, it will distribute all rows starting from thestartRowto the end of the table.
Returns
true if the row heights were successfully distributed.
Examples
const fDocument = univerAPI.getActiveDocument()const table = fDocument?.findTableByText('Status')table?.distributeRows(1, 3) // Distributes the height of rows 1 to 3 evenlyPackage: @univerjs-pro/docs-table · Type definitions
FDocumentTable.getCell
Gets a FDocumentTableCell instance for the specified cell coordinates.
getCell(row: number, column: number): FDocumentTableCell | nullParameters
row— Required. The zero-based row index.column— Required. The zero-based column index.
Returns
The FDocumentTableCell instance, or null if the cell does not exist.
Examples
const fDocument = univerAPI.getActiveDocument()const table = fDocument?.findTableByText('Status')const cell = table?.getCell(0, 0)console.log(cell?.getText()) // e.g. 'Status'Types: FDocumentTableCell
Package: @univerjs-pro/docs-table · Type definitions
FDocumentTable.getCellContentRange
Returns the editable document range inside a table cell.
The range excludes the table cell tokens and the final section break, so block/list facades
can use it as their startOffset/endOffset target.
getCellContentRange(row: number, column: number): IDocsTableCellContentRange | nullParameters
row— Required. The zero-based row index.column— Required. The zero-based column index.
Returns
The cell content range, or null if the cell does not exist.
Examples
const fDocument = univerAPI.getActiveDocument();const table = fDocument?.findTableByText('Status');const contentRange = table?.getCellContentRange(1, 1);console.log(contentRange); // e.g. { startOffset: 123, endOffset: 130, segmentId: 'segment-1' }Types: IDocsTableCellContentRange
Package: @univerjs-pro/docs-table · Type definitions
FDocumentTable.getCellInsertOffset
Returns the offset before the cell's final paragraph and section break. Use this offset to insert an empty callout, quote, code block, or paragraph in the cell.
getCellInsertOffset(row: number, column: number): number | nullParameters
row— Required. The zero-based row index.column— Required. The zero-based column index.
Returns
The insertion offset, or null if the cell does not exist.
Examples
const fDocument = univerAPI.getActiveDocument();const table = fDocument?.findTableByText('Status');const insertOffset = table?.getCellInsertOffset(1, 1);console.log(insertOffset); // e.g. 129Package: @univerjs-pro/docs-table · Type definitions
FDocumentTable.getCellMargin
Returns the effective margin used to lay out a cell. The cell override takes precedence over the table default and the built-in fallback.
getCellMargin(row: number, column: number): ITableCellMargin | nullParameters
row— Required. The zero-based row index.column— Required. The zero-based column index.
Returns
The effective margin, or null if the cell does not exist.
Types: ITableCellMargin
Package: @univerjs-pro/docs-table · Type definitions
FDocumentTable.getCellMarginOverride
Returns a cell's explicit margin override.
getCellMarginOverride(row: number, column: number): ITableCellMargin | nullParameters
row— Required. The zero-based row index.column— Required. The zero-based column index.
Returns
The explicit override, or null if the cell inherits its margin.
Types: ITableCellMargin
Package: @univerjs-pro/docs-table · Type definitions
FDocumentTable.getCellRange
Gets the table cell range for the specified cell coordinates.
getCellRange(row: number, column: number): IDocsTableCellRangeParameters
row— Required. The zero-based row index.column— Required. The zero-based column index.
Returns
The cell range, or null if the cell does not exist.
Examples
const fDocument = univerAPI.getActiveDocument()const table = fDocument?.findTableByText('Status')const cellRange = table?.getCellRange(1, 1)console.log(cellRange) // e.g. { startRow: 1, endRow: 1, startColumn: 1, endColumn: 1 }Types: IDocsTableCellRange
Package: @univerjs-pro/docs-table · Type definitions
FDocumentTable.getCellText
Gets the plain text content of a cell.
getCellText(row: number, column: number): stringParameters
row— Required. The zero-based row index.column— Required. The zero-based column index.
Returns
The cell text, or an empty string if the cell does not exist or has no text.
Examples
const fDocument = univerAPI.getActiveDocument()const table = fDocument?.findTableByText('Status')const cellText = table?.getCellText(0, 0)console.log(cellText) // e.g. 'Status'Package: @univerjs-pro/docs-table · Type definitions
FDocumentTable.getColumnCount
Gets the number of columns in the table.
getColumnCount(): numberReturns
The column count, or 0 if the table source is not found in the document snapshot.
Examples
const fDocument = univerAPI.getActiveDocument()const table = fDocument?.findTableByText('Status')console.log(table?.getColumnCount())Package: @univerjs-pro/docs-table · Type definitions
FDocumentTable.getColumnRange
Gets the cell range for the specified column index, covering all rows in the column.
getColumnRange(column: number): IDocsTableCellRangeParameters
column— Required. The zero-based column index.
Returns
The cell range for the specified column, or null if the column does not exist.
Examples
const fDocument = univerAPI.getActiveDocument()const table = fDocument?.findTableByText('Status')const columnRange = table?.getColumnRange(1)console.log(columnRange) // e.g. { startRow: 0, endRow: 4, startColumn: 1, endColumn: 1 }Types: IDocsTableCellRange
Package: @univerjs-pro/docs-table · Type definitions
FDocumentTable.getColumnsRange
Gets the cell range for the specified column index and column count, covering all rows in the columns.
getColumnsRange(startColumn: number, count?: number): IDocsTableCellRangeParameters
startColumn— Required. The zero-based starting column index.count— Optional. Default:1. The number of columns to include in the range.
Returns
The cell range for the specified columns, or null if the starting column does not exist.
Examples
const fDocument = univerAPI.getActiveDocument()const table = fDocument?.findTableByText('Status')const columnsRange = table?.getColumnsRange(1, 2)console.log(columnsRange) // e.g. { startRow: 0, endRow: 4, startColumn: 1, endColumn: 2 }Types: IDocsTableCellRange
Package: @univerjs-pro/docs-table · Type definitions
FDocumentTable.getDefaultCellMargin
Returns the effective table-level default cell margin.
getDefaultCellMargin(): ITableCellMarginTypes: ITableCellMargin
Package: @univerjs-pro/docs-table · Type definitions
FDocumentTable.getDefaultCellMarginOverride
Returns the explicit table-level default cell margin, or null when the built-in fallback is used.
getDefaultCellMarginOverride(): ITableCellMargin | nullTypes: ITableCellMargin
Package: @univerjs-pro/docs-table · Type definitions
FDocumentTable.getHeaderRowCount
Gets the number of header rows in the table.
getHeaderRowCount(): numberReturns
The number of header rows in the table.
Examples
const fDocument = univerAPI.getActiveDocument()const table = fDocument?.findTableByText('Status')const headerRowCount = table?.getHeaderRowCount()Package: @univerjs-pro/docs-table · Type definitions
FDocumentTable.getId
Returns the table id.
getId(): stringReturns
The table id stored in the document snapshot.
Examples
const fDocument = univerAPI.getActiveDocument()const table = fDocument?.findTableByText('Status')console.log(table?.getId()) // e.g. 'table-12345'Package: @univerjs-pro/docs-table · Type definitions
FDocumentTable.getInfo
Returns compact table metadata for agents.
getInfo(): IDocsTableInfoReturns
The id, row count, column count, metadata, and raw table source.
Examples
const fDocument = univerAPI.getActiveDocument()const table = fDocument?.findTableByText('Status')console.log(table?.getInfo())Types: IDocsTableInfo
Package: @univerjs-pro/docs-table · Type definitions
FDocumentTable.getMetadata
Gets the table metadata stored in the document snapshot, including header row count, title row, and column type configs.
getMetadata(): IDocsTableMetadata | undefinedReturns
The table metadata, or undefined if the table source is not found in the document snapshot.
Examples
const fDocument = univerAPI.getActiveDocument()const table = fDocument?.findTableByText('Status')console.log(table?.getMetadata())Types: IDocsTableMetadata
Package: @univerjs-pro/docs-table · Type definitions
FDocumentTable.getRange
Gets the table range with offsets for all cells in the table.
getRange(): IDocsTableOffsetRange | nullReturns
The table range with offsets, or null if the table source is not found in the document snapshot.
Examples
const fDocument = univerAPI.getActiveDocument()const table = fDocument?.findTableByText('Status')console.log(table?.getRange())Types: IDocsTableOffsetRange
Package: @univerjs-pro/docs-table · Type definitions
FDocumentTable.getRowCount
Gets the number of rows in the table.
getRowCount(): numberReturns
The row count, or 0 if the table source is not found in the document snapshot.
Examples
const fDocument = univerAPI.getActiveDocument()const table = fDocument?.findTableByText('Status')console.log(table?.getRowCount())Package: @univerjs-pro/docs-table · Type definitions
FDocumentTable.getRowHeight
Returns the row height value and its OOXML height rule.
getRowHeight(row: number): ITableRowSize | nullParameters
row— Required.
Types: ITableRowSize
Package: @univerjs-pro/docs-table · Type definitions
FDocumentTable.getRowRange
Gets the cell range for the specified row index, covering all columns in the row.
getRowRange(row: number): IDocsTableCellRangeParameters
row— Required. The zero-based row index.
Returns
The cell range for the specified row, or null if the row does not exist.
Examples
const fDocument = univerAPI.getActiveDocument()const table = fDocument?.findTableByText('Status')const rowRange = table?.getRowRange(1)console.log(rowRange) // e.g. { startRow: 1, endRow: 1, startColumn: 0, endColumn: 4 }Types: IDocsTableCellRange
Package: @univerjs-pro/docs-table · Type definitions
FDocumentTable.getRowsRange
Gets the cell range for the specified row index and row count, covering all columns in the rows.
getRowsRange(startRow: number, count?: number): IDocsTableCellRangeParameters
startRow— Required. The zero-based starting row index.count— Optional. Default:1. The number of rows to include in the range.
Returns
The cell range for the specified rows, or null if the starting row does not exist.
Examples
const fDocument = univerAPI.getActiveDocument()const table = fDocument?.findTableByText('Status')const rowsRange = table?.getRowsRange(1, 2)console.log(rowsRange) // e.g. { startRow: 1, endRow: 2, startColumn: 0, endColumn: 4 }Types: IDocsTableCellRange
Package: @univerjs-pro/docs-table · Type definitions
FDocumentTable.getSegmentId
Get the segment id of this table. The main body tables have an empty string segment id. The header and footer tables have a non-empty string segment id.
getSegmentId(): stringReturns
The segment id.
Examples
const fDocument = univerAPI.getActiveDocument()const table = fDocument?.findTableByText('Status')console.log(table?.getSegmentId())Package: @univerjs-pro/docs-table · Type definitions
FDocumentTable.getSource
Gets the raw table source from the document snapshot, including all table rows, cells, and columns.
getSource(): ITable | undefinedReturns
The table source, or undefined if the table is not found in the document snapshot.
Examples
const fDocument = univerAPI.getActiveDocument()const table = fDocument?.findTableByText('Status')console.log(table?.getSource())Types: ITable
Package: @univerjs-pro/docs-table · Type definitions
FDocumentTable.getTableRange
Gets the table cell range covering all cells in the table.
getTableRange(): IDocsTableCellRangeReturns
The table cell range covering all cells in the table, or null if the table source is not found in the document snapshot.
Examples
const fDocument = univerAPI.getActiveDocument()const table = fDocument?.findTableByText('Status')console.log(table?.getTableRange())Types: IDocsTableCellRange
Package: @univerjs-pro/docs-table · Type definitions
FDocumentTable.hasTitleRow
Checks if the table has a title row.
hasTitleRow(): booleanReturns
true if the table has a title row, otherwise false.
Examples
const fDocument = univerAPI.getActiveDocument()const table = fDocument?.findTableByText('Status')const hasTitle = table?.hasTitleRow()Package: @univerjs-pro/docs-table · Type definitions
FDocumentTable.insertColumnAfter
Inserts a new column after the specified column index.
insertColumnAfter(column: number): booleanParameters
column— Required. The zero-based column index to insert after.
Returns
true if the column was successfully inserted.
Examples
const fDocument = univerAPI.getActiveDocument()const table = fDocument?.findTableByText('Status')table?.insertColumnAfter(1) // Inserts a new column after column 1Package: @univerjs-pro/docs-table · Type definitions
FDocumentTable.insertColumnBefore
Inserts a new column before the specified column index.
insertColumnBefore(column: number): booleanParameters
column— Required. The zero-based column index to insert before.
Returns
true if the column was successfully inserted.
Examples
const fDocument = univerAPI.getActiveDocument()const table = fDocument?.findTableByText('Status')table?.insertColumnBefore(1) // Inserts a new column before column 1Package: @univerjs-pro/docs-table · Type definitions
FDocumentTable.insertColumnsAfter
Inserts multiple columns after the specified column index.
insertColumnsAfter(column: number, count: number): booleanParameters
column— Required. The zero-based column index to insert after.count— Required. The number of columns to insert.
Returns
true if the columns were successfully inserted.
Examples
const fDocument = univerAPI.getActiveDocument()const table = fDocument?.findTableByText('Status')table?.insertColumnsAfter(1, 2) // Inserts 2 new columns after column 1Package: @univerjs-pro/docs-table · Type definitions
FDocumentTable.insertColumnsBefore
Inserts multiple columns before the specified column index.
insertColumnsBefore(column: number, count: number): booleanParameters
column— Required. The zero-based column index to insert before.count— Required. The number of columns to insert.
Returns
true if the columns were successfully inserted.
Examples
const fDocument = univerAPI.getActiveDocument()const table = fDocument?.findTableByText('Status')table?.insertColumnsBefore(1, 2) // Inserts 2 new columns before column 1Package: @univerjs-pro/docs-table · Type definitions
FDocumentTable.insertRowAfter
Inserts a new row after the specified row index.
insertRowAfter(row: number): booleanParameters
row— Required. The zero-based row index to insert after.
Returns
true if the row was successfully inserted.
Examples
const fDocument = univerAPI.getActiveDocument()const table = fDocument?.findTableByText('Status')table?.insertRowAfter(1) // Inserts a new row after row 1Package: @univerjs-pro/docs-table · Type definitions
FDocumentTable.insertRowBefore
Inserts a new row before the specified row index.
insertRowBefore(row: number): booleanParameters
row— Required. The zero-based row index to insert before.
Returns
true if the row was successfully inserted.
Examples
const fDocument = univerAPI.getActiveDocument()const table = fDocument?.findTableByText('Status')table?.insertRowBefore(1) // Inserts a new row before row 1Package: @univerjs-pro/docs-table · Type definitions
FDocumentTable.insertRowsAfter
Inserts multiple rows after the specified row index.
insertRowsAfter(row: number, count: number): booleanParameters
row— Required. The zero-based row index to insert after.count— Required. The number of rows to insert.
Returns
true if the rows were successfully inserted.
Examples
const fDocument = univerAPI.getActiveDocument()const table = fDocument?.findTableByText('Status')table?.insertRowsAfter(1, 2) // Inserts 2 new rows after row 1Package: @univerjs-pro/docs-table · Type definitions
FDocumentTable.insertRowsBefore
Inserts multiple rows before the specified row index.
insertRowsBefore(row: number, count: number): booleanParameters
row— Required. The zero-based row index to insert before.count— Required. The number of rows to insert.
Returns
true if the rows were successfully inserted.
Examples
const fDocument = univerAPI.getActiveDocument()const table = fDocument?.findTableByText('Status')table?.insertRowsBefore(1, 2) // Inserts 2 new rows before row 1Package: @univerjs-pro/docs-table · Type definitions
FDocumentTable.insertTitleRow
Inserts a title row at the top of the table.
insertTitleRow(): booleanReturns
true if the title row was successfully inserted.
Examples
const fDocument = univerAPI.getActiveDocument()const table = fDocument?.findTableByText('Status')table?.insertTitleRow() // Inserts a title row at the top of the tablePackage: @univerjs-pro/docs-table · Type definitions
FDocumentTable.mergeCells
Merges a range of cells in the table into a single cell. The content of the merged cell will be taken from the top-left cell in the range.
mergeCells(range: IDocsTableCellRange): booleanParameters
range— Required. The range of cells to merge.
Returns
true if the cells were successfully merged.
Examples
const fDocument = univerAPI.getActiveDocument()const table = fDocument?.findTableByText('Status')// Merges the cells in the range from row 1 to 2 and column 1 to 2 into a single celltable?.mergeCells({ startRow: 1, endRow: 2, startColumn: 1, endColumn: 2,})Types: IDocsTableCellRange
Package: @univerjs-pro/docs-table · Type definitions
FDocumentTable.moveColumn
Moves a single column to a target column index with the specified insert position relative to the target column.
moveColumn(column: number, targetColumn: number, position?: DocsTableColumnInsertPosition): booleanParameters
column— Required. The zero-based column index to move.targetColumn— Required. The zero-based target column index to move to.position— Optional. Default:DocsTableInsertPosition.Left. The position to insert the moved column relative to the target column. Defaults toLeft.
Returns
true if the column was successfully moved.
Examples
const fDocument = univerAPI.getActiveDocument()const table = fDocument?.findTableByText('Status')table?.moveColumn(1, 3, univerAPI.Enum.DocsTableColumnInsertPosition.Right) // Moves column 1 to right of column 3Types: DocsTableColumnInsertPosition
Package: @univerjs-pro/docs-table · Type definitions
FDocumentTable.moveColumns
Moves multiple columns to a target column index with the specified insert position relative to the target column.
moveColumns(startColumn: number, count: number, targetColumn: number, position?: DocsTableColumnInsertPosition): booleanParameters
startColumn— Required. The zero-based starting column index to move.count— Required. The number of columns to move.targetColumn— Required. The zero-based target column index to move to.position— Optional. Default:DocsTableInsertPosition.Left. The position to insert the moved columns relative to the target column. Defaults toLeft.
Returns
true if the columns were successfully moved.
Examples
const fDocument = univerAPI.getActiveDocument()const table = fDocument?.findTableByText('Status')table?.moveColumns(1, 2, 4, univerAPI.Enum.DocsTableColumnInsertPosition.Right) // Moves columns 1 and 2 to right of column 4Types: DocsTableColumnInsertPosition
Package: @univerjs-pro/docs-table · Type definitions
FDocumentTable.moveRow
Moves a single row to a target row index with the specified insert position relative to the target row.
moveRow(row: number, targetRow: number, position?: DocsTableRowInsertPosition): booleanParameters
row— Required. The zero-based row index to move.targetRow— Required. The zero-based target row index to move to.position— Optional. Default:DocsTableInsertPosition.Above. The position to insert the moved row relative to the target row. Defaults toAbove.
Returns
true if the row was successfully moved.
Examples
const fDocument = univerAPI.getActiveDocument()const table = fDocument?.findTableByText('Status')table?.moveRow(1, 3, univerAPI.Enum.DocsTableRowInsertPosition.Below) // Moves row 1 to below row 3Types: DocsTableRowInsertPosition
Package: @univerjs-pro/docs-table · Type definitions
FDocumentTable.moveRows
Moves multiple rows to a target row index with the specified insert position relative to the target row.
moveRows(startRow: number, count: number, targetRow: number, position?: DocsTableRowInsertPosition): booleanParameters
startRow— Required. The zero-based starting row index to move.count— Required. The number of rows to move.targetRow— Required. The zero-based target row index to move to.position— Optional. Default:DocsTableInsertPosition.Above. The position to insert the moved rows relative to the target row. Defaults toAbove.
Returns
true if the rows were successfully moved.
Examples
const fDocument = univerAPI.getActiveDocument()const table = fDocument?.findTableByText('Status')table?.moveRows(1, 2, 4, univerAPI.Enum.DocsTableRowInsertPosition.Below) // Moves rows 1 and 2 to below row 4Types: DocsTableRowInsertPosition
Package: @univerjs-pro/docs-table · Type definitions
FDocumentTable.moveTableBy
Moves the entire table by the specified horizontal and vertical offsets.
moveTableBy(deltaX: number, deltaY: number): booleanParameters
deltaX— Required. Horizontal offset delta applied to the table's floating positiondeltaY— Required. Vertical offset delta applied to the table's floating position
Returns
true if the table was successfully moved.
Examples
const fDocument = univerAPI.getActiveDocument()const table = fDocument?.findTableByText('Status')table?.moveTableBy(50, 100) // Moves the table 50 units to the right and 100 units downPackage: @univerjs-pro/docs-table · Type definitions
FDocumentTable.moveTableToOffset
Moves the entire table to the specified offset in the document's data stream.
moveTableToOffset(offset: number): booleanParameters
offset— Required. The target offset to move the table to.
Returns
true if the table was successfully moved.
Examples
const fDocument = univerAPI.getActiveDocument()const table = fDocument?.findTableByText('Status')table?.moveTableToOffset(500) // Moves the table to offset 500 in the document's data streamPackage: @univerjs-pro/docs-table · Type definitions
FDocumentTable.pinHeaderRows
Pins the specified number of rows at the top of the table as header rows, which will be repeated on each page when the table spans multiple pages.
pinHeaderRows(count: number): booleanParameters
count— Required. The number of rows to pin as header rows.
Returns
true if the header rows were successfully pinned.
Examples
const fDocument = univerAPI.getActiveDocument()const table = fDocument?.findTableByText('Status')table?.pinHeaderRows(2) // Pins the first 2 rows of the table as header rowsPackage: @univerjs-pro/docs-table · Type definitions
FDocumentTable.selectCell
Selects a single cell in the table.
selectCell(row: number, column: number): booleanParameters
row— Required. The zero-based row index of the cell to select.column— Required. The zero-based column index of the cell to select.
Returns
true if the selection was successfully set, or false if the table source is not found in the document snapshot.
Examples
const fDocument = univerAPI.getActiveDocument()const table = fDocument?.findTableByText('Status')table?.selectCell(1, 1) // Selects the cell at row 1, column 1Package: @univerjs-pro/docs-table · Type definitions
FDocumentTable.selectColumn
Selects a single column in the table.
selectColumn(column: number): booleanParameters
column— Required. The zero-based column index to select.
Returns
true if the selection was successfully set, or false if the table source is not found in the document snapshot.
Examples
const fDocument = univerAPI.getActiveDocument()const table = fDocument?.findTableByText('Status')table?.selectColumn(1)Package: @univerjs-pro/docs-table · Type definitions
FDocumentTable.selectColumns
Selects multiple columns in the table.
selectColumns(startColumn: number, count?: number): booleanParameters
startColumn— Required. The zero-based starting column index to select.count— Optional. Default:1. The number of columns to select.
Returns
true if the selection was successfully set, or false if the table source is not found in the document snapshot.
Examples
const fDocument = univerAPI.getActiveDocument()const table = fDocument?.findTableByText('Status')table?.selectColumns(1, 2) // Selects columns 1 and 2Package: @univerjs-pro/docs-table · Type definitions
FDocumentTable.selectRange
Selects a range of cells in the table with the specified selection kind.
selectRange(range: IDocsTableCellRange, kind?: Exclude<DocsTableSelectionKind, DocsTableSelectionKind.None | DocsTableSelectionKind.Text>): booleanParameters
range— Required. The cell range to select.kind— Optional. Default:DocsTableSelectionKind.Range. The selection kind, which determines the selection behavior and UI. Defaults toRange.
Returns
true if the selection was successfully set, or false if the table source is not found in the document snapshot.
Examples
const fDocument = univerAPI.getActiveDocument()const table = fDocument?.findTableByText('Status')// Select a range of cells from row 1 to 2 and column 1 to 2 with the 'Range' selection kindtable.selectRange({ startRow: 1, endRow: 2, startColumn: 1, endColumn: 2,})Types: IDocsTableCellRange · Exclude · DocsTableSelectionKind · DocsTableSelectionKind.None · DocsTableSelectionKind.Text
Package: @univerjs-pro/docs-table · Type definitions
FDocumentTable.selectRow
Selects a single row in the table.
selectRow(row: number): booleanParameters
row— Required. The zero-based row index to select.
Returns
true if the selection was successfully set, or false if the table source is not found in the document snapshot.
Examples
const fDocument = univerAPI.getActiveDocument()const table = fDocument?.findTableByText('Status')table?.selectRow(1)Package: @univerjs-pro/docs-table · Type definitions
FDocumentTable.selectRows
Selects multiple rows in the table.
selectRows(startRow: number, count?: number): booleanParameters
startRow— Required. The zero-based starting row index to select.count— Optional. Default:1. The number of rows to select.
Returns
true if the selection was successfully set, or false if the table source is not found in the document snapshot.
Examples
const fDocument = univerAPI.getActiveDocument()const table = fDocument?.findTableByText('Status')table?.selectRows(1, 2) // Selects rows 1 and 2Package: @univerjs-pro/docs-table · Type definitions
FDocumentTable.selectTable
Selects the entire table.
selectTable(): booleanReturns
true if the selection was successfully set, or false if the table source is not found in the document snapshot.
Examples
const fDocument = univerAPI.getActiveDocument()const table = fDocument?.findTableByText('Status')table?.selectTable()Package: @univerjs-pro/docs-table · Type definitions
FDocumentTable.setBorder
Sets the border properties for a range of cells in the table.
setBorder(range: IDocsTableCellRange, options: IDocsTableBorderOptions): booleanParameters
range— Required. The range of cells to set the border for.options— Required. The border options, including color, width, dash style, and presets for which sides to apply the border to.
Returns
true if the cell border was successfully set.
Examples
const fDocument = univerAPI.getActiveDocument()const table = fDocument?.findTableByText('Status')// Sets a solid red border with a width of 2 for the cells in the range from row 1 to 2 and column 1 to 2table?.setBorder( { startRow: 1, endRow: 2, startColumn: 1, endColumn: 2, }, { preset: univerAPI.Enum.DocsTableBorderPreset.All, color: '#ff0000', width: 2, },)// Sets a dashed blue border with a width of 1 for the cells in the range from row 0 to 0 and column 0 to 2, applying only to the bottom sidetable?.setBorder( { startRow: 0, endRow: 0, startColumn: 0, endColumn: 2, }, { preset: univerAPI.Enum.DocsTableBorderPreset.Bottom, border: { color: { rgb: '#0000ff' }, width: { v: 1 }, dashStyle: univerAPI.Enum.DashStyleType.DASHED, }, },)Types: IDocsTableCellRange · IDocsTableBorderOptions
Package: @univerjs-pro/docs-table · Type definitions
FDocumentTable.setCellBackground
Sets the background color of a range of cells in the table.
setCellBackground(range: IDocsTableCellRange, color: string): booleanParameters
range— Required. The range of cells to set the background color for.color— Required. The background color to set, specified as a hex string (e.g.,#ff0000for red).
Returns
true if the cell background color was successfully set.
Examples
const fDocument = univerAPI.getActiveDocument()const table = fDocument?.findTableByText('Status')// Sets the background color of the cells in the range from row 1 to 2 and column 1 to 2 to redtable?.setCellBackground( { startRow: 1, endRow: 2, startColumn: 1, endColumn: 2, }, '#ff0000',)Types: IDocsTableCellRange
Package: @univerjs-pro/docs-table · Type definitions
FDocumentTable.setCellMargin
Sets or clears the explicit margin override for a range of cells.
Pass null to make the cells inherit the table default.
setCellMargin(range: IDocsTableCellRange, margin: Nullable<ITableCellMargin>): booleanParameters
range— Required. The target cell range.margin— Required. The margin override, ornullto clear it.
Returns
Whether the mutation succeeded.
Types: IDocsTableCellRange · Nullable · ITableCellMargin
Package: @univerjs-pro/docs-table · Type definitions
FDocumentTable.setCellText
Sets the text content of a specific cell in the table. If the cell is merged, the text will be set for the entire merged cell range.
setCellText(row: number, column: number, text: string): booleanParameters
row— Required. The zero-based row index of the cell to set text for.column— Required. The zero-based column index of the cell to set text for.text— Required. The text content to set in the cell.
Returns
true if the cell text was successfully set.
Examples
const fDocument = univerAPI.getActiveDocument()const table = fDocument?.findTableByText('Status')table?.setCellText(1, 1, 'In Progress') // Sets the text of the cell at row 1, column 1 to 'In Progress'Package: @univerjs-pro/docs-table · Type definitions
FDocumentTable.setColumnType
Sets the metadata type of a specific column in the table.
The column type is used as the value parsing hint for table features such as sorting. It does not enable dedicated cell editors or rendering for date, checkbox, or dropdown columns.
setColumnType(column: number, config: IDocsTableColumnTypeConfig): booleanParameters
column— Required. The zero-based column index to set the type for.config— Required. The column type configuration, including the type and any additional options specific to the column type.
Returns
true if the column type metadata was successfully set.
Examples
const fDocument = univerAPI.getActiveDocument()const table = fDocument?.findTableByText('Status')// Sorts column 2 as date values when table sorting is applied.table?.setColumnType(2, { type: univerAPI.Enum.DocsTableColumnType.Date,})Types: IDocsTableColumnTypeConfig
Package: @univerjs-pro/docs-table · Type definitions
FDocumentTable.setColumnWidth
Sets the width of a specific column in the table.
setColumnWidth(column: number, width: number): booleanParameters
column— Required. The zero-based column index to set the width for.width— Required. The width value to set for the column.
Returns
true if the column width was successfully set.
Examples
const fDocument = univerAPI.getActiveDocument()const table = fDocument?.findTableByText('Status')table?.setColumnWidth(1, 100) // Sets the width of column 1 to 100 unitsPackage: @univerjs-pro/docs-table · Type definitions
FDocumentTable.setDefaultCellMargin
Sets or clears the table-level default cell margin.
Pass null to restore the built-in fallback.
setDefaultCellMargin(margin: Nullable<ITableCellMargin>): booleanParameters
margin— Required. The table default, ornullto clear it.
Returns
Whether the mutation succeeded.
Types: Nullable · ITableCellMargin
Package: @univerjs-pro/docs-table · Type definitions
FDocumentTable.setHeaderRowCount
Sets the number of header rows in the table. Header rows are typically styled differently and repeated on each page when the table spans multiple pages.
setHeaderRowCount(count: number): booleanParameters
count— Required. The number of header rows to set for the table.
Returns
true if the header row count was successfully set.
Examples
const fDocument = univerAPI.getActiveDocument()const table = fDocument?.findTableByText('Status')table?.setHeaderRowCount(2) // Sets the first 2 rows of the table as header rowsPackage: @univerjs-pro/docs-table · Type definitions
FDocumentTable.setRowHeight
Sets the height of a specific row in the table.
setRowHeight(row: number, height: number, hRule?: TableRowHeightRule): booleanParameters
row— Required. The zero-based row index to set the height for.height— Required. The height value to set for the row.hRule— Optional. Default:TableRowHeightRule.AT_LEAST.
Returns
true if the row height was successfully set.
Examples
const fDocument = univerAPI.getActiveDocument()const table = fDocument?.findTableByText('Status')table?.setRowHeight(1, 30) // Sets the height of row 1 to 30 unitsTypes: TableRowHeightRule
Package: @univerjs-pro/docs-table · Type definitions
FDocumentTable.setTableBackground
Sets the background color for the entire table.
setTableBackground(color: string): booleanParameters
color— Required. The background color to set for the table, specified as a hex string (e.g.,#ff0000for red).
Returns
true if the table background color was successfully set.
Examples
const fDocument = univerAPI.getActiveDocument()const table = fDocument?.findTableByText('Status')table?.setTableBackground('#ff0000') // Sets the background color of the entire table to redPackage: @univerjs-pro/docs-table · Type definitions
FDocumentTable.setTableBorder
Sets the border properties for the entire table.
setTableBorder(border: IDocsTableBorderOptions): booleanParameters
border— Required. The border options, including color, width, dash style, and presets for which sides to apply the border to.
Returns
true if the table border was successfully set.
Examples
const fDocument = univerAPI.getActiveDocument()const table = fDocument?.findTableByText('Status')// Sets a solid red border with a width of 2 for the entire tabletable?.setTableBorder({ preset: univerAPI.Enum.DocsTableBorderPreset.All, color: '#ff0000', width: 2,})// Sets a dashed blue border with a width of 1 for the entire table, applying only to the bottom sidetable?.setTableBorder({ preset: univerAPI.Enum.DocsTableBorderPreset.Bottom, border: { color: { rgb: '#0000ff' }, width: { v: 1 }, dashStyle: univerAPI.Enum.DashStyleType.DASHED, },})Types: IDocsTableBorderOptions
Package: @univerjs-pro/docs-table · Type definitions
FDocumentTable.setTableStyle
Sets the overall style for the entire table, including background color and border properties.
setTableStyle(style: IDocsTableStyle): booleanParameters
style— Required. The table style options, including background color and border properties.
Returns
true if the table style was successfully set.
Examples
const fDocument = univerAPI.getActiveDocument()const table = fDocument?.findTableByText('Status')// Sets the background color of the entire table to light gray and applies a solid black border with a width of 1table?.setTableStyle({ backgroundColor: '#f0f0f0', border: { preset: univerAPI.Enum.DocsTableBorderPreset.All, color: '#000000', width: 1, },})Types: IDocsTableStyle
Package: @univerjs-pro/docs-table · Type definitions
FDocumentTable.sortByColumn
Sort the table by a specific column in either ascending or descending order.
sortByColumn(column: number, direction: DocsTableSortDirection): booleanParameters
column— Required. The zero-based column index to sort by.direction— Required. The direction to sort the column, either ascending or descending.
Returns
true if the table was successfully sorted.
Examples
const fDocument = univerAPI.getActiveDocument()const table = fDocument?.findTableByText('Status')table?.sortByColumn(1, univerAPI.Enum.DocsTableSortDirection.Asc) // Sorts the table by column 1 in ascending orderTypes: DocsTableSortDirection
Package: @univerjs-pro/docs-table · Type definitions
FDocumentTable.unmergeCells
Unmerges a previously merged cell back into individual cells based on the specified range.
unmergeCells(range: IDocsTableCellRange): booleanParameters
range— Required. The range of the merged cell to unmerge, which should match the original merge range.
Returns
true if the cells were successfully unmerged.
Examples
const fDocument = univerAPI.getActiveDocument()const table = fDocument?.findTableByText('Status')// Unmerges the previously merged cell in the range from row 1 to 2 and column 1 to 2 back into individual cellstable?.unmergeCells({ startRow: 1, endRow: 2, startColumn: 1, endColumn: 2,})Types: IDocsTableCellRange
Package: @univerjs-pro/docs-table · Type definitions
How is this guide?