G
Guest
Hello all,
I am doing my web-based reporting tool in ASP.Net 2.0 using Visual Web
Developer 2005.
I try to export my populated gridview to Excel spreadsheet but what I got is
just a blank spreadsheet with only <div></div> tag in the first cell.
Can anyone tell me what actually is the problem? Thanks in advance.
Below are the codes in vb:
==============================
Protected Sub but_export_1_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles but_export_1.Click
Response.Clear()
Response.AddHeader("content-disposition",
"attachment;filename=FileName.xls")
Response.Charset = ""
'If you want the option to open the Excel file without saving than
'comment out the line below
'Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.ContentType = "application/vnd.xls"
Dim strw As New System.IO.StringWriter
Dim htmlw As New System.Web.UI.HtmlTextWriter(strw)
gvResult1.RenderControl(htmlw)
Response.Write(strw.ToString())
Response.End()
End Sub
Public Overrides Sub VerifyRenderingInServerForm(ByVal gvResult1 As
Control)
End Sub
==========================================
I am doing my web-based reporting tool in ASP.Net 2.0 using Visual Web
Developer 2005.
I try to export my populated gridview to Excel spreadsheet but what I got is
just a blank spreadsheet with only <div></div> tag in the first cell.
Can anyone tell me what actually is the problem? Thanks in advance.
Below are the codes in vb:
==============================
Protected Sub but_export_1_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles but_export_1.Click
Response.Clear()
Response.AddHeader("content-disposition",
"attachment;filename=FileName.xls")
Response.Charset = ""
'If you want the option to open the Excel file without saving than
'comment out the line below
'Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.ContentType = "application/vnd.xls"
Dim strw As New System.IO.StringWriter
Dim htmlw As New System.Web.UI.HtmlTextWriter(strw)
gvResult1.RenderControl(htmlw)
Response.Write(strw.ToString())
Response.End()
End Sub
Public Overrides Sub VerifyRenderingInServerForm(ByVal gvResult1 As
Control)
End Sub
==========================================