Search Results for

    Show / Hide Table of Contents

    Class XlsxTargetFactory

    Factory methods that create an XlsxTarget<TInput> 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).

    The Input port is linked to (if available) the upstream output or error output port specified by the factory.

    Get the factory from Link when the upstream port is known ahead of time (which is usually the case). Otherwise get it from GetDownstreamFactory<TInput>(), and link the transform or target explicitly using LinkTo(InputPort<TOutput>) or LinkFrom(OutputPortBase<TInput>).

    Also see XLSX Spreadsheet.

    Inheritance
    Object
    XlsxTargetFactory
    Namespace: actionETL.EPPlus
    Assembly: actionETL.dll
    Syntax
    public static class XlsxTargetFactory

    Methods

    XlsxTarget<TInput>(in DownstreamFactory<TInput>, String, Action<IXlsxTargetCommand>, String)

    Initializes a new instance of the XlsxTarget<TInput> dataflow worker, which consumes incoming rows and writes them to an XLSX spreadsheet file. The worker will fail if the XLSX file already exists.

    The Input port is linked to (if available) the upstream output or error output port specified by the factory.

    Declaration
    public static XlsxTarget<TInput> XlsxTarget<TInput>(this in DownstreamFactory<TInput> downstreamFactory, string workerName, Action<IXlsxTargetCommand> xlsxTargetCommands, string fileName)
        where TInput : class
    Parameters
    Type Name Description
    DownstreamFactory<TInput> downstreamFactory

    The downstream factory, which specifies the parent worker and (optionally) the upstream port to link the "first" input port of this dataflow worker to.

    Get it from Link when the upstream port is known ahead of time (which is usually the case). Otherwise get it from GetDownstreamFactory<TInput>(), and link the transform or target explicitly using LinkTo(InputPort<TOutput>) or LinkFrom(OutputPortBase<TInput>).

    String workerName

    Name of the worker.

    Set to a prefix plus a trailing "/" (e.g. "MyPrefix-/") to generate a unique name from the prefix plus an increasing number starting at 1.

    While less useful, set to null, whitespace or "/" to generate a unique name from the worker type plus an increasing number starting at 1.

    The name cannot otherwise contain "/", and cannot start with double underscore "__".

    Action<IXlsxTargetCommand> xlsxTargetCommands

    The commands that defines where to write, which columns to include, and their formatting, e.g.:

    xtc => xtc
        .Address("'My Sheet'!B5")
        .FromNames("Category", "Subcategory")
        .Name("Date").Format("yyyy-mm-dd")

    Must be set before the worker runs.

    Column name matching is ordinal case insensitive, but a case sensitive match takes precedence over a case insensitive match.

    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.

    String fileName

    The filename of the XLSX file.

    Returns
    Type Description
    XlsxTarget<TInput>
    Type Parameters
    Name Description
    TInput

    The type of each Input row, which also defines the default file headers and data types of the written file.

    Exceptions
    Type Condition
    ArgumentException

    workerName:

    • Workers with the same parent must have unique names.
    • Worker and worker system names cannot contain '/' or start with double underscore '__'.
    ArgumentNullException

    workerParent - All workers must have a parent. The top level workers have the worker system as parent.

    InvalidOperationException
    • Cannot add child worker to parent which has completed. Are you adding it to the correct parent?
    • Cannot add worker to parent, since its children have been started. Are you adding it to the correct parent?

    XlsxTarget<TInput>(in DownstreamFactory<TInput>, String, Action<IXlsxTargetCommand>, String, XlsxTargetWriteOption)

    Initializes a new instance of the XlsxTarget<TInput> dataflow worker, which consumes incoming rows and writes them to an XLSX spreadsheet file.

    The Input port is linked to (if available) the upstream output or error output port specified by the factory.

    Declaration
    public static XlsxTarget<TInput> XlsxTarget<TInput>(this in DownstreamFactory<TInput> downstreamFactory, string workerName, Action<IXlsxTargetCommand> xlsxTargetCommands, string fileName, XlsxTargetWriteOption writeOption)
        where TInput : class
    Parameters
    Type Name Description
    DownstreamFactory<TInput> downstreamFactory

    The downstream factory, which specifies the parent worker and (optionally) the upstream port to link the "first" input port of this dataflow worker to.

    Get it from Link when the upstream port is known ahead of time (which is usually the case). Otherwise get it from GetDownstreamFactory<TInput>(), and link the transform or target explicitly using LinkTo(InputPort<TOutput>) or LinkFrom(OutputPortBase<TInput>).

    String workerName

    Name of the worker.

    Set to a prefix plus a trailing "/" (e.g. "MyPrefix-/") to generate a unique name from the prefix plus an increasing number starting at 1.

    While less useful, set to null, whitespace or "/" to generate a unique name from the worker type plus an increasing number starting at 1.

    The name cannot otherwise contain "/", and cannot start with double underscore "__".

    Action<IXlsxTargetCommand> xlsxTargetCommands

    The commands that defines where to write, which columns to include, and their formatting, e.g.:

    xtc => xtc
        .Address("'My Sheet'!B5")
        .FromNames("Category", "Subcategory")
        .Name("Date").Format("yyyy-mm-dd")

    Must be set before the worker runs.

    Column name matching is ordinal case insensitive, but a case sensitive match takes precedence over a case insensitive match.

    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.

    String fileName

    The filename of the XLSX file.

    XlsxTargetWriteOption writeOption

    Controls whether to use, overwrite, or fail when there is an existing file.

    Returns
    Type Description
    XlsxTarget<TInput>
    Type Parameters
    Name Description
    TInput

    The type of each Input row, which also defines the default file headers and data types of the written file.

    Exceptions
    Type Condition
    ArgumentException

    workerName:

    • Workers with the same parent must have unique names.
    • Worker and worker system names cannot contain '/' or start with double underscore '__'.
    ArgumentNullException

    workerParent - All workers must have a parent. The top level workers have the worker system as parent.

    InvalidOperationException
    • Cannot add child worker to parent which has completed. Are you adding it to the correct parent?
    • Cannot add worker to parent, since its children have been started. Are you adding it to the correct parent?

    See Also

    XlsxTarget<TInput>
    IXlsxTargetCommand
    XlsxSource<TOutput>
    OrderAttribute
    In This Article
    Back to top Copyright © 2023 Envobi Ltd