Displaying ADO.NET DataSet in Excel through Browser
Posted on 2005-04-26
The following code is returning a blank excel spreadsheet. If I change the ContentType to "text/plain" it shows me the data I want in table form, but I need it in Excel. Can anyone help?
I've tried some things with xslt, but all the examples I've found have been C# and I can't get the syntax right with VB.NET.
'Now that you have the data; display it in excel format.
If Not IsNothing(ds) Then
Response.Charset = ""
Response.ContentType = "application/vnd.ms-excel"
Dim stringWrite As New System.IO.StringWriter
Dim htmlWrite As New System.Web.UI.HtmlTextWriter(stringWrite)
Dim dg As New DataGrid
dg.DataSource = ds.Tables(0)