API 参考

FSlideTable

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

Facade object for a slide table element and its table resource.

Access

Access through:

Inheritance

Extends FPageElement. Its inherited members are available on this object.

Example

TypeScript
const fPresentation = univerAPI.getActivePresentation()const fSlide = fPresentation.getSlideByIndex(0)const tableInfo = fSlide  .newTable()  .setValues([    ['Quarter', 'Owner', 'Status'],    ['Q1', 'Sales', 'Done'],  ])  .setRows(3)  .setColumns(4)  .setColumnWidth(105)  .setRowHeight(60)  .setAbsolutePosition(80, 100)  .setSize(420, 180)  .build()const table = fSlide.insertTable(tableInfo)table?.setCellText(0, 0, 'Name')table?.setCellText(0, 1, 'Status')

Setup

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

@univerjs-pro/slides-table

FSlideTable.appendColumns

Append columns to the table.

TypeScript
appendColumns(count?: number, width?: number): boolean

Parameters

  • count — Optional. Default: 1. The number of columns to append.
  • width — Optional. Optional width for new columns.

Returns

Whether the command succeeded.

Examples

TypeScript
const fPresentation = univerAPI.getActivePresentation()const fSlide = fPresentation.getSlideByIndex(0)const table = fSlide.getTableById('status-table')table.appendColumns(2)

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

FSlideTable.appendRows

Append rows to the table.

TypeScript
appendRows(count?: number, height?: number): boolean

Parameters

  • count — Optional. Default: 1. The number of rows to append.
  • height — Optional. Optional height for new rows.

Returns

Whether the command succeeded.

Examples

TypeScript
const fPresentation = univerAPI.getActivePresentation()const fSlide = fPresentation.getSlideByIndex(0)const table = fSlide.getTableById('status-table')table.appendRows(2)

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

FSlideTable.clearCellBackground

Clear cell background for a range.

TypeScript
clearCellBackground(range: ISlideTableCellRange): boolean

Parameters

  • range — Required. The target range.

Returns

Whether the command succeeded.

Examples

TypeScript
const fPresentation = univerAPI.getActivePresentation()const fSlide = fPresentation.getSlideByIndex(0)const table = fSlide.getTableById('status-table')table.clearCellBackground(table.getTableRange())

Types: ISlideTableCellRange

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

FSlideTable.deleteColumns

Delete columns from the table.

TypeScript
deleteColumns(startColumn: number, count?: number): boolean

Parameters

  • startColumn — Required. The first column to delete.
  • count — Optional. Default: 1. The number of columns to delete.

Returns

Whether the command succeeded.

Examples

TypeScript
const fPresentation = univerAPI.getActivePresentation()const fSlide = fPresentation.getSlideByIndex(0)const table = fSlide.getTableById('status-table')table.deleteColumns(1, 2)

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

FSlideTable.deleteRows

Delete rows from the table.

TypeScript
deleteRows(startRow: number, count?: number): boolean

Parameters

  • startRow — Required. The first row to delete.
  • count — Optional. Default: 1. The number of rows to delete.

Returns

Whether the command succeeded.

Examples

TypeScript
const fPresentation = univerAPI.getActivePresentation()const fSlide = fPresentation.getSlideByIndex(0)const table = fSlide.getTableById('status-table')table.deleteRows(1, 2)

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

FSlideTable.describe

Return a human-readable table description with sample rows.

TypeScript
describe(): ISlideTableDescription

Returns

The table description.

Examples

TypeScript
const fPresentation = univerAPI.getActivePresentation()const fSlide = fPresentation.getSlideByIndex(0)const tables = fSlide.getTables()console.log(tables[0]?.describe())

Types: ISlideTableDescription

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

FSlideTable.distributeColumns

Distribute column widths evenly.

TypeScript
distributeColumns(startColumn?: number, count?: number): boolean

Parameters

  • startColumn — Optional. Default: 0. The first column.
  • count — Optional. Default: this.getColumnCount(). The number of columns.

