My stored procedure returns data that is to populate fields in an Excel file.
The data is to display in a grid on the user's monitor screen so that the user can review it before printing, viewing as an Excel file or sending the Excel file as an attachment in an e-mail.
Right now, I have this code with which to work:
How do I adapt this code so that it displays the output from my stored procedure?
Here is an image of the output:
![Name: sp-output.JPG
Views: 75
Size: 179.8 KB]()
The data is to display in a grid on the user's monitor screen so that the user can review it before printing, viewing as an Excel file or sending the Excel file as an attachment in an e-mail.
Right now, I have this code with which to work:
Code:
Dim dt As DataTable = GetData()
Dim attachment As String = "attachment; filename=Employee.xls"
Response.ClearContent()
Response.AddHeader("content-disposition", attachment)
Response.ContentType = "application/vnd.ms-excel"
Dim tab As String = ""
For Each dc As DataColumn In dt.Columns
Response.Write(tab + dc.ColumnName)
tab = vbTab
Next
Response.Write(vbLf)
Dim i As Integer
For Each dr As DataRow In dt.Rows
tab = ""
For i = 0 To dt.Columns.Count - 1
Response.Write(tab & dr(i).ToString())
tab = vbTab
Next
Response.Write(vbLf)
Next
Response.End()
Here is an image of the output: