protected void excelout_Click(object sender, EventArgs e) { reloadBtn_Click(sender, e); System.Web.UI.Control ctl = this.TablePanel; //DataGrid1是你在窗体中拖放的控件 HttpContext.Current.Response.AppendHeader("Content-Disposition", "attachment;filename=" + System.Web.HttpUtility.UrlEncode("国" + Year + "年" + titleMonth + "份计划", System.Text.Encoding.UTF8) + ".xls"); HttpContext.Current.Response.Charset = "UTF-8"; HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.Default; HttpContext.Current.Response.ContentType = "application/ms-excel"; System.IO.StringWriter tw = new System.IO.StringWriter(); System.Web.UI.HtmlTextWriter hw = new System.Web.UI.HtmlTextWriter(tw); ctl.RenderControl(hw); HttpContext.Current.Response.Write(tw.ToString()); HttpContext.Current.Response.End(); }
protected void btnExportExcel_Click(object sender, EventArgs e) { if (GridViewListTemplet.Rows.Count == 0) { ScriptManager.RegisterClientScriptBlock(this.Page, GetType(), "noneData", "alert(\"没有数据!\");", true); return; } //Catch缓存给权限 HttpContext.Current.Response.ClearHeaders(); HttpContext.Current.Response.AppendHeader("Expires ", System.DateTime.Now.AddMinutes(30).ToString()); HttpContext.Current.Response.AppendHeader("Pragma ", "public "); HttpContext.Current.Response.AppendHeader("Cache-Control ", "must-revalidate, post-check=0, pre-check=0 "); HttpContext.Current.Response.AppendHeader("Cache-Control ", "public "); GridViewListTemplet.AllowPaging = false; GridViewListTemplet.AllowSorting = false; GridViewListTemplet.DataBind(); bindData(); if (GridViewListTemplet.HeaderRow.FindControl("ckbAll") != null)//有复选框时 { GridViewListTemplet.Columns[0].Visible = false; } HttpContext.Current.Response.Charset = "UTF-8"; HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.UTF7; HttpContext.Current.Response.AppendHeader("Content-Disposition", "attachment;filename=export"+DateTime.Now.Ticks.ToString()+".xls"); HttpContext.Current.Response.ContentType = "application/ms-excel"; GridViewListTemplet.Page.EnableViewState = true;// false; System.IO.StringWriter tw = new System.IO.StringWriter(); HtmlTextWriter hw = new HtmlTextWriter(tw); GridViewListTemplet.RenderControl(hw); HttpContext.Current.Response.Write(tw.ToString()); HttpContext.Current.Response.End(); GridViewListTemplet.AllowPaging = true; GridViewListTemplet.AllowSorting = true; GridViewListTemplet.DataBind(); if (GridViewListTemplet.HeaderRow.FindControl("ckbAll") != null)//有复选框时 { GridViewListTemplet.Columns[0].Visible = true; } } #endregion
相关推荐
Java的Excel导出功能Java的Excel导出功能Java的Excel导出功能
ASP.NET导出功能,可以实现EXCEL表格进行下载,比较好用
将execl导出功能进行AOP切面 1.只需要在controller层增加自定义注解@ExportExcel就可以实现。利用切面和反射的原理 将导出和业务层分开。 2.在对应的model层增加@ExportFiled注解 表示需要导出的字段和顺序。 ...
springboot实现Excel文件导入与导出功能, 本次任务主要实现两个功能,一是如何将Excel文件导入后台服务器,解析文件中的内容,并且存入数据库中。二是如何将后台数据库中的数据导出为Excel表格。经过调研,实现此...
java实现excel导出功能,通过查询数据库指定数据,将数据以excel方式导出的功能 excel导出的功能
如题c#.net开发,网页excel导入导出功能模板,网页表格直接导出为excel2003格式。
thinkphp excel导出功能 onethink也可以用
Word文档导出,生成的word文档。 解压java2word文件,用MyEclipse导入压缩后的文件
phpcms V9 后台表单向导列表excel导出功能
java简单的Excel导出功能,把jsp界面上的数据导出到excel中已经强制实现了,简单实用!
lodop导出称excel功能示例
基于springBoot框架和poi实现Excel的导入导出功能,带数据库转储文件(自行配置maven)
Java平台下著名的POI组件下的excel导出功能代码 Java平台下著名的POI组件下的excel导出功能代码
实现java中导出一定模板格式的word文档,支持word2003.
在java语言中,一个简单的excel导出功能实例。适合入门级java语言学习者使用。
vba编写的公司人事结构树(包含查询、添加、修改、删除、导出功能) 1、查询,查询某员工的人事信息 2、添加,添加新的公司、部门、员工信息 3、修改,修改已存在节点的名称 4、删除,删除选中的节点,节点下如有子...
项目中有一个导出功能的实现,用博客来记录一下。因为需求对导出表格的数据格式和样式有要求,所以这个导出功能放到后端来做,而且后端返回的是数据流,所以需要处理成想要的表格并导出来。 先看下效果图: 页面效果...
Kendo UI框架提供了强大的Excel导出功能,通过Grid的saveAsExcel能方便地导出Grid中的数据,而且格式美观大方,使用起来也非常方便。但是在实际使用中不是很理想,主要有以下两个问题: 1. 导出的列数据是原始值 ...
自己编写的用于Grid列表导出功能的一个类,里面的一些样式类结合ColorInformation.js来使用
excel模板导出功能,快速满足模板导出,实现相应功能,快速解决问题