我正在使用下面的代码,它将网格视图导出到 Excel 工作表。问题是它只会导出页面上的记录/列(其中 10 个),因为我的 gridview 设置设置为每页仅显示 10 行并且仅显示某些列。有没有办法可以将数据源中的所有记录和列导出到 Excel?
Protected Sub ImageButton1_Click(sender As Object, e As System.Web.UI.ImageClickEventArgs) Handles ImageButton1.Click
Response.Clear()
Response.Buffer = True
Response.ContentType = "application/vnd.ms-excel"
Response.Charset = ""
Me.EnableViewState = False
Dim oStringWriter As New System.IO.StringWriter
Dim oHtmlTextWriter As New System.Web.UI.HtmlTextWriter(oStringWriter)
GridView1.RenderControl(oHtmlTextWriter)
Response.Write(oStringWriter.ToString())
Response.[End]()
End Sub