Table of Contents

Class ExcelDataConnector

Namespace
Datafication.Connectors.ExcelConnector
Assembly
Datafication.ExcelConnector.dll

Represents an Excel data connector which is used to connect to an Excel data source and retrieve data.

public class ExcelDataConnector : IDataConnector
Inheritance
object
ExcelDataConnector
Implements

Remarks

This connector uses the ExcelDataReader library (MIT licensed) to read Excel files (XLSX, XLS) into a DataBlock.

Constructors

ExcelDataConnector(ExcelConnectorConfiguration)

Initializes a new instance of the ExcelDataConnector class.

public ExcelDataConnector(ExcelConnectorConfiguration configuration)

Parameters

configuration ExcelConnectorConfiguration

The configuration for the Excel connector.

Exceptions

ArgumentNullException

Thrown when configuration is null.

ArgumentException

Thrown when the configuration validation fails.

Properties

Configuration

Gets the configuration for the Excel data connector.

public ExcelConnectorConfiguration Configuration { get; }

Property Value

ExcelConnectorConfiguration

Methods

GetConnectorId()

Gets the connector's unique identifier.

public string GetConnectorId()

Returns

string

GetDataAsync()

Asynchronously retrieves data from the Excel file specified in the configuration.

public Task<DataBlock> GetDataAsync()

Returns

Task<DataBlock>

A task that represents the asynchronous operation. The task result contains a DataBlock with the Excel data.

Remarks

This method reads the specified Excel file and converts its contents into a DataBlock. The sheet to read is determined by either SheetName or SheetIndex in the configuration. If HasHeader is true, the first row will be used as column names.

Exceptions

Exception

Thrown when there is an error reading the Excel file or when the configuration is invalid.

GetStorageDataAsync(IStorageDataBlock, int)

Asynchronously retrieves data from the Excel file and appends it in batches to the provided storage data block.

public Task<IStorageDataBlock> GetStorageDataAsync(IStorageDataBlock target, int batchSize = 10000)

Parameters

target IStorageDataBlock

The storage data block to append batches to.

batchSize int

The maximum number of rows to accumulate before appending a batch. Defaults to 10000.

Returns

Task<IStorageDataBlock>

A task that represents the asynchronous operation. The task result contains the provided IStorageDataBlock with all data appended.

Remarks

This method mirrors the exact data processing logic from GetDataAsync() but streams data in batches to the provided storage block. The sheet to read is determined by either SheetName or SheetIndex in the configuration. If HasHeader is true, the first row will be used as column names.

Exceptions

ArgumentNullException

Thrown when target is null.

Exception

Thrown when there is an error reading the Excel file or when the configuration is invalid.