如何将 table header 添加到现有的 jasper table 组件?

How to add a table header to an existing jasper table component?

有没有办法将 table header 添加到现有的 jasper 报告 table?

我有一份现有的 jasper 报告,其中包含一个 table 组件,但没有 table header。我现在想添加一个 table header,但是如果不完全重新创建 table.

就找不到任何方法来做到这一点

有人知道将 Table Header 添加到现有 jasper table 组件的方法吗?

你有2个选项,直接在jrxml中添加(xml)或者使用IDE

1。直接加入jrxml(去源码查看)

在每个 jr:column 中,您希望有一个 header 添加 jr:tableHeader 标签作为第一个元素

<jr:column width="100" uuid="accf01ee-c512-4854-ae58-97dee667c054">
     <jr:tableHeader style="Table_TH" height="30">
       <staticText>
            <reportElement x="0" y="0" width="100" height="30" uuid="41f6fe02-194f-483e-ab7b-97a6061e2c27"/>
            <text><![CDATA[My header]]></text>
        </staticText>
    </jr:tableHeader>
   ....
</jr:column>

2。直接使用IDE

双击 table 组件,这样就可以对其进行编辑,在大纲中导航到 header 节点,为您喜欢的每一列创建 header 单元格,然后您就可以将静态或动态文本字段拖到其中。