C#将html table 导出成excel实例

复制代码 代码如下:

public void ProcessRequest (HttpContext context) {

        string elxStr = "
111
222
";
        context.Response.Clear();
        context.Response.Buffer = true;
        context.Response.AppendHeader("Content-Disposition", "attachment;filename=" + DateTime.Now.ToString("yyyyMMdd") + ".xls");
        context.Response.ContentEncoding = System.Text.Encoding.UTF8;
        context.Response.ContentType = "application/vnd.ms-excel";
        context.Response.Write(elxStr);
        context.Response.End();
     }

     public bool IsReusable {
         get {
             return false;
         }
     }

你可能感兴趣的:(C#将html table 导出成excel实例)