【问题标题】:Jasper Report merging cells in jasper table results in unwanted coulmn碧玉报告合并碧玉表中的单元格导致不需要的列
【发布时间】:2014-07-07 17:41:50
【问题描述】:

我对 jasper 报告相当陌生。我需要合并 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="report1" language="groovy" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="9c6d12ac-438a-4209-b92b-fe8357e9a0ab">
    <property name="ireport.zoom" value="1.0"/>
    <property name="ireport.x" value="0"/>
    <property name="ireport.y" value="2"/>
    <style name="table">
        <box>
            <pen lineWidth="1.0" lineColor="#000000"/>
        </box>
    </style>
    <style name="table_TH" mode="Opaque" backcolor="#F0F8FF">
        <box>
            <pen lineWidth="0.5" lineColor="#000000"/>
        </box>
    </style>
    <style name="table_CH" mode="Opaque" backcolor="#BFE1FF">
        <box>
            <pen lineWidth="0.5" lineColor="#000000"/>
        </box>
    </style>
    <style name="table_TD" mode="Opaque" backcolor="#FFFFFF">
        <box>
            <pen lineWidth="0.5" lineColor="#000000"/>
        </box>
    </style>
    <subDataset name="medication" uuid="540773d1-98fb-48a3-9b89-a187c3e37e8a">
        <queryString language="SQL">
            <![CDATA[SELECT m.ID,m.medication_name,d.dose_time FROM medication m
LEFT JOIN dose_time d ON m.ID = d.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>
    <queryString>
        <![CDATA[select mdt.ID,mdt.medication_name,dt.dose_time from medication mdt left join dose_time dt on mdt.ID = dt.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>
    <background>
        <band splitType="Stretch"/>
    </background>
    <columnHeader>
        <band height="61" splitType="Stretch"/>
    </columnHeader>
    <detail>
        <band height="125" splitType="Stretch">
            <componentElement>
                <reportElement uuid="b80b6480-79a3-4c7a-b7e6-73e8df552d6a" key="table" style="table" 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">
                    <datasetRun subDataset="medication" uuid="966ad176-a042-4a9f-b4fe-3c5cf2c43370">
                        <connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
                    </datasetRun>
                    <jr:column width="90" uuid="1674ad29-29a8-47d3-9bf9-fb233d836dcc">
                        <jr:groupFooter groupName="ID">
                            <jr:cell height="0" rowSpan="1"/>
                        </jr:groupFooter>
                        <jr:columnHeader style="table_CH" height="32" rowSpan="1">
                            <staticText>
                                <reportElement uuid="1e2c5349-4cc9-4caf-9d7f-ac34dfbdb1b4" x="0" y="0" width="90" height="30"/>
                                <textElement/>
                                <text><![CDATA[Medication Name]]></text>
                            </staticText>
                        </jr:columnHeader>
                        <jr:detailCell height="30" rowSpan="1">
                            <textField>
                                <reportElement uuid="cfeb2bce-6f8d-413c-8f4e-cfbe61cc2d24" style="table_TD" x="0" y="0" width="90" height="30">
                                    <printWhenExpression><![CDATA[$V{ID_COUNT}==1]]></printWhenExpression>
                                </reportElement>
                                <box leftPadding="0">
                                    <pen lineWidth="0.5"/>
                                    <topPen lineWidth="0.5"/>
                                    <leftPen lineWidth="0.5"/>
                                    <bottomPen lineWidth="0.5"/>
                                    <rightPen lineWidth="0.5"/>
                                </box>
                                <textElement/>
                                <textFieldExpression><![CDATA[$F{ID}+$F{medication_name}]]></textFieldExpression>
                            </textField>
                        </jr:detailCell>
                    </jr:column>
                    <jr:column width="90" uuid="193e3bc0-bdba-42ec-824a-cb0e7b37b7d1">
                        <jr:columnHeader style="table_CH" height="32" rowSpan="1">
                            <staticText>
                                <reportElement uuid="c165e681-8db2-49af-9046-e3db70bfe0cf" x="0" y="0" width="90" height="30"/>
                                <textElement/>
                                <text><![CDATA[Doses Time]]></text>
                            </staticText>
                        </jr:columnHeader>
                        <jr:detailCell style="table_TD" height="30" rowSpan="1">
                            <textField>
                                <reportElement uuid="78fff516-49ab-4e1d-aa06-4c97d48bad0d" x="0" y="0" width="90" height="30"/>
                                <textElement/>
                                <textFieldExpression><![CDATA[$F{dose_time}]]></textFieldExpression>
                            </textField>
                        </jr:detailCell>
                    </jr:column>
                </jr:table>
            </componentElement>
        </band>
    </detail>
</jasperReport>

【问题讨论】:

    标签: jasper-reports


    【解决方案1】:

    我在这里看到了两种可能的解决方案:

    1. 创建一个分组带并按“药物名称”分组,您将有空单元格,但看起来很酷:)
    2. 使用一些带有函数 concat_ws() 的 SQL 功夫来获取与列表相同的字段中的“剂量时间”。

    玩得开心,希望对您有所帮助。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多