# Table Class

> Table class in the TX Sheet Control JavaScript API for the browser: A stable operational table handle. Mutations are worksheet-bound and undoable.

- **Product:** TX Sheet Control
- **Section:** Documentation
- **Kind:** Class
- **Path:** TX Sheet Control > API Reference > JavaScript API > Browser Editor > Table Class
- **1556 words**
- **Web URL:** https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/table/
- **LLMs URL:** https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/table/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/table/llms-full.txt

---

A stable operational table handle. Mutations are worksheet-bound and undoable.

Package: `@txtextcontrol/tx-sheet-control`. Version: **2.0.0**.

ES module import: `import { Table } from '@txtextcontrol/tx-sheet-control';`.

### Constructor

```javascript
new Table(sheet, id)
```

| Parameter | Type | Optional | Description |
|---|---|---|---|
| `sheet` | `Worksheet` | No | Value matching sheet's declared type and the owning object's validation rules. |
| `id` | `string` | No | Stable identity in the owning document/collection. |

Returns: `Table`.

### Members

#### Properties

| Property | Description |
|---|---|
| [id](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/table/id-property/llms-full.txt) | The id value of Table. |
| [name](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/table/name-property/llms-full.txt) | The name value of Table. |
| [range](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/table/range-property/llms-full.txt) | The range value of Table. |
| [sheet](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/table/sheet-property/llms-full.txt) | The sheet value of Table. |
| [snapshot](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/table/snapshot-property/llms-full.txt) | Returns detached current state; throws after deletion or document replacement. |

#### Methods

| Method | Description |
|---|---|
| [deleteColumns](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/table/deletecolumns-method/llms-full.txt) | Deletes count columns at a zero-based table-column index, shifting cells left within the table rows. Deleting every column removes the table and invalidates this handle. Invalid bounds, protection and split ranges throw atomically; retained columns keep their identities. This is one undo step. |
| [deleteRows](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/table/deleterows-method/llms-full.txt) | Deletes count data rows at a zero-based data-row index, shifting cells up within the table columns. Headers and totals are retained; deleting all data rows leaves one empty data row. Invalid bounds, protection and split ranges throw without changing the document. This is one undoable operation. |
| [insertColumns](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/table/insertcolumns-method/llms-full.txt) | Inserts count columns before a zero-based table-column index (columnCount appends). Shifts cells right within the table rows and creates unique headers. Invalid bounds, protection, split ranges and worksheet overflow throw atomically. Column identities and totals are retained. |
| [insertRows](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/table/insertrows-method/llms-full.txt) | Inserts count data rows before a zero-based data-row index (rowCount appends before totals). Shifts cells down within the table columns; neighboring columns stay intact. Throws for invalid bounds, protected cells, split ranges or worksheet overflow. The worksheet-bound operation is one undo step. |
| [remove](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/table/remove-method/llms-full.txt) | Converts the table to ordinary cells; cell content and existing formatting are retained. |
| [rename](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/table/rename-method/llms-full.txt) | Renames this table and updates structured references throughout the workbook. |
| [resize](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/table/resize-method/llms-full.txt) | Resizes to a non-overlapping range, retaining existing columns and deriving new header names as needed. |
| [setColumn](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/table/setcolumn-method/llms-full.txt) | Sets a calculated-column formula or totals definition by column name. |
| [update](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/table/update-method/llms-full.txt) | Changes display options, headers or totals settings while retaining table identity. |

### Examples

Use a fresh workbook. Create and format the sample data, apply this API and retain the returned document or result in your application. In the browser pass editor.workbook; in Node.js pass the server control.

