这个在asp的时候我是这么做的,但是在asp.net中,还是推荐用现成的对象好,比如
httpcontext.current.response.appendheader("content-disposition", "attachment;filename=" + filename);
httpcontext.current.response.charset = "utf-8";
httpcontext.current.response.contentencoding = system.text.encoding.default;
httpcontext.current.response.contenttype = filetype;
//httpcontext.current.response.contenttype = "application/ms-excel";//upload/200902/jpeg;text/html;image/gif;vnd.ms-excel/msword
system.io.stringwriter tw = new system.io.stringwriter();
system.web.ui.htmltextwriter hw = new system.web.ui.htmltextwriter(tw);
gv.rendercontrol(hw);
httpcontext.current.response.write(tw.tostring());
httpcontext.current.response.end(); 回复
# re: web导出word需要添加头文件 2006-08-15 23:50 尧尧
@aspnetx
是的,我也是用现成的,这就是上面我说的,我经常导出excel,那个函数我写在了
table导出为xls,doc,txt,htm方法
但如果导出word,就会出现编码的问题,当添了上面那段,问题就解决了:)
新闻热点
疑难解答
图片精选