JasperReports、PrintWhenExpression 和 RemoveLineWhenBlank →奇怪的行为
在子报表中使用 printWhenExpression 和 RemoveWhenBlank 时,我遇到 JasperReports 问题。
为了重现这个问题,我使用一个主报告和两个子报告做了一个简单的示例。 第一个子报表(我们称之为静态子报表)在标题带中包含两个静态文本组件(第一行的标签 1,第二行的标签 3),两者的 Position Type 属性都设置为 Float。标题带分割类型属性设置为“立即”。
动态子报表具有三个静态文本组件(第一行的标签 1、第二行的标签 2 和第三行的标签 3),所有这些组件的“位置类型”均设置为“浮动”。但标签 2 的 PrintWhenExpression 设置为 Boolean.FALSE,RemoveLineWhenBlank 设置为 TRUE。因此,标签 2 被隐藏,标签 3 被移动到标签 2 位于标签 1 下的位置。
因此,动态子报表和静态子报表基本上具有相同的结构,并且在报表内打印时应以相同的方式运行。但在这个小例子中情况并非如此。
在主报表中,我在详细信息区域内使用子报表组件(详细信息区域的分割类型设置为 Immediate ),并使用具有 90 个空行的 JREmptyDataSource。当将子报表组件指向静态子报表时,jasperreports生成的pdf输出是正确的。但是当使用动态子报表时,jasperreports会在第一页末尾留下一个空白(使用静态子报表时使用)并跳转到下一页打印标签3。
在实际情况下,我有一个问题,我有一个子报表,其中包含 20 多行静态文本和文本字段组件,其中大多数将 printWhenExpression 设置为字段或参数,并将 RemoveLineWhenBlank 设置为 TRUE。在某些情况下生成 pdf 输出时,我有一个特定的子报表(应仅占据一页的三分之一),跨越一页半,子报表中的可见行之间分布有很多空间。我认为RemoveLineWenBlank 和PrintWhenExpression 的组合是导致问题的原因。 所以我想知道这是一个错误还是只是我在文档中遗漏了某些内容。 这是我在 JasperReports 论坛上发表的帖子的链接,它包含主报告和两个子报告的模板,以及 jasperreports 生成的两个 pdf 和显示子报告布局的屏幕截图:链接
预先感谢您的帮助。
I have a problem with JasperReports when using printWhenExpression and RemoveWhenBlank inside a subreport.
To reproduce this problem, I made a simple example using one master report and two subreport.
The first subreport, let's call it the static subreport, contains two Static Text components in the title band (Label 1 on the first line, Label 3 on the second), both have the Position Type attribute set to Float. The title band Split Type attribute is set to "Immediate".
The dynamic subreport have three Static text components (Label 1 on the 1st line, Label 2 on the second and Label 3 on the third), all of them have the Position Type set to Float. But Label 2 has PrintWhenExpression set to Boolean.FALSE and RemoveLineWhenBlank set to TRUE. So Label 2 is hidden and Label 3 is moved to Label 2's place under Label 1.
So basically the dynamic subreport and the static one have the same structure and should behave the same way when printed inside a report. But that's not the case in this little example.
In the master report I'm using a subreport component inside the detail band ( the split type of the detail band is set to Immediate ) and using a JREmptyDataSource with 90 empty rows. When pointing the subreport component to the static subreport, the pdf output generated by jasperreports is corrrect. But when using the dynamic subreport, jasperreports leaves an empty space (that is used when using the static subreport) at the end of the first page and jumps to the next page to print Label 3.
In the real case that I have a problem with, I have a subreport that contains more than 20 lines with Static Text and Text Field components, most to them with printWhenExpression set to a field or a parameter and RemoveLineWhenBlank set to TRUE. When producing the pdf output in some cases I have that specific subreport (which should occupy just a third of a page) spanning one page and a half with a lot of space spread between the visible lines in the subreport. And I think the combination of RemoveLineWenBlank and PrintWhenExpression is what's causing the problem.
So what I want know is if this is a bug or just me missing something in the documentation.
Here is a link to the post I made at the JasperReports forum, it contains the templates for the master report and the two subreports, plus two pdfs generated by jasperreports and screenshots showing the layout of the subreports: link
Thanks in advance for your help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论