将Gridview导出到Excel
GridViewToExcel(EdceExcelGV, "application/ms-exce","xxxxxx表");
protected void GridViewToExcel(Control ctrl, string FileType, string FileName)
{
/*Response.Charset = "GB2312";
Response.ContentEncoding = Encoding.UTF8;
HttpContext.Current.Response.AppendHeader("Content-Disposition",
"attachment;filename=" + HttpUtility.UrlEncode(FileName, System.Text.Encoding.UTF8).ToString());
HttpContext.Current.Response.ContentType = FileType;//image/JPEG;text/HTML;image/GIF;vnd.ms-excel/msword
this.EnableViewState=false;
StringWriter sw=new StringWriter ();
HtmlTextWriter htw=new HtmlTextWriter(sw);
ctrl.RenderControl(htw);
HttpContext.Current.Response.Write(sw.ToString());
HttpContext.Current.Response.End();*/
Response.ClearContent();
Response.BufferOutput = true;
Response.Charset = "utf-8";
Response.ContentType = FileType;
Response.ContentEncoding = System.Text.Encoding.UTF8;
Response.AppendHeader("Content-Disposition", "attachment;filename=" + Server.UrlEncode(FileName) + ".xls");
this.EnableViewState=false;
StringWriter sw=new StringWriter ();
HtmlTextWriter htw=new HtmlTextWriter(sw);
ctrl.RenderControl(htw);
HttpContext.Current.Response.Write(sw.ToString());
HttpContext.Current.Response.End();
}
public override void VerifyRenderingInServerForm(Control control)
{
}
将Gridview导出到Excel的更多相关文章
- asp.net教程:GridView导出到Excel或Word文件
asp.net教程:GridView导出到Excel或Word文件</ br> 在项目中我们经常会遇到要求将一些数据导出成Excel或者Word表格的情况,比如中国移动(我是中国移动用户) ...
- DevExpress GridControl GridView 导出到 Excel 类
说明: 1>GridView 导出到 Excel (如果分页,只导出当前页数据) 2>GridView 导出到 Excel 3>方法2可以参考DataTable 导出到 Excel ...
- GridView导出成Excel字符"0"丢失/数字丢失的处理方式 收藏
GridView导出成Excel字符"0"丢失/数字丢失的处理方式 收藏 GridView 导出成Excel文件,这个代码在网上比较多.但是发现存在一个问题,导出的数据中如果有&q ...
- Gridview导出到Excel
#region #导出到Excel protected void Button2_Click(object sender, EventArgs e) { Respons ...
- Gridview导出成Excel
在aspx里面加上 <%@ Page Language="C#" AutoEventWireup="true" CodeFile="AAAAAA ...
- ASP.NET中GridView数据导出到Excel
/// <summary> /// 导出按钮 /// </summary> /// <param name="sender"></para ...
- GridView导出Excel的超好样例
事实上网上有非常多关于Excel的样例,可是不是非常好,他们的代码没有非常全,读的起来还非常晦涩.经过这几天的摸索,最终能够完毕我想要导出报表Excel的效果了.以下是我的效果图. 一.前台的页面图 ...
- C# GridView 导出Excel表
出错1:类型“GridView”的控件“GridView1”必须放在具有 runat=server 的窗体标记内解决方案:在后台文件中重载VerifyRenderingInServerForm方法,如 ...
- Export GridView Data to Excel. 从GridView导出数据到Excel的奇怪问题解析
GridView导出函数内容如下 string attachment = "attachment; filename=Contacts.xls"; Respo ...
随机推荐
- Swift 学习笔记 (闭包)
闭包是可以在你的代码中被传递和饮用的功能性独立模块.Swift中的闭包和C以及Objective-C中的Block很像,和其他语言中的匿名函数也很像. 闭包能捕获和存储定义在其上下文中的任何常量和变量 ...
- 使用Retrofit发送POST请求提交JSON数据
Retrofit官网:https://square.github.io/retrofit/ 示例如下 HttpService.java import okhttp3.RequestBody; impo ...
- hdu5325 树的思维题
pid=5325">http://acm.hdu.edu.cn/showproblem.php? pid=5325 Problem Description Bobo has a tre ...
- linux删除目录下所有文件,但是保留文件夹
删除目录和子目录下所有rpm文件,但是保留文件夹,先cd到想要删除的目录 命令如下 find ./ -name "*.rpm" | xargs rm
- html--<meta>设置缓存
html头文件设置常用之<meta>设置缓存 <meta http-equiv="pragma" content="no-cache"&g ...
- TCP/IP协议数据包文件PCAP分析器
一.设计原理 1.PCAP文件构成 参考http://blog.csdn.net/gulu_gulu_jp/article/details/50494909 PCAP文件由一个PCAP文件头和多个PC ...
- zabbix 报表
摘自: https://www.w3cschool.cn/zabbix_manager/zabbix_manager-z45f1zie.html
- 分享知识-快乐自己:Excel快速导入Oracle 数据库
需求: oracle 数据库有一个student表,现有一个excel表:student.xlsx,需导入oracle数据库student表中. student表的拥有者是c##MLQ1 密码为:x ...
- java数据的5种存储位置(转)
任何语言所编写的程序,其中的各类型的数据都需要一个存储位置,java中书的存储位置分为以下5种: 1.寄存器 最快的存储区,位于处理器内部,但是数量及其有限.所以寄存器根据需求自动分配,无序人为控制. ...
- Java丨角色权限控制——数据库设计
相信各位读者对于角色权限管理这个需求并不陌生.那么是怎么实现的呢?今天小编来说道说道! 1.首先我们来进行数据库的设计,如何设计数据库是实现权限控制的关键: 1)用户表: id:主键.自增.int n ...