开发者

SSRS: How to print a report without bringing up the rendered report?

I'm wondering how to print a SSRS report without bringing up a report viewer. Ri开发者_JS百科ght now my users have to press the Print button, bring up the rendered report, and then press Print again.

Current Code:

Dim report as new ReportViewer
'snip - fill datasets, set data sources, blah blah blah
report.ReportViewer1.LocalReport.DataSources.Add(datasource)
report.Show()

This brings up a viewer window, which I don't really want, since my users then have to press Print again.

So I added the following:

report.PrintDialog()

The above code results in an invalidOperationException because it hasn't finished rendering. I understand that, but is there a way to render the report programmatically (rather than onscreen) and send the user straight to the printer dialogue?

EDIT: OK, I'm 90% there. PrintDialog() isn't the way to go. I found this article but it results in an InvalidXMLException. It doesn't tell me why it's wrong, just that it's wrong... The API is totally unhelpful so... help?


You could use the SSRS Web Service to programmatically render the report (i.e. as a PDF) and then print it from your application.

http://msdn.microsoft.com/en-us/library/ms152952.aspx


Here's what I found on the subject, followed, and worked for me: http://printssrsreport.blogspot.com/2011/09/print-ssrs-report-using.html

It's important you follow "Step 1" and add the reference to "ReportExecution2005.asmx". This was confusing to me as I am using Reporting Services 2008 R2. But it is what it is, and it works.

The rest should be straight forward and work for you.


Why not just put the reports on a schedule, get them to save as a pdf to a folder then use something like Batch print pro to print them?


try to put the command report.PrintDialog() on the RenderingComplete event of the ReportViewer Control.

this will insure that the report is already rendered before you call the print dialog

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