SSRS:如何在不显示渲染报告的情况下打印报告?

发布于 2024-11-03 18:31:18 字数 771 浏览 0 评论 0原文

我想知道如何在不打开报告查看器的情况下打印 SSRS 报告。现在,我的用户必须按“打印”按钮,调出渲染的报告,然后再次按“打印”。

当前代码:

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

这会打开一个查看器窗口,我并不真正想要它,因为我的用户必须再次按“打印”。

所以我添加了以下内容:

report.PrintDialog()

上面的代码会导致 invalidOperationException 因为它尚未完成渲染。我理解这一点,但是有没有办法以编程方式(而不是在屏幕上)呈现报告并将用户直接发送到打印机对话框?

编辑:好的,我已经90%了。 PrintDialog() 不是正确的方法。我找到了这篇文章,但它导致了 InvalidXMLException.它没有告诉我为什么它是错误的,只是它是错误的...... API 完全没有帮助所以...... 帮助?

I'm wondering how to print a SSRS report without bringing up a report viewer. 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.

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

病女 2024-11-10 18:31:18

您可以使用 SSRS Web 服务以编程方式呈现报告(即作为 PDF),然后从您的应用程序打印它。

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

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

豆芽 2024-11-10 18:31:18

以下是我在这个主题上发现、遵循并为我工作的内容:
http://printssrsreport.blogspot.com/2011/09/print -ssrs-report-using.html

请务必遵循“步骤 1”并添加对“ReportExecution2005.asmx”的引用。这让我很困惑,因为我正在使用 Reporting Services 2008 R2。但它就是这样,而且有效。

其余的应该很简单并且适合您。

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.

黯然 2024-11-10 18:31:18

为什么不直接将报告放在时间表上,将它们以 pdf 格式保存到文件夹中,然后使用类似 批量打印专业版来打印它们?

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?

め七分饶幸 2024-11-10 18:31:18

尝试将命令report.PrintDialog() 放在ReportViewer 控件的RenderingComplete 事件上。

这将确保在调用打印对话框之前已呈现报告

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文