如何用内部行创建表 [英] How to create table with inner rows

查看:60
本文介绍了如何用内部行创建表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在jasper中获得这种情况(将最后一列移动为新的动态行)?

How to obtain this situation (move the last column as new dynamic row) in jasper?

Jrxml代码: https://pastebin.com/sMa1Cct2

<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 6.8.0.final utlizzo versione della libreria JasperReports6.8.0-2ed8dfabb690ff337a5797129f2cd92902b0c87b  -->
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="template_Table" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="1a0aa80b-dc07-4dca-bdbc-aa78eeb0d12b">
    <style name="Table_TH" mode="Opaque" backcolor="#F0F8FF">
        <box>
            <pen lineWidth="0.5" lineColor="#000000"/>
            <topPen lineWidth="0.5" lineColor="#000000"/>
            <leftPen lineWidth="0.5" lineColor="#000000"/>
            <bottomPen lineWidth="0.5" lineColor="#000000"/>
            <rightPen lineWidth="0.5" lineColor="#000000"/>
        </box>
    </style>
    <style name="Table_CH" mode="Opaque" backcolor="#BFE1FF">
        <box>
            <pen lineWidth="0.5" lineColor="#000000"/>
            <topPen lineWidth="0.5" lineColor="#000000"/>
            <leftPen lineWidth="0.5" lineColor="#000000"/>
            <bottomPen lineWidth="0.5" lineColor="#000000"/>
            <rightPen lineWidth="0.5" lineColor="#000000"/>
        </box>
    </style>
    <style name="Table_TD" mode="Opaque" backcolor="#FFFFFF">
        <box>
            <pen lineWidth="0.5" lineColor="#000000"/>
            <topPen lineWidth="0.5" lineColor="#000000"/>
            <leftPen lineWidth="0.5" lineColor="#000000"/>
            <bottomPen lineWidth="0.5" lineColor="#000000"/>
            <rightPen lineWidth="0.5" lineColor="#000000"/>
        </box>
    </style>
    <subDataset name="ItemDataset" uuid="2914f7c6-c2d7-448b-b0c1-090970e18ed6">
        <queryString>
            <![CDATA[]]>
        </queryString>
        <field name="descrizione" class="java.lang.String"/>
        <field name="numero_depositanti" class="java.lang.String"/>
        <field name="quantita" class="java.lang.String"/>
        <field name="percentuale" class="java.lang.String"/>
        <field name="conti" class="java.util.List"/>
        <group name="Group1"/>
    </subDataset>
    <parameter name="ItemDataSource" class="net.sf.jasperreports.engine.data.JRBeanCollectionDataSource"/>
    <queryString>
        <![CDATA[]]>
    </queryString>
    <background>
        <band splitType="Stretch"/>
    </background>
    <detail>
        <band height="256" splitType="Stretch">
            <componentElement>
                <reportElement x="0" y="0" width="555" height="200" uuid="7786bb05-503a-4b6a-991a-a7bcf3abad07">
                    <property name="com.jaspersoft.studio.layout" value="com.jaspersoft.studio.editor.layout.VerticalRowLayout"/>
                </reportElement>
                <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="ItemDataset" uuid="d3e1e03a-2c83-4436-9e50-79518bc3d337">
                        <dataSourceExpression><![CDATA[$P{ItemDataSource}]]></dataSourceExpression>
                    </datasetRun>
                    <jr:column width="75" uuid="dca8961f-ce2d-47ac-879c-b15847d170a9">
                        <property name="com.jaspersoft.studio.components.table.model.column.name" value="Colonna1"/>
                        <jr:tableHeader height="30" rowSpan="1">
                            <staticText>
                                <reportElement x="0" y="0" width="75" height="30" uuid="f60d1675-6fb6-4569-93ca-de32b3a8e861"/>
                                <text><![CDATA[Descrizione]]></text>
                            </staticText>
                        </jr:tableHeader>
                        <jr:detailCell height="30">
                            <textField>
                                <reportElement x="0" y="0" width="75" height="30" uuid="f1de366a-b36f-4200-9b1e-7a0009be5373"/>
                                <textFieldExpression><![CDATA[$F{descrizione}]]></textFieldExpression>
                            </textField>
                        </jr:detailCell>
                    </jr:column>
                    <jr:column width="140" uuid="980fffb5-1088-47a6-b00f-b5d08b7093c9">
                        <property name="com.jaspersoft.studio.components.table.model.column.name" value="Colonna2"/>
                        <jr:tableHeader height="30" rowSpan="1">
                            <staticText>
                                <reportElement x="0" y="0" width="140" height="30" uuid="16679b95-2e6e-4ca1-b8b6-dd7b74267c56"/>
                                <text><![CDATA[Numero depositanti]]></text>
                            </staticText>
                        </jr:tableHeader>
                        <jr:detailCell height="30">
                            <textField>
                                <reportElement x="0" y="0" width="140" height="30" uuid="341e7faf-9680-4941-a9a4-ac78b8f4aae0"/>
                                <textFieldExpression><![CDATA[$F{numero_depositanti}]]></textFieldExpression>
                            </textField>
                        </jr:detailCell>
                    </jr:column>
                    <jr:column width="100" uuid="980fffb5-1088-47a6-b00f-b5d08b7093c9">
                        <property name="com.jaspersoft.studio.components.table.model.column.name" value="Colonna3"/>
                        <jr:tableHeader height="30" rowSpan="1">
                            <staticText>
                                <reportElement x="0" y="0" width="100" height="30" uuid="16679b95-2e6e-4ca1-b8b6-dd7b74267c56"/>
                                <text><![CDATA[Quantita]]></text>
                            </staticText>
                        </jr:tableHeader>
                        <jr:detailCell height="30">
                            <textField>
                                <reportElement x="0" y="0" width="100" height="30" uuid="341e7faf-9680-4941-a9a4-ac78b8f4aae0"/>
                                <textFieldExpression><![CDATA[$F{quantita}]]></textFieldExpression>
                            </textField>
                        </jr:detailCell>
                    </jr:column>
                    <jr:column width="100" uuid="980fffb5-1088-47a6-b00f-b5d08b7093c9">
                        <property name="com.jaspersoft.studio.components.table.model.column.name" value="Colonna4"/>
                        <jr:tableHeader height="30" rowSpan="1">
                            <staticText>
                                <reportElement x="0" y="0" width="100" height="30" uuid="16679b95-2e6e-4ca1-b8b6-dd7b74267c56"/>
                                <text><![CDATA[Percentuale]]></text>
                            </staticText>
                        </jr:tableHeader>
                        <jr:detailCell height="30">
                            <textField>
                                <reportElement x="0" y="0" width="100" height="30" uuid="341e7faf-9680-4941-a9a4-ac78b8f4aae0"/>
                                <textFieldExpression><![CDATA[$F{percentuale}]]></textFieldExpression>
                            </textField>
                        </jr:detailCell>
                    </jr:column>
                    <jr:column width="140" uuid="980fffb5-1088-47a6-b00f-b5d08b7093c9">
                        <property name="com.jaspersoft.studio.components.table.model.column.name" value="Colonna5"/>
                        <jr:tableHeader height="30" rowSpan="1">
                            <staticText>
                                <reportElement x="0" y="0" width="140" height="30" uuid="16679b95-2e6e-4ca1-b8b6-dd7b74267c56"/>
                                <text><![CDATA[Percentuale]]></text>
                            </staticText>
                        </jr:tableHeader>
                        <jr:detailCell height="30">
                            <textField>
                                <reportElement x="0" y="0" width="140" height="30" uuid="341e7faf-9680-4941-a9a4-ac78b8f4aae0"/>
                                <textFieldExpression><![CDATA[$F{conti}]]></textFieldExpression>
                            </textField>
                        </jr:detailCell>
                    </jr:column>
                </jr:table>
            </componentElement>
        </band>
        <band height="50">
            <staticText>
                <reportElement x="0" y="0" width="75" height="20" backcolor="#151515" uuid="3316e9fe-e7e7-4020-84d6-a8f16cd8eb6b"/>
                <text><![CDATA[descrizione]]></text>
            </staticText>
            <staticText>
                <reportElement x="151" y="0" width="100" height="20" uuid="3316e9fe-e7e7-4020-84d6-a8f16cd8eb68"/>
                <text><![CDATA[quantita]]></text>
            </staticText>
            <staticText>
                <reportElement x="226" y="0" width="75" height="20" uuid="3316e9fe-e7e7-4020-84d6-a8f16cd8eb69"/>
                <text><![CDATA[percentuale]]></text>
            </staticText>
        </band>
    </detail>
