Navigate to a page and display xls/pdf/rpt

liunx

Guest
Gurus,
I have an image on a page that navigates to another aspx page. This page I display *.rpt (crystal) files by calling the load method and this works fine. However I want to display *.xls and *.pdf reports also. I can display xls or pdf via hyperlinks, I just set navigateurl to the xls or pdf file name, but I want to centralize this in one page? If it is rpt then do crystal load otherwise load the xls or pdf. Not sure what event or method to utilize. Any ideas how I would do this? Thanks in advance for any suggestions!Export the report to disk, open the exported report and read the stream into a byte array, close the stream and delete the exported report from disk, clear the http headers, write new headers, send the byte array to the client and end the stream. Assuming you can handle the export and reading part, below is the last little bit to stream the file to the client:


Response.ClearContent()
Response.ClearHeaders()
Response.ContentType = "application/pdf" 'The file's MIME type.
Response.AddHeader("Content-Disposition", "inline; filename=myfile.pdf") 'Name that corresponds to file
Response.BinaryWrite(FileBytes) 'The byte array from your file

'Using response.End() rather than response.Flush() is important
'because it will send the stream before any html is added to the buffer
Response.End()Thanks Cstick, I'll give it a try and let you know if I get it working!
 
Back
Top