DataTable dtData=GetMyTestDataTable();
   System.Web.UI.WebControls.DataGrid dgExport = null;
    System.Web.HttpContext curContext = System.Web.HttpContext.Current; 
    System.IO.StringWriter strWriter = null; 
    System.Web.UI.HtmlTextWriter htmlWriter = null;     if (dtData != null) 
    { 
       curContext.Response.ContentType = "application/vnd.ms-excel"; 
       curContext.Response.ContentEncoding =System.Text.Encoding.UTF8; 
       curContext.Response.Charset = ""; 
       curContext.Response.AppendHeader("Content-Disposition","attachment;filename=我的测试文件.xls");         strWriter = new System.IO.StringWriter(); 
       htmlWriter = new System.Web.UI.HtmlTextWriter(strWriter);        dgExport = new System.Web.UI.WebControls.DataGrid(); 
       dgExport.DataSource = dtData.DefaultView; 
       dgExport.AllowPaging = false; 
       dgExport.DataBind();         dgExport.RenderControl(htmlWriter);     
       curContext.Response.Write(strWriter.ToString()); 
       curContext.Response.End(); 
    } 
在网上参看了很多的资料 大致的修改都是集中在
curContext.Response.AppendHeader("Content-Disposition","attachment;filename=我的测试文件.xls"); 这句上我试了使用System.Web.HttpUtility.UrlEncode方法转换文件名 这样在打开文件时的提示框内文件名显示是正确的 但不保存直接打开的话Excel内的文件名就像是转码过后的显示不加的话在提示框是文件名直接就是乱码 请问这个问题该怎么解决?