首页 > 解决方案 > 如何让jasper报表上显示不同的图片?

问题描述

我有一个问题,在这种情况下,当尝试从“工作卡”中显示三个单独的图像时,会显示相同的图片。

在此处输入图像描述

但实际上数据库上有三个不同的图像

这是我的 SQL:

    select distinct job_card.job_card_name,
job_card.job_number,
job_card.job_type,
job_card.job_card_name,
client_account.account_name,
job_card.punchlist_comments,
"user".name,
job_card.customer_name,
job_card.created_at,
job_card.customer_signature_blob,
job_card.technician_signature_blob,
photograph.photo_blob
from $P!{schemaName}.job_card
left join $P!{schemaName}.photograph on $P!{schemaName}.job_card."_id_" = $P!{schemaName}.photograph.job_cards_fk
left join $P!{schemaName}."user" on $P!{schemaName}."user"."_id_" = $P!{schemaName}.job_card.technicians_fk
left join $P!{schemaName}.asset on $P!{schemaName}.asset."_id_" = $P!{schemaName}.job_card.assets_fk
left join $P!{schemaName}.client_account on $P!{schemaName}.client_account."_id_" = $P!{schemaName}.asset.clientaccounts_fk
where job_card._id_ = $P{job_cardUUID}::uuid

“photograph.photo_blob”是变量

这是碧玉元素:

<textElement verticalAlignment="Middle">
                                <font isBold="true"/>
                            </textElement>
                            <text><![CDATA[ Installation pictures ]]></text>
                        </staticText>
                        <image>
                            <reportElement x="0" y="180" width="200" height="124" uuid="8bf21ae9-eec4-4c39-b4c1-4c174ec59aab"/>
                            <box>
                                <pen lineWidth="0.25"/>
                            </box>
                            <imageExpression><![CDATA[$F{photo_blob}]]></imageExpression>
                        </image>
                        <image>
                            <reportElement x="200" y="180" width="200" height="124" uuid="aa9d55fb-184f-4098-95f8-9de17530c99b"/>
                            <box>
                                <pen lineWidth="0.25"/>
                            </box>
                            <imageExpression><![CDATA[$F{photo_blob}]]></imageExpression>
                        </image>
                        <image>
                            <reportElement x="400" y="180" width="150" height="124" uuid="64df2d59-4154-4b26-a3d1-3f54f1b54eca"/>
                            <box>
                                <pen lineWidth="0.25"/>
                            </box>
                            <imageExpression><![CDATA[$F{photo_blob}]]></imageExpression>
                        </image>

我尝试将此框放在详细信息带中,但页面只是乘以图片数量

标签: jasper-reports

解决方案


您有三张重复的图片,因为您同时使用同一波段中的三个图像元素,共享相同的表达式,即$F{photo_blob}

如果每个人都有树或更多不同的图片,则job_card._id_必须创建一个组,例如job_card,并在您放置的组标题中

<text><![CDATA[ Installation pictures ]]></text>

在你放的细节带中

<image>
    <reportElement x="0" y="180" width="200" height="124" uuid="8bf21ae9-eec4-4c39-b4c1-4c174ec59aab"/>
    <box>
        <pen lineWidth="0.25"/>
    </box>
    <imageExpression><![CDATA[$F{photo_blob}]]></imageExpression>
</image>

推荐阅读