| 何全江(队长) | 201731024218 |
|---|---|
| 胡志伟 | 201731024240 |
| 李元港 | 201731024232 |
| 孟诚成 | 201731024242 |
| 罗俊杰 | 201731024226 |
| 雷安勇 | 201731024215 |
| 李宣晓 | 201731024108 |

static public void Export(DataTable dt,string filename )
{
List<string> infoList = new List<string>();
for (int r = 0; r < dt.Rows.Count; r++)
{
string info="";
for (int c = 0; c < dt.Columns.Count; c++)
{
DataRow dr = dt.Rows[r];
info += dr[c] + " ";
}
infoList.Add(info);
}
StreamWriter sw = new StreamWriter(filename);
foreach (string i in infoList)
{
sw.WriteLine(i);
}
sw.Close();
}
private void BtnExport_Click(object sender, EventArgs e)
{
string filename= @"C:\Users\he\Desktop\考勤.txt";
if (dt.Rows.Count==0)
{
MessageBox.Show("学生信息为空");
}
else
{
User.Export(dt,filename);
MessageBox.Show("考勤信息已导出到"+filename+",请及时备份");
}
}

| 预计时间 | 7 天 |
|---|---|
| 已花时间 | 5天 |
| 剩余时间 | 2天 |

原文:https://www.cnblogs.com/ssylddd/p/11926867.html