Returns

Whether the command succeeded.

Examples

TypeScript
const fPresentation = univerAPI.getActivePresentation()const fSlide = fPresentation.getSlideByIndex(0)const table = fSlide.getTableById('status-table')table.distributeColumns()

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

FSlideTable.distributeRows

Distribute row heights evenly.

TypeScript
distributeRows(startRow?: number, count?: number): boolean

Parameters

  • startRow — Optional. Default: 0. The first row.
  • count — Optional. Default: this.getRowCount(). The number of rows.

Returns

Whether the command succeeded.

Examples

TypeScript
const fPresentation = univerAPI.getActivePresentation()const fSlide = fPresentation.getSlideByIndex(0)const table = fSlide.getTableById('status-table')table.distributeRows()

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

FSlideTable.getCell

Return a cell facade by row and column.

TypeScript
getCell(row: number, column: number): FSlideTableCell | null

Parameters

  • row — Required. The zero-based row index.
  • column — Required. The zero-based column index.

Returns

The cell facade, or null when it does not exist.

Examples

TypeScript
const fPresentation = univerAPI.getActivePresentation()const fSlide = fPresentation.getSlideByIndex(0)const table = fSlide.getTables()[0]if (table) {  const cell = table.getCell(0, 0)  console.log(cell)}

Types: FSlideTableCell

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

FSlideTable.getCellData

Return raw cell data by row and column.

TypeScript
getCellData(row: number, column: number): ISlideTableCell | null

Parameters

  • row — Required. The zero-based row index.
  • column — Required. The zero-based column index.

Returns

The cell data, or null when it does not exist.

Examples

TypeScript
const fPresentation = univerAPI.getActivePresentation()const fSlide = fPresentation.getSlideByIndex(0)const table = fSlide.getTables()[0]if (table) {  const cellData = table.getCellData(0, 0)  console.log(cellData)}

Types: ISlideTableCell

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

FSlideTable.getCellRange

Return a one-cell range.

TypeScript
getCellRange(row: number, column: number): ISlideTableCellRange

Parameters

  • row — Required. The zero-based row index.
  • column — Required. The zero-based column index.

Returns

The cell range.

Examples

TypeScript
const fPresentation = univerAPI.getActivePresentation()const fSlide = fPresentation.getSlideByIndex(0)const table = fSlide.getTables()[0]if (table) {  const cellRange = table.getCellRange(0, 0)  console.log(cellRange)}

Types: ISlideTableCellRange

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

FSlideTable.getCellRichText

Returns one cell as a detached rich-text value.

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

Parameters

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

Returns

A detached rich-text value, or null when the cell is empty.

Types: RichTextValue

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

FSlideTable.getCellStyle

Return cell style by row and column.

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

Parameters

  • row — Required. The zero-based row index.
  • column — Required. The zero-based column index.

Returns

The cell style.

Examples

TypeScript
const fPresentation = univerAPI.getActivePresentation()const fSlide = fPresentation.getSlideByIndex(0)const table = fSlide.getTables()[0]if (table) {  const cellStyle = table.getCellStyle(0, 0)  console.log(cellStyle)}

Types: ISlideTableCellStyle

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

FSlideTable.getCellText

Return plain text in a cell.

TypeScript
getCellText(row: number, column: number): string

Parameters

  • row — Required. The zero-based row index.
  • column — Required. The zero-based column index.

Returns

The cell plain text.

Examples

TypeScript
const fPresentation = univerAPI.getActivePresentation()const fSlide = fPresentation.getSlideByIndex(0)const table = fSlide.getTables()[0]if (table) {  const cellText = table.getCellText(0, 0)  console.log(cellText)}

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

FSlideTable.getCellTextData

Return the raw Univer document data in a cell.

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

TypeScript
getCellTextData(row: number, column: number): IDocumentData | undefined

Parameters

  • row — Required. The zero-based row index.
  • column — Required. The zero-based column index.

