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.

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, ILoggableTask
Type Parameters
NameDescription
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
TypeNameDescription
stringuri

The source excel file name or uri

ExcelSource(string, ResourceType)

Declaration
    public ExcelSource(string uri, ResourceType resourceType)
Parameters
TypeNameDescription
stringuri

The source excel file name or uri

ResourceTyperesourceType

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
TypeDescription
ICollection<ExcelColumn>

ExcelFilePassword

The password for the excel files.

Declaration
    public string ExcelFilePassword { get; set; }
Property Value
TypeDescription
string

FieldHeaders

The parsed header names from the excel

Declaration
    public string[] FieldHeaders { get; }
Property Value
TypeDescription
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
TypeDescription
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
TypeDescription
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
TypeDescription
bool

Range

The range in the excel where the data is located.

Declaration
    public ExcelRange Range { get; set; }
Property Value
TypeDescription
ExcelRange

SheetName

The sheet name from which data should be read

Declaration
    public string SheetName { get; set; }
Property Value
TypeDescription
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
TypeDescription
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
TypeNameDescription
stringuri

Optionally you can override the current configured Uri

Returns
TypeDescription
string[]

An array with the header names

Reset()

Declaration
    protected override void Reset()
Overrides

Implements