当前位置: 编程技术>.net/c#/asp.net
C#将html table 导出成excel实例
来源: 互联网 发布时间:2014-10-18
本文导语: 代码如下:public void ProcessRequest (HttpContext context) { string elxStr = "111222"; context.Response.Clear(); context.Response.Buffer = true; context.Response.AppendHeader("Content-Disposition", "attachment;filename=" + DateTime.Now.To...
代码如下:
public void ProcessRequest (HttpContext context) {
string elxStr = "111222";
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;
}
}