469,573 Members | 1,551 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,573 developers. It's quick & easy.

Problem to download excel file using Response.writefile

I have written a program, where I download reports in PDF or Excel format,
depends on user selection.
My code is working fine for PDF format, but same code os not working for
excel file. When I execute the code, A dialog box appears, itr shows the
file name that is same as my aspx file name, with aspx extension (like
showreport.aspx), instead of xls extension. I have also verified valid excel
file exists at that location from where I am trying to open it.

My code is,

ReportFileName = "C:\Temp\" + Session.SessionID.ToString + ".xls"

FileStream = File.Create(ReportFileName, result.Length)

FileStream.Write(result, 0, result.Length)




If format = "EXCEL" Then

Response.ContentType = "application/vnd.ms-excel"

ElseIf format = "PDF" Then

Response.ContentType = "application/pdf"

End If

Response.WriteFile("C:\temp\qcvznymz2zx5webayqzdo3 q2.xls")


Nov 22 '05 #1
0 1714

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by moondaddy | last post: by
7 posts views Thread by Bala | last post: by
5 posts views Thread by gaubo79 | last post: by
reply views Thread by Ayrin | last post: by
reply views Thread by suresh191 | last post: by
4 posts views Thread by guiromero | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.