I did this in asp, but in asp.net, it is recommended to use ready-made objects, such as
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";//image/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(); Reply
# re: Web export to Word requires adding header files2006-08-15 23:50 Yaoyao
@aspnetx
Yes, I also use ready-made ones, which is what I said above. I often export EXCEL, and I wrote that function in
Table is exported to xls, doc, txt, htm. But if you export WORD, there will be encoding problems. When you add the above paragraph, the problem is solved:)