Write data to Excel file

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



Hi

I want to export web controls value into the Excel file.

Detail :
I have a text box where user can type the filename and on click of button a
dialog box should appear that will ask user to where to save the file and
that file should contain all the data from the webcontrols for example
<asp:label>

I tried the following code.
Response.ContentType = "application/vnd.ms-excel"
Response.AddHeader("Content-Disposition", "attachment;filename=" + fileName
+ ".xls")
Response.Write("<table><tr><td>" & Me.TotalRevenueLabel1.Text &
"</td></tr></table>")

But this code doesnt write value of the "TotalRevenueLabel1.text" inside the
Excel file but it renders whole webpage.

Please provide the solution for this as soon as possible.

Thanks

Regards,
Pauravi

.


Quantcast