C# html table转excel

1.

 1         protected void ebtDC_Click(object sender, EventArgs e)
 2         {
 3 
 4             string elxStr = "<table><tbody><tr><td>1</td><td>11</td></tr><tr><td>2</td><td>22</td></tr></tbody></table>";
 5             Response.Clear();
 6             Response.Buffer = true;
 7             Response.AppendHeader("Content-Disposition", "attachment;filename=" + DateTime.Now.ToString("yyyyMMdd") + ".xls");
 8             Response.ContentEncoding = System.Text.Encoding.UTF8;
 9             Response.ContentType = "application/vnd.ms-excel";
10             Response.Write(elxStr);
11             Response.End();
12         }

如果是身份证  string.Concat("'", dt.Rows[i]["CardNum"].ToString())

作者:chenze
出处:https://www.cnblogs.com/chenze-Index/
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。
如果文中有什么错误,欢迎指出。以免更多的人被误导。
原文地址:https://www.cnblogs.com/chenze-Index/p/10416770.html