当子报表导致分页时,Tablix 标题不会在新页面上重复
我已经和 SSRS 争论了太久了,这本来应该是一件简单的事情。我希望有人能帮助我找到解决方案。
我有一份包含许多配置文件的报告,每个配置文件都有大量的数据部分。数据部分(各种表格和图表)除了“键”回父配置文件 ID 之外,没有以任何方式相互关联。
目标(看起来很简单)是在每个页面上都有一个包含配置文件信息的标题,然后布置数据部分(每个部分的格式完全不同)。
我们遇到的第一个问题是,由于某种原因,SSRS2008 不允许 tablix 单元格包含具有不同数据集的另一个 tablix(我无法理解为什么它不能只需要基于父分组的过滤器)。针对此缺点的建议解决方法是将所有数据组合成一个巨大的数据集(这里不可能,数据部分太多且多样化)或嵌入子报表并传入参数。虽然第二个选项增加了打印大量配置文件所需的“工作”,但我们继续实现了这一点,并且它确实有效。
问题出现在主 Tablix(包含子报表的 Tablix)上,该 Tablix 的静态行标题组设置为“RepeatOnNewPage = true”。此设置允许标题根据需要显示在每个页面上...除了跨多个页面的子报表,其中标题被错误地省略。
由于某种原因,当子报表跨越多个页面时,父tablix的标题不会重复!这让我发疯,因为 SSRS 中的一些糟糕的设计决策似乎让我陷入了无法创建我想要的报告的境地……标题可以在没有子报告的情况下工作,但我需要子报告才能“加入” “将数据部分添加到配置文件中。
这似乎是一个简单而常见的要求......毕竟,这是一个从几十年前的报告系统迁移而来的报告。我搜索了 StackOverflow 和 Google,但没有成功...我似乎有很多关于分页符的问题/答案,但没有任何建议用子报表解决这个问题。
我发布这个以防万一我遗漏了一些东西。如果有人有任何建议,我们将不胜感激。
I've been fighting with SSRS for too long now on what should be a simple matter. I'm hoping someone can help me see a solution.
I have a report which has a number of profiles, and each profile has a large number of data sections. The data sections (various tables and charts) are not related to each other in any way other than that they "key" back to the parent profile id.
The goal (which seems simple) is to have a header on each page with the profile information, and then have the data sections (each formatted completely differently) laid out.
The first problem we encountered was that for some reason SSRS2008 does not allow a tablix cell to contain another tablix with a different dataset (why it can't just require a filter based on the parent grouping is beyond me). The recommended workaround for this shortcoming is to either combine all data into a giant dataset (not possible here, data sections are too numerous and varied) or to embed subreports and pass in the parameters. While option number two increases the "work" needed to print a large number of profiles, we proceeded to implement this and it does work.
The problem comes in on the main tablix (the one containing the subreports) that has a static row header group set with "RepeatOnNewPage = true". This setting allows the header to show on every page as desired... except for subreports the span multiple pages, where the header is incorrectly ommitted.
For some reason, when the subreport spans multiple pages, the header of the parent tablix is not repeated! This is driving me insane as it would seem that a couple bad design decisions in SSRS has put me in a situation where I can't create the report I want... headers works without subreports, but I need subreports in order to "join" the data sections to the profile.
This would seem to be a simple and common requirement... after all, it's a report that is being migrated from a decades old reporting system. I've scoured StackOverflow and Google without success... I've seem a number of questions/answers about page breaks, but nothing that suggests a solution to this problem with subreports.
I'm posting this in case I'm missing something. If anyone has any suggestions at all, it would be much appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我们已经解决了我们的问题......尽管不是以最理想的方式。
页眉(“主”报告的页眉,而不是子报告的页眉)似乎是始终拥有页眉部分的唯一方式。
我们实施的解决方案很大程度上基于此博客文章:
在 Reporting Services 2008 中维护状态
我们对博客文章进行了稍微修改,从方法中删除了“id”并添加了一个GUID,以确保即使用户同时运行报告的多个副本,报告值也不会混淆。 (使用共享变量时,请记住,它们对于跨执行实例和报表服务器上的用户运行的报表来说是全局的,因此使用它们时需要非常小心!)
在报表正文中,我们有一个隐藏文本调用的块:
在报告页眉中,我们将它们引用为(例如):
这是有效的,因为正文是在页眉之前计算的,即使对于第 1 页也是如此。
不过,最终,它是对应该是的内容的黑客攻击在微软的产品中,考虑到他们在这方面投入了多年的开发 产品!为什么我们不能嵌套 tablix 且更易于使用的标题超出了我的范围……这又是从 90 年代初的程序升级报告,该程序毫无问题地完成了所有这一切。至少,为我们提供可以在处理报告时检索和设置的报告变量!
无论如何,事情就是这样……我们已经使用共享变量测试了该解决方案,它似乎运行得很好。我们将进行压力测试以确保其正确实施,如果我们发现任何进一步的问题,我会在这里发布一些内容。
(如果有人知道其他方法可以在页面上获得一致的标题行,即使存在高度较大的详细信息行,请分享...)
We've solved our problem... although not in the most ideal way.
The Page Header (of the "master" report, not the subreports) seems to be the only way to consistently have a header section.
We implemented a solution based in large part on this blog posting:
Maintaining State in Reporting Services 2008
We modified slightly from the blog post, removing "id" from the methods and including a GUID to ensure the report values are not mixed up even if the user runs several copies of the report at the same time. (When using shared variables, remember that they are global to the report running across execution instances and across users on the report server, so a lot of care needs to be taken when they are used!)
In the report body we have a hidden text block that calls:
and in the report page header we reference these as (for example):
This works because the body is calculated before the page header, even for Page 1.
Still, in the end it is a hack for something that should be in Microsoft's product, given that they have poured years of development into this product! Why we cannot have nested tablix's and easier to use headers is beyond me... again this is upgrading a report from a program from the early 90's which did all this without problem. At the very least, give us report variables that can be retrieved and set as the report is processed!
Regardless, things are as they are... we've tested the solution with shared variables and it seems to be working very well. We're going to run stress tests to make sure it's implemented correctly, I'll post something here if we find any further problems.
(And if anyone knows of some other way to get consistent header rows on pages, even when there are detail rows with large heights, please share...)
我们在实现客户对SSRS报告的需求时也遇到了完全相同的问题,
并尝试了很多事情,但都以失败告终。
在我们的例子中,
主报告有4个子报告。每个子报表都应该在新页面中开始。此外,当新的子报表开始时,页眉应根据当前页面正文中的子报表动态更改。
另外,其中一个 SubReports SubReport3 也有另一种情况。基本上主要报告是根据经销商级别运行的。但客户希望 SubReport3 为与 @Dealer 参数相关的每个 SubDealer 运行。此外,客户还希望看到在 SubReport3 内的新页面中开始的每个 SubDealer 数据。
结果,我们找到了不同的解决方法,如下所示。
我们创建了主报告的页眉。 (报表菜单 -> 添加页眉)(正如 @codinginthevoid 所说,这是最一致的方式)
我们将 4 个子报表放入单独的 tablix 中。我们向每个 tablix 添加了新列。每个tablix中的该列可见性= false,该列的宽度可以尽可能小,然后在该列内部创建占位符,写下表达式如下:
如果表达式在Tablix1中,则表达式为=“Tablix1”,如果在Tablix2中然后“Tablix2”等。
然后开始为 Tablix1 设计页眉,为 Tablix1 放置的页眉中的每个报表项都具有如下可见性表达式:
然后对 Tablix2 应用相同的内容并 。
最后,报表的页眉中有很多文本框,其中一些位置完全相同,重叠,但是当呈现报表时,每个文本框都会显示它是具有相关子报表的相关页面
We have faced exactly the same problem during implementation of customer demands on SSRS Reports,
And did try a lot of things which all of them resulted with failure.
In our case,
Main Report has 4 subreport. Each SubReport should be started in new page. And also when new subreport begins, page header should be changed dynamically based on Subreport in body in current page.
Also one of SubReports which was SubReport3 has another case. Basically Main Report was running based on Dealer level. But Customer wants SubReport3 to run for each SubDealer related with @Dealer parameter. Also Customer wants to see each SubDealer data started in New page inside SubReport3.
As a result, we found different workaround as follows.
We created Page Header to Main Report. (Report Menu -> Add Page Header)(As @codinginthevoid said it is most consistent way)
We putted 4 subreports inside separate tablix. We added new column to each tablix. That column in each tablix visiblity = false, width of that column can be as small as possible, then created placeholder inside of that column, wroted down expression as follows:
If expression is in Tablix1, expression was ="Tablix1", if in Tablix2 then "Tablix2" and etc.
Then started design page header for Tablix1, each report item in pageheader that was putted for Tablix1 has visibility expression as follows:
then applied same thing for Tablix2 and etc.
In the end, there were lots of textbox in PageHeader of report and some of them position was completely same, overlapped, But when reports is being rendered, each of those textboxes is being shown it is related page with related subreport.
我也遇到了同样的问题。我发现解决问题的方法是对数据进行非规范化,添加“记录类型”字段来标识该行是父行还是子行。
我的 tablix 中有两个子表,都显示链接到外部分组的详细数据。如果我将子表的标题设置为在每一页上重复(使用高级箭头 > 静态属性 > KeepTogether = True、KeepWithGroup = After、RepeatOnNewPage = True),则其中一个子表将正确显示父表的重复标题就会消失。
长话短说,这是一个需要解决的非常烦人的问题。解决方案很简单,它对我有用,但可能不适用于所有人。
下面链接的是一个连接到本地主机的 SSRS2008 示例 RDL,其中包含我遇到的问题的示例以及我实现的解决方案。如果您觉得有用,请随意使用!
(我本来会把它发布在这里,但堆栈溢出似乎因代码块而失败)
http://www.sqlservercentral.com/Forums/Topic1111567-1633-1.aspx?Update=1
I have encountered the same problem as well. What I found was that the way to solve the issue was to de-normalise the data, adding a 'Record Type' field to identify whether the row was a parent or a child.
There were two sub-tables in my tablix, both displaying detail data linked to the outer grouping. If I set the headers of the sub-tables to repeat on every page (using the Advanced arrow > Static Properties > KeepTogether = True, KeepWithGroup = After, RepeatOnNewPage = True) then one of the sub-tables would display correctly, however the parent table's repeating header would just disappear.
To keep a long story short, this was a massively annoying problem to solve. The solution is simple, it worked for me, but may not work for everyone.
Linked below is a SSRS2008 example RDL that connects to localhost and has an example of the problem I had and also the solution I implemented. Please feel free to use it if you find it useful!
(I would've posted it on here but Stack Overflow fails for code blocks it seems)
http://www.sqlservercentral.com/Forums/Topic1111567-1633-1.aspx?Update=1
在每个页面上重复列标题的一种非常干净且简单的方法
http://www.a2zmenu.com/Blogs/BI/Tablix-headers-not-repeating-in-SSRS-2008.aspx
A very clean and simple way to repeat the column header on each page
http://www.a2zmenu.com/Blogs/BI/Tablix-headers-not-repeating-in-SSRS-2008.aspx