ExcelSource<TOutput>
Class ExcelSource<TOutput>
Reads data from a excel source. While reading the data from the file, data is also asnychronously posted into the targets. You can define a sheet name and a range - only the data in the specified sheet and range is read. Otherwise, all data in all sheets will be processed.
Inheritance
Inherited Members
Namespace: ETLBox.Excel
Assembly: ETLBox.Excel.dll
Syntax
public class ExcelSource<TOutput> : DataFlowStreamSource<TOutput>, IDataFlowStreamSource<TOutput>, IDataFlowExecutableSource<TOutput>, IDataFlowSource<TOutput>, IDataFlowStreamSource, IDataFlowExecutableSource, IDataFlowSource, IDataFlowComponent, ILoggableTaskType Parameters
| Name | Description |
|---|---|
| TOutput | Type of outgoing data |
Examples
ExcelSource<ExcelData> source = new ExcelSource<ExcelData>("src/DataFlow/ExcelDataFile.xlsx") {
Range = new ExcelRange(2, 4, 5, 9),
SheetName = "Sheet2"
};Constructors
ExcelSource()
Declaration
public ExcelSource()ExcelSource(string)
Declaration
public ExcelSource(string uri)Parameters
| Type | Name | Description |
|---|---|---|
| string | uri | The source excel file name or uri |
ExcelSource(string, ResourceType)
Declaration
public ExcelSource(string uri, ResourceType resourceType)Parameters
| Type | Name | Description |
|---|---|---|
| string | uri | The source excel file name or uri |
| ResourceType | resourceType | Specifies if data is loaded from a file, a web endpoint or other storage types (e.g. Azure Blob Storage) |
Properties
ExcelColumns
List of ExcelColumn attributes to map the excel column name with a property.
E.g. if the excel has a column with the header "Key", and should be written into the property "Id",
then you can simply add a ExcelColumn mapping: ExcelColumn: ColumnName "Key" -> PropertyName: "Id".
Alternatively, you can use the Index of the column, e.g. if Key is the first column: ColumnIndex "0" -> PropertyName: "Id".
Declaration
public ICollection<ExcelColumn> ExcelColumns { get; set; }Property Value
| Type | Description |
|---|---|
| ICollection<ExcelColumn> |
ExcelFilePassword
The password for the excel files.
Declaration
public string ExcelFilePassword { get; set; }Property Value
| Type | Description |
|---|---|
| string |
FieldHeaders
The parsed header names from the excel
Declaration
public string[] FieldHeaders { get; }Property Value
| Type | Description |
|---|---|
| string[] |
HasNoHeader
Indicates that the excel data doesn't has any header information. If set to true, the ExcelSource works best with ExpandoObject or string[] arrays as output type.
Declaration
public bool HasNoHeader { get; set; }Property Value
| Type | Description |
|---|---|
| bool |
IgnoreBlankRows
If set to true, blank rows will be ignored. By default, the ExcelSource will stop reading after encountering the first blank row. Be careful if you don't define a range and set this to true.
Declaration
public bool IgnoreBlankRows { get; set; }Property Value
| Type | Description |
|---|---|
| bool |
IgnoreHiddenSheets
If set to true, sheets that are hidden in the excel file will be ignored.
Declaration
public bool IgnoreHiddenSheets { get; set; }Property Value
| Type | Description |
|---|---|
| bool |
IsCaseSensitiveSheetName
Only needed if SheetName is provided. By default, matching sheet names are case-insensitive. Set this property to true if you want to have the matching case-sensitive.
Declaration
public bool IsCaseSensitiveSheetName { get; set; }Property Value
| Type | Description |
|---|---|
| bool |
Range
The range in the excel where the data is located.
Declaration
public ExcelRange Range { get; set; }Property Value
| Type | Description |
|---|---|
| ExcelRange |
SheetName
The sheet name from which data should be read
Declaration
public string SheetName { get; set; }Property Value
| Type | Description |
|---|---|
| string |
SheetNumber
The sheet number from which data should be read - will only be taken into account if SheetName is empty.
Declaration
public int? SheetNumber { get; set; }Property Value
| Type | Description |
|---|---|
| int? |
Methods
CheckParameter()
Declaration
protected override void CheckParameter()Overrides
CloseReader()
Declaration
protected override void CloseReader()Overrides
InitReader()
Declaration
protected override void InitReader()Overrides
PrepareParameterForCheck()
Declaration
protected override void PrepareParameterForCheck()Overrides
ReadAllRecords()
Declaration
protected override void ReadAllRecords()Overrides
ReadFieldHeaders(string)
Reads the header names using the current configuration.
Declaration
public string[] ReadFieldHeaders(string uri = null)Parameters
| Type | Name | Description |
|---|---|---|
| string | uri | Optionally you can override the current configured Uri |
Returns
| Type | Description |
|---|---|
| string[] | An array with the header names |
Reset()
Declaration
protected override void Reset()