【问题标题】:How to add multiple reports to the same ReportViewer?如何将多个报表添加到同一个 ReportViewer?
【发布时间】:2012-03-21 17:33:51
【问题描述】:

我在这里遇到一种情况,我正在使用一个 SSRS 报告,我为此发送了 4 个参数。对我来说,报告工作正常。现在另一个问题是,客户需要在同一个报表查看器中查看多个报表(不同的数据),即逐页(单击下一页)。

我使用程序发送参数?我怎样才能做到这一点?

ReportViewer1.ServerReport.ReportServerCredentials = new ReportViewerCredentials(UserName, Password, Domain);
ReportViewer1.ServerReport.ReportServerUrl = new Uri(System.Configuration.ConfigurationManager.AppSettings["ReportServerURL"].ToString()); // Report Server URL

string strUrl = string.Empty;
strUrl = WebConfigurationManager.AppSettings["ReportAppName"].ToString() + "/" + ReportName.Trim();
ReportViewer1.ServerReport.ReportPath = "/" + strUrl;

ReportViewer1.ShowParameterPrompts = true;
ReportViewer1.ShowPrintButton = true;
ReportViewer1.ShowExportControls = true;

ReportParameter[] reportParameters = new ReportParameter[4];
reportParameters[0] = new ReportParameter("AccountNo", AccNo, false);
reportParameters[1] = new ReportParameter("ServiceCode", sType, false);
reportParameters[2] = new ReportParameter("BillMonth", Month, false);
reportParameters[3] = new ReportParameter("BillYear", Year, false);

ReportViewer1.ServerReport.SetParameters(reportParameters);
ReportViewer1.ServerReport.Refresh();

在上面的应用程序中,您可以看到我向其中发送了 4 个参数。该应用程序可以使用单个帐号。我的新要求是,我将拥有多个需要从中检索数据的帐号。在报告中,我应该只显示一个帐号中的数据。

我需要将其余部分显示为同一报告中的页面,以便当用户点击它时,他/她可以浏览它。有可能实现这一目标吗?如何将其显示为页面?

请帮助我。

所以,如果我可以在与页面相同的报告中获得它,我们也可以在单个文件中下载它。

【问题讨论】:

  • @smilu;嗨,你能达到你的多份报告要求吗?我有这个确切的要求。谢谢。
  • 该死,我也有同样的问题。你解决了吗?

标签: asp.net reporting-services reportviewer


【解决方案1】:

对于将原始数据填充到报告中的 sql 查询,请进行两个单独的查询,然后将结果合并为一个返回集。

select customer, address, balance, "customer" as Table from customer where balance > 0

union all

select products as customer, price as balance, "products" as Table from products

假设您知道需要哪些产品线项目。现在您有了原始数据。您的报表设计器中将有多个表格。按表名过滤以告知哪些数据要转到哪个表。

【讨论】:

  • 好的,当我们执行 UNION 时,我们将在不同的行中得到所有这些。现在我只需要每页显示一行,即如果我有 20 行,则报告应分为 20 页。
【解决方案2】:

要将多个报告添加到一个报告中,请在查询中进行联合,并使用列作为数据所属报告的标识符。如果列号类型和名称不匹配,您将不得不使用填充信息,因为联合将不起作用。

现在您已拥有所有数据,请使用报表设计器将新报表数据分配到新页面。希望这会有所帮助

【讨论】:

  • 你能详细解释一下吗?我没有正确理解它
猜你喜欢
  • 2010-10-18
  • 1970-01-01
  • 2021-05-12
  • 2013-06-14
  • 1970-01-01
  • 2016-08-24
  • 1970-01-01
  • 2013-12-07
  • 2020-02-29
相关资源
最近更新 更多