Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to print a ReportViewer's report without showing a form

While I realize that I could just show the form off-screen and hide it, along with many other forms of WinForms hackish wizardry, I'd rather stick with the zen path and get this done right. I have a SSRS local report (so no server) that I want to give the user the option of either viewing or printing (in other words, I don't want to force them to view to print). Unfortunately, the ReportViewer control complains about its "state" when I try to print it either as a component I'm creating explicitly in my code (inside a using() block, of course) or if I try to instantiate my viewer form and just print without ever showing it.

Is there a means to do this that will sit well with me, or should I just show it off-screen and move on with my life?

like image 486
Adam Robinson Avatar asked Apr 08 '09 17:04

Adam Robinson


People also ask

How can I print Rdlc directly without viewing?

How to print the RDLC report directly without viewing in WinRT ReportViewer? Printing reports directly without viewing is not supported. This can be achieved by exporting the reports into PDF and the resultant stream is used in the PdfDocument for printing. Initialize the ReportWriter and load the report stream.

How do you print the report?

Click File and then click Print. On the Print area of the File options, click the Print option to open the Print dialog box. Change the page format setup or other print options or printer selection as needed, and then click OK to print your report.

How Can Show print button in report viewer in asp net?

report. I set "showPrintButton="True"".


2 Answers

I have a sample that does this posted on my blog here: http://blogs.msdn.com/brianhartman/archive/2009/02/27/manually-printing-a-report.aspx

The LocalReport object can be instantiated independently of the ReportViewer control and used directly in the sample code attached to that blog post. Or you can pass in ReportViewer.LocalReport even if you don't first display the report in the UI.

like image 63
Brian Hartman Avatar answered Sep 27 '22 22:09

Brian Hartman


Check this out and see if it helps...http://scruffylookingcatherder.com/archive/2007/12/07/printing-reporting-services-2005-reports.aspx

A little explanation: It's using the SSRS web service to render the report to an EMF image then send the image to the printer.

like image 44
Mozy Avatar answered Sep 27 '22 22:09

Mozy