当前位置: 代码迷 >> ASP.NET >> webform listview的数据怎么导出为Excel
  详细解决方案

webform listview的数据怎么导出为Excel

热度:2823   发布时间:2013-02-25 00:00:00.0
webform listview的数据如何导出为Excel
网上的都是winform的 webform的listview 没有column属性~~~
  Response.Charset = "GB2312";
  Response.ContentEncoding = System.Text.Encoding.UTF7;
  Response.AppendHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode("CircPromblems.xls", Encoding.UTF8).ToString());
  Response.ContentType = "application/ms-excel";
  this.EnableViewState = false;
  StringWriter tw = new StringWriter();
  HtmlTextWriter hw = new HtmlTextWriter(tw);
  this.lv_MVCirc.RenderControl(hw);
  Response.Write(tw.ToString());
  Response.End();
上面的方法只能导出当前显示的listview的数据 不能导出数据源的数据~ 求各位大神帮忙啊

------解决方案--------------------------------------------------------
能导出listview的数据就是成功以99%了啊,最简单的就是放个隐藏的listview,把数据源的数据绑给它,那它就具有数据源的所有数据了,然后就可以导出了
  相关解决方案