简体   繁体   English

可以使用Microsoft报表(RDLC)从控制台应用程序进行打印

[英]Can Microsoft Report (RDLC) be used to print from a Console Application

We currently have a report done in Crystal Reports that prints reports from a console application. 我们目前在Crystal Reports中完成了一个报告,该报告从控制台应用程序打印报告。 The report is never displayed on screen. 该报告永远不会显示在屏幕上。 It simply prints the batch of reports from the data provided. 它只是根据提供的数据打印一批报告。 Because of some environmental issues with Crystal Reports, I have been looking at using Microsoft Report instead. 由于Crystal Reports存在一些环境问题,我一直在考虑使用Microsoft Report。

While I have been able to create a report in a console application, and attach it to the database, it does not appear to me to be any way to address the report programatically, let alone execute and print it. 虽然我已经能够在控制台应用程序中创建报告并将其附加到数据库,但我似乎没有任何方式以编程方式处理报告,更不用说执行和打印报告了。 Is this a correct assessment? 这是正确的评估吗?

Using Microsoft Report, you can load and export reports without using the report viewer. 使用Microsoft Report,您可以在不使用报告查看器的情况下加载和导出报告。

Here's an example from MS using a LocalReport: 以下是MS使用LocalReport的示例:

http://msdn.microsoft.com/en-us/library/microsoft.reporting.winforms.localreport(v=vs.80).aspx http://msdn.microsoft.com/en-us/library/microsoft.reporting.winforms.localreport(v=vs.80).aspx

You'll notice that while the example takes place in a button click event, it doesn't actually rely on any UI methods and will function equally well from a console application. 您会注意到,虽然示例发生在按钮单击事件中,但它实际上并不依赖于任何UI方法,并且在控制台应用程序中也能正常运行。

The same technique works with a ServerReport. 相同的技术适用于ServerReport。

If you're using Sql Server Reporting Services, you can use the web services ( http://msdn.microsoft.com/en-us/library/ms152787.aspx ) to do pretty much the same thing. 如果您使用的是Sql Server Reporting Services,则可以使用Web服务( http://msdn.microsoft.com/en-us/library/ms152787.aspx )执行相同的操作。

In each of these cases, you'd export the report to a format to one of the supported formats. 在每种情况下,您都要将报告导出为支持格式之一的格式。 There is probably more information available on the SSRS side, but a lot of the things it discusses will be applicable to the Microsoft Report stuff (for example, DeviceInfo settings are available here: http://msdn.microsoft.com/en-us/library/ms155395.aspx ) SSRS方面可能有更多可用的信息,但它讨论的很多内容将适用于Microsoft Report的内容(例如,DeviceInfo设置可在此处获得: http//msdn.microsoft.com/en-us /library/ms155395.aspx

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

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