各位大哥,此问题甚急,请有识之士赐教
我在导出DataGrid到Excel的时候,中文文件名在"打开"文件时出错
都是些"%9989%92"类似的东东
源码是这样的
Response.Charset = "GB2312";
System.Globalization.CultureInfo myCItrad = new System.Globalization.CultureInfo("ZH-CN",true); Response.ContentEncoding = System.Text.Encoding.GetEncoding("GB2312");
                    Response.ContentType = "application/vnd.ms-excel";
this.EnableViewState = false;
string title = Request.QueryString["title"];
Response.AddHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlPathEncode( title + ".xls") );

解决方案 »

  1.   

    httpResponse.AppendHeader("Content-Disposition","attachment;filename="+HttpUtility.UrlEncode(fileName,System.Text.Encoding.UTF8)); 
                
    httpResponse.ContentEncoding=System.Text.Encoding.GetEncoding("GB2312");
      

  2.   

    Dim strExcelName As String, StrTmp As String
        strExcelName = "中文文件"    If strExcelName = Nothing Then strExcelName = "ExcelFiles.xls"
        strExcelName = System.Web.HttpUtility.UrlEncode(strExcelName) ' & ".xls"
        StrTmp = "attachment;filename=" & strExcelName
        Response.ContentType = "application/vnd.ms-excel"
        Response.ContentEncoding = System.Text.Encoding.Default 'GetEncoding("GB2312")
        Response.Charset = "GB2312"
        Response.AddHeader("Content-Disposition", StrTmp)
    Response.Write("..............文件内容...............")
    response.end