ws.tables
WorksheetTables
Sub-API for table operations on a worksheet.
50 methods
add
→ Promise<TableInfo>add(range: string | CellRange, options?: TableOptions): Promise<TableInfo>;| Parameter | Type | Required |
|---|---|---|
| range | string | CellRange | required |
| options | TableOptions | optional |
Create a new table from a cell range. @param range - A1-style range string (e.g. "A1:D10") or CellRange object @param options - Optional table creation settings (name, headers, style) @returns The created table information
get
→ Promise<TableInfo | null>get(name: string): Promise<TableInfo | null>;| Parameter | Type | Required |
|---|---|---|
| name | string | required |
Get a table by name. Tables are workbook-scoped, so the name is unique across all sheets. @param name - Table name @returns Table information, or null if not found
has
→ Promise<boolean>has(name: string): Promise<boolean>;| Parameter | Type | Required |
|---|---|---|
| name | string | required |
Check if a table exists by name. @param name - Table name @returns True if the table exists
list
→ Promise<TableInfo[]>list(): Promise<TableInfo[]>;List all tables in this worksheet. @returns Array of table information objects
getCount
→ Promise<number>getCount(): Promise<number>;Get the total number of tables on this worksheet. @returns The count of tables
getItemAt
→ Promise<TableInfo | null>getItemAt(index: number): Promise<TableInfo | null>;| Parameter | Type | Required |
|---|---|---|
| index | number | required |
Get a table by its position in the list of tables on this worksheet. @param index - Zero-based index into the table list @returns Table information, or null if the index is out of range
getFirst
→ Promise<TableInfo | null>getFirst(): Promise<TableInfo | null>;Get the first table on this worksheet. Convenience shortcut equivalent to `getAt(0)`. @returns Table information, or null if no tables exist
getColumnByName
→ Promise<TableColumn | null>getColumnByName(tableName: string, columnName: string): Promise<TableColumn | null>;| Parameter | Type | Required |
|---|---|---|
| tableName | string | required |
| columnName | string | required |
Look up a column in a table by its header name. @param tableName - Table name @param columnName - Column header name to search for @returns The matching column, or null if not found
remove
→ Promise<void>remove(name: string): Promise<void>;| Parameter | Type | Required |
|---|---|---|
| name | string | required |
Remove a table definition, converting it back to a plain range. Cell data is preserved; only the table metadata is removed. @param name - Table name
clear
→ Promise<void>clear(): Promise<void>;Remove all tables from this worksheet.
rename
→ Promise<void>rename(oldName: string, newName: string): Promise<void>;| Parameter | Type | Required |
|---|---|---|
| oldName | string | required |
| newName | string | required |
Rename a table. @param oldName - Current table name @param newName - New table name
update
→ Promise<void>update(tableName: string, updates: TableUpdateOptions): Promise<void>;| Parameter | Type | Required |
|---|---|---|
| tableName | string | required |
| updates | TableUpdateOptions | required |
Update a table's properties. @param tableName - Table name @param updates - Key-value pairs of properties to update
getAtCell
→ Promise<TableInfo | null>getAtCell(address: string): Promise<TableInfo | null>;| Parameter | Type | Required |
|---|---|---|
| address | string | required |
Get the table at a specific cell position, if one exists. @param address - A1-style cell address (e.g. "B3") @returns Table information, or null if no table exists at that cell
clearFilters
→ Promise<void>clearFilters(tableName: string): Promise<void>;| Parameter | Type | Required |
|---|---|---|
| tableName | string | required |
Clear all column filters on a table. @param tableName - Table name
setStylePreset
→ Promise<void>setStylePreset(tableName: string, preset: string): Promise<void>;| Parameter | Type | Required |
|---|---|---|
| tableName | string | required |
| preset | string | required |
Set the visual style preset for a table. @param tableName - Table name @param preset - Style preset name (e.g. "TableStyleLight1")
resize
→ Promise<TableResizeReceipt>resize(name: string, newRange: string | CellRange): Promise<TableResizeReceipt>;| Parameter | Type | Required |
|---|---|---|
| name | string | required |
| newRange | string | CellRange | required |
Resize a table to a new range. @param name - Table name @param newRange - New A1-style range string or CellRange object
addColumn
→ Promise<TableAddColumnReceipt>addColumn(name: string, columnName: string, position?: number): Promise<TableAddColumnReceipt>;| Parameter | Type | Required |
|---|---|---|
| name | string | required |
| columnName | string | required |
| position | number | optional |
Add a column to a table. @param name - Table name @param columnName - Name for the new column @param position - Column position (0-based index). If omitted, appends to the end.
removeColumn
→ Promise<TableRemoveColumnReceipt>removeColumn(name: string, columnIndex: number): Promise<TableRemoveColumnReceipt>;| Parameter | Type | Required |
|---|---|---|
| name | string | required |
| columnIndex | number | required |
Remove a column from a table by index. @param name - Table name @param columnIndex - Column index within the table (0-based)
toggleTotalsRow
→ Promise<void>toggleTotalsRow(name: string): Promise<void>;| Parameter | Type | Required |
|---|---|---|
| name | string | required |
@deprecated Use {@link setShowTotals} instead. Toggle the totals row visibility on a table. @param name - Table name
toggleHeaderRow
→ Promise<void>toggleHeaderRow(name: string): Promise<void>;| Parameter | Type | Required |
|---|---|---|
| name | string | required |
@deprecated Use {@link setShowHeaders} instead. Toggle the header row visibility on a table. @param name - Table name
applyAutoExpansion
→ Promise<void>applyAutoExpansion(tableName: string): Promise<void>;| Parameter | Type | Required |
|---|---|---|
| tableName | string | required |
Apply auto-expansion to a table, extending it to include adjacent data. @param tableName - Table name
setCalculatedColumn
→ Promise<void>setCalculatedColumn(tableName: string, colIndex: number, formula: string): Promise<void>;| Parameter | Type | Required |
|---|---|---|
| tableName | string | required |
| colIndex | number | required |
| formula | string | required |
Set a calculated column formula for all data cells in a table column. @param tableName - Table name @param colIndex - Column index within the table (0-based) @param formula - The formula to set (e.g. "=[@Price]*[@Quantity]")
clearCalculatedColumn
→ Promise<void>clearCalculatedColumn(tableName: string, colIndex: number): Promise<void>;| Parameter | Type | Required |
|---|---|---|
| tableName | string | required |
| colIndex | number | required |
Clear the calculated column formula from a table column, replacing with empty values. @param tableName - Table name @param colIndex - Column index within the table (0-based)
getDataBodyRange
→ Promise<string | null>getDataBodyRange(name: string): Promise<string | null>;| Parameter | Type | Required |
|---|---|---|
| name | string | required |
Get the A1-notation range covering the data body of a table (excludes header and totals rows). @param name - Table name @returns A1-notation range string, or null if the table has no data body rows
getHeaderRowRange
→ Promise<string | null>getHeaderRowRange(name: string): Promise<string | null>;| Parameter | Type | Required |
|---|---|---|
| name | string | required |
Get the A1-notation range covering the header row of a table. @param name - Table name @returns A1-notation range string, or null if the table has no header row
getTotalRowRange
→ Promise<string | null>getTotalRowRange(name: string): Promise<string | null>;| Parameter | Type | Required |
|---|---|---|
| name | string | required |
Get the A1-notation range covering the totals row of a table. @param name - Table name @returns A1-notation range string, or null if the table has no totals row
addRow
→ Promise<TableAddRowReceipt>addRow(tableName: string, index?: number, values?: CellValue[]): Promise<TableAddRowReceipt>;| Parameter | Type | Required |
|---|---|---|
| tableName | string | required |
| index | number | optional |
| values | CellValue[] | optional |
Add a data row to a table. @param tableName - Table name @param index - Row index within the data body (0-based). If omitted, appends to the end. @param values - Optional cell values for the new row
deleteRow
→ Promise<TableDeleteRowReceipt>deleteRow(tableName: string, index: number): Promise<TableDeleteRowReceipt>;| Parameter | Type | Required |
|---|---|---|
| tableName | string | required |
| index | number | required |
Delete a data row from a table. @param tableName - Table name @param index - Row index within the data body (0-based)
deleteRows
→ Promise<void>deleteRows(tableName: string, indices: number[]): Promise<void>;| Parameter | Type | Required |
|---|---|---|
| tableName | string | required |
| indices | number[] | required |
Delete multiple data rows from a table by their data-body-relative indices. Rows are deleted in descending index order to avoid index shifting. @param tableName - Table name @param indices - Array of row indices within the data body (0-based)
deleteRowsAt
→ Promise<void>deleteRowsAt(tableName: string, index: number, count?: number): Promise<void>;| Parameter | Type | Required |
|---|---|---|
| tableName | string | required |
| index | number | required |
| count | number | optional |
Delete one or more contiguous data rows from a table starting at `index`. @param tableName - Table name @param index - Starting row index within the data body (0-based) @param count - Number of rows to delete (default 1)
getRowCount
→ Promise<number>getRowCount(tableName: string): Promise<number>;| Parameter | Type | Required |
|---|---|---|
| tableName | string | required |
Get the number of data rows in a table (excludes header and totals rows). @param tableName - Table name @returns Number of data rows
getRowRange
→ Promise<string>getRowRange(tableName: string, index: number): Promise<string>;| Parameter | Type | Required |
|---|---|---|
| tableName | string | required |
| index | number | required |
Get the A1-notation range for a specific data row. @param tableName - Table name @param index - Row index within the data body (0-based) @returns A1-notation range string
getRowValues
→ Promise<CellValue[]>getRowValues(tableName: string, index: number): Promise<CellValue[]>;| Parameter | Type | Required |
|---|---|---|
| tableName | string | required |
| index | number | required |
Get the cell values of a specific data row. @param tableName - Table name @param index - Row index within the data body (0-based) @returns Array of cell values
setRowValues
→ Promise<void>setRowValues(tableName: string, index: number, values: CellValue[]): Promise<void>;| Parameter | Type | Required |
|---|---|---|
| tableName | string | required |
| index | number | required |
| values | CellValue[] | required |
Set the cell values of a specific data row. @param tableName - Table name @param index - Row index within the data body (0-based) @param values - Cell values to set
getColumnDataBodyRange
→ Promise<string | null>getColumnDataBodyRange(tableName: string, columnIndex: number): Promise<string | null>;| Parameter | Type | Required |
|---|---|---|
| tableName | string | required |
| columnIndex | number | required |
Get the A1-notation range covering the data body cells of a table column. @param tableName - Table name @param columnIndex - Column index within the table (0-based) @returns A1-notation range string, or null if no data body rows
getColumnHeaderRange
→ Promise<string | null>getColumnHeaderRange(tableName: string, columnIndex: number): Promise<string | null>;| Parameter | Type | Required |
|---|---|---|
| tableName | string | required |
| columnIndex | number | required |
Get the A1-notation range covering the header cell of a table column. @param tableName - Table name @param columnIndex - Column index within the table (0-based) @returns A1-notation range string, or null if no header row
getColumnRange
→ Promise<string | null>getColumnRange(tableName: string, columnIndex: number): Promise<string | null>;| Parameter | Type | Required |
|---|---|---|
| tableName | string | required |
| columnIndex | number | required |
Get the A1-notation range covering the entire table column (header + data + totals). @param tableName - Table name @param columnIndex - Column index within the table (0-based) @returns A1-notation range string, or null if column does not exist
getColumnTotalRange
→ Promise<string | null>getColumnTotalRange(tableName: string, columnIndex: number): Promise<string | null>;| Parameter | Type | Required |
|---|---|---|
| tableName | string | required |
| columnIndex | number | required |
Get the A1-notation range covering the totals cell of a table column. @param tableName - Table name @param columnIndex - Column index within the table (0-based) @returns A1-notation range string, or null if no totals row
getColumnValues
→ Promise<CellValue[]>getColumnValues(tableName: string, columnIndex: number): Promise<CellValue[]>;| Parameter | Type | Required |
|---|---|---|
| tableName | string | required |
| columnIndex | number | required |
Get the cell values of a table column (data body only). @param tableName - Table name @param columnIndex - Column index within the table (0-based) @returns Array of cell values
setColumnValues
→ Promise<void>setColumnValues(tableName: string, columnIndex: number, values: CellValue[]): Promise<void>;| Parameter | Type | Required |
|---|---|---|
| tableName | string | required |
| columnIndex | number | required |
| values | CellValue[] | required |
Set the cell values of a table column (data body only). @param tableName - Table name @param columnIndex - Column index within the table (0-based) @param values - Cell values to set
setHighlightFirstColumn
→ Promise<void>setHighlightFirstColumn(tableName: string, value: boolean): Promise<void>;| Parameter | Type | Required |
|---|---|---|
| tableName | string | required |
| value | boolean | required |
Set whether the first column is highlighted. @param tableName - Table name @param value - Whether to highlight the first column
setHighlightLastColumn
→ Promise<void>setHighlightLastColumn(tableName: string, value: boolean): Promise<void>;| Parameter | Type | Required |
|---|---|---|
| tableName | string | required |
| value | boolean | required |
Set whether the last column is highlighted. @param tableName - Table name @param value - Whether to highlight the last column
setShowBandedColumns
→ Promise<void>setShowBandedColumns(tableName: string, value: boolean): Promise<void>;| Parameter | Type | Required |
|---|---|---|
| tableName | string | required |
| value | boolean | required |
Set whether banded columns are shown. @param tableName - Table name @param value - Whether to show banded columns
setShowBandedRows
→ Promise<void>setShowBandedRows(tableName: string, value: boolean): Promise<void>;| Parameter | Type | Required |
|---|---|---|
| tableName | string | required |
| value | boolean | required |
Set whether banded rows are shown. @param tableName - Table name @param value - Whether to show banded rows
setShowFilterButton
→ Promise<void>setShowFilterButton(tableName: string, value: boolean): Promise<void>;| Parameter | Type | Required |
|---|---|---|
| tableName | string | required |
| value | boolean | required |
Set whether filter buttons are shown on the header row. @param tableName - Table name @param value - Whether to show filter buttons
setShowHeaders
→ Promise<void>setShowHeaders(tableName: string, visible: boolean): Promise<void>;| Parameter | Type | Required |
|---|---|---|
| tableName | string | required |
| visible | boolean | required |
Set whether the header row is visible. @param tableName - Table name @param visible - Whether to show the header row
setShowTotals
→ Promise<void>setShowTotals(tableName: string, visible: boolean): Promise<void>;| Parameter | Type | Required |
|---|---|---|
| tableName | string | required |
| visible | boolean | required |
Set whether the totals row is visible. @param tableName - Table name @param visible - Whether to show the totals row
applyIconFilter
→ Promise<void>applyIconFilter(
tableName: string,
columnIndex: number,
icon: { set: string; index: number },
): Promise<void>;| Parameter | Type | Required |
|---|---|---|
| tableName | string | required |
| columnIndex | number | required |
| icon | { set: string; index: number } | required |
Apply an icon filter to a table column. Filters rows by conditional formatting icon: only rows whose evaluated CF icon matches the specified icon set and index are shown. Requires an icon set CF rule applied to the column's range. @param tableName - Table name @param columnIndex - Column index within the table (0-based) @param icon - Icon to filter by: set name (e.g. "3Arrows") and index (0-based)
getAutoFilter
→ Promise<FilterInfo | null>getAutoFilter(tableName: string): Promise<FilterInfo | null>;| Parameter | Type | Required |
|---|---|---|
| tableName | string | required |
Get the auto-filter associated with a table. @param tableName - Table name @returns Filter information, or null if the table has no associated filter
getRows
→ Promise<TableRowCollection>getRows(tableName: string): Promise<TableRowCollection>;| Parameter | Type | Required |
|---|---|---|
| tableName | string | required |
Get a collection-like wrapper around the table's data rows. The returned object delegates to the existing row methods on this API. The `count` property is a snapshot taken at call time and does not live-update. @param tableName - Table name @returns A TableRowCollection object