# ExcelTable

Lightweight object model wrapper for an Excel table.

Class 

`OfficeIMO.Excel`

**Namespace**

`OfficeIMO.Excel`

**Assembly**

`OfficeIMO.Excel`

**Source revision**

`273d35d5ba8a` with working tree changes

**Source**

[ExcelCell.cs:761](https://github.com/EvotecIT/OfficeIMO/blob/273d35d5ba8ab8ce3f6f1238631241c0cea26d14/OfficeIMO.Excel/ExcelCell.cs#L761)

**Modifiers**

sealed

Lightweight object model wrapper for an Excel table.

## Inheritance

- object
- ExcelTable

## Guides & Samples

Authored walkthroughs and practical samples linked to this API.

- [Excel Workbooks](/docs/excel/) Guide
  
  Overview of the OfficeIMO.Excel package for creating and manipulating Excel spreadsheets. Includes examples and API links.

## Usage

Explore 15 API references to this type

This type appears in these public API surfaces even when no hand-authored example is attached directly to the page.

### Returned or exposed by 15

- Method [ExcelRange.CreateTable](/api/excel/officeimo-excel-excelrange/#method-createtable-string-boolean-officeimo-excel-exceltablestyle-boolean)
- Method [ExcelReportBuilder.AddTable](/api/excel/officeimo-excel-excelreportbuilder/#method-addtable-data-datatable-string-action-officeimo-data-objectflatteneroptions-officeimo-excel-exceltablestyle-boolean-boolean-action-officeimo-excel-exceltablevisualoptions)
- Method [ExcelReportBuilder.AddTable``1](/api/excel/officeimo-excel-excelreportbuilder/#method-addtable-collections-generic-ienumerable-string-action-officeimo-data-objectflatteneroptions-officeimo-excel-exceltablestyle-boolean-boolean-action-officeimo-excel-exceltablevisualoptions)
- Method [ColumnComposer.AddTable``1](/api/excel/officeimo-excel-excelreportbuilder-columncomposer/#method-addtable-collections-generic-ienumerable-string-action-officeimo-data-objectflatteneroptions-officeimo-excel-exceltablestyle-boolean-action-officeimo-excel-exceltablevisualoptions)
- Method [ExcelSheet.AddTable](/api/excel/officeimo-excel-excelsheet/#method-addtable-string-boolean-string-officeimo-excel-exceltablestyle-boolean-officeimo-excel-exceltablenamevalidationmode)
- Method [ExcelSheet.AddTable``1](/api/excel/officeimo-excel-excelsheet/#method-addtable-collections-generic-ienumerable-officeimo-officetableoptions-int32-int32)
- Method [ExcelSheet.Table](/api/excel/officeimo-excel-excelsheet/#method-table-string)
- Method [ExcelTable.AppendDataTable](/api/excel/officeimo-excel-exceltable/#method-appenddatatable-data-datatable)
- Method [ExcelTable.ClearTotals](/api/excel/officeimo-excel-exceltable/#method-cleartotals)
- Method [ExcelTable.Rename](/api/excel/officeimo-excel-exceltable/#method-rename-string-officeimo-excel-exceltablenamevalidationmode)
- Method [ExcelTable.Resize](/api/excel/officeimo-excel-exceltable/#method-resize-string)
- Method [ExcelTable.SetSchema](/api/excel/officeimo-excel-exceltable/#method-setschema-collections-generic-ireadonlylist-system-string-string)
- Method [ExcelTable.SetStyle](/api/excel/officeimo-excel-exceltable/#method-setstyle-officeimo-excel-exceltablestyle-nullable-system-boolean-nullable-system-boolean-nullable-system-boolean-nullable-system-boolean)
- Method [ExcelTable.SetTotals](/api/excel/officeimo-excel-exceltable/#method-settotals-collections-generic-idictionary-system-string-officeimo-excel-exceltabletotalsfunction)
- Method [ExcelTable.SortByColumn](/api/excel/officeimo-excel-exceltable/#method-sortbycolumn-int32-boolean)

Filter members 

Show inherited

## Methods

`public ExcelTable AppendDataTable(DataTable table)` [#](#method-appenddatatable-data-datatable)

[ExcelCell.cs:816](https://github.com/EvotecIT/OfficeIMO/blob/273d35d5ba8ab8ce3f6f1238631241c0cea26d14/OfficeIMO.Excel/ExcelCell.cs#L816)

Appends rows from a data table to the Excel table.

Parameters

**table System.Data.DataTable required**

Returns

`ExcelTable`

`public ExcelRange AsRange()` [#](#method-asrange)

[ExcelCell.cs:761](https://github.com/EvotecIT/OfficeIMO/blob/273d35d5ba8ab8ce3f6f1238631241c0cea26d14/OfficeIMO.Excel/ExcelCell.cs#L761)

Returns the table as a range wrapper.

Returns

`ExcelRange`

`public ExcelTable ClearTotals()` [#](#method-cleartotals)

[ExcelCell.cs:789](https://github.com/EvotecIT/OfficeIMO/blob/273d35d5ba8ab8ce3f6f1238631241c0cea26d14/OfficeIMO.Excel/ExcelCell.cs#L789)

Clears totals row settings from the table.

Returns

`ExcelTable`

`public ExcelRange Column(string headerName, bool includeHeader = false, bool normalizeHeader = true)` [#](#method-column-string-boolean-boolean)

[ExcelCell.cs:832](https://github.com/EvotecIT/OfficeIMO/blob/273d35d5ba8ab8ce3f6f1238631241c0cea26d14/OfficeIMO.Excel/ExcelCell.cs#L832)

Resolves a data-column range in this table by its header text.

Parameters

**headerName string required**

**includeHeader bool = false optional**

**normalizeHeader bool = true optional**

Returns

`ExcelRange`

`public ExcelTable Rename(string newName, ExcelTableNameValidationMode validationMode = Strict)` [#](#method-rename-string-officeimo-excel-exceltablenamevalidationmode)

[ExcelCell.cs:795](https://github.com/EvotecIT/OfficeIMO/blob/273d35d5ba8ab8ce3f6f1238631241c0cea26d14/OfficeIMO.Excel/ExcelCell.cs#L795)

Renames this table and its workbook references.

Parameters

**newName string required**

**validationMode OfficeIMO.Excel.ExcelTableNameValidationMode = Strict optional**

Returns

`ExcelTable`

`public ExcelTable Resize(string newRange)` [#](#method-resize-string)

[ExcelCell.cs:807](https://github.com/EvotecIT/OfficeIMO/blob/273d35d5ba8ab8ce3f6f1238631241c0cea26d14/OfficeIMO.Excel/ExcelCell.cs#L807)

Resizes the table, preserving current column names where possible.

Parameters

**newRange string required**

Returns

`ExcelTable`

`public IEnumerable<T> RowsAs<T>(ExcelReaderOptions? options = null, CancellationToken cancellationToken = default)` [#](#method-rowsas-officeimo-excel-excelreaderoptions-threading-cancellationtoken)

Streams this table's data rows as typed models, using its column schema. Header and totals rows are excluded, including for tables with hidden headers. Enumerate while the owning workbook remains open; unsaved edits are included.

Type Parameters

**T**

Parameters

**options OfficeIMO.Excel.ExcelReaderOptions? = null optional**

Conversion, culture and safety options for reading the values.

**cancellationToken System.Threading.CancellationToken = default optional**

Cancels table discovery and row enumeration.

Returns

`IEnumerable<T>`

`public ExcelTable SetSchema(IReadOnlyList<string> columnNames, string? newRange = null)` [#](#method-setschema-collections-generic-ireadonlylist-system-string-string)

[ExcelCell.cs:800](https://github.com/EvotecIT/OfficeIMO/blob/273d35d5ba8ab8ce3f6f1238631241c0cea26d14/OfficeIMO.Excel/ExcelCell.cs#L800)

Replaces the table's ordered column schema and optionally resizes its range.

Parameters

**columnNames System.Collections.Generic.IReadOnlyList<string> required**

**newRange string? = null optional**

Returns

`ExcelTable`

`public ExcelTable SetStyle(ExcelTableStyle style, bool? showFirstColumn = null, bool? showLastColumn = null, bool? showRowStripes = null, bool? showColumnStripes = null)` [#](#method-setstyle-officeimo-excel-exceltablestyle-nullable-system-boolean-nullable-system-boolean-nullable-system-boolean-nullable-system-boolean)

[ExcelCell.cs:773](https://github.com/EvotecIT/OfficeIMO/blob/273d35d5ba8ab8ce3f6f1238631241c0cea26d14/OfficeIMO.Excel/ExcelCell.cs#L773)

Applies a built-in table style and optional style flags.

Parameters

**style OfficeIMO.Excel.ExcelTableStyle required**

**showFirstColumn bool? = null optional**

**showLastColumn bool? = null optional**

**showRowStripes bool? = null optional**

**showColumnStripes bool? = null optional**

Returns

`ExcelTable`

`public ExcelTable SetTotals(IDictionary<string, ExcelTableTotalsFunction> byHeader)` [#](#method-settotals-collections-generic-idictionary-system-string-officeimo-excel-exceltabletotalsfunction)

[ExcelCell.cs:781](https://github.com/EvotecIT/OfficeIMO/blob/273d35d5ba8ab8ce3f6f1238631241c0cea26d14/OfficeIMO.Excel/ExcelCell.cs#L781)

Applies totals row functions by header name.

Parameters

**byHeader System.Collections.Generic.IDictionary<string, OfficeIMO.Excel.ExcelTableTotalsFunction> required**

Returns

`ExcelTable`

`public ExcelTable SortByColumn(int columnOffset, bool ascending = true)` [#](#method-sortbycolumn-int32-boolean)

[ExcelCell.cs:824](https://github.com/EvotecIT/OfficeIMO/blob/273d35d5ba8ab8ce3f6f1238631241c0cea26d14/OfficeIMO.Excel/ExcelCell.cs#L824)

Sorts table rows by a 1-based column offset.

Parameters

**columnOffset int required**

**ascending bool = true optional**

Returns

`ExcelTable`

## Inherited Methods

`public virtual bool Equals(object? obj)` [#](#method-equals-object)

Inherited from object

Parameters

**obj object? required**

Returns

`bool`

`public virtual int GetHashCode()` [#](#method-gethashcode)

Inherited from object

Returns

`int`

`public Type GetType()` [#](#method-gettype)

Inherited from object

Returns

`Type`

`public virtual string? ToString()` [#](#method-tostring)

Inherited from object

Returns

`string?`

## Properties

`public ExcelSheet Sheet { get; }` [#](#property-sheet)

[ExcelCell.cs:751](https://github.com/EvotecIT/OfficeIMO/blob/273d35d5ba8ab8ce3f6f1238631241c0cea26d14/OfficeIMO.Excel/ExcelCell.cs#L751)

Gets the worksheet that owns the table.

`public string NameOrRange { get; }` [#](#property-nameorrange)

[ExcelCell.cs:753](https://github.com/EvotecIT/OfficeIMO/blob/273d35d5ba8ab8ce3f6f1238631241c0cea26d14/OfficeIMO.Excel/ExcelCell.cs#L753)

Gets the table name, display name, or A1 range used to locate the table.

`public string? Range { get; }` [#](#property-range)

[ExcelCell.cs:755](https://github.com/EvotecIT/OfficeIMO/blob/273d35d5ba8ab8ce3f6f1238631241c0cea26d14/OfficeIMO.Excel/ExcelCell.cs#L755)

Gets the table range when it can be resolved.

<!-- PowerForge markdown artifact sha256:9442F96E0D3D742A83F83A7102181DEB635F76BB61C63EF30DCBF8449608C540 -->
