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的更多相关文章

  1. asp.net教程:GridView导出到Excel或Word文件

    asp.net教程:GridView导出到Excel或Word文件</ br> 在项目中我们经常会遇到要求将一些数据导出成Excel或者Word表格的情况,比如中国移动(我是中国移动用户) ...

  2. DevExpress GridControl GridView 导出到 Excel 类

    说明: 1>GridView 导出到 Excel (如果分页,只导出当前页数据) 2>GridView 导出到 Excel 3>方法2可以参考DataTable 导出到 Excel ...

  3. GridView导出成Excel字符"0"丢失/数字丢失的处理方式 收藏

    GridView导出成Excel字符"0"丢失/数字丢失的处理方式 收藏 GridView 导出成Excel文件,这个代码在网上比较多.但是发现存在一个问题,导出的数据中如果有&q ...

  4. Gridview导出到Excel

    #region #导出到Excel     protected void Button2_Click(object sender, EventArgs e)     {         Respons ...

  5. Gridview导出成Excel

    在aspx里面加上 <%@ Page Language="C#" AutoEventWireup="true" CodeFile="AAAAAA ...

  6. ASP.NET中GridView数据导出到Excel

    /// <summary> /// 导出按钮 /// </summary> /// <param name="sender"></para ...

  7. GridView导出Excel的超好样例

    事实上网上有非常多关于Excel的样例,可是不是非常好,他们的代码没有非常全,读的起来还非常晦涩.经过这几天的摸索,最终能够完毕我想要导出报表Excel的效果了.以下是我的效果图. 一.前台的页面图 ...

  8. C# GridView 导出Excel表

    出错1:类型“GridView”的控件“GridView1”必须放在具有 runat=server 的窗体标记内解决方案:在后台文件中重载VerifyRenderingInServerForm方法,如 ...

  9. Export GridView Data to Excel. 从GridView导出数据到Excel的奇怪问题解析

    GridView导出函数内容如下 string attachment = "attachment; filename=Contacts.xls";            Respo ...

随机推荐

  1. 【题解】Painting Fence

    [题解]Painting Fence 分治模板.贪心加分治.直接\(O(n^2logn)\)分治过去.考虑一块联通的柱形是子问题的,是递归的,贪心分治就可.记得对\(r-l+1\)取\(min\). ...

  2. Django框架ORM单表添加表记录_模型层

    此方法依赖的表时之前创建的过的一张表 参考链接:https://www.cnblogs.com/apollo1616/p/9840354.html 方法1: # 语法 [变量] = [表名].obje ...

  3. UVA 11077 - Find the Permutations(递推)

    UVA 11077 - Find the Permutations option=com_onlinejudge&Itemid=8&page=show_problem&cate ...

  4. python 创建一个实例:步骤一 编写一个构造函数

    编写一个构造函数 #在python中,person 类的第一件是就是记录关于人员的基本信息,这叫做实例对象属性,并且它们通常通过给类方法函数中的self 属性赋值来创建. #赋给实力属性第一个值得通常 ...

  5. Java多线程系列 基础篇02 线程的创建和运行

    1.线程创建的方式常用有两种 1. 继承 Thread 类创建线程 2. 实现 Runnable 接口创建线程 2.Thread 和 Runnable的区别 Thread和Runnable的相同点:都 ...

  6. leetcode 890. Possible Bipartition

    Given a set of N people (numbered 1, 2, ..., N), we would like to split everyone into two groups of ...

  7. Python网络编程--Echo服务

    Python网络编程--Echo服务 学习网络编程必须要练习的三个小项目就是Echo服务,Chat服务和Proxy服务.在接下来的几篇文章会详细介绍. 今天就来介绍Echo服务,Echo服务是最基本的 ...

  8. 初学OpenMP

    这两天在看多核计算的书,就要用到openmp,因为我使用vs2015,从微软可以看到是支持openmp2.0版本的 具体使用: 在vs里创造一个控制台项目,然后打开属性管理器,在属性管理器里找到配置属 ...

  9. 解决使用mybatis做批量操作时发生的异常:Parameter '__frch_item_0' not found. Available parameters are [list] 记录

    本文主要描述 使用mybatis进行批量更新.批量插入 过程中遇到的异常及总结: 首先贴出使用批量操作报的异常信息: java.lang.RuntimeException: org.mybatis.s ...

  10. android 电池(一):锂电池基本原理篇【转】

    本文转载自:http://blog.csdn.net/xubin341719/article/details/8497830 关键词:Android  电池关机充电 androidboot.mode ...