Click or drag to resize

XlsWorksheet InsertDataColumn Method

Imports data column.
Examples
The following code illustrates how to Imports data from a DataColumn 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>//Insert the DataColumn to worksheet</para><para>System.Data.DataColumn column = table.Columns[2];</para><para>worksheet.InsertDataColumn(column, true, 1, 1);</para><para>//Save to file</para><para>workbook.SaveToFile(InsertDataColumn.xlsx");</para>

Namespace: Spire.Xls.Core.Spreadsheet
Assembly: Spire.XLS (in Spire.XLS.dll) Version: 15.4.0.0 (15.4.0.5046)
Syntax
public int InsertDataColumn(
	DataColumn dataColumn,
	bool columnHeaders,
	int firstRow,
	int firstColumn
)

Parameters

dataColumn
Type: System.Data DataColumn
Data column to import.
columnHeaders
Type: System Boolean
Indicates whether to import field names.
firstRow
Type: System Int32
Index of the first row.
firstColumn
Type: System Int32
Index of the first column

Return Value

Type: Int32

Implements

IWorksheet InsertDataColumn(DataColumn, Boolean, Int32, Int32)
See Also