C#将html table 导出成excel实例_C#教程-查字典教程网
C#将html table 导出成excel实例
C#将html table 导出成excel实例
发布时间:2016-12-28 来源:查字典编辑
摘要:复制代码代码如下:publicvoidProcessRequest(HttpContextcontext){stringelxStr="11...

复制代码 代码如下:

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;

}

}

相关阅读
推荐文章
猜你喜欢
附近的人在看
推荐阅读
拓展阅读
  • 大家都在看
  • 小编推荐
  • 猜你喜欢
  • 最新C#教程学习
    热门C#教程学习
    编程开发子分类