将行和列添加到 Google DataTable Net Wrapper
Add Rows and Columns to Google DataTable Net Wrapper
我正在从头开始创建 Google DataTable Net Wrapper DataTable。但我不知道如何向数据表中添加行。我已经取得了如下代码
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
}
}
无法找到将值添加到行和特定列的代码。帮助表示赞赏。
这是一种适合您现有代码的方法:
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);
}
我正在从头开始创建 Google DataTable Net Wrapper DataTable。但我不知道如何向数据表中添加行。我已经取得了如下代码
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
}
}
无法找到将值添加到行和特定列的代码。帮助表示赞赏。
这是一种适合您现有代码的方法:
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);
}