怎样将Repeater里的内容导出到客户端的Excel?我用了以下两种方法,但导出的都是Html,不是Repeater里的内容.
怎样控制读出Repeater里的每行每列?Sub ExportToExcel(ByVal ctl As System.Web.UI.Control)
Response.Clear()
Response.AppendHeader("Content-Disposition", "attachment;filename=WP_List.xls")
Response.ContentEncoding = System.Text.Encoding.GetEncoding("UTF-8")
Response.ContentType = "application/ms-excel"
ctl.Page.EnableViewState = False
Dim tw As New System.IO.StringWriter()
Dim hw = New System.Web.UI.HtmlTextWriter(tw)
ctl.RenderControl(hw)
Response.Write("<meta http-equiv=Content-Type content=text/html;charset=UTF-8>")
Response.Write(tw.ToString())
Response.End()
ctl.Page.EnableViewState = True
End Sub 'ExportToExcel
Public Shared Sub ToExcel(ByVal ctl As System.Web.UI.Control)
HttpContext.Current.Response.Charset = "UTF-8"
HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.Default
HttpContext.Current.Response.ContentType = "application/ms-excel"
HttpContext.Current.Response.AppendHeader("Content-Disposition", "attachment;filename=WP_List.xls")
ctl.Page.EnableViewState = False
Dim tw As New System.IO.StringWriter()
Dim hw As New System.Web.UI.HtmlTextWriter(tw)
ctl.RenderControl(hw)
HttpContext.Current.Response.Write(tw.ToString())
HttpContext.Current.Response.End()
End Sub 'ToExcel
怎样控制读出Repeater里的每行每列?Sub ExportToExcel(ByVal ctl As System.Web.UI.Control)
Response.Clear()
Response.AppendHeader("Content-Disposition", "attachment;filename=WP_List.xls")
Response.ContentEncoding = System.Text.Encoding.GetEncoding("UTF-8")
Response.ContentType = "application/ms-excel"
ctl.Page.EnableViewState = False
Dim tw As New System.IO.StringWriter()
Dim hw = New System.Web.UI.HtmlTextWriter(tw)
ctl.RenderControl(hw)
Response.Write("<meta http-equiv=Content-Type content=text/html;charset=UTF-8>")
Response.Write(tw.ToString())
Response.End()
ctl.Page.EnableViewState = True
End Sub 'ExportToExcel
Public Shared Sub ToExcel(ByVal ctl As System.Web.UI.Control)
HttpContext.Current.Response.Charset = "UTF-8"
HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.Default
HttpContext.Current.Response.ContentType = "application/ms-excel"
HttpContext.Current.Response.AppendHeader("Content-Disposition", "attachment;filename=WP_List.xls")
ctl.Page.EnableViewState = False
Dim tw As New System.IO.StringWriter()
Dim hw As New System.Web.UI.HtmlTextWriter(tw)
ctl.RenderControl(hw)
HttpContext.Current.Response.Write(tw.ToString())
HttpContext.Current.Response.End()
End Sub 'ToExcel
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货