C# 如何在没有 SSRS 服务器的情况下使用报表查看器控件执行 .rdl 报表?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/17621346/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-10 10:03:34  来源:igfitidea点击:

How can I execute an .rdl report with a Report Viewer control without an SSRS server?

c#asp.netreporting-servicesrdl

提问by qJake

I'm trying to set up a web page where users can select an .rdl file to run, and it will open a Report Viewer control (ASPX), load the report definition file, run it, and display the report.

我正在尝试设置一个网页,用户可以在其中选择要运行的 .rdl 文件,它将打开一个报表查看器控件 (ASPX),加载报表定义文件,运行它并显示报表。

So far, what I've found is, "local" reports can only accept data sources from code (so you have to execute the database code manually, which would be a pain since the datasource can vary widely between reports), and "remote" reports require an SSRS server, something I am unable to set up.

到目前为止,我发现“本地”报告只能接受来自代码的数据源(因此您必须手动执行数据库代码,这会很痛苦,因为报告之间的数据源可能差异很大),而“远程” " 报告需要 SSRS 服务器,这是我无法设置的。

What puzzles me is, Report Builder 3 is able to run .rdl files with embedded Data Sources in them, so why can't the Report Viewer control? Is there some way I can make the Report Viewer control act like Report Builder 3 and just have it run .rdl files?

令我困惑的是,Report Builder 3 能够运行其中嵌入数据源的 .rdl 文件,那么为什么 Report Viewer 不能控制呢?有什么方法可以让 Report Viewer 控件像 Report Builder 3 一样运行并且让它运行 .rdl 文件?

采纳答案by djangojazz

The Report Viewer CAN run RDL files but they need to be hosted/published somewhere first is the rub then the reportviewer is in remote mode. The ReportView has different modes it can run in and one of them is basically just talking to the SSRS server and saying: "What you got up there?". There are a great great many debates of when to the local reports or the hosted ones and what are advantages/disadvantages of one over the other. You can develop just a regular SSRS Server with 'advanced options' to get the SSRS instance on a box if costs are a concern and adjust firewalls accordingly. If it is a policy setting I can't help with that.

报告查看器可以运行 RDL 文件,但它们首先需要托管/发布在某个地方,然后报告查看器处于远程模式。ReportView 有不同的模式可以运行,其中之一基本上只是与 SSRS 服务器交谈并说:“你在那里得到了什么?”。关于何时使用本地报告或托管报告以及其中一个相对于另一个的优点/缺点有很多争论。如果需要考虑成本并相应地调整防火墙,您可以只开发一个带有“高级选项”的常规 SSRS 服务器,以将 SSRS 实例放在一个盒子上。如果这是一个策略设置,我无能为力。

Honestly if you want more coupled control to something like Entity Framework or WCF service and want to massage your data BEFORE you put it to a report, I would go RDLC. If you want to create a report with large datasets and give the user lots of options to alter the report layout and values from parameters I would go rdl but know you need to set up an SSRS instance. To try to set up RDL reports WITHOUT the server and then run them is a big pain that does not get you much but heartache. If it is the parameters you are wanting you can create your own, then massage the data BEFORE it goes to the datasource of the RDLC, then present the RDLC to an end user. This method involves reading more of the MS whitepaper on the reporting language and understanding how to implement the RDLC object in code behind.

老实说,如果您想要对实体框架或 WCF 服务之类的东西进行更多的耦合控制,并且想要在将数据放入报告之前对其进行处理,我会去 RDLC。如果你想创建一个包含大型数据集的报告,并为用户提供很多选项来改变报告布局和参数值,我会去 rdl 但知道你需要设置一个 SSRS 实例。尝试在没有服务器的情况下设置 RDL 报告然后运行它们是一种巨大的痛苦,它不会让您感到非常痛苦,但会感到心痛。如果这是您想要的参数,您可以创建自己的参数,然后在数据进入 RDLC 的数据源之前对其进行按摩,然后将 RDLC 呈现给最终用户。此方法涉及阅读有关报告语言的更多 MS 白皮书并了解如何在代码隐藏中实现 RDLC 对象。

More of the eternal argument of RDL versus RDLC here: When to use RDLC over RDL reports?

更多关于 RDL 与 RDLC 的永恒争论在这里:何时使用 RDLC 而不是 RDL 报告?

回答by Cam Bruce

No, you will need an SSRS Server to do what you are trying to do, unless you use RDLC files. You could get very creative and parse the RDL xml for the datasources yourself and perform the actions, but that is basically doing the same thing as RDLC.

不,除非您使用 RDLC 文件,否则您将需要一个 SSRS 服务器来执行您要执行的操作。您可以非常有创意,自己解析数据源的 RDL xml 并执行操作,但这基本上与 RDLC 做同样的事情。

回答by Murali Uppangala

Here is a link to an MSDN article that will provide some information about using the WebForms ReportViewer control:

这是 MSDN 文章的链接,该文章将提供有关使用 WebForms ReportViewer 控件的一些信息:

http://technet.microsoft.com/en-us/library/aa337091(v=sql.100).aspx

http://technet.microsoft.com/en-us/library/aa337091(v=sql.100).aspx