[]
        
(Showing Draft Content)

GrapeCity.Documents.Excel.IRange.ImportData

ImportData Method

ImportData(IEnumerable, DataImportOptions)

Imports data from a data source (up to 2D) to the range.

Declaration
DataImportResult ImportData(IEnumerable items, DataImportOptions options = null)
Function ImportData(items As IEnumerable, Optional options As DataImportOptions = Nothing) As DataImportResult
Parameters
Type Name Description
IEnumerable items

The items to import. The element type can be:

The collection type can be:
  • Flat (non-jagged, 1D in total) IEnumerable. For example, DataView.
  • Jagged (2D in total) IEnumerable or IEnumerable<T> where the element type of inner collection is primitive or nullable primitive.
  • 2D array where element type is primitive or nullable primitive.
DataImportOptions options

The import options.

Returns
Type Description
DataImportResult
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.

Exceptions
Type Condition
InvalidCastException

The data type of a column is inconsistent. Use ItemTypeProvider to fix it.

ArgumentException

An item is of an unsupported type or options contains incorrect information.

NotSupportedException

It's typically thrown when AOT compatibility issues occur at runtime.

ImportData<T>(IEnumerable<T>, DataImportOptions)

Imports data from a data source (up to 2D) to the range.

Declaration
DataImportResult ImportData<T>(IEnumerable<T> items, DataImportOptions options = null)
Function ImportData(Of T)(items As IEnumerable(Of T), Optional options As DataImportOptions = Nothing) As DataImportResult
Parameters
Type Name Description
IEnumerable<T> items

The items to import. The element type can be:

The collection type can be:
  • Flat (non-jagged, 1D in total) IEnumerable<T>.
  • Jagged (2D in total) IEnumerable<T> where the element type of inner collection is primitive or nullable primitive.
  • 2D array where element type is primitive or nullable primitive.
DataImportOptions options

The import options.

Returns
Type Description
DataImportResult
Type Parameters
Name Description
T
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.

Exceptions
Type Condition
InvalidCastException

The data type of a column is inconsistent. Check whether the implementation of ItemTypeProvider is correct.

ArgumentException

An item is of an unsupported type or options contains incorrect information.

NotSupportedException

It's typically thrown when AOT compatibility issues occur at runtime.

ImportData(DataTable, DataImportOptions)

Imports data from a table to the range.

Declaration
DataImportResult ImportData(DataTable table, DataImportOptions options = null)
Function ImportData(table As DataTable, Optional options As DataImportOptions = Nothing) As DataImportResult
Parameters
Type Name Description
DataTable table

The table to import. The column type can be:

DataImportOptions options

The import options.

Returns
Type Description
DataImportResult
Exceptions
Type Condition
InvalidCastException

The data type of a column is inconsistent.

ArgumentException

options contains incorrect information.

NotSupportedException

It's typically thrown when AOT compatibility issues occur at runtime.