ImportData(IEnumerable,DataImportOptions) Method
In This Topic
Imports data from a data source (up to 2D) to the range.
Syntax
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
Exception | Description |
System.InvalidCastException | The data type of a column is inconsistent. Use DataImportOptions.ItemTypeProvider to fix it. |
System.ArgumentException | An item is of an unsupported type or contains incorrect information. |
System.NotSupportedException |
It's typically thrown when AOT compatibility issues occur at runtime.
|
See Also