Class ExcelTable
An Excel Table
Implements
Inherited Members
Namespace: OfficeOpenXml.Table
Assembly: EPPlus.dll
Syntax
public class ExcelTable : ExcelTableDxfBase, IEqualityComparer<ExcelTable>
Properties
Address
The address of the table
Declaration
public ExcelAddressBase Address { get; }
Property Value
Type | Description |
---|---|
ExcelAddressBase |
AutoFilter
Autofilter settings for the table
Declaration
public ExcelAutoFilter AutoFilter { get; }
Property Value
Type | Description |
---|---|
ExcelAutoFilter |
Columns
Collection of the columns in the table
Declaration
public ExcelTableColumnCollection Columns { get; }
Property Value
Type | Description |
---|---|
ExcelTableColumnCollection |
DataCellStyleName
Named style used for the data cells
Declaration
public string DataCellStyleName { get; set; }
Property Value
Type | Description |
---|---|
System.String |
HeaderRowBorderStyle
Sets differential formatting styles for the table header row border style.
Declaration
public ExcelDxfBorderBase HeaderRowBorderStyle { get; set; }
Property Value
Type | Description |
---|---|
ExcelDxfBorderBase |
HeaderRowCellStyle
Named style used for the header row
Declaration
public string HeaderRowCellStyle { get; set; }
Property Value
Type | Description |
---|---|
System.String |
Name
The name of the table object in Excel
Declaration
public string Name { get; set; }
Property Value
Type | Description |
---|---|
System.String |
Range
The table range
Declaration
public ExcelRangeBase Range { get; }
Property Value
Type | Description |
---|---|
ExcelRangeBase |
ShowColumnStripes
Display banded columns
Declaration
public bool ShowColumnStripes { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
ShowFilter
If the header row has an autofilter
Declaration
public bool ShowFilter { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
ShowFirstColumn
Display special formatting for the first row
Declaration
public bool ShowFirstColumn { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
ShowHeader
If the header row is visible or not
Declaration
public bool ShowHeader { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
ShowLastColumn
Display special formatting for the last row
Declaration
public bool ShowLastColumn { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
ShowRowStripes
Display banded rows
Declaration
public bool ShowRowStripes { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
ShowTotal
If the total row is visible or not
Declaration
public bool ShowTotal { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
SortState
Gets the sort state of the table. Sort(Action<TableSortOptions>) Sort(TableSortOptions)
Declaration
public SortState SortState { get; }
Property Value
Type | Description |
---|---|
SortState |
StyleName
The style name for custum styles
Declaration
public string StyleName { get; set; }
Property Value
Type | Description |
---|---|
System.String |
TableBorderStyle
Sets differential formatting styles for the tables row border style.
Declaration
public ExcelDxfBorderBase TableBorderStyle { get; set; }
Property Value
Type | Description |
---|---|
ExcelDxfBorderBase |
TableStyle
The table style. If this property is custom, the style from the StyleName propery is used.
Declaration
public TableStyles TableStyle { get; set; }
Property Value
Type | Description |
---|---|
TableStyles |
TableUri
The package internal URI to the Table Xml Document.
Declaration
public Uri TableUri { get; }
Property Value
Type | Description |
---|---|
System.Uri |
TableXml
Provides access to the XML data representing the table in the package.
Declaration
public XmlDocument TableXml { get; set; }
Property Value
Type | Description |
---|---|
System.Xml.XmlDocument |
TotalsRowCellStyle
Named style used for the total row
Declaration
public string TotalsRowCellStyle { get; set; }
Property Value
Type | Description |
---|---|
System.String |
WorkSheet
The worksheet of the table
Declaration
public ExcelWorksheet WorkSheet { get; set; }
Property Value
Type | Description |
---|---|
ExcelWorksheet |
Methods
AddRow(Int32)
Adds new rows to the table.
Declaration
public ExcelRangeBase AddRow(int rows = 1)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | rows | Number of rows to add to the table. Default is 1 |
Returns
Type | Description |
---|---|
ExcelRangeBase |
CreateHtmlExporter()
Creates an IExcelHtmlTableExporter object to export the table to HTML
Declaration
public IExcelHtmlTableExporter CreateHtmlExporter()
Returns
Type | Description |
---|---|
IExcelHtmlTableExporter | The exporter object |
DeleteRow(Int32, Int32)
Deletes one or more rows at the specified position in the table.
Declaration
public ExcelRangeBase DeleteRow(int position, int rows = 1)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | position | The position in the table where the row will be deleted. 0 will delete the first row. |
System.Int32 | rows | Number of rows to delete. |
Returns
Type | Description |
---|---|
ExcelRangeBase |
Equals(ExcelTable, ExcelTable)
Checkes if two tables are the same
Declaration
public bool Equals(ExcelTable x, ExcelTable y)
Parameters
Type | Name | Description |
---|---|---|
ExcelTable | x | Table 1 |
ExcelTable | y | Table 2 |
Returns
Type | Description |
---|---|
System.Boolean |
GetHashCode(ExcelTable)
Returns a hashcode generated from the TableXml
Declaration
public int GetHashCode(ExcelTable obj)
Parameters
Type | Name | Description |
---|---|---|
ExcelTable | obj | The table |
Returns
Type | Description |
---|---|
System.Int32 | The hashcode |
InsertRow(Int32, Int32, Boolean)
Inserts one or more rows before the specified position in the table.
Declaration
public ExcelRangeBase InsertRow(int position, int rows = 1, bool copyStyles = true)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | position | The position in the table where the row will be inserted. Default is in the end of the table. 0 will insert the row at the top. Any value larger than the number of rows in the table will insert a row at the bottom of the table. |
System.Int32 | rows | Number of rows to insert. |
System.Boolean | copyStyles | Copy styles from the row above. If inserting a row at position 0, the first row will be used as a template. |
Returns
Type | Description |
---|---|
ExcelRangeBase | The inserted range |
SaveToJson(Stream)
Saves the table as a JSON string to a string
Declaration
public void SaveToJson(Stream stream)
Parameters
Type | Name | Description |
---|---|---|
System.IO.Stream | stream | The stream to write the JSON to. |
SaveToJson(Stream, Action<JsonTableExportSettings>)
Saves the table as a JSON string to a string
Declaration
public void SaveToJson(Stream stream, Action<JsonTableExportSettings> settings)
Parameters
Type | Name | Description |
---|---|---|
System.IO.Stream | stream | The stream to write the JSON to. |
System.Action<JsonTableExportSettings> | settings | Settings to configure the JSON output |
SaveToJsonAsync(Stream)
Save the table to json
Declaration
public async Task SaveToJsonAsync(Stream stream)
Parameters
Type | Name | Description |
---|---|---|
System.IO.Stream | stream | The stream to save to. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task |
SaveToJsonAsync(Stream, Action<JsonTableExportSettings>)
Save the table to json
Declaration
public async Task SaveToJsonAsync(Stream stream, Action<JsonTableExportSettings> settings)
Parameters
Type | Name | Description |
---|---|---|
System.IO.Stream | stream | The stream to save to. |
System.Action<JsonTableExportSettings> | settings | Settings for the json output. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task |
SaveToText(FileInfo, ExcelOutputTextFormat)
Exports the table to a file
Declaration
public void SaveToText(FileInfo file, ExcelOutputTextFormat format)
Parameters
Type | Name | Description |
---|---|---|
System.IO.FileInfo | file | The export file |
ExcelOutputTextFormat | format | Export options |
See Also
SaveToText(Stream, ExcelOutputTextFormat)
Exports the table to a System.IO.Stream
Declaration
public void SaveToText(Stream stream, ExcelOutputTextFormat format)
Parameters
Type | Name | Description |
---|---|---|
System.IO.Stream | stream | Data will be exported to this stream |
ExcelOutputTextFormat | format | Export options |
See Also
SaveToTextAsync(FileInfo, ExcelOutputTextFormat)
Exports the table to a file
Declaration
public async Task SaveToTextAsync(FileInfo file, ExcelOutputTextFormat format)
Parameters
Type | Name | Description |
---|---|---|
System.IO.FileInfo | file | Data will be exported to this stream |
ExcelOutputTextFormat | format | Export options |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task |
See Also
SaveToTextAsync(Stream, ExcelOutputTextFormat)
Exports the table to a System.IO.Stream
Declaration
public async Task SaveToTextAsync(Stream stream, ExcelOutputTextFormat format)
Parameters
Type | Name | Description |
---|---|---|
System.IO.Stream | stream | Data will be exported to this stream |
ExcelOutputTextFormat | format | Export options |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task |
See Also
Sort(TableSortOptions)
Sorts the data in the table according to the supplied RangeSortOptions
Declaration
public void Sort(TableSortOptions options)
Parameters
Type | Name | Description |
---|---|---|
TableSortOptions | options |
Examples
var options = new SortOptions();
options.SortBy.Column(0).ThenSortBy.Column(1, eSortDirection.Descending);
Sort(Action<TableSortOptions>)
Sorts the data in the table according to the supplied action of RangeSortOptions
Declaration
public void Sort(Action<TableSortOptions> configuration)
Parameters
Type | Name | Description |
---|---|---|
System.Action<TableSortOptions> | configuration | An action with parameters for sorting |
Examples
table.Sort(x => x.SortBy.Column(0).ThenSortBy.Column(1, eSortDirection.Descending);
ToCollection<T>()
Returns a collection of T for the tables data range. The total row is not included. The table must have headers. Headers will be mapped to properties using the name or the objects attributes without white spaces. The attributes that can be used are: EpplusTableColumnAttributeBase.Header, DescriptionAttribute.Description or DisplayNameAttribute.Name.
Declaration
public List<T> ToCollection<T>()
Returns
Type | Description |
---|---|
System.Collections.Generic.List<T> | A list of T |
Type Parameters
Name | Description |
---|---|
T | The type to map to |
ToCollection<T>(ToCollectionTableOptions)
Returns a collection of T for the tables data range. The total row is not included. The table must have headers. Headers will be mapped to properties using the name or the property attributes without white spaces. The attributes that can be used are: EpplusTableColumnAttributeBase.Header, DescriptionAttribute.Description or DisplayNameAttribute.Name.
Declaration
public List<T> ToCollection<T>(ToCollectionTableOptions options)
Parameters
Type | Name | Description |
---|---|---|
ToCollectionTableOptions | options | Settings for the method |
Returns
Type | Description |
---|---|
System.Collections.Generic.List<T> | A list of T |
Type Parameters
Name | Description |
---|---|
T | The type to map to |
ToCollection<T>(Action<ToCollectionTableOptions>)
Returns a collection of T for the tables data range. The total row is not included. The table must have headers. Headers will be mapped to properties using the name or the property attributes without white spaces. The attributes that can be used are: EpplusTableColumnAttributeBase.Header, DescriptionAttribute.Description or DisplayNameAttribute.Name.
Declaration
public List<T> ToCollection<T>(Action<ToCollectionTableOptions> options)
Parameters
Type | Name | Description |
---|---|---|
System.Action<ToCollectionTableOptions> | options | Configures the settings for the function |
Returns
Type | Description |
---|---|
System.Collections.Generic.List<T> | A list of T |
Type Parameters
Name | Description |
---|---|
T | The type to map to |
ToCollection<T>(Func<ToCollectionRow, T>)
Returns a collection of T for the table. If the range contains multiple addresses the first range is used. The the table must have headers. Headers will be mapped to properties using the name or the attributes without white spaces. The attributes that can be used are: EpplusTableColumnAttributeBase.Header, DescriptionAttribute.Description or DisplayNameAttribute.Name.
Declaration
public List<T> ToCollection<T>(Func<ToCollectionRow, T> setRow)
Parameters
Type | Name | Description |
---|---|---|
System.Func<ToCollectionRow, T> | setRow | The call back function to map each row to the item of type T. |
Returns
Type | Description |
---|---|
System.Collections.Generic.List<T> | A list of T |
Type Parameters
Name | Description |
---|---|
T | The type to map to |
ToCollectionWithMappings<T>(Func<ToCollectionRow, T>, ToCollectionTableOptions)
Returns a collection of T for the table. If the range contains multiple addresses the first range is used. The the table must have headers. Headers will be mapped to properties using the name or the attributes without white spaces. The attributes that can be used are: EpplusTableColumnAttributeBase.Header, DescriptionAttribute.Description or DisplayNameAttribute.Name.
Declaration
public List<T> ToCollectionWithMappings<T>(Func<ToCollectionRow, T> setRow, ToCollectionTableOptions options)
Parameters
Type | Name | Description |
---|---|---|
System.Func<ToCollectionRow, T> | setRow | The call back function to map each row to the item of type T. |
ToCollectionTableOptions | options | Configures the settings for the function |
Returns
Type | Description |
---|---|
System.Collections.Generic.List<T> | A list of T |
Type Parameters
Name | Description |
---|---|
T | The type to map to |
ToCollectionWithMappings<T>(Func<ToCollectionRow, T>, Action<ToCollectionTableOptions>)
Returns a collection of T for the table. If the range contains multiple addresses the first range is used. The the table must have headers. Headers will be mapped to properties using the name or the attributes without white spaces. The attributes that can be used are: EpplusTableColumnAttributeBase.Header, DescriptionAttribute.Description or DisplayNameAttribute.Name.
Declaration
public List<T> ToCollectionWithMappings<T>(Func<ToCollectionRow, T> setRow, Action<ToCollectionTableOptions> options)
Parameters
Type | Name | Description |
---|---|---|
System.Func<ToCollectionRow, T> | setRow | The call back function to map each row to the item of type T. |
System.Action<ToCollectionTableOptions> | options | Configures the settings for the function |
Returns
Type | Description |
---|---|
System.Collections.Generic.List<T> | A list of T |
Type Parameters
Name | Description |
---|---|
T | The type to map to |
ToDataTable()
Exports the table to a System.Data.DataTable
Declaration
public DataTable ToDataTable()
Returns
Type | Description |
---|---|
System.Data.DataTable | A System.Data.DataTable containing the data in the table range |
See Also
ToDataTable(ToDataTableOptions)
Exports the table to a System.Data.DataTable
Declaration
public DataTable ToDataTable(ToDataTableOptions options)
Parameters
Type | Name | Description |
---|---|---|
ToDataTableOptions | options |
Returns
Type | Description |
---|---|
System.Data.DataTable | A System.Data.DataTable containing the data in the table range |
See Also
ToDataTable(Action<ToDataTableOptions>)
Exports the table to a System.Data.DataTable
Declaration
public DataTable ToDataTable(Action<ToDataTableOptions> configHandler)
Parameters
Type | Name | Description |
---|---|---|
System.Action<ToDataTableOptions> | configHandler |
Returns
Type | Description |
---|---|
System.Data.DataTable | A System.Data.DataTable containing the data in the table range |
See Also
ToJson()
Returns the table as a JSON string
Declaration
public string ToJson()
Returns
Type | Description |
---|---|
System.String | A string containing the JSON document. |
ToJson(Action<JsonTableExportSettings>)
Returns the table as a JSON string
Declaration
public string ToJson(Action<JsonTableExportSettings> settings)
Parameters
Type | Name | Description |
---|---|---|
System.Action<JsonTableExportSettings> | settings | Settings to configure the JSON output |
Returns
Type | Description |
---|---|
System.String | A string containing the JSON document. |
ToText()
Converts the table range to CSV format
Declaration
public string ToText()
Returns
Type | Description |
---|---|
System.String |
See Also
ToText(ExcelOutputTextFormat)
Converts the table range to CSV format
Declaration
public string ToText(ExcelOutputTextFormat format)
Parameters
Type | Name | Description |
---|---|---|
ExcelOutputTextFormat | format | Parameters/options for conversion to text |
Returns
Type | Description |
---|---|
System.String |
See Also
ToTextAsync()
Converts the table range to CSV format
Declaration
public Task<string> ToTextAsync()
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.String> |
See Also
ToTextAsync(ExcelOutputTextFormat)
Converts the table range to CSV format
Declaration
public Task<string> ToTextAsync(ExcelOutputTextFormat format)
Parameters
Type | Name | Description |
---|---|---|
ExcelOutputTextFormat | format |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.String> |