Tables
An Excel-style table is an operational worksheet object: a header range, named columns, formatting options and structured references such as [@Quantity]. Formatting a plain range with colors alone does not create a table. A table keeps its formulas and column names when its rows and columns change, which also makes it a good source for a dashboard.
Create a Table
The following code fills a range of the first worksheet with two invoice items and turns it into a table. editor is the Spreadsheet of the browser editor, created as in JavaScript:
const sheet = editor.workbook.sheets.at(0);
sheet.range('A1:D3').setValues([
['Item', 'Quantity', 'Price', 'Amount'],
['Hardware', 2, 120, null], ['Software', 3, 80, null]
]);
const table = sheet.tables.add('Sales', 'A1:D3', {
style: 'TableStyleMedium2', hasHeaderRow: true, showRowStripes: true
});
table.setColumn('Amount', { formula: '=[@Quantity]*[@Price]' });
The code works as follows:
- Workbook.sheets and SheetCollection.at return the first worksheet.
- Worksheet.range and Range.setValues write the column headings and the items. The
Amountcells stay empty, because the table calculates them. - TableCollection.add, reached through Worksheet.tables, creates the table
SalesoverA1:D3with the styleTableStyleMedium2, a header row and row stripes, and returns a Table. - Table.setColumn makes
Amounta calculated column. The structured references[@Quantity]and[@Price]refer to the cells of the same row.
Table names are unique across the workbook. Column names derive from the headers unless you provide them explicitly. Use the table's handle or ID for later updates, and acquire a new handle after the document is replaced.
Choose a Table Style in the Ribbon
Click inside a table, such as SalesData in the sales workbook, to show the Table Design tab, then open More Table Styles:

Choose a preset, then adjust the header and totals rows, the striping, the emphasis and the filter buttons independently. A style tile changes the table's appearance and retains its named columns and formulas. Ribbon and Contextual Commands shows where these commands are located on the Table Design tab.
Set the Display Options and Totals
The display options of a table are independent of each other: the header and totals rows, row and column stripes, emphasis of the first and last column and the filter buttons. The Table Design ribbon groups its style galleries into Light, Medium and Dark. Native style names such as TableStyleMedium2 are retained in XLSX.
A calculated column propagates its formula across all rows of the table. Totals functions and formulas belong to the settings of a column. After a quantity or a rate changes, review the formula results rather than trusting totals cached in an imported file.
Change the Structure
Insert and delete table rows and columns with the methods of the table: insertRows, deleteRows, insertColumns and deleteColumns. Row indices are zero-based and count the data rows only.
- What a structure change keeps. Supported identities are retained and references are adjusted.
- What it rejects. Invalid bounds, protection, split ranges and worksheet overflow reject the operation.
- Removing every column removes the table.
- Converting to a range with remove keeps the content and formatting but removes the operational table object.
- Resizing with resize must leave a valid range that does not overlap another one.
Tables are useful sources for dashboards, because their fields have stable identities.
Custom Table Recipes
Excel custom table styles retain their named role recipes, including header and totals rows, row and column stripes and internal borders. Author the same recipes using customStyle when adding or updating a table. Direct cell formatting takes precedence; conditional formatting has highest priority. Changing the selected style does not rewrite cell contents.
const sheet = book.sheets.at(0);
sheet.range('A1:B4').setValues([['Category', 'Amount'], ['Site', 500], ['Food', 20], ['Program', 30]]);
const table = sheet.tables.add('BudgetLines', 'A1:B4', {
style: 'Budget', showRowStripes: true,
customStyle: { name: 'Budget', elements: [
{ type: 'wholeTable', formatting: { fillColor: '#f2f2f2',
borderEdges: { horizontal: { style: 'thin', color: '#3c7e51' } } } },
{ type: 'headerRow', formatting: { bold: true, fillColor: '#a4d4b4' } },
{ type: 'firstRowStripe', size: 2, formatting: { fillColor: '#d1e8d8' } }
] }
});
Recipes accept up to thirteen unique roles, with stripe sizes from 1 to 4096. Their names must match the selected style. XLSX writes native custom table definitions; ODS also writes the resolved cell appearance; TXWB retains editable recipes. PDF uses the same display-style pipeline.
Next Steps
- Sorting and Filtering: sort, filter and transform the data of a table.
- Creating Dashboards: use a table as the source of a dashboard.
- XLSX Compatibility: check how tables and their styles survive the exchange with Excel.