当前位置: 移动技术网 > IT编程>开发语言>c# > C#将html table 导出成excel实例

C#将html table 导出成excel实例

2019年07月18日  | 移动技术网IT编程  | 我要评论
复制代码 代码如下:

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;
         }
     }

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网