标签:datagrid 验证 ati end position 下载 输出 www app
摘要:如何在将Datagrid的数据存成Excel列出
按下button产生Excel档,(好像是直接下载)
将你DataGrid的html输出到HtmlText
而HtmlText使用StringWriter的数据
Protected Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim sw As New System.IO.StringWriter
Dim hw As New System.Web.UI.HtmlTextWriter(sw)
Response.Clear()
Response.AppendHeader("Content-Disposition", "attachment; filename=P.xls")
Response.ContentType = "application/vnd.ms-excel"
GridView1.RenderControl(hw)
Response.Write(sw.ToString())
Response.End()
End Sub
‘一定要加这一段,否则会有验证问题
Public Overrides Sub VerifyRenderingInSer verForm(ByVal control As Control)
‘处理‘GridView‘ 的控件 ‘GridView‘ 必须置于有 runat=server 的表单标记之中
End Sub
原文:大专栏 如何在将Datagrid的数据存成Excel列出
标签:datagrid 验证 ati end position 下载 输出 www app
原文地址:https://www.cnblogs.com/petewell/p/11474080.html