简体   繁体   English

SSRS:如何在不提交呈现报告的情况下打印报告?

[英]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. 我想知道如何在不打开报表查看器的情况下打印SSRS报表。 Right 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. 这会打开一个我不想要的查看器窗口,因为我的用户必须再次按Print。

So I added the following: 所以我添加了以下内容:

report.PrintDialog()

The above code results in an invalidOperationException because it hasn't finished rendering. 上面的代码导致invalidOperationException因为它还没有完成渲染。 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. 编辑:好的,我90%在那里。 PrintDialog() isn't the way to go. PrintDialog()不是要走的路。 I found this article but it results in an InvalidXMLException . 我发现了这篇文章,但它导致了一个InvalidXMLException It doesn't tell me why it's wrong, just that it's wrong... The API is totally unhelpful so... help? 它没有告诉我为什么它是错的,只是它是错的...... API完全没有帮助所以...帮助?

Here's what I found on the subject, followed, and worked for me: http://printssrsreport.blogspot.com/2011/09/print-ssrs-report-using.html 以下是我在这个主题上发现的内容,随后为我工作: 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". 重要的是你按照“步骤1”并添加对“ReportExecution2005.asmx”的引用。 This was confusing to me as I am using Reporting Services 2008 R2. 当我使用Reporting Services 2008 R2时,这让我感到困惑。 But it is what it is, and it works. 但事实就是如此,而且它有效。

The rest should be straight forward and work for you. 其余的应该是直截了当的,为你工作。

You could use the SSRS Web Service to programmatically render the report (ie as a PDF) and then print it from your application. 您可以使用SSRS Web服务以编程方式呈现报告(即PDF格式),然后从您的应用程序中打印它。

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

try to put the command report.PrintDialog() on the RenderingComplete event of the ReportViewer Control. 尝试将命令report.PrintDialog()放在ReportViewer Control的RenderingComplete事件上。

this will insure that the report is already rendered before you call the print dialog 这将确保在调用打印对话框之前已经呈现报告

为什么不把报告按计划进行,让它们作为pdf保存到文件夹然后使用Batch print pro之类的东西来打印它们?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM