求查询数据库数据导出到EXCEL方法,不要下面这种方法,方法要有引用集什么的
不要这个代码,数据少了我就日了弹出框一闪而过
Response.Clear();
Response.AddHeader("Content-Type ", "application/octet-stream ");
Response.AddHeader("content-disposition", "attachment;filename=AJ_JC.xls");
Response.Charset = "UTF-8";
Response.ContentType = "application/ms-excel";
System.IO.StringWriter stringWrite = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite);
GridView1.AllowPaging = false;
GridView1.AllowSorting = false;
Bind1();
//GridView1.Columns[0].Visible = false;
GridView1.RenderControl(htmlWrite);
Response.Write(stringWrite.ToString());
Response.End();
路过的大哥哥大姐姐们帮帮忙
------解决方案--------------------
遇到个这个问题,当时在受信站点的“自定义级别”中“启动文件下载”和“启动文件下载的自动提示”
然后在文件夹选项中添加.XLS的文件类型,解决问题
IE中 工具internet选项-》安全-》自定义级别-》下载-》文件下载,
把这个启用就OK了。