I am creating a Google DataTable Net Wrapper DataTable from the scratch. But I dont know how to add rows to the datatable. I have progressed to the code as below
Google.DataTable.Net.Wrapper.DataTable GDt = new Google.DataTable.Net.Wrapper.DataTable();
for (int i = 0; i < dtReports.Columns.Count; i++)
{
Google.DataTable.Net.Wrapper.Column gc = new Google.DataTable.Net.Wrapper.Column();
gc.Id = dtReports.Columns[i].Caption.Substring(0, dtReports.Columns[i].Caption.IndexOf("~"));
gc.Label = dtReports.Columns[i].Caption.Substring(dtReports.Columns[i].Caption.IndexOf("~"), dtReports.Columns[i].Caption.Length);
GDt.AddColumn(gc);
for (int j = 0; j < dtReports.Rows.Count; j++)
{
Google.DataTable.Net.Wrapper.Row gr = GDt.NewRow();
// Code to add datatable current column and row value to Google Row
}
}
Not able to find code to add the values to the row and particular column. Help appreciated.
Here is one way you could do it which fits with your existing code:
for (int j = 0; j < dtReports.Rows.Count; j++)
{
// Code to add datatable current column and row value to Google Row
Google.DataTable.Net.Wrapper.Row gr = i == 0 ? GDt.NewRow() : GDt.Rows.ElementAt(j);
gr.AddCell(new Cell(dtReports.Rows[j][i]));
if (i == 0) GDt.AddRow(gr);
}