# FSlideTableCell

> Language fallback: requested `zh-CN`; content is `en-US`.

- Human documentation: [https://docs.univer.ai/zh-CN/reference/facade/slide-table-cell](https://docs.univer.ai/zh-CN/reference/facade/slide-table-cell)

- Agent Markdown: [https://docs.univer.ai/zh-CN/reference/facade/slide-table-cell.md](https://docs.univer.ai/zh-CN/reference/facade/slide-table-cell.md)

- Requested language: `zh-CN`

- Content language: `en-US`

- Documentation version: `1.0.0-rc.0`

- Source: [facade/slide-table-cell.mdx](https://github.com/dream-num/documentation/blob/dev/content/reference/facade/slide-table-cell.mdx)

---

Facade object for a single slide table cell.

## Access

Access through:

* [`FSlideTable.getCell()`](https://docs.univer.ai/zh-CN/reference/facade/slide-table.md#getcell)

## Example

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

const cell = table.getCell(0, 0)
cell?.setText('Ready')
cell?.setBackgroundColor('#E8F1FF')
```

## Setup

Register [`@univerjs-pro/slides-table`](https://docs.univer.ai/zh-CN/reference/packages/plugins/univerjs-pro/slides-table.md) 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](https://docs.univer.ai/zh-CN/guides/slides/getting-started/facade.md).

## `@univerjs-pro/slides-table`

### `FSlideTableCell.clearBackground`

Clear this cell's fill.

```typescript
clearBackground(): boolean
```

**Returns**

Whether the command succeeded.

**Examples**

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

const cell = table.getCell(0, 0)
cell?.clearBackground()
```

**Package:** [`@univerjs-pro/slides-table`](https://docs.univer.ai/zh-CN/reference/packages/plugins/univerjs-pro/slides-table.md) · [Type definitions](https://unpkg.com/@univerjs-pro/slides-table@1.0.0-rc.0/lib/types/facade/f-slide-table-cell.d.ts)

### `FSlideTableCell.getColumnIndex`

Return the zero-based column index.

```typescript
getColumnIndex(): number
```

**Returns**

The column index.

**Examples**

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

const cell = table.getCell(0, 1)
console.log(cell?.getColumnIndex())
```

**Package:** [`@univerjs-pro/slides-table`](https://docs.univer.ai/zh-CN/reference/packages/plugins/univerjs-pro/slides-table.md) · [Type definitions](https://unpkg.com/@univerjs-pro/slides-table@1.0.0-rc.0/lib/types/facade/f-slide-table-cell.d.ts)

### `FSlideTableCell.getData`

Return the raw cell snapshot.

```typescript
getData(): ISlideTableCell | null
```

**Returns**

The cell snapshot, or `null` when the cell does not exist.

**Examples**

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

const cell = table.getCell(0, 0)
console.log(cell?.getData())
```

**Types:** [`ISlideTableCell`](https://unpkg.com/@univerjs-pro/slides-table@1.0.0-rc.0/lib/types/types.d.ts)

**Package:** [`@univerjs-pro/slides-table`](https://docs.univer.ai/zh-CN/reference/packages/plugins/univerjs-pro/slides-table.md) · [Type definitions](https://unpkg.com/@univerjs-pro/slides-table@1.0.0-rc.0/lib/types/facade/f-slide-table-cell.d.ts)

### `FSlideTableCell.getRichText`

Returns this cell as a detached rich-text value.

```typescript
getRichText(): RichTextValue | null
```

**Returns**

A detached value suitable for `.copy()` and `setRichText()`, or `null` for an empty cell.

**Types:** [`RichTextValue`](https://unpkg.com/@univerjs/core@1.0.0-rc.0/lib/types/docs/data-model/rich-text-builder.d.ts)

**Package:** [`@univerjs-pro/slides-table`](https://docs.univer.ai/zh-CN/reference/packages/plugins/univerjs-pro/slides-table.md) · [Type definitions](https://unpkg.com/@univerjs-pro/slides-table@1.0.0-rc.0/lib/types/facade/f-slide-table-cell.d.ts)

### `FSlideTableCell.getRowIndex`

Return the zero-based row index.

```typescript
getRowIndex(): number
```

**Returns**

The row index.

**Examples**

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

const cell = table.getCell(1, 0)
console.log(cell?.getRowIndex())
```

**Package:** [`@univerjs-pro/slides-table`](https://docs.univer.ai/zh-CN/reference/packages/plugins/univerjs-pro/slides-table.md) · [Type definitions](https://unpkg.com/@univerjs-pro/slides-table@1.0.0-rc.0/lib/types/facade/f-slide-table-cell.d.ts)

### `FSlideTableCell.getStyle`

Return the cell style.

```typescript
getStyle(): ISlideTableCellStyle | undefined
```

**Returns**

The cell style.

**Examples**

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

const cell = table.getCell(0, 0)
console.log(cell?.getStyle())
```

**Types:** [`ISlideTableCellStyle`](https://unpkg.com/@univerjs-pro/slides-table@1.0.0-rc.0/lib/types/types.d.ts)

**Package:** [`@univerjs-pro/slides-table`](https://docs.univer.ai/zh-CN/reference/packages/plugins/univerjs-pro/slides-table.md) · [Type definitions](https://unpkg.com/@univerjs-pro/slides-table@1.0.0-rc.0/lib/types/facade/f-slide-table-cell.d.ts)

### `FSlideTableCell.getTable`

Return the parent table facade.

```typescript
getTable(): FSlideTable
```

**Returns**

The parent table.

**Examples**

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

const cell = table.getCell(0, 0)
console.log(cell?.getTable())
```

**Types:** [`FSlideTable`](https://docs.univer.ai/zh-CN/reference/facade/slide-table.md)

**Package:** [`@univerjs-pro/slides-table`](https://docs.univer.ai/zh-CN/reference/packages/plugins/univerjs-pro/slides-table.md) · [Type definitions](https://unpkg.com/@univerjs-pro/slides-table@1.0.0-rc.0/lib/types/facade/f-slide-table-cell.d.ts)

### `FSlideTableCell.getText`

Return the plain text in this cell.

```typescript
getText(): string
```

**Returns**

The plain cell text.

**Examples**

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

const cell = table.getCell(0, 0)
console.log(cell?.getText())
```

**Package:** [`@univerjs-pro/slides-table`](https://docs.univer.ai/zh-CN/reference/packages/plugins/univerjs-pro/slides-table.md) · [Type definitions](https://unpkg.com/@univerjs-pro/slides-table@1.0.0-rc.0/lib/types/facade/f-slide-table-cell.d.ts)

### `FSlideTableCell.getTextData`

Return the raw Univer document data in this cell.

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

```typescript
getTextData(): IDocumentData | undefined
```

**Returns**

The cell rich text data.

**Examples**

```ts
// 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 cell = table?.getCell(0, 0)
const textData = cell?.getTextData()
if (textData) console.log(JSON.stringify(textData))
```

**Types:** [`IDocumentData`](https://docs.univer.ai/zh-CN/reference/types/document-data.md)

**Package:** [`@univerjs-pro/slides-table`](https://docs.univer.ai/zh-CN/reference/packages/plugins/univerjs-pro/slides-table.md) · [Type definitions](https://unpkg.com/@univerjs-pro/slides-table@1.0.0-rc.0/lib/types/facade/f-slide-table-cell.d.ts)

### `FSlideTableCell.mergeTo`

Merge this cell with a rectangular span starting at this cell.

```typescript
mergeTo(rowSpan: number, columnSpan: number): boolean
```

**Parameters**

* `rowSpan` — Required. The number of rows to include.
* `columnSpan` — Required. The number of columns to include.

**Returns**

Whether the command succeeded.

**Examples**

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

const cell = table.getCell(0, 0)
cell?.mergeTo(2, 2)
```

**Package:** [`@univerjs-pro/slides-table`](https://docs.univer.ai/zh-CN/reference/packages/plugins/univerjs-pro/slides-table.md) · [Type definitions](https://unpkg.com/@univerjs-pro/slides-table@1.0.0-rc.0/lib/types/facade/f-slide-table-cell.d.ts)

### `FSlideTableCell.setBackgroundColor`

Set a solid background color for this cell.

```typescript
setBackgroundColor(color: string): boolean
```

**Parameters**

* `color` — Required. The background color.

**Returns**

Whether the command succeeded.

**Examples**

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

const cell = table.getCell(0, 0)
cell?.setBackgroundColor('#E8F1FF')
```

**Package:** [`@univerjs-pro/slides-table`](https://docs.univer.ai/zh-CN/reference/packages/plugins/univerjs-pro/slides-table.md) · [Type definitions](https://unpkg.com/@univerjs-pro/slides-table@1.0.0-rc.0/lib/types/facade/f-slide-table-cell.d.ts)

### `FSlideTableCell.setBorder`

Apply borders to this cell.

```typescript
setBorder(border: ISlideTableBorder): boolean
```

**Parameters**

* `border` — Required. The border style.

**Returns**

Whether the command succeeded.

**Examples**

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

const cell = table.getCell(0, 0)
cell?.setBorder({
  color: '#111827',
  width: 1,
  dash: univerAPI.Enum.SlideTableBorderDashEnum.Solid,
})
```

**Types:** [`ISlideTableBorder`](https://unpkg.com/@univerjs-pro/slides-table@1.0.0-rc.0/lib/types/types.d.ts)

**Package:** [`@univerjs-pro/slides-table`](https://docs.univer.ai/zh-CN/reference/packages/plugins/univerjs-pro/slides-table.md) · [Type definitions](https://unpkg.com/@univerjs-pro/slides-table@1.0.0-rc.0/lib/types/facade/f-slide-table-cell.d.ts)

### `FSlideTableCell.setFill`

Set the cell fill.

```typescript
setFill(fill?: ISlideTableFill): boolean
```

**Parameters**

* `fill` — Optional. The fill, or `undefined` to clear it.

**Returns**

Whether the command succeeded.

**Examples**

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

const cell = table.getCell(0, 0)
cell?.setFill({
  type: univerAPI.Enum.SlideTableFillTypeEnum.Solid,
  color: '#E8F1FF',
  alpha: 1,
})
```

**Types:** [`ISlideTableFill`](https://unpkg.com/@univerjs-pro/slides-table@1.0.0-rc.0/lib/types/types.d.ts)

**Package:** [`@univerjs-pro/slides-table`](https://docs.univer.ai/zh-CN/reference/packages/plugins/univerjs-pro/slides-table.md) · [Type definitions](https://unpkg.com/@univerjs-pro/slides-table@1.0.0-rc.0/lib/types/facade/f-slide-table-cell.d.ts)

### `FSlideTableCell.setRichText`

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

```typescript
setRichText(richText: RichTextValue): boolean
```

**Parameters**

* `richText` — Required. Rich-text value to store in the cell.

**Returns**

Whether the command succeeded.

**Examples**

```ts
const text = univerAPI
  .newRichText()
  .align({ horizontal: univerAPI.Enum.HorizontalAlign.CENTER })
  .text('Ready')
cell.setRichText(text)
```

**Types:** [`RichTextValue`](https://unpkg.com/@univerjs/core@1.0.0-rc.0/lib/types/docs/data-model/rich-text-builder.d.ts)

**Package:** [`@univerjs-pro/slides-table`](https://docs.univer.ai/zh-CN/reference/packages/plugins/univerjs-pro/slides-table.md) · [Type definitions](https://unpkg.com/@univerjs-pro/slides-table@1.0.0-rc.0/lib/types/facade/f-slide-table-cell.d.ts)

### `FSlideTableCell.setStyle`

Merge supported style fields into this cell.

```typescript
setStyle(style: ISlideTableCellStyle): boolean
```

**Parameters**

* `style` — Required. The style patch.

**Returns**

Whether the command succeeded.

**Examples**

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

const cell = table.getCell(0, 0)
cell?.setStyle({
  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:** [`ISlideTableCellStyle`](https://unpkg.com/@univerjs-pro/slides-table@1.0.0-rc.0/lib/types/types.d.ts)

**Package:** [`@univerjs-pro/slides-table`](https://docs.univer.ai/zh-CN/reference/packages/plugins/univerjs-pro/slides-table.md) · [Type definitions](https://unpkg.com/@univerjs-pro/slides-table@1.0.0-rc.0/lib/types/facade/f-slide-table-cell.d.ts)

### `FSlideTableCell.setText`

Replace this cell with plain text.

```typescript
setText(text: string): boolean
```

**Parameters**

* `text` — Required. The new plain text.

**Returns**

Whether the command succeeded.

**Examples**

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

const cell = table.getCell(0, 0)
cell?.setText('Ready')
```

**Package:** [`@univerjs-pro/slides-table`](https://docs.univer.ai/zh-CN/reference/packages/plugins/univerjs-pro/slides-table.md) · [Type definitions](https://unpkg.com/@univerjs-pro/slides-table@1.0.0-rc.0/lib/types/facade/f-slide-table-cell.d.ts)

### `FSlideTableCell.setTextData`

Replace this cell with raw Univer document data.

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

```typescript
setTextData(textData: IDocumentData): boolean
```

**Parameters**

* `textData` — Required. The rich text document data.

**Returns**

Whether the command succeeded.

**Examples**

```ts
// 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')
const importedTextData = table?.getCell(0, 0)?.getTextData()
if (!importedTextData) throw new Error('Imported cell data is unavailable')
const targetCell = table?.getCell(0, 1)
if (!targetCell?.setTextData(importedTextData)) throw new Error('Cannot restore raw cell data')
```

**Types:** [`IDocumentData`](https://docs.univer.ai/zh-CN/reference/types/document-data.md)

**Package:** [`@univerjs-pro/slides-table`](https://docs.univer.ai/zh-CN/reference/packages/plugins/univerjs-pro/slides-table.md) · [Type definitions](https://unpkg.com/@univerjs-pro/slides-table@1.0.0-rc.0/lib/types/facade/f-slide-table-cell.d.ts)

### `FSlideTableCell.unmerge`

Unmerge the merged range containing this cell.

```typescript
unmerge(): boolean
```

**Returns**

Whether the command succeeded.

**Examples**

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

const cell = table.getCell(0, 0)
cell?.unmerge()
```

**Package:** [`@univerjs-pro/slides-table`](https://docs.univer.ai/zh-CN/reference/packages/plugins/univerjs-pro/slides-table.md) · [Type definitions](https://unpkg.com/@univerjs-pro/slides-table@1.0.0-rc.0/lib/types/facade/f-slide-table-cell.d.ts)
