How to export a dataset to excel?

  • Thread starter Thread starter Luis Esteban Valencia
  • Start date Start date
L

Luis Esteban Valencia

I have a page that generates a table depending on the querystring from a
master page. But as its a transaction history I want to show it in excel.
How can I generate an excel file from a DATASET?
 
try this way .... i am using Datagrid

Response.Clear()
Response.Buffer = True
Response.ContentType = "application/vnd.ms-excel"
Response.Charset = ""
Dim oStringWriter As New System.IO.StringWriter
Dim oHtmlTextWriter As New System.Web.UI.HtmlTextWriter(oStringWriter)

oHtmlTextWriter.Write("<html><head>")
oHtmlTextWriter.Write("</head><body>")

oHtmlTextWriter.WriteBeginTag("form runat=server ")
oHtmlTextWriter.WriteAttribute("target", "_blank")
oHtmlTextWriter.Write(">")
dgReport.RenderControl(oHtmlTextWriter)
oHtmlTextWriter.Write("</form></body></html>")
Response.Write(oStringWriter.ToString())
Response.End()
 
Back
Top