Returns

The rich text document data.

Examples

TypeScript
// Advanced: export the exact document model for lossless storage or migration.const presentation = univerAPI.getActivePresentation()if (!presentation) throw new Error('No active presentation')const slide = presentation.getSlideByIndex(0)const table = slide.getTableById('status-table')const textData = table?.getCellTextData(0, 0)if (textData) console.log(JSON.stringify(textData))

Types: IDocumentData

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

FSlideTable.getColumnCount

Return the number of columns.

TypeScript
getColumnCount(): number

Returns

The column count.

Examples

TypeScript
const fPresentation = univerAPI.getActivePresentation()const fSlide = fPresentation.getSlideByIndex(0)const tables = fSlide.getTables()console.log(tables[0]?.getColumnCount())

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

FSlideTable.getColumnsRange

Return a column range.

TypeScript
getColumnsRange(startColumn: number, count?: number): ISlideTableCellRange

Parameters

  • startColumn — Required. The first column.
  • count — Optional. Default: 1. The number of columns.

Returns

The column range.

Examples

TypeScript
const fPresentation = univerAPI.getActivePresentation()const fSlide = fPresentation.getSlideByIndex(0)const tables = fSlide.getTables()console.log(tables[0]?.getColumnsRange())

Types: ISlideTableCellRange

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

FSlideTable.getRowCount

Return the number of rows.

TypeScript
getRowCount(): number

Returns

The row count.

Examples

TypeScript
const fPresentation = univerAPI.getActivePresentation()const fSlide = fPresentation.getSlideByIndex(0)const tables = fSlide.getTables()console.log(tables[0]?.getRowCount())

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

FSlideTable.getRowsRange

Return a row range.

TypeScript
getRowsRange(startRow: number, count?: number): ISlideTableCellRange

Parameters

  • startRow — Required. The first row.
  • count — Optional. Default: 1. The number of rows.

Returns

The row range.

Examples

TypeScript
const fPresentation = univerAPI.getActivePresentation()const fSlide = fPresentation.getSlideByIndex(0)const tables = fSlide.getTables()console.log(tables[0]?.getRowsRange())

Types: ISlideTableCellRange

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

FSlideTable.getTableData

Return the raw table resource snapshot.

TypeScript
getTableData(): ISlideTableSnapshot

Returns

The table resource snapshot.

Examples

TypeScript
const fPresentation = univerAPI.getActivePresentation()const fSlide = fPresentation.getSlideByIndex(0)const tables = fSlide.getTables()console.log(tables[0]?.getTableData())

Types: ISlideTableSnapshot

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

FSlideTable.getTableId

Return the table resource id.

TypeScript
getTableId(): string

Returns

The table resource id.

Examples

TypeScript
const fPresentation = univerAPI.getActivePresentation()const fSlide = fPresentation.getSlideByIndex(0)const tables = fSlide.getTables()console.log(tables[0]?.getTableId())

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

FSlideTable.getTableRange

Return a range covering the whole table.

TypeScript
getTableRange(): ISlideTableCellRange

Returns

The table range.

Examples

TypeScript
const fPresentation = univerAPI.getActivePresentation()const fSlide = fPresentation.getSlideByIndex(0)const tables = fSlide.getTables()console.log(tables[0]?.getTableRange())

Types: ISlideTableCellRange

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

FSlideTable.insertColumnsAfter

Insert columns after a column.

TypeScript
insertColumnsAfter(column: number, count?: number, width?: number): boolean

Parameters

  • column — Required. The column index to insert after.
  • count — Optional. Default: 1. The number of columns to insert.
  • width — Optional. Optional width for new columns.

Returns

Whether the command succeeded.

Examples

TypeScript
const fPresentation = univerAPI.getActivePresentation()const fSlide = fPresentation.getSlideByIndex(0)const table = fSlide.getTableById('status-table')table.insertColumnsAfter(0, 1)

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

