弹框的效果还木实现。
只是简单的导出。
protected void imgExport_Click(object sender, EventArgs e) { if (this.GridView1.PageCount == 0) { Page.RegisterStartupScript(DateTime.Now.ToString(), "<script>alert('没有数据!')</script>"); } else { Response.Clear(); //设定编码格式 Response.Charset = "UTF-8"; //设定文件名 Response.AddHeader("content-disposition", "attachment;filename=Neware Ip.xls"); //设定类型 Response.ContentType = "application/vnd.xls"; //创建写入器 StringWriter sw = new StringWriter(); //创建写入流 HtmlTextWriter htw = new HtmlTextWriter(sw); //写入数据 GridView1.RenderControl(htw); Response.Write(sw.ToString()); //关闭请求 Response.End(); } }