private DataTable RowToCol(DataTable Dt_newData)
{
DataTable Dt_Return = new DataTable();
DataColumn col = new DataColumn();
col.ColumnName = "Title";
col.Caption = "Title";
Dt_Return.Columns.Add(col);
List<string> colName = new List<string>();
foreach (DataColumn dc in Dt_NewData.Columns) //(DataColumn dc in Dt_NewData.Columns)
{
Dt_Return.Rows.Add(dc.ColumnName);
}
int c = 0;
for (int n = 0; n < Dt_NewData.Rows.Count; n++)//DataRow dr in Dt_NewData.Rows
{
c = c + 1;
col = new DataColumn();
col.DataType = typeof(string);
col.ColumnName = "cols" + c;
col.Caption = "cols " + c;
Dt_Return.Columns.Add(col);
// 全部显示
for (int m = 0; m < Dt_NewData.Columns.Count; m++)
{
Dt_Return.Rows[m][col.ColumnName] = Dt_NewData.Rows[n][m].ToString();
// Dt_Return.Rows[m][n] = Dt_NewData.Rows[n][m].ToString();
}
}
return Dt_Return;
}