ha.122.gow.gn,热河杆子帮原型,工业区位论
dt:datatable
strfile:filename
strext:type
private void gridexport(datatable dt, string strfile, string strext)
{
string strapptype = "";
switch (strext)
{
case "xls":
strapptype = "application/ms-excel";
break;
case "doc":
strapptype = "application/ms-word";
break;
case "txt":
strapptype = "application/ms-txt";
break;
case "html":
case "htm":
strapptype = "application/ms-html";
break;
default: return;
}
gridview mygridview = new gridview();
mygridview.datasource = dt;
mygridview.databind();
httpcontext.current.response.clear();
httpcontext.current.response.buffer = true;
httpcontext.current.response.addheader("content-type", "text/html; charset=gb2312");
httpcontext.current.response.appendheader("content-disposition", string.format("attachment;filename={0}.{1}", httputility.urlencode(strfile,encoding.getencoding("gb2312")), strext));
httpcontext.current.response.contentencoding = system.text.encoding.getencoding("gb2312");
httpcontext.current.response.contenttype = strapptype;
//mygridview.page.enableviewstate = false;
//二、定义一个输入流
system.globalization.cultureinfo mycitrad = new system.globalization.cultureinfo("zh-cn", true);
system.io.stringwriter ostringwriter = new system.io.stringwriter(mycitrad);
system.web.ui.htmltextwriter ohtmltextwriter = new system.web.ui.htmltextwriter(ostringwriter);
//三、将目标数据绑定到输入流输出
mygridview.rendercontrol(ohtmltextwriter);
httpcontext.current.response.write(ostringwriter.tostring());
httpcontext.current.response.end();
}
如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复
Blazor server side 自家的一些开源的, 实用型项目的进度之 CEF客户端
.NET IoC模式依赖反转(DIP)、控制反转(Ioc)、依赖注入(DI)
vue+.netcore可支持业务代码扩展的开发框架 VOL.Vue 2.0版本发布
网友评论