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_Cl ick(ByVal sender As Object, ByVal e As
System.EventArg s) Handles but_export_1.Cl ick
Response.Clear( )
Response.AddHea der("content-disposition",
"attachment;fil ename=FileName. xls")
Response.Charse t = ""
'If you want the option to open the Excel file without saving than
'comment out the line below
'Response.Cache .SetCacheabilit y(HttpCacheabil ity.NoCache);
Response.Conten tType = "applicatio n/vnd.xls"
Dim strw As New System.IO.Strin gWriter
Dim htmlw As New System.Web.UI.H tmlTextWriter(s trw)
gvResult1.Rende rControl(htmlw)
Response.Write( strw.ToString() )
Response.End()
End Sub
Public Overrides Sub VerifyRendering InServerForm(By Val gvResult1 As
Control)
End Sub
=============== =============== ============