我用:
//导出Excel2003
                string FileName = DropDownList1.SelectedValue.ToString().Replace(" ", "") + "年级成绩总表" + ".xls";
                Response.Clear();
                Response.AddHeader("content-disposition", "attachment;filename=" + HttpUtility.UrlPathEncode(FileName));
                Response.Charset = "gb2312";
                Response.ContentEncoding = System.Text.Encoding.UTF8;                Response.ContentType = "application/vnd.xls";
                System.IO.StringWriter stringWrite = new System.IO.StringWriter();
                System.Web.UI.HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite);
                GridView1.AllowPaging = false;                GridView1.RenderControl(htmlWrite);
                Response.Write(stringWrite.ToString());
                Response.End();
                GridView1.AllowPaging = true;    public override void VerifyRenderingInServerForm(Control control)
    {
        // Confirms that an HtmlForm control is rendered for
    }
用中文文件名,例如:9年级成绩总表
点击导出提示框中的“保存”,则保存为 9年级成绩总表.xls ;
保存后用Excel2003打开所保存的“9年级成绩总表.xls ”不会出现乱码,

如果点击提示框中的“打开”时,客户端和服务器端安装的是Excel2003,打开就会出现Excel的标题和工作表名是乱码:
标题栏 9%e5%b9%b4%e7%ba%a7%e6%88%90%e7...%78.xls
工作表名 9%e5%b9%b4%e7%ba%a7%e6%88%90%e7感觉看的不是很舒服(不够完善),不知如何解决,希望得到各位大师的帮助,十分感激!

解决方案 »

  1.   

    Response.AppendHeader("Content-Disposition", "attachment;filename=" + System.Web.HttpUtility.UrlEncode(FileName, System.Text.Encoding.GetEncoding("utf-8")));
      

  2.   


      Response.Charset = "gb2312";
      Response.ContentEncoding = System.Text.Encoding.UTF8;
    编码要统一
      

  3.   

    我已用了:
    Response.Charset = "gb2312";
    Response.ContentEncoding = System.Text.Encoding.UTF8;

    不行!
    下班了,
    下午我试试“人生如梦”
      

  4.   

    string FileName = DropDownList1.SelectedValue.ToString().Replace(" ", "") + "年级成绩总表" + ".xls";
    不出乱码才怪啊。
    // 给你改了下,看看行不行。
    string FileName = DropDownList1.SelectedValue.ToString().Replace(" ", "") + "年级成绩总表" + ".xls";
    FileName = System.Web.HttpUtility.UrlEncode(Request.ContentEncoding.GetBytes(FileName));
      

  5.   

    忘了,这个FileName要加到Response.AddHeader("Content-Disposition", "attachment;filename=\"" + FileName + "\"");