JasperReports:报告中反复显示了一些信息

时间:2015-11-18 03:08:01

标签: jasper-reports subreport

我正在使用JasperReports根据三个不同数据库中的数据生成简历。简历有3个部分,分别是个人背景,职业背景和工作经历。个人背景和职业背景的细节不可重复。但是,工作经验可以有多个条目,这些条目可以是不可重复的。

我输出有问题,因为我希望它显示如下:

[个人背景]

信息

[职业背景]

信息

[工作经验]

工作经验1

信息

工作经验2

信息

然而,每个工作经验1和2都会重复个人背景和职业背景。我希望迭代只能在工作经验中,而不是全部三个。

我只是使用文本字段和框架(没有子报告,列表或表组件)。 我尝试创建子数据集,但我对如何使用它感到很遗憾。

我是JasperReports的新手,我被要求创建一份报告。 我希望得到最快的回应。那我很高兴。

以下是一些代码段:

                <queryString>
                    <![CDATA[SELECT user.user_id, user.name, user.image, user.email, user.department, user.birthday, user.location, user.system_role, user.date_updated, user.date_deleted, user.gender, user.course, user.college_end, user.awards, user.industry_start, user.school,
            certification.uID,
            certification.ACTION_Graduate   ,
            certification.JLPT_Level_Internal   ,
            certification.JLPT_Level_Official   ,
            proj_exp.uID    ,
            proj_exp.Customer_Name  ,
            proj_exp.Project_Name   ,
            proj_exp.Start_Date ,
            proj_exp.End_Date   ,
            proj_exp.Project_Role_Project_Manager   ,
            proj_exp.Project_Role_Project_Consultant    ,
            proj_exp.Project_Role_Project_Leader    ,
            proj_exp.Project_Role_Sub_Leader    
            FROM user
                JOIN certification ON 
                 user.user_id = certification.`uID` 
                JOIN proj_exp ON 
                 certification.`uID` = proj_exp.`uID` 
            WHERE 
                 user.user_id = 1527257724]]>
                </queryString>

