Document Solutions for Excel, .NET Edition | Document Solutions
GrapeCity.Documents.Excel Namespace / IRange Interface / ImportData Method / ImportData(IEnumerable,DataImportOptions) Method
The items to import. The element type can be:
The collection type can be:
The import options.
In This Topic
    ImportData(IEnumerable,DataImportOptions) Method
    In This Topic
    Imports data from a data source (up to 2D) to the range.
    Syntax
    DataImportResult ImportData( 
       System.Collections.IEnumerable items,
       DataImportOptions options
    )

    Parameters

    items
    The items to import. The element type can be:
    • Primitive types: System.SByte, System.Byte, System.Int16, System.UInt16, System.Int32, System.UInt32, System.Int64, System.UInt64, System.Single, System.Double, System.Decimal, System.Boolean, System.DateTime, System.TimeSpan or CalcError.
    • Nullable primitives: System.String or System.Nullable`1 where T is a primitive type.
    • Custom objects: objects that have properties to be mapped to cell values.
    • System.Collections.Generic.IReadOnlyDictionary`2 or System.Collections.Generic.IDictionary`2 or System.Collections.IDictionary where the key is System.String: It will be treated as collection of property names and values.
    • System.Data.DataRow or System.Data.DataRowView.
    The collection type can be:
    • Flat (non-jagged, 1D in total) System.Collections.IEnumerable. For example, System.Data.DataView.
    • Jagged (2D in total) System.Collections.IEnumerable or System.Collections.Generic.IEnumerable`1 where the element type of inner collection is primitive or nullable primitive.
    • 2D array where element type is primitive or nullable primitive.
    options
    The import options.
    Exceptions
    ExceptionDescription
    The data type of a column is inconsistent. Use DataImportOptions.ItemTypeProvider to fix it.
    An item is of an unsupported type or options contains incorrect information.
    It's typically thrown when AOT compatibility issues occur at runtime.
    Remarks
    If the item collection is a list of primitive types, the orientation is determined by the shape of range. If the row count of the range is greater than column count, we import the collection vertically. Otherwise, we import the collection horizontally.
    See Also