FSlideTable.insertColumnsBefore

Insert columns before a column.

TypeScript
insertColumnsBefore(column: number, count?: number, width?: number): boolean

Parameters

  • column — Required. The column index to insert before.
  • count — Optional. Default: 1. The number of columns to insert.
  • width — Optional. Optional width for new columns.

Returns

Whether the command succeeded.

Examples

TypeScript
const fPresentation = univerAPI.getActivePresentation()const fSlide = fPresentation.getSlideByIndex(0)const table = fSlide.getTableById('status-table')table.insertColumnsBefore(1, 2, 96)

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

FSlideTable.insertRowsAfter

Insert rows after a row.

TypeScript
insertRowsAfter(row: number, count?: number, height?: number): boolean

Parameters

  • row — Required. The row index to insert after.
  • count — Optional. Default: 1. The number of rows to insert.
  • height — Optional. Optional height for new rows.

Returns

Whether the command succeeded.

Examples

TypeScript
const fPresentation = univerAPI.getActivePresentation()const fSlide = fPresentation.getSlideByIndex(0)const table = fSlide.getTableById('status-table')table.insertRowsAfter(0, 1)

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

FSlideTable.insertRowsBefore

Insert rows before a row.

TypeScript
insertRowsBefore(row: number, count?: number, height?: number): boolean

Parameters

  • row — Required. The row index to insert before.
  • count — Optional. Default: 1. The number of rows to insert.
  • height — Optional. Optional height for new rows.

Returns

Whether the command succeeded.

Examples

TypeScript
const fPresentation = univerAPI.getActivePresentation()const fSlide = fPresentation.getSlideByIndex(0)const table = fSlide.getTableById('status-table')table.insertRowsBefore(1, 2, 32)

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

FSlideTable.mergeCells

Merge a rectangular cell range.

TypeScript
mergeCells(range: ISlideTableCellRange): boolean

Parameters

  • range — Required. The range to merge.

Returns

Whether the command succeeded.

Examples

TypeScript
const fPresentation = univerAPI.getActivePresentation()const fSlide = fPresentation.getSlideByIndex(0)const table = fSlide.getTableById('status-table')table.mergeCells({  startRow: 0,  endRow: 1,  startColumn: 0,  endColumn: 1,})

Types: ISlideTableCellRange

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

FSlideTable.remove

Remove this table element and resource.

TypeScript
remove(): boolean

Returns

Whether the command succeeded.

Examples

TypeScript
const fPresentation = univerAPI.getActivePresentation()const fSlide = fPresentation.getSlideByIndex(0)const table = fSlide.getTableById('status-table')table.remove()

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

FSlideTable.resize

Resize the table grid.

TypeScript
resize(rows: number, columns: number): boolean

Parameters

  • rows — Required. The target row count.
  • columns — Required. The target column count.

Returns

Whether the command succeeded.

Examples

TypeScript
const fPresentation = univerAPI.getActivePresentation()const fSlide = fPresentation.getSlideByIndex(0)const table = fSlide.getTableById('status-table')table.resize(5, 4)

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

FSlideTable.setBorder

Apply borders to a range.

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

Parameters

  • range — Required. The target range.
  • border — Required. The border style.
  • preset — Optional. Default: SlideTableBorderPresetEnum.All. Which borders to apply.

Returns

Whether the command succeeded.

Examples

TypeScript
const fPresentation = univerAPI.getActivePresentation()const fSlide = fPresentation.getSlideByIndex(0)const table = fSlide.getTableById('status-table')table.setBorder(  table.getTableRange(),  {    color: '#111827',    width: 1,    dash: univerAPI.Enum.SlideTableBorderDashEnum.Dash,  },  univerAPI.Enum.SlideTableBorderPresetEnum.Outer,)

Types: ISlideTableCellRange · ISlideTableBorder · SlideTableBorderPresetEnum

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

FSlideTable.setCellBackground

Set solid background color for a range.

