B
Bill E.
I've used the following code countless times to successfully create an
excel export from a datagrid.
Protected Sub ExportToExcel(ByVal datagrid As Control)
'Create an MS Excel Response
Response.Clear()
Response.Buffer = True
Response.ContentType = "application/vnd.ms-excel"
Response.Charset = ""
Dim oStringWriter As System.IO.StringWriter = New
System.IO.StringWriter
Dim oHtmlTextWriter As System.Web.UI.HtmlTextWriter = New
System.Web.UI.HtmlTextWriter(oStringWriter)
datagrid.RenderControl(oHtmlTextWriter)
Response.Write(oStringWriter.ToString)
Response.End()
End Sub
However, for some reason on one particular project I'm only getting
the first row of results
when the browser returns with the response.
If I comment out the line
Response.ContentType = "application/vnd.ms-excel"
I receive all rows. Is there a browser directive that I'm missing?
Bill E.
Hollywood, FL
excel export from a datagrid.
Protected Sub ExportToExcel(ByVal datagrid As Control)
'Create an MS Excel Response
Response.Clear()
Response.Buffer = True
Response.ContentType = "application/vnd.ms-excel"
Response.Charset = ""
Dim oStringWriter As System.IO.StringWriter = New
System.IO.StringWriter
Dim oHtmlTextWriter As System.Web.UI.HtmlTextWriter = New
System.Web.UI.HtmlTextWriter(oStringWriter)
datagrid.RenderControl(oHtmlTextWriter)
Response.Write(oStringWriter.ToString)
Response.End()
End Sub
However, for some reason on one particular project I'm only getting
the first row of results
when the browser returns with the response.
If I comment out the line
Response.ContentType = "application/vnd.ms-excel"
I receive all rows. Is there a browser directive that I'm missing?
Bill E.
Hollywood, FL