G
Guest
I have the following routine to export gridview data to excel. The excel file
has an extra line added on the top. Is there anyway to get rid of it? The
environment of dev box is WindowsXP, Msft windows frmwk 2, VS2005, Office
2003. Any help would be very much appreciated.
===============================================
Protected Sub ibtnExcel_Click(ByVal sender As Object, ByVal e As
System.Web.UI.ImageClickEventArgs) Handles ibtnExcel.Click
'Dim streamwriter As HTMLS
Dim defaultFileName As String = "MyTestExcelFile"
Response.Clear()
Response.Buffer = False
Response.BufferOutput = False
Response.ContentType = "application/ms-excel"
Response.AddHeader("content-disposition", "attachment;filename=" +
defaultFileName + ".xls;")
Response.Charset = ""
Me.EnableViewState = False
Dim sw As New System.IO.StringWriter()
Dim hw As New System.Web.UI.HtmlTextWriter(sw)
Dim frm As HtmlForm = New HtmlForm()
Me.Controls.Add(frm)
grdQueryResult.AllowSorting = False
grdQueryResult.AllowPaging = False
grdQueryResult.DataSource = Session("Sql_select")
grdQueryResult.DataBind()
frm.Controls.Add(grdQueryResult)
frm.RenderControl(hw)
Response.Write(sw.ToString())
Response.End()
End Sub
has an extra line added on the top. Is there anyway to get rid of it? The
environment of dev box is WindowsXP, Msft windows frmwk 2, VS2005, Office
2003. Any help would be very much appreciated.
===============================================
Protected Sub ibtnExcel_Click(ByVal sender As Object, ByVal e As
System.Web.UI.ImageClickEventArgs) Handles ibtnExcel.Click
'Dim streamwriter As HTMLS
Dim defaultFileName As String = "MyTestExcelFile"
Response.Clear()
Response.Buffer = False
Response.BufferOutput = False
Response.ContentType = "application/ms-excel"
Response.AddHeader("content-disposition", "attachment;filename=" +
defaultFileName + ".xls;")
Response.Charset = ""
Me.EnableViewState = False
Dim sw As New System.IO.StringWriter()
Dim hw As New System.Web.UI.HtmlTextWriter(sw)
Dim frm As HtmlForm = New HtmlForm()
Me.Controls.Add(frm)
grdQueryResult.AllowSorting = False
grdQueryResult.AllowPaging = False
grdQueryResult.DataSource = Session("Sql_select")
grdQueryResult.DataBind()
frm.Controls.Add(grdQueryResult)
frm.RenderControl(hw)
Response.Write(sw.ToString())
Response.End()
End Sub