zoukankan      html  css  js  c++  java
  • 将GridView的数据导出Excel

     1                 HttpContext.Current.Response.AppendHeader("Content-Disposition", "attachment;filename=CALLINTOTALLIST_Excel.xls");
     2                 HttpContext.Current.Response.Charset = "UTF-8";
     3                 HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.UTF8;
     4                 HttpContext.Current.Response.ContentType = "application/ms-excel";
     5                 Gri_CallInRecord.Page.EnableViewState = false;
     6                 System.IO.StringWriter tw = new System.IO.StringWriter();
     7                 System.Web.UI.HtmlTextWriter hw = new System.Web.UI.HtmlTextWriter(tw);
     8                 Gri_CallInRecord.RenderControl(hw);
     9                 HttpContext.Current.Response.Write(tw.ToString());
    10                 HttpContext.Current.Response.End();                
    View Code

    开发语言:c#
    开发环境:Win7+VS2008

    开发模式:webForm

    作用:用于导出GridView的数据,导出文件为Excel

  • 相关阅读:
    错题
    URL和URI区别
    适配器
    JAVA 反射机制
    JAVA 面试题
    JAVA 继承
    多态 JAVA
    Java面向对象编辑
    [LeetCode] Merge k Sorted Lists
    [LeetCode] Valid Palindrome
  • 原文地址:https://www.cnblogs.com/work-at-home-helloworld/p/export_GridView.html
Copyright © 2011-2022 走看看