Class ExcelRangeBase
A range of cells
Inheritance
Implements
Inherited Members
Namespace: Experior.Core.Data.OfficeOpenXml
Assembly: Experior.Core.dll
Syntax
public class ExcelRangeBase : ExcelAddress, IExcelCell, IEnumerable<ExcelRangeBase>, IEnumerable, IEnumerator<ExcelRangeBase>, IDisposable, IEnumerator
Fields
_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 |
Formula
Gets or sets a formula for a range.
Declaration
public 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 sheetname
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 |
Merge
If the cells in the range are merged.
Declaration
public bool Merge { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
RichText
Cell value is richtext formated.
Declaration
public ExcelRichTextCollection RichText { get; }
Property Value
Type | Description |
---|---|
ExcelRichTextCollection |
Style
The styleobject 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 |
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)
Parameters
Type | Name | Description |
---|---|---|
System.String | Text | |
System.String | Author |
Returns
Type | Description |
---|---|
ExcelComment | A reference comment of the top left cell |
AutoFitColumns()
Set the column width from the content of the range. The minimum width is the value of the ExcelWorksheet.defaultColumnWidth property. Note: Cells containing formulas are ignored since EPPlus don't have a calculation engine. Wrapped and merged cells are also ignored.
Declaration
public void AutoFitColumns()
AutoFitColumns(Double)
Set the column width from the content of the range. Note: Cells containing formulas are ignored since EPPlus don't have a calculation engine. Wrapped and merged cells are also 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
AutoFitColumns(Double, Double)
Set the column width from the content of the range. Note: Cells containing formulas are ignored since EPPlus don't have a calculation engine. Wrapped and merged cells are also 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 |
Clear()
Clear all cells
Declaration
public void Clear()
Copy(ExcelRangeBase)
Copies the range of cells to an other range
Declaration
public void Copy(ExcelRangeBase Destination)
Parameters
Type | Name | Description |
---|---|---|
ExcelRangeBase | Destination | The start cell where the range will be copied. |
CreateArrayFormula(String)
Creates an array-formula.
Declaration
public void CreateArrayFormula(string ArrayFormula)
Parameters
Type | Name | Description |
---|---|---|
System.String | ArrayFormula | The formula |
Dispose()
Declaration
public void Dispose()
Finalize()
Declaration
protected void Finalize()
GetEnumerator()
Declaration
public IEnumerator<ExcelRangeBase> GetEnumerator()
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerator<ExcelRangeBase> |
GetValue<T>()
Get the strongly typed value of the cell.
Declaration
public T GetValue<T>()
Returns
Type | Description |
---|---|
T | The value. If the value can't be converted to the specified type, the default value will be returned |
Type Parameters
Name | Description |
---|---|
T | The type |
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>, 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 |
Returns
Type | Description |
---|---|
ExcelRangeBase | The filled range |
Type Parameters
Name | Description |
---|---|
T | The datatype in the collection |
LoadFromCollection<T>(IEnumerable<T>, Boolean, 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 |
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, 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. |
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 |
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, 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 |
TableStyles | TableStyle | The table style to apply to the data |
Returns
Type | Description |
---|---|
ExcelRangeBase | The filled range |
LoadFromText(FileInfo)
Loads a CSV file into a range starting from the top left cell.
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, 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 |
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 TextBlock |
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 TextBlock |
ExcelTextFormat | Format | Information how to load the text |
Returns
Type | Description |
---|---|
ExcelRangeBase | The range containing the data |
LoadFromText(String, ExcelTextFormat, 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 TextBlock |
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 |
---|---|
ExcelRangeBase |
MoveNext()
Declaration
public bool MoveNext()
Returns
Type | Description |
---|---|
System.Boolean |
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()
Declaration
public void Reset()
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 |