# Javascript: Table.splitCells Method

> Splits all selected table cells in this table. Only previously merged cells can be split. The getCanSplitCells method can be used to determine, if table cells can be split or not.

- **Product:** DS Server
- **Section:** Reference
- **Kind:** Method
- **Introduced:** 28.0
- **Path:** DS Server > Reference > JavaScript API > Javascript: Table.splitCells Method
- **537 words**
- **Web URL:** https://docs.textcontrol.com/ds-server/reference/javascript/table/splitcells-method/
- **LLMs URL:** https://docs.textcontrol.com/ds-server/reference/javascript/table/splitcells-method/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/ds-server/reference/javascript/table/splitcells-method/llms-full.txt

---

### Description

Splits all selected table cells in this table. Only previously merged cells can be split. The [getCanSplitCells](https://docs.textcontrol.com/ds-server/reference/javascript/table/getcansplitcells-method/llms-full.txt) method can be used to determine, if table cells can be split or not.

### Syntax

```javascript
<void> Table.splitCells([<RequestBooleanCallback> callback], [<ErrorCallback> errorCallback])
```

### Parameters

| Parameter | Description |
|---|---|
| callback | Optional. Receives whether the cells could be split. |
| errorCallback | Optional. Is called when the operation failed with an error. |

### Examples

The following example demonstrates `Table.splitCells` in a practical document-editing workflow. It splits all selected table cells in this table. Only previously merged cells can be split. The getCanSplitCells method can be used to determine, if table cells can be split or not.

```javascript
function onTxError(error) {
    console.error("TX Text Control error:", error.msg);
    error.handled = true;
}

TXTextControl.textParts.getMainText(function(mainText) {
    const tables = mainText.tables;
    tables.getItem(function(table) {
        if (!table) {
            console.warn("No table is available at the current input position.");
            return;
        }
    
        table.splitCells(
            function(result) {
                if (result) {
                    console.log("split cells is available.");
                } else {
                    console.warn("split cells is not available in the current document state.");
                }
            },
            onTxError
        );
    }, onTxError);
}, onTxError);
```

---

## Nearby

- **Previous:** [Javascript: Table.split Method](https://docs.textcontrol.com/ds-server/reference/javascript/table/split-method/llms-full.txt)
- **Next:** [TableBaseCollection Object](https://docs.textcontrol.com/ds-server/reference/javascript/tablebasecollection/llms-full.txt)
