Skip to content

ws.tables

WorksheetTables

Sub-API for table operations on a worksheet.

50 methods

add

Promise<TableInfo>
add(range: string | CellRange, options?: TableOptions): Promise<TableInfo>;
ParameterTypeRequired
rangestring | CellRangerequired
optionsTableOptionsoptional

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>;
ParameterTypeRequired
namestringrequired

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>;
ParameterTypeRequired
namestringrequired

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>;
ParameterTypeRequired
indexnumberrequired

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>;
ParameterTypeRequired
tableNamestringrequired
columnNamestringrequired

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>;
ParameterTypeRequired
namestringrequired

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>;
ParameterTypeRequired
oldNamestringrequired
newNamestringrequired

Rename a table. @param oldName - Current table name @param newName - New table name

update

Promise<void>
update(tableName: string, updates: TableUpdateOptions): Promise<void>;
ParameterTypeRequired
tableNamestringrequired
updatesTableUpdateOptionsrequired

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>;
ParameterTypeRequired
addressstringrequired

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>;
ParameterTypeRequired
tableNamestringrequired

Clear all column filters on a table. @param tableName - Table name

setStylePreset

Promise<void>
setStylePreset(tableName: string, preset: string): Promise<void>;
ParameterTypeRequired
tableNamestringrequired
presetstringrequired

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>;
ParameterTypeRequired
namestringrequired
newRangestring | CellRangerequired

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>;
ParameterTypeRequired
namestringrequired
columnNamestringrequired
positionnumberoptional

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>;
ParameterTypeRequired
namestringrequired
columnIndexnumberrequired

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>;
ParameterTypeRequired
namestringrequired

@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>;
ParameterTypeRequired
namestringrequired

@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>;
ParameterTypeRequired
tableNamestringrequired

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>;
ParameterTypeRequired
tableNamestringrequired
colIndexnumberrequired
formulastringrequired

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>;
ParameterTypeRequired
tableNamestringrequired
colIndexnumberrequired

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>;
ParameterTypeRequired
namestringrequired

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>;
ParameterTypeRequired
namestringrequired

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>;
ParameterTypeRequired
namestringrequired

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>;
ParameterTypeRequired
tableNamestringrequired
indexnumberoptional
valuesCellValue[]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>;
ParameterTypeRequired
tableNamestringrequired
indexnumberrequired

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>;
ParameterTypeRequired
tableNamestringrequired
indicesnumber[]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>;
ParameterTypeRequired
tableNamestringrequired
indexnumberrequired
countnumberoptional

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>;
ParameterTypeRequired
tableNamestringrequired

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>;
ParameterTypeRequired
tableNamestringrequired
indexnumberrequired

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[]>;
ParameterTypeRequired
tableNamestringrequired
indexnumberrequired

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>;
ParameterTypeRequired
tableNamestringrequired
indexnumberrequired
valuesCellValue[]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>;
ParameterTypeRequired
tableNamestringrequired
columnIndexnumberrequired

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>;
ParameterTypeRequired
tableNamestringrequired
columnIndexnumberrequired

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>;
ParameterTypeRequired
tableNamestringrequired
columnIndexnumberrequired

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>;
ParameterTypeRequired
tableNamestringrequired
columnIndexnumberrequired

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[]>;
ParameterTypeRequired
tableNamestringrequired
columnIndexnumberrequired

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>;
ParameterTypeRequired
tableNamestringrequired
columnIndexnumberrequired
valuesCellValue[]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>;
ParameterTypeRequired
tableNamestringrequired
valuebooleanrequired

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>;
ParameterTypeRequired
tableNamestringrequired
valuebooleanrequired

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>;
ParameterTypeRequired
tableNamestringrequired
valuebooleanrequired

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>;
ParameterTypeRequired
tableNamestringrequired
valuebooleanrequired

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>;
ParameterTypeRequired
tableNamestringrequired
valuebooleanrequired

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>;
ParameterTypeRequired
tableNamestringrequired
visiblebooleanrequired

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>;
ParameterTypeRequired
tableNamestringrequired
visiblebooleanrequired

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>;
ParameterTypeRequired
tableNamestringrequired
columnIndexnumberrequired
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>;
ParameterTypeRequired
tableNamestringrequired

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>;
ParameterTypeRequired
tableNamestringrequired

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