Skip to main content

Cell.Table

Cell.Table is an object type of the Spreadsheet module (Office.cell(iframe)). 15 methods.

Remarks​

  • Module: Spreadsheet · Office.cell(iframe) · namespace Cell
  • Obtained from: Workbook.getTable(name), Worksheet.addTable(dataRange, hasHeaders)
  • Navigation methods (getFilter(), getRange()) return a child handle synchronously without a round trip; the request is sent by the next terminal call. Every other method returns a Promise.

Methods​

MethodDescription
delete()Deletes the table.
getFilter()Returns the Filter for the AutoFilter of this table.
getInfo()Returns the name, location, range, and display options of the table in a single call.
getName()Returns the table name.
getOptions()Returns the display options of the table in a single call.
getRange()Returns a Range for the entire table range, including the header row and totals row.
resize(range)Changes the table range to a new range.
setBandedColumns(isOn)Changes whether alternate columns are shaded in different colors.
setBandedRows(isOn)Changes whether alternate rows are shaded in different colors.
setFirstColumn(isOn)Changes whether the first column is highlighted.
setHeaderRow(isOn)Changes whether the header row is shown.
setLastColumn(isOn)Changes whether the last column is highlighted.
setName(name)Renames the table.
setOptions(options)Changes the display options of the table.
setTotalsRow(isOn)Changes whether the totals row is shown.

Method details​

delete()​

Deletes the table. Removes the table definition and the AutoFilter of the table, and clears the cell content of the table range.

delete(): Promise<void>;

Returns

none

getFilter()​

Returns the Filter for the AutoFilter of this table. Because filtering is inherent to the table structure, a Filter is returned even if no filter has been created yet. Check whether a filter exists with getInfo() of the Filter. A Filter obtained before the table is renamed can no longer be used.

getFilter(): Filter;

Returns

Filter

getInfo()​

Returns the name, location, range, and display options of the table in a single call.

getInfo(): Promise<TableInfo>;

Returns

Promise<TableInfo>

getName()​

Returns the table name.

getName(): Promise<string>;

Returns

Promise<string>

getOptions()​

Returns the display options of the table in a single call.

getOptions(): Promise<TableOptions>;

Returns

Promise<TableOptions>

getRange()​

Returns a Range for the entire table range, including the header row and totals row. The returned Range holds the coordinates at the time of the call and does not follow later changes to the table range.

getRange(): Range;

Returns

Range

resize(range)​

Changes the table range to a new range. The new range must keep the header row in place while overlapping the current table range, must contain at least two cells, and cannot be entire rows or entire columns. Passing the same range as the current table range does nothing.

resize(range: string | RangeCoords): Promise<void>;

Parameters

NameTypeDescription
rangestring | RangeCoordsnew table range. An A1 notation string is also accepted ("A1:B2", or "E10" for a single cell)

Returns

none

setBandedColumns(isOn)​

Changes whether alternate columns are shaded in different colors.

setBandedColumns(isOn: boolean): Promise<void>;

Parameters

NameTypeDescription
isOnbooleantrue to turn on, false to turn off

Returns

none

setBandedRows(isOn)​

Changes whether alternate rows are shaded in different colors.

setBandedRows(isOn: boolean): Promise<void>;

Parameters

NameTypeDescription
isOnbooleantrue to turn on, false to turn off

Returns

none

setFirstColumn(isOn)​

Changes whether the first column is highlighted.

setFirstColumn(isOn: boolean): Promise<void>;

Parameters

NameTypeDescription
isOnbooleantrue to turn on, false to turn off

Returns

none

setHeaderRow(isOn)​

Changes whether the header row is shown. When turned on, if the adjacent row just outside the table is not empty, a new row is inserted into the sheet and the content below is pushed down. When turned off, the cell values in that row are cleared. Turning on the header row also creates the table's AutoFilter, and turning it off removes it.

setHeaderRow(isOn: boolean): Promise<void>;

Parameters

NameTypeDescription
isOnbooleantrue to turn on, false to turn off

Returns

none

setLastColumn(isOn)​

Changes whether the last column is highlighted.

setLastColumn(isOn: boolean): Promise<void>;

Parameters

NameTypeDescription
isOnbooleantrue to turn on, false to turn off

Returns

none

setName(name)​

Renames the table. This Table points to the new name and can still be used, but other Table objects that pointed to the same table and any Filter obtained from this table beforehand can no longer be used. The table cannot be renamed if a table or defined name with the same name already exists, and the comparison is case-insensitive.

setName(name: string): Promise<void>;

Parameters

NameTypeDescription
namestringnew table name. It cannot contain spaces or disallowed characters, and names that read as cell references and names longer than the maximum length are not accepted

Returns

none

setOptions(options)​

Changes the display options of the table. Only the specified options are applied, and the rest keep their current values. When the header row or totals row is turned on, if the adjacent row just outside the table is not empty, a new row is inserted into the sheet and the content below is pushed down. When turned off, the cell values in that row are cleared. Turning on the header row also creates the table's AutoFilter, and turning it off removes it. The table style cannot be changed with this method.

setOptions(options: TableOptionUpdate): Promise<void>;

Parameters

NameTypeDescription
optionsTableOptionUpdateoptions to change

Returns

none

setTotalsRow(isOn)​

Changes whether the totals row is shown. When turned on, if the adjacent row just outside the table is not empty, a new row is inserted into the sheet and the content below is pushed down. When turned off, the cell values in that row are cleared.

setTotalsRow(isOn: boolean): Promise<void>;

Parameters

NameTypeDescription
isOnbooleantrue to turn on, false to turn off

Returns

none