Jasper 表组件
我正在尝试生成包含表格的报告。这些是 jrxml 中的重要部分:
<jasperReport
<subDataset name="Table Dataset 1">
<field name="field1" class="java.lang.String"/>
</subDataset>
<summary>
<jr:table>
<datasetRun subDataset="Table Dataset 1">
<dataSourceExpression>
<![CDATA[$P{REPORT_DATA_SOURCE}]]>
</dataSourceExpression>
</datasetRun>
<jr:column width="90">
<jr:columnHeader>...</jr:columnHeader>
<jr:detailCell height="20">
<textField>
<textFieldExpression class="java.lang.String">
<![CDATA[$F{territory}]]>
</textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
<jr:table>
</summary>
</jasperReport>
我传递给报告的数据源类型是 JRBeanArrayDataSource,这似乎没问题,因为数据出现在报告中(如果我在主文件中使用 $F{field1} -桌子外面)。
您发现我使用表格组件的方式有问题吗? 我没有看到任何错误...但是表格没有显示...只有一条水平线而不是表格。
I am trying to generate a report containing a table. These are the important parts from the jrxml:
<jasperReport
<subDataset name="Table Dataset 1">
<field name="field1" class="java.lang.String"/>
</subDataset>
<summary>
<jr:table>
<datasetRun subDataset="Table Dataset 1">
<dataSourceExpression>
<![CDATA[$P{REPORT_DATA_SOURCE}]]>
</dataSourceExpression>
</datasetRun>
<jr:column width="90">
<jr:columnHeader>...</jr:columnHeader>
<jr:detailCell height="20">
<textField>
<textFieldExpression class="java.lang.String">
<![CDATA[$F{territory}]]>
</textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
<jr:table>
</summary>
</jasperReport>
The type of datasource I am passing to the report is a JRBeanArrayDataSource, which seems to be ok, because the data appears in the report (if I am using $F{field1} in the master - outside the table).
Do you see something wrong in the way I am using the table component?
I don't see any errors...but the table is not being displayed...only a horizontal line instead of the table.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我遇到了同样的问题并在这里找到了解决方案
https ://web.archive.org/web/20111130110022/http://thilosdevblog.wordpress.com/2011/03/27/beans-in-jasperreports4/
表数据源必须是这样的:
想知道为什么这种东西不在 jasper/ireport FAQ 中!
I had the same problem and found the solution here
https://web.archive.org/web/20111130110022/http://thilosdevblog.wordpress.com/2011/03/27/beans-in-jasperreports4/
the table datasource has to be like this:
Wonder why this kind how stuff is not in the jasper/ireport FAQ !
好吧,我无法发表评论,也无法投票,但我已经测试过并可以确认@Flo 的答案有效。
编辑:第一行丢失。了解如何修复它:Jasper 报告缺少第一行 和 JasperReports 教程:缺少记录错误
Well, I can't comment and can't vote up but I have tested and can confirm that @Flo's answer works all right.
Edit: the first row is missing. See how to fix it: Jasper report missing first row and JasperReports Tutorial: Missing Record Bug