原来代码
gvMonograph.DataBind(); Response.Charset = "GB2312"; Response.ContentEncoding = System.Text.Encoding.UTF7; Response.AppendHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode(FileName, System.Text.Encoding.UTF8).ToString()); Response.ContentType = FileType; this.EnableViewState = false; StringWriter tw = new StringWriter(); HtmlTextWriter hw = new HtmlTextWriter(tw); gvMonograph.RenderControl(hw); Response.Write(tw.ToString()); Response.End();
?需要更改一个地方也就是Response.ContentEncoding = System.Text.Encoding.UTF7;
为Response.ContentEncoding = System.Text.Encoding.UTF8; 后即可在2007 2010下正常打开
改后代码:
gvMonograph.DataBind(); Response.Charset = "GB2312"; Response.ContentEncoding = System.Text.Encoding.UTF8; Response.AppendHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode(FileName, System.Text.Encoding.UTF8).ToString()); Response.ContentType = FileType; this.EnableViewState = false; StringWriter tw = new StringWriter(); HtmlTextWriter hw = new HtmlTextWriter(tw); gvMonograph.RenderControl(hw); Response.Write(tw.ToString()); Response.End();
?