c# DataTable第二行改为各列标题字段
2021-01-27 21:16
标签:tar item break path file inf foreach highlight new c# DataTable第二行改为各列标题字段 c# DataTable第二行改为各列标题字段 标签:tar item break path file inf foreach highlight new 原文地址:https://www.cnblogs.com/SeNaiTes/p/11919105.htmlDataTable dt = ExcelHelper.ToDataTable(fileinfo.FilePath);
//将datatable的第二行变为列标题字段
DataTable dt2 = new DataTable();
foreach (DataRow item in dt.Rows)
{
foreach (var item2 in item.ItemArray)
dt2.Columns.Add(item2.ToString(), typeof(string));
break;
}
int k = 0;
foreach (DataRow item in dt.Rows)
if (k == 0)
{
k++;
continue;
}
else
dt2.Rows.Add(item.ItemArray);
文章标题:c# DataTable第二行改为各列标题字段
文章链接:http://soscw.com/index.php/essay/47930.html