.jrxml代码的简化版:

            <?xml version="1.0" encoding="UTF-8"?>
            <!-- Created with Jaspersoft Studio version 6.1.1.final using JasperReports Library version 6.1.1  -->
            <!-- 2015-11-18T10:33:04 -->
            <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="atss_resume" pageWidth="595" pageHeight="842" columnWidth="595" leftMargin="0" rightMargin="0" topMargin="0" bottomMargin="0" uuid="efaabc27-78c1-480d-92f0-3de6a2ee75a6">
                <property name="com.jaspersoft.studio.unit." value="pixel"/>
                <property name="com.jaspersoft.studio.data.sql.tables" value=""/>
                <property name="com.jaspersoft.studio.unit.pageHeight" value="pixel"/>
                <property name="com.jaspersoft.studio.unit.pageWidth" value="pixel"/>
                <property name="com.jaspersoft.studio.unit.topMargin" value="pixel"/>
                <property name="com.jaspersoft.studio.unit.bottomMargin" value="pixel"/>
                <property name="com.jaspersoft.studio.unit.leftMargin" value="pixel"/>
                <property name="com.jaspersoft.studio.unit.rightMargin" value="pixel"/>
                <property name="com.jaspersoft.studio.unit.columnWidth" value="pixel"/>
                <property name="com.jaspersoft.studio.unit.columnSpacing" value="pixel"/>
                <property name="com.jaspersoft.studio.data.defaultdataadapter" value="atss"/>
                <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>
                <style name="Table 1_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 1_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 1_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>
                <style name="Table 2_TH" 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>
                <style name="Table 2_CH" 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>
                <style name="Table 2_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>
                <queryString>
                    <![CDATA[SELECT user.user_id, user.name, user.image, user.email, user.department, user.birthday, user.location, user.system_role, user.date_updated, user.date_deleted, user.gender, user.course, user.college_end, user.awards, user.industry_start, user.school,
            certification.uID,
            certification.ACTION_Graduate   ,
            certification.JLPT_Level_Internal   ,
            certification.JLPT_Level_Official   ,
            proj_exp.uID    ,
            proj_exp.Customer_Name  ,
            proj_exp.Project_Name   ,
            proj_exp.Start_Date ,
            proj_exp.End_Date   ,
            proj_exp.Work_Location  ,
            proj_exp.Work_Location_Others   ,
            proj_exp.Project_Type   ,
            proj_exp.Project_Type_Others    ,
            proj_exp.Project_Role_Project_Manager   ,
            proj_exp.Project_Role_Project_Consultant    ,
            proj_exp.Project_Role_Project_Leader    ,
            proj_exp.Project_Role_Sub_Leader    
            FROM user
                JOIN certification ON 
                 user.user_id = certification.`uID` 
                JOIN proj_exp ON 
                 certification.`uID` = proj_exp.`uID` 
            WHERE 
                 user.user_id = 1527257724]]>
                </queryString>
                <field name="user_id" class="java.lang.Long">
                    <fieldDescription><![CDATA[]]></fieldDescription>
                </field>
                <field name="name" class="java.lang.String">
                    <fieldDescription><![CDATA[]]></fieldDescription>
                </field>
                <field name="image" class="java.lang.String">
                    <fieldDescription><![CDATA[]]></fieldDescription>
                </field>
                <field name="email" class="java.lang.String">
                    <fieldDescription><![CDATA[]]></fieldDescription>
                </field>
                <field name="department" class="java.lang.String">
                    <fieldDescription><![CDATA[]]></fieldDescription>
                </field>
                <field name="birthday" class="java.lang.String">
                    <fieldDescription><![CDATA[]]></fieldDescription>
                </field>
                <field name="location" class="java.lang.String">
                    <fieldDescription><![CDATA[]]></fieldDescription>
                </field>
                <field name="system_role" class="java.lang.String">
                    <fieldDescription><![CDATA[]]></fieldDescription>
                </field>
                <field name="date_updated" class="java.sql.Timestamp">
                    <fieldDescription><![CDATA[]]></fieldDescription>
                </field>
                <field name="date_deleted" class="java.sql.Timestamp">
                    <fieldDescription><![CDATA[]]></fieldDescription>
                </field>
                <field name="gender" class="java.lang.String">
                    <fieldDescription><![CDATA[]]></fieldDescription>
                </field>
                <field name="course" class="java.lang.String">
                    <fieldDescription><![CDATA[]]></fieldDescription>
                </field>
                <field name="college_end" class="java.sql.Date">
                    <fieldDescription><![CDATA[]]></fieldDescription>
                </field>
                <field name="awards" class="java.lang.String">
                    <fieldDescription><![CDATA[]]></fieldDescription>
                </field>
                <field name="industry_start" class="java.sql.Date">
                    <fieldDescription><![CDATA[]]></fieldDescription>
                </field>
                <field name="school" class="java.lang.String">
                    <fieldDescription><![CDATA[]]></fieldDescription>
                </field>
                <field name="uID" class="java.lang.Long">
                    <fieldDescription><![CDATA[User ID]]></fieldDescription>
                </field>
                <field name="ACTION_Graduate" class="java.lang.Boolean">
                    <fieldDescription><![CDATA[ACTION Graduate]]></fieldDescription>
                </field>
                <field name="JLPT_Level_Internal" class="java.lang.Integer">
                    <fieldDescription><![CDATA[JLPT Level Internal  0:  none 1:  N5 / L4 2:  N4 / L3 3:  N3 4:  N2 / L2 5:  N1 / L1 JLPT Level Internal]]></fieldDescription>
                </field>
                <field name="JLPT_Level_Official" class="java.lang.Integer">
                    <fieldDescription><![CDATA[JLPT Level Official  0:  none 1:  N5 / L4 2:  N4 / L3 3:  N3 4:  N2 / L2 5:  N1 / L1 JLPT Level Official]]></fieldDescription>
                </field>
                <field name="COLUMN_21" class="java.lang.Long"/>
                <field name="Customer_Name" class="java.lang.String">
                    <fieldDescription><![CDATA[Customer Name]]></fieldDescription>
                </field>
                <field name="Project_Name" class="java.lang.String">
                    <fieldDescription><![CDATA[Project Name]]></fieldDescription>
                </field>
                <field name="Start_Date" class="java.lang.String">
                    <fieldDescription><![CDATA[Start Date]]></fieldDescription>
                </field>
                <field name="End_Date" class="java.lang.String">
                    <fieldDescription><![CDATA[End Date]]></fieldDescription>
                </field>
                <field name="Work_Location" class="java.lang.Boolean">
                    <fieldDescription><![CDATA[1:  Philippines 2:  Japan 3:  China 4:  Others]]></fieldDescription>
                </field>
                <field name="Work_Location_Others" class="java.lang.String">
                    <fieldDescription><![CDATA[Work Location Others]]></fieldDescription>
                </field>
                <field name="Project_Type" class="java.lang.Boolean">
                    <fieldDescription><![CDATA[1:  Development 2:  Verification 3:  Translation 4:  Infra 5:  Support]]></fieldDescription>
                </field>
                <field name="Project_Type_Others" class="java.lang.String">
                    <fieldDescription><![CDATA[Project Type Others]]></fieldDescription>
                </field>
                <field name="Project_Role_Project_Manager" class="java.lang.Boolean">
                    <fieldDescription><![CDATA[Project Role - Project Manager (PM)]]></fieldDescription>
                </field>
                <field name="Project_Role_Project_Consultant" class="java.lang.Boolean">
                    <fieldDescription><![CDATA[Project Role - Project Consultant / Advisor]]></fieldDescription>
                </field>
                <field name="Project_Role_Project_Leader" class="java.lang.Boolean">
                    <fieldDescription><![CDATA[Project Role - Project Leader / Scrum Master (PL)]]></fieldDescription>
                </field>
                <field name="Project_Role_Sub_Leader" class="java.lang.Boolean">
                    <fieldDescription><![CDATA[Project Role - Sub Leader (SL)]]></fieldDescription>
                </field>
                <background>
                    <band splitType="Stretch"/>
                </background>
                <title>
                    <band height="18" splitType="Stretch"/>
                </title>
                <pageHeader>
                    <band height="22" splitType="Stretch">
                        <staticText>
                            <reportElement x="40" y="4" width="100" height="10" uuid="95db4088-edf7-4b2e-a759-8e618c1492c7"/>
                            <textElement>
                                <font fontName="Arial" size="8"/>
                            </textElement>
                            <text><![CDATA[AWS Confidential]]></text>
                        </staticText>
                    </band>
                </pageHeader>
                <columnHeader>
                    <band height="75" splitType="Stretch">
                        <textField>
                            <reportElement x="40" y="30" width="320" height="30" uuid="93d6debe-5114-47cf-bef8-a39c628e2117"/>
                            <textElement>
                                <font fontName="Times New Roman" size="20" isBold="true"/>
                                <paragraph leftIndent="0"/>
                            </textElement>
                            <textFieldExpression><![CDATA[$F{name}]]></textFieldExpression>
                        </textField>
                        <staticText>
                            <reportElement x="40" y="10" width="79" height="19" uuid="4564b3fc-d6b9-4178-9f95-fac5cbd37f88"/>
                            <textElement>
                                <font fontName="Times New Roman" size="16" isBold="true"/>
                            </textElement>
                            <text><![CDATA[PROFILE]]></text>
                        </staticText>
                        <image>
                            <reportElement x="422" y="7" width="72" height="60" uuid="09d1c125-7f6c-4f10-9fd3-f047d003ed99"/>
                            <imageExpression><![CDATA["C:/Users/kristian.bautista/JaspersoftWorkspace/MyReports/bin/AWS logo.png"]]></imageExpression>
                        </image>
                    </band>
                </columnHeader>
                <detail>
                    <band height="359" splitType="Stretch">
                        <property name="com.jaspersoft.studio.unit.height" value="pixel"/>
                        <staticText>
                            <reportElement mode="Opaque" x="40" y="10" width="452" height="16" forecolor="#3688E0" backcolor="#E3DEDE" uuid="af1be546-40bb-44cc-8a44-f36fc222f70e"/>
                            <box>
                                <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>
                            <textElement>
                                <font fontName="Verdana" size="12" isBold="true"/>
                                <paragraph leftIndent="10"/>
                            </textElement>
                            <text><![CDATA[Personal Background]]></text>
                        </staticText>
                        <frame>
                            <reportElement x="40" y="26" width="150" height="54" uuid="c5641bf3-e03b-4d3d-8863-3c338d875d6f">
                                <property name="com.jaspersoft.studio.layout" value="com.jaspersoft.studio.editor.layout.VerticalRowLayout"/>
                            </reportElement>
                            <box>
                                <topPen lineWidth="0.5"/>
                                <leftPen lineWidth="0.5"/>
                                <bottomPen lineWidth="0.5"/>
                                <rightPen lineWidth="0.5"/>
                            </box>
                            <staticText>
                                <reportElement x="0" y="0" width="150" height="18" uuid="36d9f5d0-5722-4c96-adfe-b2db0f4a6c30"/>
                                <box>
                                    <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>
                                <textElement>
                                    <font fontName="Verdana" size="9" isBold="true"/>
                                    <paragraph leftIndent="10"/>
                                </textElement>
                                <text><![CDATA[Age]]></text>
                            </staticText>
                            <staticText>
                                <reportElement x="0" y="18" width="150" height="18" uuid="d4fbdaa2-de9f-457b-8422-f60063c216e6"/>
                                <box>
                                    <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>
                                <textElement>
                                    <font fontName="Verdana" size="9" isBold="true"/>
                                    <paragraph leftIndent="10"/>
                                </textElement>
                                <text><![CDATA[Gender]]></text>
                            </staticText>
                            <staticText>
                                <reportElement x="0" y="36" width="150" height="18" uuid="16316821-0aa5-4c0b-aa1d-8ac1fff51729"/>
                                <box>
                                    <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>
                                <textElement>
                                    <font fontName="Verdana" size="9" isBold="true"/>
                                    <paragraph leftIndent="10"/>
                                </textElement>
                                <text><![CDATA[Undergraduate Course]]></text>
                            </staticText>
                        </frame>
                        <staticText>
                            <reportElement mode="Opaque" x="40" y="113" width="452" height="16" forecolor="#3688E0" backcolor="#E3DEDE" uuid="05513f9a-6018-4730-b4ed-6ac48bac612e"/>
                            <box>
                                <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>
                            <textElement>
                                <font fontName="Verdana" size="12" isBold="true"/>
                                <paragraph leftIndent="10"/>
                            </textElement>
                            <text><![CDATA[Career Background]]></text>
                        </staticText>
                        <frame>
                            <reportElement x="40" y="129" width="150" height="74" uuid="18c90b2c-4376-445c-9c2b-bdcd588228a2">
                                <property name="com.jaspersoft.studio.layout" value="com.jaspersoft.studio.editor.layout.VerticalRowLayout"/>
                            </reportElement>
                            <box>
                                <topPen lineWidth="0.5"/>
                                <leftPen lineWidth="0.5"/>
                                <bottomPen lineWidth="0.5"/>
                                <rightPen lineWidth="0.5"/>
                            </box>
                            <staticText>
                                <reportElement x="0" y="0" width="150" height="26" uuid="76743f2b-0f74-4a94-b6d3-9a40b1e2b67a"/>
                                <box>
                                    <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>
                                <textElement>
                                    <font fontName="Verdana" size="9" isBold="true"/>
                                    <paragraph leftIndent="10"/>
                                </textElement>
                                <text><![CDATA[Years Working in Industry]]></text>
                            </staticText>
                            <staticText>
                                <reportElement x="0" y="26" width="150" height="24" uuid="62c04f1a-d664-408e-b809-9c6938bf34f7"/>
                                <box>
                                    <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>
                                <textElement>
                                    <font fontName="Verdana" size="9" isBold="true"/>
                                    <paragraph leftIndent="10"/>
                                </textElement>
                                <text><![CDATA[English Language Skill]]></text>
                            </staticText>
                            <staticText>
                                <reportElement x="0" y="50" width="150" height="24" uuid="cb821738-3193-46c4-9f32-de20199e5a55"/>
                                <box>
                                    <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>
                                <textElement>
                                    <font fontName="Verdana" size="9" isBold="true"/>
                                    <paragraph leftIndent="10"/>
                                </textElement>
                                <text><![CDATA[Japanese Language Skill]]></text>
                            </staticText>
                        </frame>
                        <frame>
                            <reportElement x="190" y="26" width="302" height="54" uuid="082d0f9e-dad5-405e-ae60-17483e5c0623"/>
                            <textField isBlankWhenNull="true">
                                <reportElement x="0" y="0" width="302" height="18" uuid="9aeba03d-ea9e-4e02-9cd2-c32d620df0b0"/>
                                <box>
                                    <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>
                                <textElement>
                                    <font fontName="Verdana"/>
                                    <paragraph leftIndent="10"/>
                                </textElement>
                            </textField>
                            <textField isBlankWhenNull="true">
                                <reportElement x="0" y="18" width="302" height="18" uuid="2e79d960-147a-4d54-8a3e-e03e190e498a"/>
                                <box>
                                    <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>
                                <textElement>
                                    <font fontName="Verdana"/>
                                    <paragraph leftIndent="10"/>
                                </textElement>
                                <textFieldExpression><![CDATA[$F{gender}]]></textFieldExpression>
                            </textField>
                            <textField isBlankWhenNull="true">
                                <reportElement x="0" y="36" width="302" height="51" uuid="ad7c33b1-4ca1-4055-93f1-2d122ce5385f"/>
                                <box>
                                    <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>
                                <textElement>
                                    <font fontName="Verdana"/>
                                    <paragraph leftIndent="10"/>
                                </textElement>
                                <textFieldExpression><![CDATA[$F{course} + " (" + DATEFORMAT($F{college_end}, "MMM yyyy") + ") " + "\n" +
            $F{school} + "\n" + "Awarded " + $F{awards}]]></textFieldExpression>
                            </textField>
                        </frame>
                        <frame>
                            <reportElement x="190" y="129" width="302" height="74" uuid="7fdb6ee8-f15d-4a36-90b0-14757690af9a"/>
                            <textField isBlankWhenNull="true">
                                <reportElement x="0" y="0" width="302" height="26" uuid="005615f1-e118-4348-83dc-1f44eb338960"/>
                                <box>
                                    <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>
                                <textElement>
                                    <font fontName="Verdana"/>
                                    <paragraph leftIndent="10"/>
                                </textElement>
                                <textFieldExpression><![CDATA[YEARS($F{industry_start},TODAY( ))]]></textFieldExpression>
                            </textField>
                            <textField isBlankWhenNull="true">
                                <reportElement x="0" y="26" width="302" height="24" uuid="4b64a97c-d01e-43e0-9cfa-749f7b2daaf4"/>
                                <box>
                                    <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>
                                <textElement>
                                    <font fontName="Verdana"/>
                                    <paragraph leftIndent="10"/>
                                </textElement>
                            </textField>
                            <textField isBlankWhenNull="true">
                                <reportElement x="0" y="50" width="302" height="24" uuid="c66829bf-5979-4fac-9fbc-753c5ea68f50"/>
                                <box>
                                    <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>
                                <textElement>
                                    <font fontName="Verdana"/>
                                    <paragraph leftIndent="10"/>
                                </textElement>
                                <textFieldExpression><![CDATA[$F{JLPT_Level_Official} == 1 ? "Japanese Language Proficiency - N5 Level":
            $F{JLPT_Level_Official} == 2 ? "Japanese Language Proficiency - N4 Level":
            $F{JLPT_Level_Official} == 3 ? "Japanese Language Proficiency - N3 Level":
            $F{JLPT_Level_Official} == 4 ? "Japanese Language Proficiency - N2 Level":
            $F{JLPT_Level_Official} == 5 ? "Japanese Language Proficiency - N1 Level": "none"]]></textFieldExpression>
                            </textField>
                        </frame>
                        <break>
                            <reportElement x="0" y="210" width="97" height="1" uuid="fcfa0301-1ee1-4633-9a9a-eff55911400f"/>
                        </break>
                        <frame>
                            <reportElement x="40" y="224" width="451" height="135" uuid="c8f2d1ae-cb0d-4cd8-ac4d-8dbd4ae2f26f"/>
                            <staticText>
                                <reportElement mode="Opaque" x="0" y="5" width="451" height="16" forecolor="#3688E0" backcolor="#E3DEDE" uuid="8757cd3c-3194-469f-9a3f-2c158cd1c4ec"/>
                                <box>
                                    <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>
                                <textElement>
                                    <font fontName="Verdana" size="12" isBold="true"/>
                                    <paragraph leftIndent="10"/>
                                </textElement>
                                <text><![CDATA[Work Experience]]></text>
                            </staticText>
                            <textField>
                                <reportElement x="11" y="30" width="429" height="19" uuid="9ad6fca5-7a33-49d5-a4f6-bbd5060169e7"/>
                                <textElement verticalAlignment="Middle">
                                    <font fontName="Verdana" isBold="true" isUnderline="true"/>
                                </textElement>
                                <textFieldExpression><![CDATA[$F{Project_Name} + " (" + $F{Start_Date} + " - " + $F{End_Date} + ") "]]></textFieldExpression>
                            </textField>
                            <staticText>
                                <reportElement x="11" y="49" width="130" height="20" uuid="5399a915-d463-45b3-92f0-88f6ae35212c"/>
                                <textElement verticalAlignment="Middle">
                                    <font fontName="Verdana" isBold="true" isItalic="true"/>
                                </textElement>
                                <text><![CDATA[Project Description:]]></text>
                            </staticText>
                            <textField>
                                <reportElement x="41" y="69" width="330" height="20" uuid="7ce9748f-d059-4122-a917-98392c2bf60e"/>
                                <textElement>
                                    <font fontName="Verdana"/>
                                </textElement>
                                <textFieldExpression><![CDATA["Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."]]></textFieldExpression>
                            </textField>
                            <staticText>
                                <reportElement x="11" y="89" width="130" height="20" uuid="d79477cd-bdda-408a-b085-e0481fdfb836"/>
                                <textElement verticalAlignment="Middle">
                                    <font fontName="Verdana" isBold="true" isItalic="true"/>
                                </textElement>
                                <text><![CDATA[Responsibilities:]]></text>
                            </staticText>
                            <textField>
                                <reportElement x="41" y="109" width="330" height="20" uuid="0c2bd147-fc15-44bd-87ec-065b10f8eb1d">
                                    <property name="com.jaspersoft.studio.unit.y" value="pixel"/>
                                    <property name="com.jaspersoft.studio.unit.height" value="pixel"/>
                                </reportElement>
                                <textElement>
                                    <font fontName="Verdana"/>
                                </textElement>
                                <textFieldExpression><![CDATA[($F{Project_Role_Project_Manager}?"Project Manager (PM)":null)+", "+
            ($F{Project_Role_Project_Consultant}?"Project Consultant / Advisor":null)+", "+
            ($F{Project_Role_Project_Leader}?"Project Leader / Scrum Master (PL)":null)+", "+
            ($F{Project_Role_Sub_Leader}?"Sub Leader (SL)":null)]]></textFieldExpression>
                            </textField>
                        </frame>
                    </band>
                </detail>
                <columnFooter>
                    <band height="23" splitType="Stretch"/>
                </columnFooter>
                <pageFooter>
                    <band height="40" splitType="Stretch">
                        <textField>
                            <reportElement x="353" y="5" width="70" height="30" uuid="60675991-82e8-45b5-9080-3d09285609e9"/>
                            <textElement textAlignment="Right">
                                <font fontName="Arial" size="8" isBold="false"/>
                            </textElement>
                            <textFieldExpression><![CDATA["Page " + $V{PAGE_NUMBER}]]></textFieldExpression>
                        </textField>
                        <textField evaluationTime="Report">
                            <reportElement x="424" y="5" width="69" height="30" uuid="bd616de3-1e5d-4a30-8a28-a06cf0011598"/>
                            <textElement textAlignment="Left">
                                <font fontName="Arial" size="8" isBold="false"/>
                            </textElement>
                            <textFieldExpression><![CDATA[" of " + $V{PAGE_NUMBER}]]></textFieldExpression>
                        </textField>
                    </band>
                </pageFooter>
                <summary>
                    <band height="24" splitType="Stretch"/>
                </summary>
            </jasperReport>

