Class XlsxTarget<TInput>
A dataflow worker with one Input port, which consumes incoming rows and
writes them to a rectangular area on one sheet in an XLSX spreadsheet file.
No driver installation is required (it uses the
EPPlus library internally).
Note: Use the factory methods in XlsxTargetFactory to create instances of this class.
Also see XLSX Spreadsheet.
Implements
Inherited Members
Namespace: actionETL.EPPlus
Assembly: actionETL.dll
Syntax
public class XlsxTarget<TInput> : WorkerBase<XlsxTarget<TInput>>, IDisposeOnFinished where TInput : class
Type Parameters
| Name | Description |
|---|---|
| TInput | The type of each |
Properties
FileName
The filename to write to. Cannot be set after the worker has started running.
Note: This property is thread-safe.
Declaration
public string FileName { get; set; }
Property Value
| Type | Description |
|---|---|
| String |
Exceptions
| Type | Condition |
|---|---|
| InvalidOperationException | Cannot set the value after the worker has started running. |
HeaderRow
Gets or sets a value indicating whether to write a header row.
If true, the header column names are taken from the column names of the incoming rows.
Cannot be set after the worker has started running.
Note: This property is thread-safe.
Declaration
public bool HeaderRow { get; set; }
Property Value
| Type | Description |
|---|---|
| Boolean |
|
Exceptions
| Type | Condition |
|---|---|
| InvalidOperationException | Cannot set the value after the worker has started running. |
Input
Gets the input port for receiving rows from an upstream worker.
Declaration
public InputPort<TInput> Input { get; }
Property Value
| Type | Description |
|---|---|
| InputPort<TInput> |
PasswordFunc
Gets or sets the password function. If set, this function is called to retrieve the password string
when the worker saves the XLSX file. Cannot be set after the worker has started running.
It defaults to null.
Note: This property is thread-safe.
Declaration
public Func<string> PasswordFunc { get; set; }
Property Value
| Type | Description |
|---|---|
| Func<String> | The password function, which must return the password to use, or |
Exceptions
| Type | Condition |
|---|---|
| InvalidOperationException | Cannot set the value after the worker has started running. |
TemplateFileName
Gets or sets the name of a template file, a copy of which will be used as a starting point when
creating a new XLSX file. Defaults to null, i.e. do not use a template file.
Cannot be set after the worker has started running.
Use the template file to add charts, borders etc. as well as static data.
TemplateFileName is mutually exclusive with UseExisting.
Note: This property is thread-safe.
Declaration
public string TemplateFileName { get; set; }
Property Value
| Type | Description |
|---|---|
| String |
Exceptions
| Type | Condition |
|---|---|
| InvalidOperationException | Cannot set the value after the worker has started running. |
WriteOption
Gets or sets a value indicating whether to use or overwrite any existing file. Cannot be set after the worker has started running.
Note: This property is thread-safe.
Declaration
public XlsxTargetWriteOption WriteOption { get; set; }
Property Value
| Type | Description |
|---|---|
| XlsxTargetWriteOption | The write option value. |
Exceptions
| Type | Condition |
|---|---|
| InvalidOperationException | Cannot set the value after the worker has started running. |
XlsxTargetCommands
Gets or sets the commands that defines where to write, which columns to include, and their formatting, e.g.:
XlsxTargetCommands = xtc => xtc
.Address("'My Sheet'!B5")
.FromNames("Category", "Subcategory")
.Name("Date").Format("yyyy-mm-dd");
Must be set before the worker runs, and cannot be set after the worker has started running.
Column name matching is ordinal case insensitive, but a case sensitive match takes precedence over a case insensitive match.
The Address() specifies the top left cell to export to,
e.g. "B10", or a range, e.g. "A1:F15". The address can optionally include a sheet
name, e.g. "'My Sheet'!A1".
The default write address is the top left cell (i.e. "A1") on the first sheet. If there is no
existing sheet, a new sheet called "Sheet1" will be created.
Note: This property is thread-safe.
Declaration
public Action<IXlsxTargetCommand> XlsxTargetCommands { get; set; }
Property Value
| Type | Description |
|---|---|
| Action<IXlsxTargetCommand> |
Exceptions
| Type | Condition |
|---|---|
| InvalidOperationException | Cannot set the value after the worker has started running. |
Methods
RunAsync()
This method can be overridden to add custom functionality to the derived worker that runs before
and after the row processing. In this case, the base class base.RunAsync() must
be called for the worker to function correctly.
Typically, this worker is used without overriding this method.
Declaration
protected override async Task<OutcomeStatus> RunAsync()
Returns
| Type | Description |
|---|---|
| Task<OutcomeStatus> | A |