Ihave the below code to export to excel which I got from other posts.
However my output to excel only shows the tags and not just the data.
Any help would be appreciated.
Here is my output from excel:
<form name="_ctl5" method="post" action="DatabaseList.aspx" id="_ctl5">
<input type="hidden" name="__VIEWSTATE" id="
__VIEWSTATE" value="" />
<div>
</div></form>
To go where no programmer has gone before.
However my output to excel only shows the tags and not just the data.
Any help would be appreciated.
Here is my output from excel:
<form name="_ctl5" method="post" action="DatabaseList.aspx" id="_ctl5">
<input type="hidden" name="__VIEWSTATE" id="
__VIEWSTATE" value="" />
<div>
</div></form>
Code:
Private Sub Export_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Export.Click
'//export to excel
Me.dgDatabase.AllowPaging = False
Me.dgDatabase.Columns(0).Visible = False
Me.dgDatabase.Columns(1).Visible = True
Me.dgDatabase.Columns(2).Visible = True
Me.dgDatabase.Columns(3).Visible = True
Me.dgDatabase.AllowSorting = False
Me.dgDatabase.DataBind()
' the excel expot....
Response.AddHeader("content-disposition", "attachment;filename=Databaselist.xls")
Response.ContentType = "application/vnd.ms-excel"
Response.Charset = ""
Me.EnableViewState = False
Dim tw As New System.IO.StringWriter()
Dim hw As New System.Web.UI.HtmlTextWriter(tw)
Dim frm As HtmlForm = New HtmlForm()
Dim grd As New GridView
Me.Controls.Add(frm)
frm.Controls.Add(dgDatabase)
frm.RenderControl(hw)
Response.Write(tw.ToString())
Response.End()
End Sub
To go where no programmer has gone before.