1 个答案:

答案 0 :(得分:1)

是的,frame元素只是对元素进行分组的一种方式。

  

框架是一个可以包含其他元素的元素,并可选择在它们周围绘制边框。由于框架是其他元素的容器,因此在文档大纲视图中,框架表示为包含其他元素的节点。

所以可能你应该转向使用子报表或表/列表组件。我会回答

如何使用子报告实现所需的结果?

  

子报表是另一个报表中包含的报表。这允许创建非常复杂的布局,使用不同的数据源和报告填充单个文档的不同部分。

结构

  1. 在主报告中加载用户(仅限用户,不在其他表上加入)并显示&#34;个人背景&#34;适用于where statement

  2. 中的所有用户
  3. 在用户信息下方(始终在详细信息区域中)包含一个通过user id的子报告。子报表是另一个报表,它使用certification语句加载where表中的数据users id并显示&#34; [职业背景]&#34;

    < / LI>
  4. 在子报告&#34; [职业背景]&#34;内,信息下方(始终在详细信息区域中)包含通过认证的子报告。uID。子报表是另一个报表,它将proj_exp中的数据与proj_exp。uID上的where语句一起加载,并显示&#34; [工作经验]&#34;相对于&#34; [职业背景]&#34;

  5. 我不会完成您的代码,但会告诉您另一个子报表如何包括传递参数以及如何在该子报表中使用传递的参数执行另一个SQL

    包含子报告(另一个报告)传递参数

    <subreport>
        <reportElement x="0" y="20" width="555" height="20" uuid="8ee71878-fc35-4991-a7dc-5199f23f2978"/>
        <subreportParameter name="user_id">
          <subreportParameterExpression><![CDATA[$F{user_id}]]></subreportParameterExpression>
        </subreportParameter>
        <connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
        <subreportExpression><![CDATA[$P{SUBREPORT_DIR} + "certification.jasper"]]></subreportExpression>
    </subreport>
    

    注意:

    1. 我们正在将$F{user_id}传递给我们的子报告,该子报告的参数名称为user_idclass="java.lang.Long"

    2. 作为连接,我们传递$P{REPORT_CONNECTION},与主报告相同的连接

    3. 子报告名称为certification.jrxml,我们已将已编译certification.jasper,因为我们需要将绝对路径传递到主报表中的子报表我们有一个名称为SUBREPORT_DIR的参数,其值类似于c:/the path to our subreports/

    4. 子报告

      <?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="subreport" language="java" pageWidth="555" pageHeight="842" columnWidth="555" leftMargin="0" rightMargin="0" topMargin="0" bottomMargin="0" uuid="6afeba62-b470-4dfb-a8fb-42e2226b906d">
       <parameter name="user_id" class="java.lang.Long"/>
       <queryString>
          <![CDATA[SELECT * FROM certification WHERE certification.`uID` = $P{user_id}]]>
       </queryString>
       <field name="uID" class="java.lang.Long">
         <fieldDescription><![CDATA[User ID]]></fieldDescription>
       </field>
         .. all the other fields you like ...
        <detail>
          <band height="125" splitType="Immediate">
            Here goes the textfields to display Career Background ] and below you included another subreport for the [ Work experience ] (same procedure as above)
          </band>
        </detail>
      </jasperReport>
      

      重复工作经验,你就完成了。

      提防:

      1. 请记住在执行主报告之前编译子报告(如果您使用IDE es .iReport它足以让您按下&#34;预览&#34;它将编译报告对你而言。

      2. 当你包含一个子报告时,让高度变小(它会自动拉伸),这将有助于你在你喜欢的地方获得分页符。

      3. 在子报表上设置正确的大小和边距。

      4. 当然,还有其他方法来实现您的结果,例如使用数据分组

        <group name="User">
            <groupExpression><![CDATA[$F{user_id}]]></groupExpression>
            <groupHeader>
                <band height="50">... texField .. with the user info</band>
            </groupHeader>
        </group>
        

        或代替子报表使用<jr:table><jr:list>等组件定义其数据源,但是现在(即使子报表方法不是最有效的方法,多次查询)我相信它&#39 ; s是您获得理想结果的最直接,最简单的方法。