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
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
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
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 |
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 |
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 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 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);
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
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> |