首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

为什么导出excel 在本地不会乱码,下传到服务器却乱码了,也不知道是哪出有关问题了

2012-09-17 
为什么导出excel 在本地不会乱码,上传到服务器却乱码了,也不知道是哪出问题了//Response.Clear()//Respon

为什么导出excel 在本地不会乱码,上传到服务器却乱码了,也不知道是哪出问题了
//Response.Clear();
  //Response.AddHeader("Content-Disposition", "inline;filename=EService.xls");
  //Response.Buffer = true;
  //Response.Charset = "GB2312";

  //Response.ContentEncoding = System.Text.Encoding.GetEncoding("GB2312");
  //Response.ContentType = "application/vnd.xls";
  //System.IO.StringWriter stringWrite = new System.IO.StringWriter();
  //System.Web.UI.HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite);

  //Page.EnableViewState = false;
  //this.rptEserver.RenderControl(htmlWrite);

  //Response.Write(stringWrite.ToString());

  //Response.End();

[解决办法]

C# code
    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();    }
[解决办法]
应该是编码不一样。
[解决办法]
探讨
应该是编码不一样。

[解决办法]
这个问题应该怎么解决啊。我也遇到了这个问题。不知如何解决!

热点排行