C#将html table 导出成excel实例
程序员文章站
2023-12-13 10:41:40
复制代码 代码如下:public void processrequest (httpcontext context) { &n...
复制代码 代码如下:
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;
}
}