ReportViewer:将多个报告合并为一份报告

发布于 2024-07-16 07:15:02 字数 304 浏览 5 评论 0原文

我有一个报告需要运行多次,每次输入不同的数据。 每个报告都有一个唯一标识它的页眉、实际数据正文以及包含 [x of y 页] 格式的页数的页脚。 显然,我可以单独运行每个报告,但我需要所有报告的页码。 因此,如果我运行它两次,第一次有 3 页,第二次有两页,则页脚会在每个报告的底部显示 [x of 5 页]。

我尝试创建一个主报告并只是嵌入报告,但它不显示页眉,我也考虑过单独运行它们,并传入一个参数来调整页码,但我显然需要渲染每个报告,找出总页数,然后重新呈现每个报告以在页脚处获得正确的总页数。

有什么建议么? 我明显遗漏了什么吗?

I have a report that I need to run multiple times, with different data input each time. Each report has a page header that uniquely identifies it, the actual body of data, and then a footer that contains the page count in a [x of y pages] format. Obviously I could run each report separately, but I need the page numbers to be across all reports. So that if I'm running it two times, and the first time it has 3 pages, and the second time it has two pages, the footer shows [x of 5 pages] at the bottom of each report.

I tried creating a master report and just embedding the report, but it doesn't show the page header then, I've also considered running them separately, and passing in a parameter to adjust the page number, but I would obviously need to render each report, find out the page total, then re-render each report to have the correct page total at the footer.

Any suggestions? Anything I'm obviously missing?

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

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

发布评论

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

评论(1

一页 2024-07-23 07:15:02

如果有人最终遇到类似的情况,这是我的解决方案:

首先解释我的数据集:

public Foo
{
  string a;
  List<Bar> subInfo;
}

public Bar
{
  string b;
  string c;
}

List<Foo> allFoos;

基本上不是将 allFoos 对象传递给主报告,然后尝试将相应的 Bar 对象传递给子报告,我创建了一个新对象:

Public FooBar
{
  string a;
  string b;
  string c;
}

List<FooBar> allFooBars;

所以基本上我展平了数据。 从那里我创建了一份报告。 我添加了一张包含“FooBar”作为数据集的表,并传入了“allFooBars”的集合。 我还在报告上创建了页脚,以便在所有页面上保持一致的分页。 然后我使用分组将“Foo”对象保持在一起。 在组中,我将“开始时分页符”、“包括组标题”和“重复组标题”选项设置为 true。 然后我将组标题设置为与组标题一起假冒为我的页面标题(基本上只有 5 行组标题,其中一行是空白的以提供一些空间)。

基本上就是这样。

In case anyone ends up running into a similar situation, here was my solution:

First to explain my datasets:

public Foo
{
  string a;
  List<Bar> subInfo;
}

public Bar
{
  string b;
  string c;
}

List<Foo> allFoos;

Basically instead of having the allFoos object that I passed to a master report, and then trying to pass the corresponding Bar object to the subReport, I created a new object:

Public FooBar
{
  string a;
  string b;
  string c;
}

List<FooBar> allFooBars;

So basically I flattened the data. From there I created a single report. I added one table that had "FooBar" as it's DataSet, and passed in the collection of "allFooBars." I also created a footer on the report, so that I would have consistent paging across all pages. I then used grouping to keep "Foo" objects together. On the groups I set the "Page Break at start" and "Include Group Header" and "Repeat Group Header" options to true. Then I just set up the Group Headers to fake being my Page Headers along with group headers (basically just 5 lines of Group Headers, one of which was blank to provide some space).

And that was basically it.

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