Jasper reports Jasper报告在表中添加静态文本行

Jasper reports Jasper报告在表中添加静态文本行,jasper-reports,Jasper Reports,目前,我在jasper报告中显示如下表格 Col1 | Col2 | Col3 | Col4 ------------------------------------ Row1C1 | Row1C2 | Row1C3 | Row1C4 Row2C1 | Row2C2 | Row2C3 | Row2C4 Row3C1 | Row3C2 | Row3C3 | Row3C4 Row4C1 | Row4C2 | Row4C3 | Row4C4 Col1 |

目前,我在jasper报告中显示如下表格

Col1   |  Col2   |  Col3   |  Col4   
------------------------------------
Row1C1 | Row1C2  | Row1C3  | Row1C4
Row2C1 | Row2C2  | Row2C3  | Row2C4
Row3C1 | Row3C2  | Row3C3  | Row3C4
Row4C1 | Row4C2  | Row4C3  | Row4C4
Col1   |  Col2   |  Col3   |  Col4   
------------------------------------
Row1C1 | Row1C2  | Row1C3  | Row1C4
Row2C1 | Row2C2  | Row2C3  | Row2C4
Added static row here with colspan
Row3C1 | Row3C2  | Row3C3  | Row3C4
Row4C1 | Row4C2  | Row4C3  | Row4C4
但现在我想做这样的桌子

Col1   |  Col2   |  Col3   |  Col4   
------------------------------------
Row1C1 | Row1C2  | Row1C3  | Row1C4
Row2C1 | Row2C2  | Row2C3  | Row2C4
Row3C1 | Row3C2  | Row3C3  | Row3C4
Row4C1 | Row4C2  | Row4C3  | Row4C4
Col1   |  Col2   |  Col3   |  Col4   
------------------------------------
Row1C1 | Row1C2  | Row1C3  | Row1C4
Row2C1 | Row2C2  | Row2C3  | Row2C4
Added static row here with colspan
Row3C1 | Row3C2  | Row3C3  | Row3C4
Row4C1 | Row4C2  | Row4C3  | Row4C4
有没有可能?
如果是,那么如何在表中添加静态行?

您可以使用数据组进行添加。以下是如何实现这一目标的示例:

<queryString language="SQL">
    <![CDATA[SELECT col1, col2, col3 FROM some_table ORDER BY flag]]>
</queryString>
<field name="col1" class="java.lang.Integer">
    <property name="com.jaspersoft.studio.field.label" value="col1"/>
    <property name="com.jaspersoft.studio.field.tree.path" value="some_table"/>
</field>
<field name="col2" class="java.lang.String">
    <property name="com.jaspersoft.studio.field.label" value="col2"/>
    <property name="com.jaspersoft.studio.field.tree.path" value="some_table"/>
</field>
<field name="flag" class="java.lang.Bolean">
    <property name="com.jaspersoft.studio.field.label" value="flag"/>
    <property name="com.jaspersoft.studio.field.tree.path" value="some_table"/>
</field>
<group name="flagGroup">
    <groupExpression><![CDATA[$F{flag}]]></groupExpression>
    <groupFooter>
        <band height="39">
            <printWhenExpression><![CDATA[$F{flag}]]></printWhenExpression>
            <staticText>
                <reportElement x="0" y="10" width="380" height="20" uuid="d4d760c5-0587-4bd7-973a-de1d9b0c8da6"/>
                <text><![CDATA[Any static text to separate groups]]></text>
            </staticText>
            <line>
                <reportElement x="0" y="0" width="330" height="1" uuid="b00741f6-3d2c-4cca-a3fe-397aa7fbf906"/>
            </line>
            <line>
                <reportElement x="0" y="30" width="330" height="1" uuid="0f30d1bc-30ef-48e9-b40e-ab4a3e2b1ffc"/>
            </line>
        </band>
    </groupFooter>
</group>
然后在
jr:table
jr:columnGroup
中添加组页脚(或页眉)定义:

<jr:table xmlns:jr="http://jasperreports.sourceforge.net/jasperreports/components" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports/components http://jasperreports.sourceforge.net/xsd/components.xsd">
    <datasetRun subDataset="Dataset1" uuid="0e226f43-fb2c-43df-baa8-4cf91b3e0523">
        <datasetParameter name="REPORT_DATA_SOURCE">
            <datasetParameterExpression><![CDATA[new net.sf.jasperreports.engine.data.JRBeanCollectionDataSource($P{reportData})]]></datasetParameterExpression>
        </datasetParameter>
    </datasetRun>
    <jr:columnGroup width="210" uuid="1b2e36c1-0c14-48a0-97b8-66fa4330a71a">
        <jr:groupFooter groupName="flagGroup">
            <jr:cell style="Table_CH" height="30" rowSpan="1">
                <staticText>
                    <reportElement x="0" y="0" width="210" height="30" uuid="840fd833-5895-47d0-b63f-dd058a936a8a">
                        <printWhenExpression><![CDATA[$F{flag}]]></printWhenExpression>
                    </reportElement>
                    <text><![CDATA[Any static text to separate groups]]></text>
                </staticText>
            </jr:cell>
        </jr:groupFooter>
...
    </jr:columnGroup>
</jr:table>

...

插入静态行的条件是什么?我的意思是,如果它应该在每个X行之后,或者当输入数据源中出现某个特定值时,或者您只想将表分成两部分?
静态行
上方的@cgrim用于启用记录,下方的
静态行
用于禁用记录。我们需要显示表(数据库)中的所有记录。我们需要在这些记录之间放置带有
静态文本的单行。只有一个表,我还有静态行的索引。只需要将带有colspan的静态文本放在该行索引处。但是不知道如何放置静态行在这种情况下,您可以通过使用两个由静态文本分隔的独立子报表来实现它。第一个子报表将筛选数据集以仅显示启用的记录,第二个子报表将筛选数据集以仅显示禁用的记录。感谢您的回复。。我有
,而您的
标记代码对
不起作用,所以您知道如何在
标记中使用
标记吗?所以您有一个主查询报告(
数据集
)对于主
数据集
中的每个项目,您都有
子数据集
,在这里,您希望使用启用标志呈现由静态文本分隔的表-是否正确?通过
subReport
或如何从
subDatset
中呈现项目?我没有在jasper报表中使用任何查询,我可以将对象列表作为参数从JAVA类传递给jasper报表,和
使用表中的这些代码从列表中获取数据。我用
子数据集的示例更新了答案,希望能有所帮助。
报表设计无效:1。元素到达表组外部页脚内容高度:y=101,高度=21,单元格可用高度=21。2.元素到达表组外部页脚内容宽度:x=5,宽度=548,单元格可用宽度=548