• DataTable里的内容导出到EXCEL


     1 private void toExcel(DataTable tb) 
     2 
     3     System.Web.UI.WebControls.DataGrid dgrid = null
     4     System.Web.HttpContext context = System.Web.HttpContext.Current; 
     5     System.IO.StringWriter strOur = null
     6     System.Web.UI.HtmlTextWriter htmlWriter = null
     7     if ((tb != null)) { 
     8         context.Response.ContentType = "application/vnd.ms-excel "
     9         context.Response.ContentEncoding = System.Text.Encoding.UTF8; 
    10         context.Response.Charset = " "
    11         
    12         strOur = new IO.StringWriter(); 
    13         htmlWriter = new System.Web.UI.HtmlTextWriter(strOur); 
    14         dgrid = new DataGrid(); 
    15         dgrid.DataSource = tb.DefaultView; 
    16         dgrid.AllowPaging = false
    17         dgrid.DataBind(); 
    18         
    19         dgrid.RenderControl(htmlWriter); 
    20         context.Response.Write(strOur.ToString); 
    21         context.Response.End(); 
    22     } 
    23 
  • 相关阅读:
    15 Action View 以及监听 的使用
    15 ActionProvider代码例子
    15 ActionBar 总结
    15 Actionbar的显示和隐藏
    14 fragment传值
    14 fragment 创建
    14 Fragment 注意点
    14 Fragment 碎片总结
    GSON TypeToken 解决泛型问题
    Intent传递对象——Serializable和Parcelable区别
  • 原文地址:https://www.cnblogs.com/cxy521/p/1048869.html
Copyright © 2020-2023  润新知