```javascript
function createTableReport(book) {
    const sheet = book.sheets.at(0);
    sheet.cell('A1').setText('October invoice');
    sheet.cell('A1').format({
        fontFamily: 'Liberation Sans',
        fontSize: 16,
        bold: true,
        textColor: '#ffffff',
        fillColor: '#163b63',
    });

    sheet.columns.at(0).setWidth({ pixels: 240 });
    sheet.range('B8:B9').setValues([[120], [80]]);
    sheet.cell('B10').setFormula('=SUM(B8:B9)');
    sheet.range('B8:B10').format({ numberFormatCode: '#,##0.00', fontSize: 11 });
    sheet.range('A7:D9').setValues([
        ['Description', 'Quantity', 'UnitPrice', 'Amount'],
        ['Consulting', 3, 120, 360],
        ['Training', 2, 90, 180],
    ]);

    const table = sheet.tables.add('InvoiceLines', 'A7:D9', {
        style: 'TableStyleMedium2',
        hasHeaderRow: true,
        showRowStripes: true,
    });

    table.setColumn('Amount', { formula: '=[@Quantity]*[@UnitPrice]' });
    sheet.range('C8:D9').format({ numberFormatCode: '#,##0.00' });
    return sheet;
}
```

### See Also

- [JavaScript Browser Editor API](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/llms-full.txt)
- [Tables](https://docs.textcontrol.com/tx-sheet-control/spreadsheets/tables/llms-full.txt)

---

## In This Section

- [Table.deleteColumns Method](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/table/deletecolumns-method/llms-full.txt): Table.deleteColumns method in the browser JavaScript API: Deletes count columns at a zero-based table-column index, shifting cells left within the table rows.
- [Table.deleteRows Method](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/table/deleterows-method/llms-full.txt): Table.deleteRows method in the browser JavaScript API: Deletes count data rows at a zero-based data-row index, shifting cells up within the table columns.
- [Table.id Property](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/table/id-property/llms-full.txt): Table.id property in the TX Sheet Control JavaScript API for the browser, with its type string and a JavaScript example.
- [Table.insertColumns Method](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/table/insertcolumns-method/llms-full.txt): Table.insertColumns method in the browser JavaScript API: Inserts count columns before a zero-based table-column index (columnCount appends).
- [Table.insertRows Method](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/table/insertrows-method/llms-full.txt): Table.insertRows method in the browser JavaScript API: Inserts count data rows before a zero-based data-row index (rowCount appends before totals).
- [Table.name Property](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/table/name-property/llms-full.txt): Table.name property in the TX Sheet Control JavaScript API for the browser, with its type string and a JavaScript example.
- [Table.range Property](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/table/range-property/llms-full.txt): Table.range property in the TX Sheet Control JavaScript API for the browser, with its type string and a JavaScript example.
- [Table.remove Method](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/table/remove-method/llms-full.txt): Table.remove method in the browser JavaScript API: Converts the table to ordinary cells; cell content and existing formatting are retained.
- [Table.rename Method](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/table/rename-method/llms-full.txt): Table.rename method in the TX Sheet Control JavaScript API for the browser: Renames this table and updates structured references throughout the workbook.
- [Table.resize Method](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/table/resize-method/llms-full.txt): Table.resize method in the browser JavaScript API: Resizes to a non-overlapping range, retaining existing columns and deriving new header names as needed.
- [Table.setColumn Method](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/table/setcolumn-method/llms-full.txt): Table.setColumn method in the TX Sheet Control JavaScript API for the browser: Sets a calculated-column formula or totals definition by column name.
- [Table.sheet Property](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/table/sheet-property/llms-full.txt): Table.sheet property in the TX Sheet Control JavaScript API for the browser, with its type Worksheet and a JavaScript example.
- [Table.snapshot Property](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/table/snapshot-property/llms-full.txt): Table.snapshot property in the TX Sheet Control JavaScript API for the browser: Returns detached current state; throws after deletion or document replacement.
- [Table.update Method](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/table/update-method/llms-full.txt): Table.update method in the TX Sheet Control JavaScript API for the browser: Changes display options, headers or totals settings while retaining table identity.

---

## Nearby

- **Previous:** [StreamType Enumeration](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/streamtype/llms-full.txt)
- **Next:** [Table.deleteColumns Method](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/table/deletecolumns-method/llms-full.txt)
