Click or drag to resize

IWorksheet InsertDataView Method (DataView, Boolean, Int32, Int32)

Imports data from a DataView into worksheet.
Examples
The following code illustrates how to Imports data from a DataView into a worksheet with the specified row and column:
<para>//Create worksheet</para><para>Workbook workbook = new Workbook();</para><para>Worksheet worksheet = workbook.Worksheets[0];</para><para>//Create a DataTable</para><para>System.Data.DataTable table = new System.Data.DataTable();</para><para>table.Columns.Add("ID", typeof(int));
 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>//Initialize dataview of datatable</para><para>System.Data.DataView view = table.DefaultView;</para><para>//Import data from DataView</para><para>worksheet.InsertDataView(view, true, 1, 1);</para><para>//Save to file</para><para>workbook.SaveToFile(InsertDataView.xlsx");</para>

Namespace: Spire.Xls.Core
Assembly: Spire.XLS (in Spire.XLS.dll) Version: 15.4.0.0 (15.4.0.5046)
Syntax
int InsertDataView(
	DataView dataView,
	bool isFieldNameShown,
	int firstRow,
	int firstColumn
)

Parameters

dataView
Type: System.Data DataView
DataView 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 DataView should be imported.
firstColumn
Type: System Int32
Column of the first cell where DataView should be imported.

Return Value

Type: Int32
Number of imported rows.
See Also