Export a dataset or datatable to excel .csv then stream (prompt for download) the file.
Dim dt as new DataTable
dt = ds.Tables(0)
Dim sw As New System.IO.StreamWriter(Server.MapPath("~/data.csv"), false);
Dim ds As New DataSet
Dim dt As New DataTable
ds = Session("trkDsResults")
dt = ds.Tables(0)
Dim iCol As Int16 = dt.Columns.Count
Dim i As Int16
For i = 0 To iCol - 1
sw.Write(dt.Columns(i))
If i < iCol - 1 Then sw.Write(",")
Next
sw.Write(sw.NewLine)
For Each dr As DataRow In dt.Rows
For i = 0 To iCol - 1
If Not IsDBNull(dr(i)) Then
sw.Write(dr(i).ToString)
If i < iCol - 1 Then sw.Write(",")
End If
Next
sw.Write(sw.NewLine)
Next
sw.Close()
Me.DownloadFile(Server.MapPath("~/", "data.csv"))