//内容很好理解,只需当成Table来拼字符串即可
private string getExcelContent(DataTable dt)
{
StringBuilder sb = new StringBuilder();
sb.Append("<table>");
sb.Append("<thead><tr>");
for (int m = 0; m < dt.Columns.Count; m++)
{
sb.Append("<th>" + dt.Columns[m] + "</th>");
}
sb.Append("</tr></thead>");
sb.Append("<tbody>");
for (int i = 0; i < dt.Rows.Count; i++)
{
sb.Append("<tr>");
for (int j = 0; j < dt.Columns.Count; j++)
{
sb.Append("<td>" + dt.Rows[i][dt.Columns[j]] + "</td>");
}
sb.Append("</tr>");
}
sb.Append("</tbody></table>");
return sb.ToString();
}