> ## Documentation Index
> Fetch the complete documentation index at: https://docs.reducto.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Tables

`sheet.tables.add(address, hasHeaders)` turns a block of cells into a table. A formula in a table column fills down the column.

```ts theme={null}
import { ExcelWorkbook } from "@reductoai/xlsx/node";

const book = ExcelWorkbook.create();
const sheet = book.worksheets.getActiveWorksheet();
sheet.getRange("A1:C4").values = [
  ["Region", "Q1", "Q2"],
  ["North", 10, 12],
  ["South", 8, 15],
  ["West", 11, 9],
];
const table = sheet.tables.add("A1:C4", true);
table.name = "Sales";
table.style = "TableStyleMedium2";
table.columns.add(null, [["Total"], ["=[@Q1]+[@Q2]"], ["=[@Q1]+[@Q2]"], ["=[@Q1]+[@Q2]"]]);
table.rows.add(null, [["East", 7, 13, "=[@Q1]+[@Q2]"]]);
await book.save("table.xlsx");
```

## Sort

```ts theme={null}
import { ExcelWorkbook } from "@reductoai/xlsx/officejs";

const book = ExcelWorkbook.fromBytes(bytes);
const sheet = book.worksheets.getItem("Sheet1");
sheet.getRange("A2:D10").sort.apply([{ key: 1, ascending: false }]); // by the second column, largest first
```