TypeScript
setCellBackground(range: ISlideTableCellRange, color: string): boolean

Parameters

  • range — Required. The target range.
  • color — Required. The background color.

Returns

Whether the command succeeded.

Examples

TypeScript
const fPresentation = univerAPI.getActivePresentation()const fSlide = fPresentation.getSlideByIndex(0)const table = fSlide.getTableById('status-table')table.setCellBackground(table.getTableRange(), '#F8FAFC')

Types: ISlideTableCellRange

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

FSlideTable.setCellFill

Set cell fill for a range.

TypeScript
setCellFill(range: ISlideTableCellRange, fill?: ISlideTableFill): boolean

Parameters

  • range — Required. The target range.
  • fill — Optional. The fill, or undefined to clear it.

Returns

Whether the command succeeded.

Examples

TypeScript
const fPresentation = univerAPI.getActivePresentation()const fSlide = fPresentation.getSlideByIndex(0)const table = fSlide.getTableById('status-table')table.setCellFill(table.getCellRange(0, 0), {  type: univerAPI.Enum.SlideTableFillTypeEnum.Solid,  color: '#E8F1FF',  alpha: 1,})

Types: ISlideTableCellRange · ISlideTableFill

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

FSlideTable.setCellHorizontalAlign

Set horizontal text alignment for a range.

TypeScript
setCellHorizontalAlign(range: ISlideTableCellRange, horizontalAlign: HorizontalAlign): boolean

Parameters

  • range — Required. The target range.
  • horizontalAlign — Required. The horizontal alignment.

Returns

Whether the command succeeded.

Examples

TypeScript
const fPresentation = univerAPI.getActivePresentation()const fSlide = fPresentation.getSlideByIndex(0)const table = fSlide.getTableById('status-table')table.setCellHorizontalAlign(table.getTableRange(), univerAPI.Enum.HorizontalAlign.CENTER)

Types: ISlideTableCellRange · HorizontalAlign

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

FSlideTable.setCellRichText

Replaces one cell with a detached value returned by univerAPI.newRichText().

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 to store.

Returns

Whether the command succeeded.

Examples

TypeScript
const text = univerAPI  .newRichText()  .align({    horizontal: univerAPI.Enum.HorizontalAlign.CENTER,    vertical: univerAPI.Enum.VerticalAlign.MIDDLE,  })  .text('Ready')table.setCellRichText(0, 0, text)

Types: RichTextValue

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

FSlideTable.setCellStyle

Merge style fields into a cell range.

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

Parameters

  • range — Required. The target range.
  • style — Required. The style patch.

Returns

Whether the command succeeded.

Examples

TypeScript
const fPresentation = univerAPI.getActivePresentation()const fSlide = fPresentation.getSlideByIndex(0)const table = fSlide.getTableById('status-table')table.setCellStyle(table.getTableRange(), {  fill: {    type: univerAPI.Enum.SlideTableFillTypeEnum.Solid,    color: '#E8F1FF',    alpha: 1,  },  borders: {    left: {      color: '#111827',      width: 1,      dash: univerAPI.Enum.SlideTableBorderDashEnum.Dash,    },  },  margins: {    left: 8,    right: 8,  },  verticalAlign: univerAPI.Enum.SlideTableVerticalAlignEnum.Middle,  textDirection: univerAPI.Enum.SlideTableTextDirectionEnum.Horizontal,})

Types: ISlideTableCellRange · ISlideTableCellStyle

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

FSlideTable.setCellText

Replace a cell with plain text.

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

Parameters

  • row — Required. The row index.
  • column — Required. The column index.
  • text — Required. The new text.

Returns

Whether the command succeeded.

Examples

TypeScript
const fPresentation = univerAPI.getActivePresentation()const fSlide = fPresentation.getSlideByIndex(0)const table = fSlide.getTableById('status-table')table.setCellText(0, 0, 'Ready')

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

FSlideTable.setCellTextColor

Set text color for a range.

