C#将html table 导出成excel

 1     public void ProcessRequest (HttpContext context) {
 2 
 3        string elxStr = "<table><tbody><tr><td>1</td><td>11</td></tr><tr><td>2</td><td>22</td></tr></tbody></table>";
 4        context.Response.Clear();
 5        context.Response.Buffer = true;
 6        context.Response.AppendHeader("Content-Disposition", "attachment;filename=" + DateTime.Now.ToString("yyyyMMdd") + ".xls");
 7        context.Response.ContentEncoding = System.Text.Encoding.UTF8;
 8        context.Response.ContentType = "application/vnd.ms-excel";
 9        context.Response.Write(elxStr);
10        context.Response.End();
11     }
12  
13     public bool IsReusable {
14         get {
15             return false;
16         }
17     }
原文地址:https://www.cnblogs.com/servant/p/3027916.html