jasper 表中单列内的多行

nts*_*tha 5 jasper-reports ireport

我只是贾斯珀报告的初学者,我在一个问题上被困了几天。我有两张桌子

药物{ID,medication_name}和剂量_时间{ID,medication_id,dose_time}

正在申请

SELECT m.id,m.medication_name,d_t.dose_time FROM medication `m`
LEFT JOIN dose_time d_t ON m.id=d_t.medication_id;
Run Code Online (Sandbox Code Playgroud)

给了我三个结果在此输入图像描述

现在我想要的是跟随贾斯珀报告

在此输入图像描述

但我可能会卡住并且只能生成以下 jasper 格式

在此输入图像描述

我的jrxml文件如下

<?xml version="1.0" encoding="UTF-8"?>
<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="PracticeReport" language="groovy" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="67dfb372-a5be-403b-9007-61ab07fe88e7">
    <property name="ireport.zoom" value="1.0"/>
    <property name="ireport.x" value="0"/>
    <property name="ireport.y" value="0"/>
    <subDataset name="Medication" uuid="1cccb880-701b-491e-8094-c133d4bd3819">
        <queryString>
            <![CDATA[SELECT m.id,m.medication_name,d_t.dose_time FROM medication `m`
LEFT JOIN dose_time d_t ON m.id=d_t.medication_id;]]>
        </queryString>
        <field name="id" class="java.lang.Integer">
            <fieldDescription><![CDATA[]]></fieldDescription>
        </field>
        <field name="medication_name" class="java.lang.String">
            <fieldDescription><![CDATA[]]></fieldDescription>
        </field>
        <field name="dose_time" class="java.lang.String">
            <fieldDescription><![CDATA[]]></fieldDescription>
        </field>
        <group name="id">
            <groupExpression><![CDATA[$F{id}]]></groupExpression>
        </group>
    </subDataset>
    <title>
        <band height="79" splitType="Stretch">
            <staticText>
                <reportElement uuid="8bc54002-3e51-4bd6-8801-9856ef627b99" x="154" y="28" width="240" height="20"/>
                <textElement textAlignment="Center" verticalAlignment="Middle"/>
                <text><![CDATA[Practicing Jasper]]></text>
            </staticText>
        </band>
    </title>
    <pageHeader>
        <band height="35" splitType="Stretch"/>
    </pageHeader>
    <columnHeader>
        <band height="61" splitType="Stretch"/>
    </columnHeader>
    <detail>
        <band height="125" splitType="Stretch">
            <componentElement>
                <reportElement uuid="5976a679-e65a-4880-a9e7-74fd65f9e80d" key="" isPrintRepeatedValues="false" x="0" y="0" width="555" height="125">
                    <printWhenExpression><![CDATA[$V{REPORT_COUNT}==1]]></printWhenExpression>
                </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" whenNoDataType="AllSectionsNoDetail">
                    <datasetRun subDataset="Medication" uuid="5f6c54e4-9c5c-4120-8ac7-32793ec39d00"/>
                    <jr:column width="232" uuid="c5a6dca0-3be4-422f-8f13-4462d2e4caee">
                        <jr:detailCell height="124" rowSpan="1">
                            <textField>
                                <reportElement uuid="080e50f3-23a0-4bf2-8d6f-b63618dfdc51" isPrintRepeatedValues="false" x="0" y="0" width="232" height="124"/>
                                <box>
                                    <pen lineWidth="0.75"/>
                                    <topPen lineWidth="0.75"/>
                                    <leftPen lineWidth="0.75"/>
                                    <bottomPen lineWidth="0.75"/>
                                    <rightPen lineWidth="0.75"/>
                                </box>
                                <textElement/>
                                <textFieldExpression><![CDATA[$F{id} + ","+$F{medication_name}]]></textFieldExpression>
                            </textField>
                        </jr:detailCell>
                    </jr:column>
                    <jr:column width="232" uuid="b7bef864-31db-4b77-a929-a0d59e754b36">
                        <jr:detailCell height="124" rowSpan="1">
                            <textField>
                                <reportElement uuid="7b3c68b6-6048-4690-b8e7-14a286f94297" x="0" y="0" width="232" height="124"/>
                                <box>
                                    <pen lineWidth="0.75"/>
                                    <topPen lineWidth="0.75"/>
                                    <leftPen lineWidth="0.75"/>
                                    <bottomPen lineWidth="0.75"/>
                                    <rightPen lineWidth="0.75"/>
                                </box>
                                <textElement/>
                                <textFieldExpression><![CDATA[$F{dose_time}]]></textFieldExpression>
                            </textField>
                        </jr:detailCell>
                    </jr:column>
                </jr:table>
            </componentElement>
        </band>
    </detail>
    <columnFooter>
        <band height="45" splitType="Stretch"/>
    </columnFooter>
    <pageFooter>
        <band height="54" splitType="Stretch"/>
    </pageFooter>
    <summary>
        <band height="42" splitType="Stretch"/>
    </summary>
</jasperReport>
Run Code Online (Sandbox Code Playgroud)

拜托各位,我需要你们的帮助。

小智 0

您可以为此使用交叉表。转到窗口并单击调色板。比调色板会显示正确。最后,将“交叉表”拖到摘要部分并填写向导。