TypeScript
setCellTextColor(range: ISlideTableCellRange, color: string): boolean

Parameters

  • range — Required. The target range.
  • color — Required. The text color.

Returns

Whether the command succeeded.

Examples

TypeScript
const fPresentation = univerAPI.getActivePresentation()const fSlide = fPresentation.getSlideByIndex(0)const table = fSlide.getTableById('status-table')table.setCellTextColor(table.getTableRange(), '#111827')

Types: ISlideTableCellRange

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

FSlideTable.setCellTextData

Replace a 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): boolean

Parameters

  • row — Required. The row index.
  • column — Required. The column index.
  • textData — Required. The rich text document data.

Returns

Whether the command succeeded.

Examples

TypeScript
// Advanced: copy exact imported document data without rebuilding its runs and ranges.const presentation = univerAPI.getActivePresentation()if (!presentation) throw new Error('No active presentation')const slide = presentation.getSlideByIndex(0)const table = slide.getTableById('status-table')if (!table) throw new Error('Cannot find status table')const importedTextData = table.getCellTextData(0, 0)if (!importedTextData) throw new Error('Imported cell data is unavailable')if (!table.setCellTextData(0, 1, importedTextData)) throw new Error('Cannot restore raw cell data')

Types: IDocumentData

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

FSlideTable.setCellTextDirection

Set text direction for a range.

TypeScript
setCellTextDirection(range: ISlideTableCellRange, textDirection: SlideTableTextDirectionEnum | undefined): boolean

Parameters

  • range — Required. The target range.
  • textDirection — Required. The text direction.

Returns

Whether the command succeeded.

Examples

TypeScript
const fPresentation = univerAPI.getActivePresentation()const fSlide = fPresentation.getSlideByIndex(0)const table = fSlide.getTableById('status-table')table.setCellTextDirection(  table.getTableRange(),  univerAPI.Enum.SlideTableTextDirectionEnum.Horizontal,)

Types: ISlideTableCellRange · SlideTableTextDirectionEnum

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

FSlideTable.setCellTextFill

Apply rich text fill to a range.

TypeScript
setCellTextFill(range: ISlideTableCellRange, fill?: IDocTextFill): boolean

Parameters

  • range — Required. The target range.
  • fill — Optional. The rich text fill, or undefined to clear it.

Returns

Whether the command succeeded.

Examples

TypeScript
const fPresentation = univerAPI.getActivePresentation()const fSlide = fPresentation.getSlideByIndex(0)const table = fSlide.getTableById('status-table')table.setCellTextFill(table.getTableRange(), { type: 'solid', color: '#111827', opacity: 1 })

Types: ISlideTableCellRange · IDocTextFill

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

FSlideTable.setCellTextStyle

Apply document text style to a range.

TypeScript
setCellTextStyle(range: ISlideTableCellRange, textStyle: ITextStyle): boolean

Parameters

  • range — Required. The target range.
  • textStyle — Required. The document text style patch.

Returns

Whether the command succeeded.

Examples

TypeScript
const fPresentation = univerAPI.getActivePresentation()const fSlide = fPresentation.getSlideByIndex(0)const table = fSlide.getTableById('status-table')table.setCellTextStyle(table.getTableRange(), { fs: 14, bl: 1 })

Types: ISlideTableCellRange · ITextStyle

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

FSlideTable.setCellVerticalAlign

Set vertical text alignment for a range.

TypeScript
setCellVerticalAlign(range: ISlideTableCellRange, verticalAlign: SlideTableVerticalAlignEnum | undefined): boolean

Parameters

  • range — Required. The target range.
  • verticalAlign — Required. The vertical alignment.

Returns

Whether the command succeeded.

Examples

TypeScript
const fPresentation = univerAPI.getActivePresentation()const fSlide = fPresentation.getSlideByIndex(0)const table = fSlide.getTableById('status-table')table.setCellVerticalAlign(table.getTableRange(), univerAPI.Enum.SlideTableVerticalAlignEnum.Middle)

