2

我有一个简单的报告。它有两个乐队的标题和细节。在Title我有一个静态文本,在Detail我有一个textField

textField设置为stretchwithoverflow = "true " 。如果我将此字段的高度设置为适合一个原始信息,我会得到一排半的更大信息。所以一个textField,在textField我有 2 行信息,第一行显示正确,第二行 - 我可以看到半个高度。

这可以做到吗?仅展开包含较大信息的行,较大的信息将很好地适合文本字段?

<?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="report7" language="groovy" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="15f9d2dd-21ce-41ec-bcb8-c1aca3a77e37">
    <parameter name="EndDate" class="java.util.Date">
        <defaultValueExpression><![CDATA[new java.util.Date()]]></defaultValueExpression>
    </parameter>
    <parameter name="Project" class="java.util.Collection"/>
    <parameter name="Severity" class="java.util.Collection"/>
    <parameter name="StartDate" class="java.util.Date">
        <defaultValueExpression><![CDATA[new java.util.Date(112, 0, 01)]]></defaultValueExpression>
    </parameter>
    <parameter name="Project_Sets" class="java.util.Collection"/>
    <queryString>
        <![CDATA[some query]]>
    </queryString>
    <field name="crid" class="java.lang.String"/>
    <field name="SEVER" class="java.lang.String"/>
    <field name="product" class="java.lang.String"/>
    <field name="state" class="java.lang.String"/>
    <field name="status" class="java.lang.String"/>
    <field name="submit_date" class="java.lang.String"/>
    <field name="aging" class="java.lang.Long"/>
    <title>
        <band height="25" splitType="Stretch">
            <staticText>
                <reportElement uuid="63eef93a-7e8f-4c69-b9d6-4447fe90673d" x="0" y="0" width="555" height="25" forecolor="#3399FF"/>
                <textElement textAlignment="Center">
                    <font size="16" isBold="true"/>
                </textElement>
                <text><![CDATA[Defects Aging]]></text>
            </staticText>
        </band>
    </title>
    <columnHeader>
        <band height="32">
            <rectangle>
                <reportElement uuid="9a2288d4-87ce-4ee7-b04e-267a7ee0ea8b" x="0" y="0" width="555" height="32" backcolor="#99CC00"/>
            </rectangle>
            <staticText>
                <reportElement uuid="9281aa7a-4bcc-4456-9f25-83c7b2360a01" x="0" y="0" width="79" height="32" forecolor="#FFFFFF"/>
                <textElement textAlignment="Center" verticalAlignment="Middle">
                    <font fontName="Arial" size="12" isBold="true"/>
                </textElement>
                <text><![CDATA[CRID]]></text>
            </staticText>
            <staticText>
                <reportElement uuid="cacda134-069c-43ae-abc1-76f5c865df41" x="79" y="0" width="79" height="32" forecolor="#FFFFFF"/>
                <textElement textAlignment="Center" verticalAlignment="Middle">
                    <font fontName="Arial" size="12" isBold="true"/>
                </textElement>
                <text><![CDATA[Severity]]></text>
            </staticText>
            <staticText>
                <reportElement uuid="d798786f-5ee0-4e76-8a35-2f908af6e92c" positionType="Float" x="158" y="0" width="79" height="32" forecolor="#FFFFFF"/>
                <textElement textAlignment="Center" verticalAlignment="Middle">
                    <font fontName="Arial" size="12" isBold="true"/>
                </textElement>
                <text><![CDATA[Product]]></text>
            </staticText>
            <staticText>
                <reportElement uuid="6be4792d-01a5-4d18-940d-90f40417c7ad" positionType="Float" x="237" y="0" width="79" height="32" forecolor="#FFFFFF"/>
                <textElement textAlignment="Center" verticalAlignment="Middle">
                    <font fontName="Arial" size="12" isBold="true"/>
                </textElement>
                <text><![CDATA[State]]></text>
            </staticText>
            <staticText>
                <reportElement uuid="fa447ca9-121c-43fb-a7bf-1b29ada93adf" positionType="Float" x="316" y="0" width="79" height="32" forecolor="#FFFFFF"/>
                <textElement textAlignment="Center" verticalAlignment="Middle">
                    <font fontName="Arial" size="12" isBold="true"/>
                </textElement>
                <text><![CDATA[Status]]></text>
            </staticText>
            <staticText>
                <reportElement uuid="b2d8f1db-871b-4e34-942f-b8c4a87a358b" positionType="Float" x="395" y="0" width="79" height="32" forecolor="#FFFFFF"/>
                <textElement textAlignment="Center" verticalAlignment="Middle">
                    <font fontName="Arial" size="12" isBold="true"/>
                </textElement>
                <text><![CDATA[Submit Date]]></text>
            </staticText>
            <staticText>
                <reportElement uuid="c3eddc7c-25ca-4e29-a01e-13e856b67d03" x="474" y="0" width="79" height="32" forecolor="#FFFFFF"/>
                <textElement textAlignment="Center" verticalAlignment="Middle">
                    <font fontName="Arial" size="12" isBold="true"/>
                </textElement>
                <text><![CDATA[Days]]></text>
            </staticText>
        </band>
    </columnHeader>
    <detail>
        <band height="81" splitType="Stretch">
            <elementGroup>
                <textField isStretchWithOverflow="true">
                    <reportElement uuid="6422c6d3-40b9-4e38-8bb4-ded91c91ac17" stretchType="RelativeToBandHeight" x="158" y="0" width="79" height="39"/>
                    <textElement textAlignment="Left" verticalAlignment="Middle"/>
                    <textFieldExpression><![CDATA[$F{product}]]></textFieldExpression>
                </textField>
            </elementGroup>
        </band>
    </detail>
</jasperReport>
4

2 回答 2

3

如果有更多项目并且您希望所有项目都相同,则在同一个乐队中。必须将它们全部设置为stretchType="RelativeToTallestObject" 和isStretchWithOverflow="true"。

    <textField isStretchWithOverflow="true" pattern="###0">
            <reportElement stretchType="RelativeToTallestObject" x="1576" y="0" width="91" height="20"/>
            <textElement textAlignment="Center"/>
            <textFieldExpression class="java.lang.Long"><![CDATA[$F{count_tohfa}]]></textFieldExpression>
        </textField>
于 2012-11-11T16:47:06.070 回答
0

报告属性:添加此

net.sf.jasperreports.text.save.line = true

net.sf.jasperreports.export.html.wrap.break.word = true

来源:Word Wrapping HTML 与 PDF

于 2018-10-10T11:40:27.273 回答