IWorksheet
InsertDataTable Method (DataTable, Boolean, Int32, Int32, Int32, Int32, Boolean)
|
Imports data from a DataTable into worksheet.
Examples
The following code illustrates how to Imports data from a DataTable into a worksheet with specified range along with preserve type:
<para>
table.Columns.Add("Item", typeof(string));
table.Columns.Add("Name", typeof(string));</para><para>table.Rows.Add(1, "Soap", "David");
table.Rows.Add(2, "Paste", "Sam");
table.Rows.Add(3, "Cream", "Christoff");</para><para>
Namespace:
Spire.Xls.Core
Assembly:
Spire.XLS (in Spire.XLS.dll) Version: 15.4.0.0 (15.4.0.5046)
Syntax
int InsertDataTable(
DataTable dataTable,
bool isFieldNameShown,
int firstRow,
int firstColumn,
int maxRows,
int maxColumns,
bool preserveTypes
)
Function InsertDataTable (
dataTable As DataTable,
isFieldNameShown As Boolean,
firstRow As Integer,
firstColumn As Integer,
maxRows As Integer,
maxColumns As Integer,
preserveTypes As Boolean
) As Integer
int InsertDataTable(
DataTable^ dataTable,
bool isFieldNameShown,
int firstRow,
int firstColumn,
int maxRows,
int maxColumns,
bool preserveTypes
)
abstract InsertDataTable :
dataTable : DataTable *
isFieldNameShown : bool *
firstRow : int *
firstColumn : int *
maxRows : int *
maxColumns : int *
preserveTypes : bool -> int
Parameters
-
dataTable
-
Type:
System.Data
DataTable
DataTable with desired data.
-
isFieldNameShown
-
Type:
System
Boolean
True if column names must also be imported.
-
firstRow
-
Type:
System
Int32
Row of the first cell where DataTable should be imported.
-
firstColumn
-
Type:
System
Int32
Column of the first cell where DataTable should be imported.
-
maxRows
-
Type:
System
Int32
Maximum number of rows to import.
-
maxColumns
-
Type:
System
Int32
Maximum number of columns to import.
-
preserveTypes
-
Type:
System
Boolean
Indicates whether XlsIO should try to preserve types in DataTable,
i.e. if it is set to False (default) and in DataTable we have in string column
value that contains only numbers, it would be converted to number.
Return Value
Type:
Int32
Number of imported rows.
See Also