.net开发中用下面的代码输出excel
this.Response.Clear();
this.Response.Buffer = true;
string filename = HttpUtility.UrlEncode(strFJ1MC);
this.Response.ContentType = "application/octet-stream";
this.Response.AddHeader("content-type", "application/x-msdownload;");
this.Response.AppendHeader("Content-Disposition", "attachment;filename=" + filename);
this.Response.BinaryWrite(ImgByte);
this.Response.Flush();
this.Response.End();但是点IE打开时报错文件名过长!!怎么办!!在线等

解决方案 »

  1.   


    Response.AddHeader("content-disposition", "attachment;filename=Temp.xls");
    Response.ContentType = "application/vnd.ms-excel";
    Response.AddHeader("Content-Length", ImgByte.Length.ToString());
    Response.BinaryWrite(ImgByte);
    Response.Flush();
    Response.End();
      

  2.   

    不行啊哥们,那个excel的名字是上传的不能改。最是字太多形成的乱码太长才报的错!!!