</jasperReport>

推荐答案

我在玩耍时发现了另一种可能的方法(没有数据,我无法确认它是否有效). :

Playing around I found another possible way (without the data I can't confirm it working). :

<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 6.5.1.final using JasperReports Library version 6.5.1  -->
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="template_Table" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="1a0aa80b-dc07-4dca-bdbc-aa78eeb0d12b">
    <style name="Table_TH" mode="Opaque" backcolor="#F0F8FF">
        <box>
            <pen lineWidth="0.5" lineColor="#000000"/>
            <topPen lineWidth="0.5" lineColor="#000000"/>
            <leftPen lineWidth="0.5" lineColor="#000000"/>
            <bottomPen lineWidth="0.5" lineColor="#000000"/>
            <rightPen lineWidth="0.5" lineColor="#000000"/>
        </box>
    </style>
    <style name="Table_CH" mode="Opaque" backcolor="#BFE1FF">
        <box>
            <pen lineWidth="0.5" lineColor="#000000"/>
            <topPen lineWidth="0.5" lineColor="#000000"/>
            <leftPen lineWidth="0.5" lineColor="#000000"/>
            <bottomPen lineWidth="0.5" lineColor="#000000"/>
            <rightPen lineWidth="0.5" lineColor="#000000"/>
        </box>
    </style>
    <style name="Table_TD" mode="Opaque" backcolor="#FFFFFF">
        <box>
            <pen lineWidth="0.5" lineColor="#000000"/>
            <topPen lineWidth="0.5" lineColor="#000000"/>
            <leftPen lineWidth="0.5" lineColor="#000000"/>
            <bottomPen lineWidth="0.5" lineColor="#000000"/>
            <rightPen lineWidth="0.5" lineColor="#000000"/>
        </box>
    </style>
    <subDataset name="ItemDataset" uuid="2914f7c6-c2d7-448b-b0c1-090970e18ed6">
        <queryString>
            <![CDATA[]]>
        </queryString>
        <field name="descrizione" class="java.lang.String"/>
        <field name="numero_depositanti" class="java.lang.String"/>
        <field name="quantita" class="java.lang.String"/>
        <field name="percentuale" class="java.lang.String"/>
        <field name="conti" class="java.util.List"/>
        <group name="Group1"/>
    </subDataset>
    <parameter name="ItemDataSource" class="net.sf.jasperreports.engine.data.JRBeanCollectionDataSource"/>
    <queryString>
        <![CDATA[]]>
    </queryString>
    <background>
        <band splitType="Stretch"/>
    </background>
    <detail>
        <band height="256" splitType="Stretch">
            <componentElement>
                <reportElement x="0" y="0" width="555" height="200" uuid="7786bb05-503a-4b6a-991a-a7bcf3abad07">
                    <property name="com.jaspersoft.studio.layout" value="com.jaspersoft.studio.editor.layout.VerticalRowLayout"/>
                </reportElement>
                <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="ItemDataset" uuid="d3e1e03a-2c83-4436-9e50-79518bc3d337">
                        <dataSourceExpression><![CDATA[$P{ItemDataSource}]]></dataSourceExpression>
                    </datasetRun>
                    <jr:column width="75" uuid="dca8961f-ce2d-47ac-879c-b15847d170a9">
                        <property name="com.jaspersoft.studio.components.table.model.column.name" value="Colonna1"/>
                        <jr:tableHeader height="30" rowSpan="1">
                            <staticText>
                                <reportElement x="0" y="0" width="75" height="30" uuid="f60d1675-6fb6-4569-93ca-de32b3a8e861"/>
                                <text><![CDATA[Descrizione]]></text>
                            </staticText>
                        </jr:tableHeader>
                        <jr:detailCell height="60">
                            <textField>
                                <reportElement x="0" y="0" width="75" height="60" uuid="f1de366a-b36f-4200-9b1e-7a0009be5373"/>
                                <textFieldExpression><![CDATA[$F{descrizione}]]></textFieldExpression>
                            </textField>
                        </jr:detailCell>
                    </jr:column>
                    <jr:column width="225" uuid="980fffb5-1088-47a6-b00f-b5d08b7093c9">
                        <property name="com.jaspersoft.studio.components.table.model.column.name" value="Colonna2"/>
                        <jr:tableHeader height="30" rowSpan="1">
                            <staticText>
                                <reportElement x="0" y="0" width="225" height="30" uuid="16679b95-2e6e-4ca1-b8b6-dd7b74267c56"/>
                                <text><![CDATA[Numero depositanti]]></text>
                            </staticText>
                        </jr:tableHeader>
                        <jr:detailCell height="60">
                            <textField>
                                <reportElement x="0" y="0" width="225" height="30" uuid="341e7faf-9680-4941-a9a4-ac78b8f4aae0"/>
                                <textFieldExpression><![CDATA[$F{numero_depositanti}]]></textFieldExpression>
                            </textField>
                            <textField>
                                <reportElement x="0" y="30" width="225" height="30" uuid="341e7faf-9680-4941-a9a4-ac78b8f4aae0"/>
                                <textFieldExpression><![CDATA[$F{conti}]]></textFieldExpression>
                            </textField>
                        </jr:detailCell>
                    </jr:column>
                    <jr:column width="101" uuid="980fffb5-1088-47a6-b00f-b5d08b7093c9">
                        <property name="com.jaspersoft.studio.components.table.model.column.name" value="Colonna3"/>
                        <jr:tableHeader height="30" rowSpan="1">
                            <staticText>
                                <reportElement x="0" y="0" width="101" height="30" uuid="16679b95-2e6e-4ca1-b8b6-dd7b74267c56"/>
                                <text><![CDATA[Quantita]]></text>
                            </staticText>
                        </jr:tableHeader>
                        <jr:detailCell height="60">
                            <textField>
                                <reportElement x="0" y="0" width="101" height="60" uuid="341e7faf-9680-4941-a9a4-ac78b8f4aae0"/>
                                <textFieldExpression><![CDATA[$F{quantita}]]></textFieldExpression>
                            </textField>
                        </jr:detailCell>
                    </jr:column>
                    <jr:column width="99" uuid="980fffb5-1088-47a6-b00f-b5d08b7093c9">
                        <property name="com.jaspersoft.studio.components.table.model.column.name" value="Colonna4"/>
                        <jr:tableHeader height="30" rowSpan="1">
                            <staticText>
                                <reportElement x="0" y="0" width="99" height="30" uuid="16679b95-2e6e-4ca1-b8b6-dd7b74267c56"/>
                                <text><![CDATA[Percentuale]]></text>
                            </staticText>
                        </jr:tableHeader>
                        <jr:detailCell height="60">
                            <textField>
                                <reportElement x="0" y="0" width="99" height="60" uuid="341e7faf-9680-4941-a9a4-ac78b8f4aae0"/>
                                <textFieldExpression><![CDATA[$F{percentuale}]]></textFieldExpression>
                            </textField>
                        </jr:detailCell>
                    </jr:column>
                    <jr:column width="55" uuid="980fffb5-1088-47a6-b00f-b5d08b7093c9">
                        <property name="com.jaspersoft.studio.components.table.model.column.name" value="Colonna5"/>
                        <jr:tableHeader height="30" rowSpan="1"/>
                        <jr:detailCell height="60">
                            <property name="com.jaspersoft.studio.layout" value="com.jaspersoft.studio.editor.layout.FreeLayout"/>
                        </jr:detailCell>
                    </jr:column>
                </jr:table>
            </componentElement>
        </band>
        <band height="50">
            <staticText>
                <reportElement x="0" y="0" width="75" height="20" backcolor="#151515" uuid="3316e9fe-e7e7-4020-84d6-a8f16cd8eb6b"/>
                <text><![CDATA[descrizione]]></text>
            </staticText>
            <staticText>
                <reportElement x="151" y="0" width="100" height="20" uuid="3316e9fe-e7e7-4020-84d6-a8f16cd8eb68"/>
                <text><![CDATA[quantita]]></text>
            </staticText>
            <staticText>
                <reportElement x="226" y="0" width="75" height="20" uuid="3316e9fe-e7e7-4020-84d6-a8f16cd8eb69"/>
                <text><![CDATA[percentuale]]></text>
            </staticText>
        </band>
    </detail>
</jasperReport>

这篇关于如何用内部行创建表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