Types: ISlideTableCellRange · SlideTableVerticalAlignEnum

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

FSlideTable.setColumnWidth

Set one column's width.

TypeScript
setColumnWidth(column: number, width: number): boolean

Parameters

  • column — Required. The column index.
  • width — Required. The column width.

Returns

Whether the command succeeded.

Examples

TypeScript
const fPresentation = univerAPI.getActivePresentation()const fSlide = fPresentation.getSlideByIndex(0)const table = fSlide.getTableById('status-table')table.setColumnWidth(1, 160)

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

FSlideTable.setCustom

Set custom table metadata.

TypeScript
setCustom(custom: Record<string, unknown> | null): boolean

Parameters

  • custom — Required. Custom metadata, or null to clear it.

Returns

Whether the command succeeded.

Examples

TypeScript
const fPresentation = univerAPI.getActivePresentation()const fSlide = fPresentation.getSlideByIndex(0)const table = fSlide.getTableById('status-table')table.setCustom({ source: 'agent' })

Types: Record

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

FSlideTable.setOptions

Set table style options.

TypeScript
setOptions(options: ISlideTableStyleOptions): boolean

Parameters

  • options — Required. The table style options.

Returns

Whether the command succeeded.

Examples

TypeScript
const fPresentation = univerAPI.getActivePresentation()const fSlide = fPresentation.getSlideByIndex(0)const table = fSlide.getTableById('status-table')table.setOptions({ firstRow: true, bandRow: true })

Types: ISlideTableStyleOptions

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

FSlideTable.setRowHeight

Set one row's height.

TypeScript
setRowHeight(row: number, height: number): boolean

Parameters

  • row — Required. The row index.
  • height — Required. The row height.

Returns

Whether the command succeeded.

Examples

TypeScript
const fPresentation = univerAPI.getActivePresentation()const fSlide = fPresentation.getSlideByIndex(0)const table = fSlide.getTableById('status-table')table.setRowHeight(0, 40)

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

FSlideTable.setStyleId

Set the table theme style id. Built-in ids include: univerPrimaryPlainGrid, univerPrimaryHeader, univerPrimaryHeaderBandedRows, univerNeutralPlainGrid, univerGreenHeaderBandedRows, univerPurpleStrongHeader; univer{Neutral|Primary|Blue|Cyan|Green|Orange|Purple|Pink}LightPlainGrid, univer{Neutral|Primary|Blue|Cyan|Green|Orange|Purple|Pink}LightHeader, univer{Neutral|Primary|Blue|Cyan|Green|Orange|Purple|Pink}LightHeaderBandedRows; univer{Neutral|Primary|Blue|Cyan|Green|Orange|Purple|Pink}MediumStrongHeader, univer{Neutral|Primary|Blue|Cyan|Green|Orange|Purple|Pink}MediumFirstColumn, univer{Neutral|Primary|Blue|Cyan|Green|Orange|Purple|Pink}MediumHeaderFirstColumn; univer{Neutral|Primary|Blue|Cyan|Green|Orange|Purple|Pink}HorizontalLines, univerPrimarySoftGrid, and univerNeutralSoftGrid.

TypeScript
setStyleId(styleId: string | null): boolean

Parameters

  • styleId — Required. The style id, or null to clear it.

Returns

Whether the command succeeded.

Examples

TypeScript
const fPresentation = univerAPI.getActivePresentation()const fSlide = fPresentation.getSlideByIndex(0)const table = fSlide.getTableById('status-table')table.setStyleId('univerGreenMediumHeaderFirstColumn')table.setOptions({  firstRow: true,  firstCol: true,  bandRow: true,})

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

FSlideTable.setTableBackground

Set table background color.

TypeScript
setTableBackground(color: string): boolean

Parameters

  • color — Required. The background color.

Returns

Whether the command succeeded.

Examples

