Class ExcelRangeBase
A range of cells
Inheritance
Implements
Inherited Members
Namespace: OfficeOpenXml
Assembly: EPPlus.dll
Syntax
public class ExcelRangeBase : ExcelAddress, IEnumerable<ExcelRangeBase>, IEnumerable, IEnumerator<ExcelRangeBase>, IEnumerator, IDisposable
Fields
_rtc
The richtext collection
Declaration
protected ExcelRichTextCollection _rtc
Field Value
Type | Description |
---|---|
ExcelRichTextCollection |
_worksheet
Reference to the worksheet
Declaration
protected ExcelWorksheet _worksheet
Field Value
Type | Description |
---|---|
ExcelWorksheet |
Properties
AutoFilter
Set an autofilter for the range
Declaration
public bool AutoFilter { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
Comment
Returns the comment object of the first cell in the range
Declaration
public ExcelComment Comment { get; }
Property Value
Type | Description |
---|---|
ExcelComment |
ConditionalFormatting
Conditional Formatting for this range.
Declaration
public IRangeConditionalFormatting ConditionalFormatting { get; }
Property Value
Type | Description |
---|---|
IRangeConditionalFormatting |
Current
The current range when enumerating
Declaration
public ExcelRangeBase Current { get; }
Property Value
Type | Description |
---|---|
ExcelRangeBase |
DataValidation
Data validation for this range.
Declaration
public IRangeDataValidation DataValidation { get; }
Property Value
Type | Description |
---|---|
IRangeDataValidation |
EntireColumn
A reference to the column properties for column(s= referenced by this range. If multiple ranges are addressed (e.g a1:a2,c1:c3), only the first address is used.
Declaration
public ExcelRangeColumn EntireColumn { get; }
Property Value
Type | Description |
---|---|
ExcelRangeColumn |
EntireRow
A reference to the row properties for row(s) referenced by this range. If multiple ranges are addressed (e.g a1:a2,c1:c3), only the first address is used.
Declaration
public ExcelRangeRow EntireRow { get; }
Property Value
Type | Description |
---|---|
ExcelRangeRow |
Formula
Gets or sets a formula for a range.
Declaration
public virtual string Formula { get; set; }
Property Value
Type | Description |
---|---|
System.String |
FormulaR1C1
Gets or Set a formula in R1C1 format.
Declaration
public string FormulaR1C1 { get; set; }
Property Value
Type | Description |
---|---|
System.String |
FullAddress
Address including sheet name
Declaration
public string FullAddress { get; }
Property Value
Type | Description |
---|---|
System.String |
FullAddressAbsolute
Address including sheetname
Declaration
public string FullAddressAbsolute { get; }
Property Value
Type | Description |
---|---|
System.String |
Hyperlink
Set the Hyperlink property for a range of cells
Declaration
public Uri Hyperlink { get; set; }
Property Value
Type | Description |
---|---|
System.Uri |
IsArrayFormula
Is the range a part of an Arrayformula
Declaration
public bool IsArrayFormula { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
IsRichText
If the value is in richtext format.
Declaration
public bool IsRichText { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
IsTable
Returns true if the range is a table. If the range partly matches a table range false will be returned. IsTable
Declaration
public bool IsTable { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
Merge
If the cells in the range are merged.
Declaration
public bool Merge { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
RichText
The cell value is rich text formatted. The RichText-property only apply to the left-top cell of the range.
Declaration
public ExcelRichTextCollection RichText { get; }
Property Value
Type | Description |
---|---|
ExcelRichTextCollection |
Style
The style object for the range.
Declaration
public ExcelStyle Style { get; }
Property Value
Type | Description |
---|---|
ExcelStyle |
StyleID
The style ID. It is not recomended to use this one. Use Named styles as an alternative. If you do, make sure that you use the Style.UpdateXml() method to update any new styles added to the workbook.
Declaration
public int StyleID { get; set; }
Property Value
Type | Description |
---|---|
System.Int32 |
StyleName
The named style
Declaration
public string StyleName { get; set; }
Property Value
Type | Description |
---|---|
System.String |
Text
Returns the formatted value.
Declaration
public string Text { get; }
Property Value
Type | Description |
---|---|
System.String |
ThreadedComment
Returns the threaded comment object of the first cell in the range
Declaration
public ExcelThreadedCommentThread ThreadedComment { get; }
Property Value
Type | Description |
---|---|
ExcelThreadedCommentThread |
UseImplicitItersection
If the formula in the single cell returns an array, implicit intersection will be used instead of creating a dynamic array formula. Please note that this property must be set after setting the formula, as default behaviour is to create a dynamic array formula. Shared formulas will always use implicit intersection.
Declaration
public bool UseImplicitItersection { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
Value
Set the range to a specific value
Declaration
public object Value { get; set; }
Property Value
Type | Description |
---|---|
System.Object |
Worksheet
WorkSheet object
Declaration
public ExcelWorksheet Worksheet { get; }
Property Value
Type | Description |
---|---|
ExcelWorksheet |
Methods
AddComment(String, String)
Adds a new comment for the range. If this range contains more than one cell, the top left comment is returned by the method.
Declaration
public ExcelComment AddComment(string Text, string Author = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | Text | The text for the comment |
System.String | Author | The author for the comment. If this property is null or blank EPPlus will set it to the identity of the ClaimsPrincipal if available otherwise to "Anonymous" |
Returns
Type | Description |
---|---|
ExcelComment | A reference comment of the top left cell |
AddThreadedComment()
Adds a new threaded comment for the range. If this range contains more than one cell, the top left comment is returned by the method.
Declaration
public ExcelThreadedCommentThread AddThreadedComment()
Returns
Type | Description |
---|---|
ExcelThreadedCommentThread | A reference comment of the top left cell |
AutoFitColumns()
Set the column width from the content of the range. Columns outside of the worksheets dimension are ignored. The minimum width is the value of the ExcelWorksheet.defaultColumnWidth property.
Declaration
public void AutoFitColumns()
Remarks
Cells containing formulas must be calculated before autofit is called. Wrapped and merged cells are also ignored.
AutoFitColumns(Double)
Set the column width from the content of the range. Columns outside of the worksheets dimension are ignored.
Declaration
public void AutoFitColumns(double MinimumWidth)
Parameters
Type | Name | Description |
---|---|---|
System.Double | MinimumWidth | Minimum column width |
Remarks
This method will not work if you run in an environment that does not support GDI. Cells containing formulas are ignored if no calculation is made. Wrapped and merged cells are also ignored.
AutoFitColumns(Double, Double)
Set the column width from the content of the range. Columns outside of the worksheets dimension are ignored.
Declaration
public void AutoFitColumns(double MinimumWidth, double MaximumWidth)
Parameters
Type | Name | Description |
---|---|---|
System.Double | MinimumWidth | Minimum column width |
System.Double | MaximumWidth | Maximum column width |
Remarks
This method will not work if you run in an environment that does not support GDI. Cells containing formulas are ignored if no calculation is made. Wrapped and merged cells are also ignored.
ChangeAddress()
On change address handler
Declaration
protected override void ChangeAddress()
Overrides
Clear()
Clear all cells
Declaration
public void Clear()
ClearFormulas()
Removes all formulas within the range, but keeps the calculated values.
Declaration
public void ClearFormulas()
ClearFormulaValues()
Removes all values of cells with formulas, but keeps the formulas.
Declaration
public void ClearFormulaValues()
Copy(ExcelRangeBase)
Copies the range of cells to another range.
Declaration
public void Copy(ExcelRangeBase Destination)
Parameters
Type | Name | Description |
---|---|---|
ExcelRangeBase | Destination | The top-left cell where the range will be copied. |
Copy(ExcelRangeBase, ExcelRangeCopyOptionFlags[])
Copies the range of cells to an other range
Declaration
public void Copy(ExcelRangeBase Destination, params ExcelRangeCopyOptionFlags[] excelRangeCopyOptionFlags)
Parameters
Type | Name | Description |
---|---|---|
ExcelRangeBase | Destination | The start cell where the range will be copied. |
ExcelRangeCopyOptionFlags[] | excelRangeCopyOptionFlags | Cell properties that will not be copied. |
Copy(ExcelRangeBase, Nullable<ExcelRangeCopyOptionFlags>)
Copies the range of cells to an other range
Declaration
public void Copy(ExcelRangeBase Destination, ExcelRangeCopyOptionFlags? excelRangeCopyOptionFlags)
Parameters
Type | Name | Description |
---|---|---|
ExcelRangeBase | Destination | The start cell where the range will be copied. |
System.Nullable<ExcelRangeCopyOptionFlags> | excelRangeCopyOptionFlags | Cell properties that will not be copied. |
CopyStyles(ExcelRangeBase)
Copy the styles from the source range to the destination range. If the destination range is larger than the source range, the styles of the column to the right and the row at the bottom will be expanded to the destination.
Declaration
public void CopyStyles(ExcelRangeBase Destination)
Parameters
Type | Name | Description |
---|---|---|
ExcelRangeBase | Destination | The destination range |
CreateArrayFormula(String)
Creates an array-formula.
Declaration
public void CreateArrayFormula(string ArrayFormula)
Parameters
Type | Name | Description |
---|---|---|
System.String | ArrayFormula | The formula |
CreateHtmlExporter()
Creates an IExcelHtmlRangeExporter for html export of this range.
Declaration
public IExcelHtmlRangeExporter CreateHtmlExporter()
Returns
Type | Description |
---|---|
IExcelHtmlRangeExporter | A html exporter |
Delete(eShiftTypeDelete)
Delete the range from the worksheet and shift affected cells in the selected direction.
Declaration
public void Delete(eShiftTypeDelete shift)
Parameters
Type | Name | Description |
---|---|---|
eShiftTypeDelete | shift | The direction that the cells will shift. |
Dispose()
Disposes the object
Declaration
public void Dispose()
FillDateTime()
Fills the range by adding 1 day to each cell starting from the value in the top left cell by column.
Declaration
public void FillDateTime()
FillDateTime(Action<FillDateParams>)
Fill the range with dates.
Declaration
public void FillDateTime(Action<FillDateParams> options)
Parameters
Type | Name | Description |
---|---|---|
System.Action<FillDateParams> | options | Options how to perform the fill |
FillDateTime(Nullable<DateTime>, eDateTimeUnit, Int32)
Fills the range by adding 1 day to each cell per column starting from startValue
.
Declaration
public void FillDateTime(DateTime? startValue, eDateTimeUnit dateTimeUnit = eDateTimeUnit.Day, int stepValue = 1)
Parameters
Type | Name | Description |
---|---|---|
System.Nullable<System.DateTime> | startValue | |
eDateTimeUnit | dateTimeUnit | |
System.Int32 | stepValue |
FillList<T>(IEnumerable<T>)
Fills the range columnwise using the values in the list.
Declaration
public void FillList<T>(IEnumerable<T> list)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<T> | list | The list to use. |
Type Parameters
Name | Description |
---|---|
T | Type used in the list. |
FillList<T>(IEnumerable<T>, Action<FillListParams>)
Declaration
public void FillList<T>(IEnumerable<T> list, Action<FillListParams> options)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<T> | list | |
System.Action<FillListParams> | options |
Type Parameters
Name | Description |
---|---|
T |
FillNumber()
Fills the range by adding 1 to each cell starting from the value in the top left cell by column
Declaration
public void FillNumber()
FillNumber(Action<FillNumberParams>)
Fills a range by using the argument options.
Declaration
public void FillNumber(Action<FillNumberParams> options)
Parameters
Type | Name | Description |
---|---|---|
System.Action<FillNumberParams> | options | The option to configure the fill. |
FillNumber(Nullable<Double>, Double)
Fills a range by adding the step value to the start Value. If startValue
is null the first value in the row/column is used.
Fill is done by column from top to bottom
Declaration
public void FillNumber(double? startValue, double stepValue = 1)
Parameters
Type | Name | Description |
---|---|---|
System.Nullable<System.Double> | startValue | The start value of the first cell. If this value is null the value of the first cell is used. |
System.Double | stepValue | The value used for each step |
GetCellValue<T>()
Gets the typed value of a cell
Declaration
public T GetCellValue<T>()
Returns
Type | Description |
---|---|
T | The value of the cell |
Type Parameters
Name | Description |
---|---|
T | The returned type |
GetCellValue<T>(Int32)
Gets the value of a cell using an offset from the top-left cell in the range.
Declaration
public T GetCellValue<T>(int columnOffset)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | columnOffset | Column offset from the top-left cell in the range |
Returns
Type | Description |
---|---|
T |
Type Parameters
Name | Description |
---|---|
T | The returned type |
GetCellValue<T>(Int32, Int32)
Gets the value of a cell using an offset from the top-left cell in the range.
Declaration
public T GetCellValue<T>(int rowOffset, int columnOffset)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | rowOffset | Row offset from the top-left cell in the range |
System.Int32 | columnOffset | Column offset from the top-left cell in the range |
Returns
Type | Description |
---|---|
T |
Type Parameters
Name | Description |
---|---|
T | The returned type |
GetEnumerator()
Gets the enumerator for the collection
Declaration
public IEnumerator<ExcelRangeBase> GetEnumerator()
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerator<ExcelRangeBase> | The enumerator |
GetTable()
Returns the ExcelTable if the range is a table. If the range doesn't or partly matches a table range, null is returned. IsTable
Declaration
public ExcelTable GetTable()
Returns
Type | Description |
---|---|
ExcelTable |
GetValue<T>()
Convert cell value to desired type, including nullable structs. When converting blank string to nullable struct (e.g. ' ' to int?) null is returned. When attempted conversion fails exception is passed through.
Declaration
public T GetValue<T>()
Returns
Type | Description |
---|---|
T | The Value converted to |
Type Parameters
Name | Description |
---|---|
T | The type to convert to. |
Remarks
If Value is string, parsing is performed for output types of DateTime and TimeSpan, which if fails throws System.FormatException. Another special case for output types of DateTime and TimeSpan is when input is double, in which case System.DateTime.FromOADate(System.Double) is used for conversion. This special case does not work through other types convertible to double (e.g. integer or string with number). In all other cases 'direct' conversion System.Convert.ChangeType(System.Object,System.Type) is performed.
Exceptions
Type | Condition |
---|---|
System.FormatException | Value is string and its format is invalid for conversion (parsing fails) |
System.InvalidCastException | Value is not string and direct conversion fails |
Insert(eShiftTypeInsert)
Insert cells into the worksheet and shift the cells to the selected direction.
Declaration
public void Insert(eShiftTypeInsert shift)
Parameters
Type | Name | Description |
---|---|---|
eShiftTypeInsert | shift | The direction that the cells will shift. |
LoadFromArrays(IEnumerable<Object[]>)
Loads data from the collection of arrays of objects into the range, starting from the top-left cell.
Declaration
public ExcelRangeBase LoadFromArrays(IEnumerable<object[]> Data)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<System.Object[]> | Data | The data. |
Returns
Type | Description |
---|---|
ExcelRangeBase |
LoadFromCollection<T>(IEnumerable<T>)
Load a collection into a the worksheet starting from the top left row of the range.
Declaration
public ExcelRangeBase LoadFromCollection<T>(IEnumerable<T> Collection)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<T> | Collection | The collection to load |
Returns
Type | Description |
---|---|
ExcelRangeBase | The filled range |
Type Parameters
Name | Description |
---|---|
T | The datatype in the collection |
LoadFromCollection<T>(IEnumerable<T>, Action<LoadFromCollectionParams>)
Load a collection into the worksheet starting from the top left row of the range.
Declaration
public ExcelRangeBase LoadFromCollection<T>(IEnumerable<T> collection, Action<LoadFromCollectionParams> paramsConfig)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<T> | collection | The collection to load |
System.Action<LoadFromCollectionParams> | paramsConfig | System.Action<T> to provide parameters to the function |
Returns
Type | Description |
---|---|
ExcelRangeBase | The filled range |
Type Parameters
Name | Description |
---|---|
T | The datatype in the collection |
Examples
sheet.Cells["C1"].LoadFromCollection(items, c =>
{
c.PrintHeaders = true;
c.TableStyle = TableStyles.Dark1;
});
LoadFromCollection<T>(IEnumerable<T>, Boolean)
Load a collection of T into the worksheet starting from the top left row of the range. Default option will load all public instance properties of T
Declaration
public ExcelRangeBase LoadFromCollection<T>(IEnumerable<T> Collection, bool PrintHeaders)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<T> | Collection | The collection to load |
System.Boolean | PrintHeaders | Print the property names on the first row. If the property is decorated with a System.ComponentModel.DisplayNameAttribute or a System.ComponentModel.DescriptionAttribute that attribute will be used instead of the reflected member name. |
Returns
Type | Description |
---|---|
ExcelRangeBase | The filled range |
Type Parameters
Name | Description |
---|---|
T | The datatype in the collection |
LoadFromCollection<T>(IEnumerable<T>, Boolean, Nullable<TableStyles>)
Load a collection of T into the worksheet starting from the top left row of the range. Default option will load all public instance properties of T
Declaration
public ExcelRangeBase LoadFromCollection<T>(IEnumerable<T> Collection, bool PrintHeaders, TableStyles? TableStyle)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<T> | Collection | The collection to load |
System.Boolean | PrintHeaders | Print the property names on the first row. If the property is decorated with a System.ComponentModel.DisplayNameAttribute or a System.ComponentModel.DescriptionAttribute that attribute will be used instead of the reflected member name. |
System.Nullable<TableStyles> | TableStyle | Will create a table with this style. If set to TableStyles.None no table will be created |
Returns
Type | Description |
---|---|
ExcelRangeBase | The filled range |
Type Parameters
Name | Description |
---|---|
T | The datatype in the collection |
LoadFromCollection<T>(IEnumerable<T>, Boolean, Nullable<TableStyles>, BindingFlags, MemberInfo[])
Load a collection into the worksheet starting from the top left row of the range.
Declaration
public ExcelRangeBase LoadFromCollection<T>(IEnumerable<T> Collection, bool PrintHeaders, TableStyles? TableStyle, BindingFlags memberFlags, MemberInfo[] Members)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<T> | Collection | The collection to load |
System.Boolean | PrintHeaders | Print the property names on the first row. Any underscore in the property name will be converted to a space. If the property is decorated with a System.ComponentModel.DisplayNameAttribute or a System.ComponentModel.DescriptionAttribute that attribute will be used instead of the reflected member name. |
System.Nullable<TableStyles> | TableStyle | Will create a table with this style. If set to TableStyles.None no table will be created |
System.Reflection.BindingFlags | memberFlags | Property flags to use |
System.Reflection.MemberInfo[] | Members | The properties to output. Must be of type T |
Returns
Type | Description |
---|---|
ExcelRangeBase | The filled range |
Type Parameters
Name | Description |
---|---|
T | The datatype in the collection |
LoadFromDataReader(IDataReader, Boolean)
Load the data from the datareader starting from the top left cell of the range
Declaration
public ExcelRangeBase LoadFromDataReader(IDataReader Reader, bool PrintHeaders)
Parameters
Type | Name | Description |
---|---|---|
System.Data.IDataReader | Reader | The datareader to load from |
System.Boolean | PrintHeaders | Print the caption property (if set) or the columnname property if not, on first row |
Returns
Type | Description |
---|---|
ExcelRangeBase | The filled range |
LoadFromDataReader(IDataReader, Boolean, String, TableStyles)
Load the data from the datareader starting from the top left cell of the range
Declaration
public ExcelRangeBase LoadFromDataReader(IDataReader Reader, bool PrintHeaders, string TableName, TableStyles TableStyle = TableStyles.None)
Parameters
Type | Name | Description |
---|---|---|
System.Data.IDataReader | Reader | The datareader to loadfrom |
System.Boolean | PrintHeaders | Print the column caption property (if set) or the columnname property if not, on first row |
System.String | TableName | The name of the table |
TableStyles | TableStyle | The table style to apply to the data |
Returns
Type | Description |
---|---|
ExcelRangeBase | The filled range |
LoadFromDataReaderAsync(DbDataReader, Boolean)
Load the data from the datareader starting from the top left cell of the range
Declaration
public async Task<ExcelRangeBase> LoadFromDataReaderAsync(DbDataReader Reader, bool PrintHeaders)
Parameters
Type | Name | Description |
---|---|---|
System.Data.Common.DbDataReader | Reader | The datareader to load from |
System.Boolean | PrintHeaders | Print the caption property (if set) or the columnname property if not, on first row |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<ExcelRangeBase> | The filled range |
LoadFromDataReaderAsync(DbDataReader, Boolean, String, TableStyles, Nullable<CancellationToken>)
Load the data from the datareader starting from the top left cell of the range
Declaration
public async Task<ExcelRangeBase> LoadFromDataReaderAsync(DbDataReader Reader, bool PrintHeaders, string TableName, TableStyles TableStyle = TableStyles.None, CancellationToken? cancellationToken = null)
Parameters
Type | Name | Description |
---|---|---|
System.Data.Common.DbDataReader | Reader | The datareader to loadfrom |
System.Boolean | PrintHeaders | Print the column caption property (if set) or the columnname property if not, on first row |
System.String | TableName | The name of the table |
TableStyles | TableStyle | The table style to apply to the data |
System.Nullable<System.Threading.CancellationToken> | cancellationToken | The cancellation token to use |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<ExcelRangeBase> | The filled range |
LoadFromDataReaderAsync(DbDataReader, Boolean, CancellationToken)
Load the data from the datareader starting from the top left cell of the range
Declaration
public async Task<ExcelRangeBase> LoadFromDataReaderAsync(DbDataReader Reader, bool PrintHeaders, CancellationToken cancellationToken)
Parameters
Type | Name | Description |
---|---|---|
System.Data.Common.DbDataReader | Reader | The datareader to load from |
System.Boolean | PrintHeaders | Print the caption property (if set) or the columnname property if not, on first row |
System.Threading.CancellationToken | cancellationToken | The cancellation token to use |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<ExcelRangeBase> | The filled range |
LoadFromDataTable(DataTable)
Load the data from the datatable starting from the top left cell of the range
Declaration
public ExcelRangeBase LoadFromDataTable(DataTable table)
Parameters
Type | Name | Description |
---|---|---|
System.Data.DataTable | table | The datatable to load |
Returns
Type | Description |
---|---|
ExcelRangeBase | The filled range |
LoadFromDataTable(DataTable, Action<LoadFromDataTableParams>)
Load the data from the System.Data.DataTable starting from the top left cell of the range
Declaration
public ExcelRangeBase LoadFromDataTable(DataTable table, Action<LoadFromDataTableParams> paramsConfig)
Parameters
Type | Name | Description |
---|---|---|
System.Data.DataTable | table | |
System.Action<LoadFromDataTableParams> | paramsConfig | System.Action<T> to provide parameters to the function |
Returns
Type | Description |
---|---|
ExcelRangeBase | The filled range |
Examples
sheet.Cells["C1"].LoadFromDataTable(dataTable, c =>
{
c.PrintHeaders = true;
c.TableStyle = TableStyles.Dark1;
});
LoadFromDataTable(DataTable, Boolean)
Load the data from the datatable starting from the top left cell of the range
Declaration
public ExcelRangeBase LoadFromDataTable(DataTable Table, bool PrintHeaders)
Parameters
Type | Name | Description |
---|---|---|
System.Data.DataTable | Table | The datatable to load |
System.Boolean | PrintHeaders | Print the caption property (if set) or the columnname property if not, on first row |
Returns
Type | Description |
---|---|
ExcelRangeBase | The filled range |
LoadFromDataTable(DataTable, Boolean, Nullable<TableStyles>)
Load the data from the datatable starting from the top left cell of the range
Declaration
public ExcelRangeBase LoadFromDataTable(DataTable Table, bool PrintHeaders, TableStyles? TableStyle)
Parameters
Type | Name | Description |
---|---|---|
System.Data.DataTable | Table | The datatable to load |
System.Boolean | PrintHeaders | Print the column caption property (if set) or the columnname property if not, on first row |
System.Nullable<TableStyles> | TableStyle | The table style to apply to the data |
Returns
Type | Description |
---|---|
ExcelRangeBase | The filled range |
LoadFromDictionaries(IEnumerable<IDictionary<String, Object>>)
Load a collection of dictionaries (or dynamic/ExpandoObjects) into the worksheet starting from the top left row of the range. These dictionaries should have the same set of keys.
Declaration
public ExcelRangeBase LoadFromDictionaries(IEnumerable<IDictionary<string, object>> items)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<System.Collections.Generic.IDictionary<System.String, System.Object>> | items | A list of dictionaries/> |
Returns
Type | Description |
---|---|
ExcelRangeBase | The filled range |
Examples
var items = new List<IDictionary<string, object>>()
{
new Dictionary<string, object>()
{
{ "Id", 1 },
{ "Name", "TestName 1" }
},
new Dictionary<string, object>()
{
{ "Id", 2 },
{ "Name", "TestName 2" }
}
};
using(var package = new ExcelPackage())
{
var sheet = package.Workbook.Worksheets.Add("test");
var r = sheet.Cells["A1"].LoadFromDictionaries(items);
}
LoadFromDictionaries(IEnumerable<IDictionary<String, Object>>, Action<LoadFromDictionariesParams>)
Load a collection of dictionaries (or dynamic/ExpandoObjects) into the worksheet starting from the top left row of the range. These dictionaries should have the same set of keys.
Declaration
public ExcelRangeBase LoadFromDictionaries(IEnumerable<IDictionary<string, object>> items, Action<LoadFromDictionariesParams> paramsConfig)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<System.Collections.Generic.IDictionary<System.String, System.Object>> | items | A list of dictionaries/ExpandoObjects |
System.Action<LoadFromDictionariesParams> | paramsConfig | System.Action<T> to provide parameters to the function |
Returns
Type | Description |
---|---|
ExcelRangeBase |
Examples
sheet.Cells["C1"].LoadFromDictionaries(items, c => { c.PrintHeaders = true; c.TableStyle = TableStyles.Dark1; });
LoadFromDictionaries(IEnumerable<IDictionary<String, Object>>, Boolean)
Load a collection of dictionaries (or dynamic/ExpandoObjects) into the worksheet starting from the top left row of the range. These dictionaries should have the same set of keys.
Declaration
public ExcelRangeBase LoadFromDictionaries(IEnumerable<IDictionary<string, object>> items, bool printHeaders)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<System.Collections.Generic.IDictionary<System.String, System.Object>> | items | A list of dictionaries/> |
System.Boolean | printHeaders | If true the key names from the first instance will be used as headers |
Returns
Type | Description |
---|---|
ExcelRangeBase | The filled range |
Examples
var items = new List<IDictionary<string, object>>()
{
new Dictionary<string, object>()
{
{ "Id", 1 },
{ "Name", "TestName 1" }
},
new Dictionary<string, object>()
{
{ "Id", 2 },
{ "Name", "TestName 2" }
}
};
using(var package = new ExcelPackage())
{
var sheet = package.Workbook.Worksheets.Add("test");
var r = sheet.Cells["A1"].LoadFromDictionaries(items, true);
}
LoadFromDictionaries(IEnumerable<IDictionary<String, Object>>, Boolean, Nullable<TableStyles>)
Load a collection of dictionaries (or dynamic/ExpandoObjects) into the worksheet starting from the top left row of the range. These dictionaries should have the same set of keys.
Declaration
public ExcelRangeBase LoadFromDictionaries(IEnumerable<IDictionary<string, object>> items, bool printHeaders, TableStyles? tableStyle)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<System.Collections.Generic.IDictionary<System.String, System.Object>> | items | A list of dictionaries/> |
System.Boolean | printHeaders | If true the key names from the first instance will be used as headers |
System.Nullable<TableStyles> | tableStyle | Will create a table with this style. If set to TableStyles.None no table will be created |
Returns
Type | Description |
---|---|
ExcelRangeBase | The filled range |
Examples
var items = new List<IDictionary<string, object>>()
{
new Dictionary<string, object>()
{
{ "Id", 1 },
{ "Name", "TestName 1" }
},
new Dictionary<string, object>()
{
{ "Id", 2 },
{ "Name", "TestName 2" }
}
};
using(var package = new ExcelPackage())
{
var sheet = package.Workbook.Worksheets.Add("test");
var r = sheet.Cells["A1"].LoadFromDictionaries(items, true, TableStyles.None);
}
LoadFromDictionaries(IEnumerable<IDictionary<String, Object>>, Boolean, Nullable<TableStyles>, IEnumerable<String>)
Load a collection of dictionaries (or dynamic/ExpandoObjects) into the worksheet starting from the top left row of the range. These dictionaries should have the same set of keys.
Declaration
public ExcelRangeBase LoadFromDictionaries(IEnumerable<IDictionary<string, object>> items, bool printHeaders, TableStyles? tableStyle, IEnumerable<string> keys)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<System.Collections.Generic.IDictionary<System.String, System.Object>> | items | A list of dictionaries |
System.Boolean | printHeaders | If true the key names from the first instance will be used as headers |
System.Nullable<TableStyles> | tableStyle | Will create a table with this style. If set to TableStyles.None no table will be created |
System.Collections.Generic.IEnumerable<System.String> | keys | Keys that should be used, keys omitted will not be included |
Returns
Type | Description |
---|---|
ExcelRangeBase | The filled range |
Examples
var items = new List<IDictionary<string, object>>()
{
new Dictionary<string, object>()
{
{ "Id", 1 },
{ "Name", "TestName 1" }
},
new Dictionary<string, object>()
{
{ "Id", 2 },
{ "Name", "TestName 2" }
}
};
using(var package = new ExcelPackage())
{
var sheet = package.Workbook.Worksheets.Add("test");
var r = sheet.Cells["A1"].LoadFromDictionaries(items, true, TableStyles.None, null);
}
LoadFromDictionaries(IEnumerable<Object>, Action<LoadFromDictionariesParams>)
Load a collection of dictionaries (or dynamic/ExpandoObjects) into the worksheet starting from the top left row of the range. These dictionaries should have the same set of keys.
Declaration
public ExcelRangeBase LoadFromDictionaries(IEnumerable<dynamic> items, Action<LoadFromDictionariesParams> paramsConfig)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<System.Object> | items | A list of dictionaries/ExpandoObjects |
System.Action<LoadFromDictionariesParams> | paramsConfig | System.Action<T> to provide parameters to the function |
Returns
Type | Description |
---|---|
ExcelRangeBase |
Examples
sheet.Cells["C1"].LoadFromDictionaries(items, c => { c.PrintHeaders = true; c.TableStyle = TableStyles.Dark1; });
LoadFromDictionaries(IEnumerable<Object>, Boolean, Nullable<TableStyles>, IEnumerable<String>)
Load a collection of dictionaries (or dynamic/ExpandoObjects) into the worksheet starting from the top left row of the range. These dictionaries should have the same set of keys.
Declaration
public ExcelRangeBase LoadFromDictionaries(IEnumerable<dynamic> items, bool printHeaders, TableStyles? tableStyle, IEnumerable<string> keys)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<System.Object> | items | A list of dictionaries |
System.Boolean | printHeaders | If true the key names from the first instance will be used as headers |
System.Nullable<TableStyles> | tableStyle | Will create a table with this style. If set to TableStyles.None no table will be created |
System.Collections.Generic.IEnumerable<System.String> | keys | Keys that should be used, keys omitted will not be included |
Returns
Type | Description |
---|---|
ExcelRangeBase | The filled range |
Examples
var items = new List<IDictionary<string, object>>()
{
new Dictionary<string, object>()
{
{ "Id", 1 },
{ "Name", "TestName 1" }
},
new Dictionary<string, object>()
{
{ "Id", 2 },
{ "Name", "TestName 2" }
}
};
using(var package = new ExcelPackage())
{
var sheet = package.Workbook.Worksheets.Add("test");
var r = sheet.Cells["A1"].LoadFromDictionaries(items, true, TableStyles.None, null);
}
LoadFromText(FileInfo)
Loads a CSV file into a range starting from the top left cell using ASCII Encoding.
Declaration
public ExcelRangeBase LoadFromText(FileInfo TextFile)
Parameters
Type | Name | Description |
---|---|---|
System.IO.FileInfo | TextFile | The Textfile |
Returns
Type | Description |
---|---|
ExcelRangeBase |
LoadFromText(FileInfo, ExcelTextFormat)
Loads a CSV file into a range starting from the top left cell.
Declaration
public ExcelRangeBase LoadFromText(FileInfo TextFile, ExcelTextFormat Format)
Parameters
Type | Name | Description |
---|---|---|
System.IO.FileInfo | TextFile | The Textfile |
ExcelTextFormat | Format | Information how to load the text |
Returns
Type | Description |
---|---|
ExcelRangeBase |
LoadFromText(FileInfo, ExcelTextFormat, Nullable<TableStyles>, Boolean)
Loads a CSV file into a range starting from the top left cell.
Declaration
public ExcelRangeBase LoadFromText(FileInfo TextFile, ExcelTextFormat Format, TableStyles? TableStyle, bool FirstRowIsHeader)
Parameters
Type | Name | Description |
---|---|---|
System.IO.FileInfo | TextFile | The Textfile |
ExcelTextFormat | Format | Information how to load the text |
System.Nullable<TableStyles> | TableStyle | Create a table with this style |
System.Boolean | FirstRowIsHeader | Use the first row as header |
Returns
Type | Description |
---|---|
ExcelRangeBase |
LoadFromText(String)
Loads a CSV text into a range starting from the top left cell. Default settings is Comma separation
Declaration
public ExcelRangeBase LoadFromText(string Text)
Parameters
Type | Name | Description |
---|---|---|
System.String | Text | The Text |
Returns
Type | Description |
---|---|
ExcelRangeBase | The range containing the data |
LoadFromText(String, ExcelTextFormat)
Loads a CSV text into a range starting from the top left cell.
Declaration
public ExcelRangeBase LoadFromText(string Text, ExcelTextFormat Format)
Parameters
Type | Name | Description |
---|---|---|
System.String | Text | The Text |
ExcelTextFormat | Format | Information how to load the text |
Returns
Type | Description |
---|---|
ExcelRangeBase | The range containing the data |
LoadFromText(String, ExcelTextFormat, Nullable<TableStyles>, Boolean)
Loads a CSV text into a range starting from the top left cell.
Declaration
public ExcelRangeBase LoadFromText(string Text, ExcelTextFormat Format, TableStyles? TableStyle, bool FirstRowIsHeader)
Parameters
Type | Name | Description |
---|---|---|
System.String | Text | The Text |
ExcelTextFormat | Format | Information how to load the text |
System.Nullable<TableStyles> | TableStyle | Create a table with this style. If this parameter is not null no table will be created. |
System.Boolean | FirstRowIsHeader | Use the first row as header |
Returns
Type | Description |
---|---|
ExcelRangeBase |
LoadFromTextAsync(FileInfo)
Loads a CSV file into a range starting from the top left cell.
Declaration
public async Task<ExcelRangeBase> LoadFromTextAsync(FileInfo TextFile)
Parameters
Type | Name | Description |
---|---|---|
System.IO.FileInfo | TextFile | The Textfile |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<ExcelRangeBase> |
LoadFromTextAsync(FileInfo, ExcelTextFormat)
Loads a CSV file into a range starting from the top left cell.
Declaration
public async Task<ExcelRangeBase> LoadFromTextAsync(FileInfo TextFile, ExcelTextFormat Format)
Parameters
Type | Name | Description |
---|---|---|
System.IO.FileInfo | TextFile | The Textfile |
ExcelTextFormat | Format | Information how to load the text |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<ExcelRangeBase> |
LoadFromTextAsync(FileInfo, ExcelTextFormat, TableStyles, Boolean)
Loads a CSV file into a range starting from the top left cell.
Declaration
public async Task<ExcelRangeBase> LoadFromTextAsync(FileInfo TextFile, ExcelTextFormat Format, TableStyles TableStyle, bool FirstRowIsHeader)
Parameters
Type | Name | Description |
---|---|---|
System.IO.FileInfo | TextFile | The Textfile |
ExcelTextFormat | Format | Information how to load the text |
TableStyles | TableStyle | Create a table with this style |
System.Boolean | FirstRowIsHeader | Use the first row as header |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<ExcelRangeBase> |
MoveNext()
Iterate to the next cell
Declaration
public bool MoveNext()
Returns
Type | Description |
---|---|
System.Boolean | False if no more cells exists |
Offset(Int32, Int32)
Get a range with an offset from the top left cell. The new range has the same dimensions as the current range
Declaration
public ExcelRangeBase Offset(int RowOffset, int ColumnOffset)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | RowOffset | Row Offset |
System.Int32 | ColumnOffset | Column Offset |
Returns
Type | Description |
---|---|
ExcelRangeBase |
Offset(Int32, Int32, Int32, Int32)
Get a range with an offset from the top left cell.
Declaration
public ExcelRangeBase Offset(int RowOffset, int ColumnOffset, int NumberOfRows, int NumberOfColumns)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | RowOffset | Row Offset |
System.Int32 | ColumnOffset | Column Offset |
System.Int32 | NumberOfRows | Number of rows. Minimum 1 |
System.Int32 | NumberOfColumns | Number of colums. Minimum 1 |
Returns
Type | Description |
---|---|
ExcelRangeBase |
Reset()
Reset the enumerator
Declaration
public void Reset()
SaveToJson(Stream)
Saves the range as JSON to a stream.
Declaration
public void SaveToJson(Stream stream)
Parameters
Type | Name | Description |
---|---|---|
System.IO.Stream | stream | The writable stream to write the JSON to. |
SaveToJson(Stream, Action<JsonRangeExportSettings>)
Saves the range as JSON to a stream.
Declaration
public void SaveToJson(Stream stream, Action<JsonRangeExportSettings> settings)
Parameters
Type | Name | Description |
---|---|---|
System.IO.Stream | stream | The writable stream to write the JSON to |
System.Action<JsonRangeExportSettings> | settings | Configures settings for the JSON export |
SaveToJsonAsync(Stream)
Save the range 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<JsonRangeExportSettings>)
Save the range to json
Declaration
public async Task SaveToJsonAsync(Stream stream, Action<JsonRangeExportSettings> settings)
Parameters
Type | Name | Description |
---|---|---|
System.IO.Stream | stream | The stream to save to. |
System.Action<JsonRangeExportSettings> | settings | Settings for the json output. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task |
SaveToText(FileInfo, ExcelOutputTextFormat)
Converts a range to text in CSV format. Invariant culture is used by default.
Declaration
public void SaveToText(FileInfo file, ExcelOutputTextFormat Format)
Parameters
Type | Name | Description |
---|---|---|
System.IO.FileInfo | file | The file to write to |
ExcelOutputTextFormat | Format | Information how to create the csv text |
SaveToText(Stream, ExcelOutputTextFormat)
Converts a range to text in CSV format. Invariant culture is used by default.
Declaration
public void SaveToText(Stream stream, ExcelOutputTextFormat Format)
Parameters
Type | Name | Description |
---|---|---|
System.IO.Stream | stream | The strem to write to |
ExcelOutputTextFormat | Format | Information how to create the csv text |
SaveToTextAsync(FileInfo, ExcelOutputTextFormat)
Converts a range to text in CSV format. Invariant culture is used by default.
Declaration
public async Task SaveToTextAsync(FileInfo file, ExcelOutputTextFormat Format)
Parameters
Type | Name | Description |
---|---|---|
System.IO.FileInfo | file | The file to write to |
ExcelOutputTextFormat | Format | Information how to create the csv text |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task |
SaveToTextAsync(Stream, ExcelOutputTextFormat)
Converts a range to text in CSV format. Invariant culture is used by default.
Declaration
public async Task SaveToTextAsync(Stream stream, ExcelOutputTextFormat Format)
Parameters
Type | Name | Description |
---|---|---|
System.IO.Stream | stream | The strem to write to |
ExcelOutputTextFormat | Format | Information how to create the csv text |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task |
SetCellValue(Int32, Int32, Object)
Sets the value of a cell using an offset from the top-left cell in the range.
Declaration
public void SetCellValue(int rowOffset, int columnOffset, object value)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | rowOffset | Row offset from the top-left cell in the range |
System.Int32 | columnOffset | Column offset from the top-left cell in the range |
System.Object | value | The value to set. |
SetErrorValue(eErrorType)
Sets the range to an Error value
Declaration
public void SetErrorValue(eErrorType errorType)
Parameters
Type | Name | Description |
---|---|---|
eErrorType | errorType | The type of error |
SetHyperlink(ExcelHyperLink)
Sets the Hyperlink property using the ExcelHyperLink class.
Declaration
public void SetHyperlink(ExcelHyperLink uri)
Parameters
Type | Name | Description |
---|---|---|
ExcelHyperLink | uri | The ExcelHyperLink uri to set |
SetHyperlink(ExcelRange)
Sets the Hyperlink property to an url within the workbook. The hyperlink will display the value of the cell.
Declaration
public void SetHyperlink(ExcelRange range)
Parameters
Type | Name | Description |
---|---|---|
ExcelRange | range | A reference within the same workbook |
SetHyperlink(ExcelRange, String)
Sets the Hyperlink property to an url within the workbook.
Declaration
public void SetHyperlink(ExcelRange range, string display)
Parameters
Type | Name | Description |
---|---|---|
ExcelRange | range | A reference within the same workbook |
System.String | display | The displayed text in the cell. If display is null or empty, the address of the range will be set. |
SetHyperlink(Uri)
Sets the hyperlink property
Declaration
public void SetHyperlink(Uri uri)
Parameters
Type | Name | Description |
---|---|---|
System.Uri | uri | The URI to set |
Sort()
Sort the range by value of the first column, Ascending.
Declaration
public void Sort()
Sort(RangeSortOptions)
Sort the range by value. Use RangeSortOptions.Create() to create an instance of the sort options, then use the SortBy or SortLeftToRightBy properties to build up your sort parameters.
Declaration
public void Sort(RangeSortOptions options)
Parameters
Type | Name | Description |
---|---|---|
RangeSortOptions | options | Options for the sort |
Examples
var options = RangeSortOptions.Create();
var builder = options.SortBy.Column(0);
builder.ThenSortBy.Column(2).UsingCustomList("S", "M", "L", "XL");
builder.ThenSortBy.Column(3);
worksheet.Cells["A1:D15"].Sort(options);
Sort(Action<RangeSortOptions>)
Sort the range by value. Supports top-down and left to right sort.
Declaration
public void Sort(Action<RangeSortOptions> configuration)
Parameters
Type | Name | Description |
---|---|---|
System.Action<RangeSortOptions> | configuration | An action of RangeSortOptions where sort parameters can be set. |
Examples
// 1. Sort rows (top-down)
// The Column function takes the zero based column index in the range
worksheet.Cells["A1:D15"].Sort(x => x.SortBy.Column(0).ThenSortBy.Column(1, eSortOrder.Descending));
// 2. Sort columns(left to right)
// The Row function takes the zero based row index in the range
worksheet.Cells["A1:D15"].Sort(x => x.SortLeftToRightBy.Row(0));
// 3. Sort using a custom list
worksheet.Cells["A1:D15"].Sort(x => x.SortBy.Column(0).UsingCustomList("S", "M", "L", "XL"));
worksheet.Cells["A1:D15"].Sort(x => x.SortLeftToRightBy.Row(0).UsingCustomList("S", "M", "L", "XL"));
Sort(Int32, Boolean)
Sort the range by value of the supplied column, Ascending.
The column to sort by within the range. Zerobased Descending if true, otherwise Ascending. Default Ascending. ZerobasedDeclaration
public void Sort(int column, bool descending = false)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | column | |
System.Boolean | descending |
Sort(Int32[], Boolean[], CultureInfo, CompareOptions)
Sort the range by value
Declaration
public void Sort(int[] columns, bool[] descending = null, CultureInfo culture = null, CompareOptions compareOptions = CompareOptions.None)
Parameters
Type | Name | Description |
---|---|---|
System.Int32[] | columns | The column(s) to sort by within the range. Zerobased |
System.Boolean[] | descending | Descending if true, otherwise Ascending. Default Ascending. Zerobased |
System.Globalization.CultureInfo | culture | The CultureInfo used to compare values. A null value means CurrentCulture |
System.Globalization.CompareOptions | compareOptions | String compare option |
ToCollection<T>()
Returns a collection of T for the range. If the range contains multiple addresses the first range is used. The first row must contain the unique headers used as keys in the row dictionary. 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>()
Returns
Type | Description |
---|---|
System.Collections.Generic.List<T> | A list of T |
Type Parameters
Name | Description |
---|---|
T | The type to map to |
ToCollection<T>(ToCollectionRangeOptions)
Automatically maps the range to the properties OfficeOpenXml.FormulaParsing.Excel.Functions.Text.T using the headers. Using this method requires a 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>(ToCollectionRangeOptions options)
Parameters
Type | Name | Description |
---|---|---|
ToCollectionRangeOptions | options | Settings for the method |
Returns
Type | Description |
---|---|
System.Collections.Generic.List<T> | A list of OfficeOpenXml.FormulaParsing.Excel.Functions.Text.T |
Type Parameters
Name | Description |
---|---|
T | The type to use |
ToCollection<T>(Action<ToCollectionRangeOptions>)
Automatically maps the range to the properties OfficeOpenXml.FormulaParsing.Excel.Functions.Text.T using the headers. Using this method requires a 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>(Action<ToCollectionRangeOptions> options)
Parameters
Type | Name | Description |
---|---|---|
System.Action<ToCollectionRangeOptions> | options | Configures the settings for the function |
Returns
Type | Description |
---|---|
System.Collections.Generic.List<T> | A list of OfficeOpenXml.FormulaParsing.Excel.Functions.Text.T |
Type Parameters
Name | Description |
---|---|
T | The type to use |
ToCollectionWithMappings<T>(Func<ToCollectionRow, T>)
Returns a collection of T for the range. If the range contains multiple addresses the first range is used. The first row must containt the unique headers used as keys in the row dictionary.
Declaration
public List<T> ToCollectionWithMappings<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>, ToCollectionRangeOptions)
Returns a collection of T for the range. If the range contains multiple addresses the first range is used. The first row must containt the unique headers used as keys in the row dictionary.
Declaration
public List<T> ToCollectionWithMappings<T>(Func<ToCollectionRow, T> setRow, ToCollectionRangeOptions options)
Parameters
Type | Name | Description |
---|---|---|
System.Func<ToCollectionRow, T> | setRow | The call back function to map each row to the item of type T. |
ToCollectionRangeOptions | options | Parameters to 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<ToCollectionRangeOptions>)
Returns a collection of T for the range. If the range contains multiple addresses the first range is used. The first row must contain the unique headers used as keys in the row dictionary.
Declaration
public List<T> ToCollectionWithMappings<T>(Func<ToCollectionRow, T> setRow, Action<ToCollectionRangeOptions> 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<ToCollectionRangeOptions> | 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()
Returns the range as a System.Data.DataTable with the OfficeOpenXml.Export.ToDataTable.ToDataTableOptions.Default settings.
Declaration
public DataTable ToDataTable()
Returns
Type | Description |
---|---|
System.Data.DataTable | A System.Data.DataTable representing the range. |
ToDataTable(ToDataTableOptions)
Returns the range as a System.Data.DataTable with the option supplied.
Declaration
public DataTable ToDataTable(ToDataTableOptions options)
Parameters
Type | Name | Description |
---|---|---|
ToDataTableOptions | options | Sets the settings used to convert the range. |
Returns
Type | Description |
---|---|
System.Data.DataTable | A System.Data.DataTable representing the range. |
ToDataTable(ToDataTableOptions, DataTable)
Returns the range as a System.Data.DataTable with the option supplied.
Declaration
public DataTable ToDataTable(ToDataTableOptions options, DataTable dataTable)
Parameters
Type | Name | Description |
---|---|---|
ToDataTableOptions | options | Sets the settings used to convert the range. |
System.Data.DataTable | dataTable | The data table to add the range data to. |
Returns
Type | Description |
---|---|
System.Data.DataTable | A System.Data.DataTable representing the range. |
ToDataTable(Action<ToDataTableOptions>)
Returns the range as a System.Data.DataTable with the option supplied.
Declaration
public DataTable ToDataTable(Action<ToDataTableOptions> configHandler)
Parameters
Type | Name | Description |
---|---|---|
System.Action<ToDataTableOptions> | configHandler | Configures the settings used to convert the range. |
Returns
Type | Description |
---|---|
System.Data.DataTable | A System.Data.DataTable representing the range. |
ToDataTable(Action<ToDataTableOptions>, DataTable)
Returns the range as a System.Data.DataTable with the option supplied.
Declaration
public DataTable ToDataTable(Action<ToDataTableOptions> configHandler, DataTable dataTable)
Parameters
Type | Name | Description |
---|---|---|
System.Action<ToDataTableOptions> | configHandler | Configures the settings used to convert the range. |
System.Data.DataTable | dataTable | The data table to add the range data to. |
Returns
Type | Description |
---|---|
System.Data.DataTable | A System.Data.DataTable representing the range. |
ToDataTable(DataTable)
Returns the range as a System.Data.DataTable with the option supplied.
Declaration
public DataTable ToDataTable(DataTable dataTable)
Parameters
Type | Name | Description |
---|---|---|
System.Data.DataTable | dataTable | The data table to add the range data to. |
Returns
Type | Description |
---|---|
System.Data.DataTable | A System.Data.DataTable representing the range. |
ToJson()
Returns the range as JSON
Declaration
public string ToJson()
Returns
Type | Description |
---|---|
System.String | A JSON string |
ToJson(Action<JsonRangeExportSettings>)
Returns the range as JSON
Declaration
public string ToJson(Action<JsonRangeExportSettings> settings)
Parameters
Type | Name | Description |
---|---|---|
System.Action<JsonRangeExportSettings> | settings | Configures settings for the JSON export |
Returns
Type | Description |
---|---|
System.String |
ToText()
Converts a range to text in CSV format.
Declaration
public string ToText()
Returns
Type | Description |
---|---|
System.String | A string containing the text |
ToText(ExcelOutputTextFormat)
Converts a range to text in CSV format. Invariant culture is used by default.
Declaration
public string ToText(ExcelOutputTextFormat Format)
Parameters
Type | Name | Description |
---|---|---|
ExcelOutputTextFormat | Format | Information how to create the csv text |
Returns
Type | Description |
---|---|
System.String | A string containing the text |
ToTextAsync()
Converts a range to text in CSV format.
Declaration
public async Task<string> ToTextAsync()
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.String> | A string containing the text |
ToTextAsync(ExcelOutputTextFormat)
Converts a range to text in CSV format. Invariant culture is used by default.
Declaration
public async Task<string> ToTextAsync(ExcelOutputTextFormat Format)
Parameters
Type | Name | Description |
---|---|---|
ExcelOutputTextFormat | Format | Information how to create the csv text |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.String> | A string containing the text |
Explicit Interface Implementations
IEnumerable.GetEnumerator()
Declaration
IEnumerator IEnumerable.GetEnumerator()
Returns
Type | Description |
---|---|
System.Collections.IEnumerator |
IEnumerator.Current
The current range when enumerating
Declaration
object IEnumerator.Current { get; }
Returns
Type | Description |
---|---|
System.Object |