Document Solutions for Excel, .NET Edition | Document Solutions
GrapeCity.Documents.Excel Namespace / DataImportOptions Class / ColumnsSelector Property
In This Topic
    ColumnsSelector Property
    In This Topic
    Selects columns to import. The default behavior is to auto-generate all columns.
    Syntax
    public System.Func<object,IEnumerable> ColumnsSelector {get; set;}

    Property Value

    The delegate accepts the collection or System.Data.DataTable to select columns.
    The delegate returns different types of values to describe selected columns:
    • Returns System.Collections.Generic.IEnumerable`1 of System.Data.DataColumn to select columns for the specified System.Data.DataTable.
    • Returns System.Collections.Generic.IEnumerable`1 of System.Int32 to select columns by indexes for the specified System.Data.DataTable.
    • Returns System.Collections.Generic.IEnumerable`1 of System.String to select columns by names for the specified System.Data.DataTable, dictionary or custom object. This option is not AOT-compatible for custom objects.
    • Returns System.Collections.Generic.IEnumerable`1 of property getter System.Delegate (where the delegate type of each element is System.Func`2, T is the element type of collection, TResult is the property type) to select columns with custom column getters.
      In this case, IncludeColumnsHeader must be false. Otherwise, an exception will be thrown. Because we don't know the column names.
    • Returns System.Collections.Generic.IEnumerable`1 of named property getter System.ValueTuple`2 (where T1 is column name System.String, T2 is property getter System.Delegate; The delegate type of each element is System.Func`2, T is the element type of collection, TResult is the property type) to select columns with custom column names and custom column getters.
      In this case, IncludeColumnsHeader should be true. Otherwise, the column names will be ignored.
    Remarks
    The default behavior is not AOT-compatible for custom objects.
    See Also