Jasper 表组件

发布于 2024-10-09 17:22:42 字数 1194 浏览 0 评论 0原文

我正在尝试生成包含表格的报告。这些是 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

演出会有结束 2024-10-16 17:22:42

我遇到了同样的问题并在这里找到了解决方案
https ://web.archive.org/web/20111130110022/http://thilosdevblog.wordpress.com/2011/03/27/beans-in-jasperreports4/

表数据源必须是这样的:

<datasetRun subDataset="TableDataset">
    <datasetParameter name="REPORT_DATA_SOURCE">
       <datasetParameterExpression><![CDATA[$P{REPORT_DATA_SOURCE}]]></datasetParameterExpression>
    </datasetParameter>
</datasetRun>

想知道为什么这种东西不在 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:

<datasetRun subDataset="TableDataset">
    <datasetParameter name="REPORT_DATA_SOURCE">
       <datasetParameterExpression><![CDATA[$P{REPORT_DATA_SOURCE}]]></datasetParameterExpression>
    </datasetParameter>
</datasetRun>

Wonder why this kind how stuff is not in the jasper/ireport FAQ !

寄居者 2024-10-16 17:22:42

好吧,我无法发表评论,也无法投票,但我已经测试过并可以确认@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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文