DataTable 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第二行改为各列标题字段