路径有问题。你直接用grid导出不行吗,先生成一个再去保存,不是每次都要生成一个。。。
Response.Clear();
Response.Buffer=true;
Response.Charset="gb2312";
Response.AppendHeader("Content-Disposition","attachment;filename=file.xls");
Response.ContentEncoding=System.Text.Encoding.GetEncoding("gb2312");//设置输出流为简体中文
Response.ContentType="application/ms-excel";//设置输出文件类型为excel文件。
this.EnableViewState=false;
System.Globalization.CultureInfomyCItrad=newSystem.Globalization.CultureInfo("ZH-CN",true);
System.IO.StringWriteroStringWriter=newSystem.IO.StringWriter(myCItrad);
System.Web.UI.HtmlTextWriteroHtmlTextWriter=newSystem.Web.UI.HtmlTextWriter(oStringWriter);
this.GridView1.RenderControl(oHtmlTextWriter);
Response.Write(oStringWriter.ToString());
Response.End();