這個在asp的時候我是這么做的,但是在asp.net中,還是推薦用現(xiàn)成的對象好,比如
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(); 回復(fù)
# re: web導(dǎo)出word需要添加頭文件 2006-08-15 23:50 堯堯
@aspnetx
是的,我也是用現(xiàn)成的,這就是上面我說的,我經(jīng)常導(dǎo)出excel,那個函數(shù)我寫在了
table導(dǎo)出為xls,doc,txt,htm方法
但如果導(dǎo)出word,就會出現(xiàn)編碼的問題,當(dāng)添了上面那段,問題就解決了:)
新聞熱點
疑難解答
圖片精選