6", "信息6");
DataSet ds = new DataSet();
List<DataTable> newTables = new List<DataTable>();
HashSet<string> groupNames = new HashSet<string>();
foreach (DataRow row in dt.Rows)
{
string groupName = row["分组"].ToString();
if (!groupNames.Contains(groupName))
{
groupNames.Add(groupName);
DataTable newTable = new DataTable(groupName);
newTable.Columns.Add("名字");
newTable.Columns.Add("信息");
newTable.Rows.Add(row["名字"], row["信息"]);
newTables.Add(newTable);
}
else
{
DataTable newTable = newTables.Find(x => x.TableName == groupName);
newTable.Rows.Add(row["名字"], row["信息"]);
}
}
ds.Tables.AddRange(newTables.ToArray());
上一页 [1] [2]