TypeScript
const fPresentation = univerAPI.getActivePresentation()const fSlide = fPresentation.getSlideByIndex(0)const table = fSlide.getTableById('status-table')table.setTableBackground('#F8FAFC')

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

FSlideTable.setTableBorder

Apply borders to the whole table.

TypeScript
setTableBorder(border: ISlideTableBorder, preset?: SlideTableBorderPresetEnum): boolean

Parameters

  • border — Required. The border style.
  • preset — Optional. Default: SlideTableBorderPresetEnum.All. Which borders to apply.

Returns

Whether the command succeeded.

Examples

TypeScript
const fPresentation = univerAPI.getActivePresentation()const fSlide = fPresentation.getSlideByIndex(0)const table = fSlide.getTableById('status-table')table.setTableBorder(  {    color: '#111827',    width: 1,    dash: univerAPI.Enum.SlideTableBorderDashEnum.Solid,  },  univerAPI.Enum.SlideTableBorderPresetEnum.All,)

Types: ISlideTableBorder · SlideTableBorderPresetEnum

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

FSlideTable.setTableDescription

Set the table description.

TypeScript
setTableDescription(description: string | null): boolean

Parameters

  • description — Required. The description, or null to clear it.

Returns

Whether the command succeeded.

Examples

TypeScript
const fPresentation = univerAPI.getActivePresentation()const fSlide = fPresentation.getSlideByIndex(0)const table = fSlide.getTableById('status-table')table.setTableDescription('Quarterly status table')

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

FSlideTable.setTableName

Set the table name.

TypeScript
setTableName(name: string | null): boolean

Parameters

  • name — Required. The table name, or null to clear it.

Returns

Whether the command succeeded.

Examples

TypeScript
const fPresentation = univerAPI.getActivePresentation()const fSlide = fPresentation.getSlideByIndex(0)const table = fSlide.getTableById('status-table')table.setTableName('Status table')

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

FSlideTable.setTableStyle

Apply table-level style settings.

TypeScript
setTableStyle(style: ISlideTableFacadeStyle): boolean

Parameters

  • style — Required. Table style settings.

Returns

Whether every command succeeded.

Examples

TypeScript
const fPresentation = univerAPI.getActivePresentation()const fSlide = fPresentation.getSlideByIndex(0)const table = fSlide.getTableById('status-table')table.setTableStyle({  fill: {    type: univerAPI.Enum.SlideTableFillTypeEnum.Solid,    color: '#F8FAFC',    alpha: 1,  },  border: {    color: '#111827',    width: 1,    dash: univerAPI.Enum.SlideTableBorderDashEnum.Solid,  },  options: {    firstRow: true,  },})

Types: ISlideTableFacadeStyle

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

FSlideTable.toBuilder

Return a builder initialized from this table.

TypeScript
toBuilder(): FSlideTableBuilder

Returns

A table builder.

Examples

TypeScript
const fPresentation = univerAPI.getActivePresentation()const fSlide = fPresentation.getSlideByIndex(0)const table = fSlide.getTableById('status-table')const tableInfo = table  .toBuilder()  .setValues([    ['Quarter', 'Owner', 'Status'],    ['Q1', 'Sales', 'Done'],  ])  .setRows(3)  .setColumns(4)  .setColumnWidth(105)  .setRowHeight(60)  .setAbsolutePosition(80, 120)  .setSize(420, 180)  .build()fSlide.updateTable(tableInfo)

Types: FSlideTableBuilder

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

FSlideTable.unmergeCell

Unmerge the merged range containing a cell.

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

Parameters

  • row — Required. The row index.
  • column — Required. The column index.

Returns

Whether the command succeeded.

Examples

TypeScript
const fPresentation = univerAPI.getActivePresentation()const fSlide = fPresentation.getSlideByIndex(0)const table = fSlide.getTableById('status-table')table.unmergeCell(0, 0)

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

你觉得这篇文档如何?

© 2026 DreamNum Co., Ltd.