动态列
我需要创建一个报告,其中列数根据传递到 iReport 的数据而变化,就像子报告一样。有办法做到这一点吗?
I need to create a report where the number of columns changes based on the data being passed to iReport just like with a subreport. Is there a way to do this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我同意 Ischin 的回答,但我会详细说明。
交叉表报告将允许您拥有动态列,因为它允许您旋转数据。您可以选择一个或多个字段作为分组依据来创建列。组的值成为列的标签,然后您必须对报告中称为“度量”的值使用聚合函数(例如,总和或计数)。如果您选择多个字段,您将拥有多个级别的列。当您设计报表时,您可以选择列的大小——它们必须具有相同的大小。
JasperReports 是一款旨在创建能够一致打印在纸上的内容的产品,例如 PDF。 iReport 至少从 5.1.0 版本开始,没有任何其他方法可以真正动态创建列。您可以编写逻辑来根据参数显示或隐藏列,但这将非常乏味,并且不符合 JasperReports 的设计目的。例如,允许用户运行报告来选择允许用户控制报告中的列以及列的位置的参数将是非常困难的。
I agree with Ischin's answer, but I will elaborate.
The Crosstab Report will allow you to have dynamic columns because it allows you to pivot your data. You can select one or more fields to group by to create the columns. The values of the groups become the labels for the columns and then you must use aggregate functions for the values in the report called Measures (e.g., sum or count). If you select more than one field, you will have multiple levels of columns. When you design the report, you pick the size of the columns--they must all have the same size.
JasperReports is a product designed for creating something that will print on a piece of paper consistently, like a PDF. iReport as of at least version 5.1.0, does not have any other way to truly dynamically create columns. You could write in logic to show or hide columns based on parameters, but this would be very tedious and does not fit in with what JasperReports is designed for. It would be very difficult, for example, to allow the user running the report to select parameters that allow the user to control which columns are in the report and the positions of the columns.