C#将html table 导出成excel实例
发布时间:2020-12-15 05:51:49 所属栏目:百科 来源:网络整理
导读:复制代码 代码如下: public void ProcessRequest (HttpContext context) { string elxStr = "tabletbodytrtd1/tdtd11/td/trtrtd2/tdtd22/td/tr/tbody/table"; context.Response.Clear(); context.Response.Buffer = true; context.Response.AppendHeader("Co
复制代码 代码如下: public void ProcessRequest (HttpContext context) { string elxStr = "<table><tbody><tr><td>1</td><td>11</td></tr><tr><td>2</td><td>22</td></tr></tbody></table>"; 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; } } (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |