public void OUTEXCEL()
{
DataSet ds = new GW_T_DemandDAL().GetWzH(GetPersonInfoData(UserInfo), Request.QueryString["id"].ToString());
if (ds != null && ds.Tables[0].Rows.Count > 0)
{
if (ds.Tables[0].Rows.Count > 65536)
{
this.Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "", "<script>alert('导出数据超过最大限制行数,请添加条件再试!');</script>");
return;
} GridView1.DataSource = ds.Tables[0];
GridView1.AllowPaging = false;
GridView1.DataBind(); Response.ClearContent(); Response.AddHeader("content-disposition", "attachment; filename=MyExcelFile.xls"); Response.ContentType = "application/excel"; using (StringWriter sw = new StringWriter())
{ HtmlTextWriter htw = new HtmlTextWriter(sw); GridView1.RenderControl(htw); Response.Write(sw.ToString());
}
Response.End();
}
}
public override void VerifyRenderingInServerForm(Control control)
{
// 方法重写 }

GridView导出Excel的更多相关文章

  1. Asp.net Gridview导出Excel

    前台页面放一个GridView什么的就不说了,要注意的是在 <%@ Page Language="C#" AutoEventWireup="true" C ...

  2. GridView导出Excel的超好样例

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

  3. C#实现GridView导出Excel

    using System.Data;using System.Web;using System.Web.UI;using System.Web.UI.WebControls;using System. ...

  4. ASP.NET gridview导出excel,防止繁体产生有乱码的方式

    //1.先引用比如 : using System; using System.Collections.Generic; using System.Linq; using System.Web; usi ...

  5. GridView导出excel格式问题

    在导出的点击事件中,代码如下: //指定导出对应单元格为文本样式 string style = @"<style> .test { vnd.ms-excel.numberform ...

  6. C# GridView 导出Excel表

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

  7. GridView导出Excel(中文乱码)

    public void OUTEXCEL(string items,string where) { DataSet ds = new StudentBLL().GetTable(items,where ...

  8. GridView 导出Excel

    protected void btnExcel_Click(object sender, EventArgs e) { ) { ExportGridViewForUTF8(GridView1, Dat ...

  9. C#通过gridview导出excel

    [CustomAuthorize]        public FileResult ExportQuestionCenterExcel(SearchBaseQuestion search)      ...

随机推荐

  1. The Economist

      The turning point in the process of growing up is when you discover the core of strength within yo ...

  2. jQuery 请指出'.bind()','.live()'和'.delegate()'的区别

    http://kb.cnblogs.com/page/94469/网上好多类似的 简言之bind可以绑定页面上已有的,live和delegate可以绑定到还未存在于页面中的元素之上.delegate又 ...

  3. python中列表的操作

    list1 = ['A' , 'B' , 'C'] list1[0] ; list1[-1] # 取第一个和最后一个元素 list1[ : ] ; list1[ : len(list1)] # 取所有 ...

  4. C#.web 打开PDF

    转自:http://blog.163.com/red_guitar@126/blog/static/11720612820112483221665/ string fileName = "2 ...

  5. class、interface、struct的区别

    1 struct和class有什么区别 1.1默认的继承访问权限 Struct是public的,class是private的. 你可以写如下的代码: struct A { char a; }; str ...

  6. python与字符集编码

    讲的比较明白的博客:http://www.cnblogs.com/huxi/archive/2010/12/05/1897271.html 以上面博文的汉为例子,汉字的GBK编码是baba, UNIC ...

  7. iOS App Icon图标 尺寸规范

    Commit to AppStore:1024*1024 //for App IconIcon-60@3x.png:180*180 //iPhone 6 Plus (@3x)Icon-60@2x.pn ...

  8. ASP.NET-遇到的错误汇总

    错误:“未在本地计算机上注册“Microsoft.Jet.OLEDB.4.0”提供程序.” 在win7 64未上,读取Excel中的数据时报的错误, 解决方法:在生成"配置管理器中" ...

  9. J2EE面试题

    J2EE面试题 J2EE相关基础知识 1.面向对象的特征有哪些方面  1.  抽象:抽象就是忽略一个主题中与当前目标无关的那些方面,以便更充分地注意与当前目标有关的方面.抽象并不打算了解全部问题,而只 ...

  10. Windows安装配置php+memcached的方法

    Windows下Memcached的安装配置方法 1.将第一个包解压放某个盘下面,比如在c:\memcached. 2.在终端(也即cmd命令界面)下输入 'c:\memcached\memcache ...