我正在尝试将 gridview 数据导出到 Excel。
但我Property Evaluation Failed
在Response.End()
这是我的代码 - 有什么想法吗?
Private Sub ExportGridToExcel()
Try
Response.Clear()
Response.AddHeader("content-disposition", "attachment;filename=NPS.xls")
Response.ContentType = "application/vnd.ms-excel"
' Remove the charset from the Content-Type header.
Response.Charset = ""
' Turn off the view state.
Me.EnableViewState = False
Dim tw As New System.IO.StringWriter()
Dim hw As New System.Web.UI.HtmlTextWriter(tw)
' Get the HTML for the control.
gvNPSResults.RenderControl(hw)
' Write the HTML back to the browser.
Response.Write(tw.ToString())
' End the response.
HttpContext.Current.ApplicationInstance.CompleteRequest()
Response.End()
Catch ex As Exception
'Throw ex
End Try
End Sub