首 页 ASP ASP.NET PHP JSP Ajax DIV+CSS JavaScript XML C#
MySQL MSSQL Access Oracle Linux Server 电脑技巧 网络安全 建站经验 其它

Asp.NET中把DataTable或DataGrid导出为Excel

整理日期:2007年08月14日 【字体:


伊图教程网[www.etoow.com]
http://www.etoow.com/html/2007-08/1187074458.html
        curContext.Response.Charset = "";

        // 导出excel文件
        strWriter = new System.IO.StringWriter();
        htmlWriter = new System.Web.UI.HtmlTextWriter(strWriter);

        // 为了解决dgData中可能进行了分页的情况,需要重新定义一个无分页的DataGrid
        dgExport = new System.Web.UI.WebControls.DataGrid();
        dgExport.DataSource = dtData.DefaultView;
        dgExport.AllowPaging = false;
        dgExport.DataBind();

        // 返回客户端
        dgExport.RenderControl(htmlWriter);
        curContext.Response.Write(strWriter.ToString());
        curContext.Response.End();
      }
    }
Tags:
Asp.NET中把DataTable或DataGrid导出为Excel
'http://www.etoow.com/html/2007-08/1187074458.html
1
 
信息搜索
  
联系我们关于本站广告服务设为首页 收藏本站友情链接网站地图
Copyright © Etoow.com Inc. All Rights Reserved