I am unable to export my data into excel.
I have tried the suggestions on S/O, but have not had any luck.
Dim sqlString As String = "spExportRateProfile" & Session("OfficeNumber") & "," & Session("SalesRepID")
Dim conn As SqlConnection = New SqlConnection(Utils.GetConfigKey("ConnectionStringVimas"))
conn.Open()
Dim dt As DataTable = New DataTable()
Dim da As SqlDataAdapter = New SqlDataAdapter(sqlString, conn)
da.Fill(dt)
Response.AddHeader("content-disposition", "attachment;filename=ReportExport.xlsx")
Response.ContentType = "application/vnd.ms-excel"
What do I need do after this to export my data to excel?
You could use a ExcelLibrary like EPPlus(GPL) which i can warmly recommend.
Then it is as easy as this to create Excel-Files from a DataTable and write it to the Response:
Here is another example: http://epplus.codeplex.com/wikipage?title=WebapplicationExample