Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
342 views
in Technique[技术] by (71.8m points)

How to include field value inside columnHeader - Jasper Reports

I have the code below with a field named 'anneeFiscale' that is used inside a title section. I want to use that same field inside the detail section and replace the element and the '2017' text with the appropriate element and variable, but can't seem to make it work.

Can u help me?

<?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="report2" pageWidth="842" pageHeight="595" orientation="Landscape" columnWidth="802" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="b360aaed-6a96-4db6-8e04-cc51258303e8">
    <property name="ireport.zoom" value="1.0"/>
    <property name="ireport.x" value="0"/>
    <property name="ireport.y" value="0"/>
    <property name="net.sf.jasperreports.style.evaluation.time.enabled" value="true"/>
    <style name="table" pattern="" fontName="Calibri" fontSize="10"/>

...

<parameter name="DECLARATIONS" class="java.util.Collection">
        <defaultValueExpression><![CDATA[$P{DECLARATIONS}]]></defaultValueExpression>
    </parameter>
    <queryString>
        <![CDATA[]]>
    </queryString>
    <field name="anneeFiscale" class="java.lang.Integer"/>

...

    <title>
        <band height="79" splitType="Stretch">
            <textField>
                <reportElement mode="Opaque" x="0" y="0" width="775" height="28" backcolor="#D8D8D8" uuid="6c128184-6ec8-4f18-9f3b-3f073fcd9b09"/>
                <box topPadding="0" leftPadding="0">
                    <pen lineWidth="1.0"/>
                    <topPen lineWidth="1.0"/>
                    <leftPen lineWidth="1.0"/>
                    <bottomPen lineWidth="1.0"/>
                    <rightPen lineWidth="1.0"/>
                </box>
                <textElement textAlignment="Center" verticalAlignment="Middle">
                    <font fontName="Calibri" size="10" isBold="true"/>
                </textElement>
                <textFieldExpression><![CDATA["FICHIER " + $F{anneeFiscale}.toString() + " - IFER "TRANSFORMATEURS ELECTRIQUES" (ART. 1519 G DU CGI)"]]></textFieldExpression>
            </textField>
        </band>
    </title>
<detail>
        <band height="103">
            <componentElement>
                <reportElement key="table" style="table" mode="Opaque" x="0" y="-33" width="1977" height="103" uuid="d93751a1-792b-4dc6-acd0-495fc54499e0"/>
                <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="declarations" uuid="44dc34c0-6e9f-494a-9c4c-146876054898">
                        <dataSourceExpression><![CDATA[new net.sf.jasperreports.engine.data.JRBeanCollectionDataSource($P{DECLARATIONS})]]></dataSourceExpression>
                    </datasetRun>
<jr:columnGroup width="312" uuid="c5ba7fef-8a16-4394-880e-34770b067ed5">
                        <jr:columnHeader style="table_CH" height="33" rowSpan="1">
                            <staticText>
                                <reportElement style="table_CH" x="0" y="0" width="312" height="33" uuid="212158cf-8b8c-43b3-a66b-a3cb2e86bdcf"/>
                                <textElement textAlignment="Center" verticalAlignment="Middle">
                                    <font fontName="Arial" size="12" isBold="true"/>
                                </textElement>
                                <text><![CDATA[ELEMENTS DECLARES AU TITRE DE L'IFER 2017]]></text>
                            </staticText>
                        </jr:columnHeader>

...

</jr:columnGroup>
                </jr:table>
            </componentElement>
        </band>
    </detail>
</jasperReport>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...