Behind code of aspx page, I have a Datatable:
Dim people As DataTable = New DataTable()
people.Columns.Add("ID", System.Type.GetType("System.Int32"))
people.Columns.Add("FirstName", System.Type.GetType("System.String"))
people.Columns.Add("LastName", System.Type.GetType("System.String"))
people.Rows.Add(10, "Merci", "Beaucoup")
and this the GridViewData: (Not asp:GridView)
Dim gvPeople As System.Windows.Forms.DataGridView = New DataGridView()
gvPeople.AutoGenerateColumns = False
'Set Columns Count
gvPeople.ColumnCount = 3
'Add Columns
gvPeople.Columns(0).Name = "ID"
gvPeople.Columns(0).HeaderText = "ID"
gvPeople.Columns(0).DataPropertyName = "ID"
gvPeople.Columns(1).Name = "FirstName"
gvPeople.Columns(1).HeaderText = "FirstName"
gvPeople.Columns(1).DataPropertyName = "FirstName"
gvPeople.Columns(2).Name = "LastName"
gvPeople.Columns(2).HeaderText = "LastName"
gvPeople.Columns(2).DataPropertyName = "LastName"
Here I set the datasource of the DataGridView to the DataTable:
gvPeople.DataSource = people
When I import the DataGridView into the Excel sheet using Gembox.Spreadsheet
, it only shows me the headerText of the DataGridView without the data.
This is the Import Code:
DataGridViewConverter.ImportFromDataGridView(ws, gvPeople, New ImportFromDataGridViewOptions() With _
{
.ColumnHeaders = True,
.StartRow = 8,
.StartColumn = 0
})
I tried multiple things such as:
setting up the
.DataMember
to the DataTable name :gvPeople.DataMember=people.TableName
Refresh()
orUpdate()
the DataGridView after assigning the.Datasource
.
Note: This is not an asp:GridView
, it's a DataGridView
and it does not have a DataBind()
method.