Friday, March 30, 2012

ReportViewer exporting

Hi,

When you export a report in localmode using the ReportViewer export function, a new window will pop up with the download. Is there a way to eliminate that new browser window from coming up? Also, I'm having a little trouble writing some custom code to export the report instead of using the export toolbar. I found the following in a previous post...

1Dim bufferAs Byte(), fAs String, fsAs System.IO.FileStream2 f = System.IO.Path.GetTempFileName()3 System.IO.Path.ChangeExtension(f,"xls")4' there is probably a better way to set up the rendered PDF5 ' for redirecting to the Response output, but this one works.67 ' here is the binding bit. Revise to suit your dynamic situation.8 ' if you aren't really dynamically binding data against one9 ' loaded report, but rather changing10 ' reports to suit the user's needs, that will work too.11Dim ReportDataSourceX =New ReportDataSource()12With Me.ReportViewer1.LocalReport13 buffer = .Render("EXCEL", _14Nothing,Nothing,Nothing,Nothing,Nothing,Nothing)15End With1617 fs =New System.IO.FileStream(f, System.IO.FileMode.Create)18 fs.Write(buffer, 0, buffer.Length)19 fs.Close()20 fs.Dispose()2122 Response.ContentType ="Application/vnd.ms-excel"23 Response.WriteFile(f)24 Response.End()25 System.IO.File.Delete(f)
When  I run this and export, the excel file comes up very quarky with all sorts of symbols and such and does not render correctly, e,g,. the rdlc isn't even loaded and it seems like it is taking the whole page into excel from what I can read from the file.
 
Thanks in advance.

Hi Heyden,

You can do this by usingReportViewer.ExportContentDispositionproperty. UseAlwayInline.

For reference -

http://msdn2.microsoft.com/en-us/library/microsoft.reporting.webforms.reportviewer.exportcontentdisposition(VS.80).aspx

|||

and for custom export functionality check this post -

https://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=139828&SiteID=1

|||

Many thank for the AlwaysInline. Solved my problem. I was either going to use custom exporting or try to find a way to eliminate that page. Thanks a bunch again!

|||

I have the same problem. A new window pops-up when trying to download the report in excel through the export toolbar. I don't want to open the report inline. I need a separate window to open the report but I don't want the pop-up window to be present while downloading the report. Is there any way to eliminate the blank window or any way to close it once the download is done.

Thanks in advance !

Shabs

sql

No comments:

Post a Comment