如何水平显示自定义数量的元素?
我想水平显示元素(在一“行”中)。我把这个问题想象成一个只有一行和动态列数的表。该表中的每个单元格都包含相同的子报表,但具有不同的数据源。
一开始我尝试将组件列表和子报表结合起来。但事实证明,列表组件不支持水平布局。我在某处读到使用交叉表代替。但是,当我尝试将子报表插入度量单元格时,iReport 显示一条消息,提示我无法执行此操作。那我能做什么呢?
I want to display elements horizontally (in one "line"). I'm imagining this problem like a table with one row and dynamic number of columns. Each cell in this table contains the same subreport but with different data source.
At the beginning I was trying combining a component list and the subreport. But it turned out that the list component doesn't support a horizontal layout. I read somewhere to use the crosstab instead. But when I'm trying to insert the subreport into a measure cell iReport displays a message that I can't do it. So what can I do?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
根据您的上述评论,我想说水平打印元素列表并不困难。列表组件基本上是一个子报表。因此,您还可以创建一个自定义列表组件,它水平打印元素列表。您所需要做的就是创建一个没有任何边距的新报告,将其“打印顺序”设置为“水平”并设置列数根据您的要求。然后,您可以将此报告作为子报告嵌入到某些主报告中并水平打印元素。
根据您的要求,您可以相应地设置报告和文本字段的大小。这是我创建的报告的屏幕截图:
这是我创建的示例 jrxml 文档:
Based on your above comment, I would say that it is not that difficult to print a list of elements horizontally. A List component is basically a subreport. So, you could also create a custom List component, which prints a list of elements horizontally. All you need is to create a new report without any margins, set it's "Print Order" to "Horizontal" and set the number of columns as per your requirements. You could then embed this report as subreport in some main report and print elements horizontally.
Based on your requirements, you can set the report and text-field sizes accordingly. Here's the screenshot for that report I created:
And here's the sample jrxml document that I created:
@bchetty:抱歉,我选择回答而不是发表评论,因为我没有足够的声誉来这样做。您发布的解决方案工作正常,但它使报告布局变得相当不好。我有一个类似的要求,我将列大小保持为 20,但我永远无法预测它在某些查询中不会超过 20。同样,如果从列的查询中仅获取三个值,则剩余的列空间仍为空,并且不会为生成的报告提供良好的布局。
我在iReport终极指南中读到,如果将List用作子报表并且printOrder“水平”,我们可以获得动态列的效果。但我想这只是一个“效果”,而不是真正的动态列,因为列大小必须固定为大于 1 的某个值。
我在试图实现这一目标时束手无策,但我想我可能不得不放弃。交叉表也无法解决这个问题,因为它受到两个行组和两个列组的限制。但该报告还有其他字段也必须与动态列一起打印。
水平打印子报表数据
@bchetty : Sorry I chose to answer rather than comment as I do not have enough reputation to do so. The solution posted by you works fine but it leaves the report layout pretty Not Ok. I had a smilar requirement where I kept the columns size as 20 but then I can never predict that it would not cross 20 in some query. Again if only three values are fetched from the query for the columns then the remaining column spaces remain empty and do not give a good layout for the report generated.
I read in iReport ultimate guide book that if the List is being used as a sub report and the printOrder "horizontal" we can get the effect of dynamic columns. But I guess this is just an "effect" and not actually dynamic columns as the columns size has to be fixed to some value greater than 1.
I am at wits end trying to achieve this but I guess I might have to give up. Crosstab can't come to rescue either as it is limited by two row groups and two column groups. But the report has other fields which must be printed too alongwith the dynamic columns.
Printing a sub report data horizontally