日期:2014-05-17 浏览次数:20515 次
private void Export() { string strActionID = listActionName.SelectedItem.Text.ToString() + ".xls"; Response.Clear(); Response.Buffer = true; Response.Charset = "GB2312"; Response.AppendHeader("Content-Disposition", "attachment;filename=\"" + Server.UrlPathEncode(strActionID) + "\""); Response.ContentEncoding = System.Text.Encoding.GetEncoding("GB2312"); //Response.ContentEncoding = System.Text.Encoding.UTF8; Response.ContentType = "application/ms-excel"; [color=#FF0000] Response.Write("<meta http-equiv=Content-Type content=\"text/html; charset=GB2312\">");[/color] this.EnableViewState = false; System.Globalization.CultureInfo myCItrad = new System.Globalization.CultureInfo("ZH-CN", true); System.IO.StringWriter oStringWriter = new System.IO.StringWriter(myCItrad); System.Web.UI.HtmlTextWriter oHtmlTextWriter = new System.Web.UI.HtmlTextWriter(oStringWriter); this.gvResult.RenderControl(oHtmlTextWriter); Response.Write(oStringWriter.ToString()); Response.End(); }
------解决方案--------------------
应该是编码不一样。
------解决方案--------------------