导出Word文件时,中文乱码!
我是英文的操作系统,将页面用Word导出,页面html放在sHtml中,导出没有问题,但是页面里的中文成了乱码,用System.Text.Encoding.UTF8或者System.Text.Encoding.GetEncoding("GBK")或者System.Text.Encoding.GetEncoding("GB2312")都没有效果,比较郁闷:
sHtml="我的页面(里面有中文)";
DivMain.InnerHtml = sHtml;
System.IO.StringWriter SW = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter HTW = new System.Web.UI.HtmlTextWriter(SW);
this.DivMain.RenderControl(HTW);
Response.Buffer = true;
Response.Clear();
Response.ClearContent();
Response.ClearHeaders();
Response.ContentType = "Application/octet-stream";
//Response.ContentEncoding = System.Text.Encoding.UTF8;
//Response.ContentEncoding = System.Text.Encoding.GetEncoding("GBK");
Response.AddHeader("Content-Disposition", "attachment;filename=ECO.doc");
Response.Write(SW.ToString());
Response.Flush();
Response.Close();