response.clear();
response.buffer= true;
response.charset="gb2312";
response.appendheader("content-disposition","attachment;filename=filename.xls");
response.contentencoding=system.text.encoding.getencoding("gb2312");
//设置输出流为简体中文
response.contenttype = "application/ms-excel";
//设置输出文件类型为excel文件。
this.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);
datagrid1.rendercontrol(ohtmltextwriter);
response.write(ostringwriter.tostring());
response.end();
}
新闻热点
疑难解答