Report design with flexible frames

Hi folks,

does anyone know how to design a report with frames where the textfields can be streched very long like this example:

I would like to have flexible and dynamic frames which will be strechted if the textfield are very long.

Is there any solution provided by jasper studio? Is it prossible to work with a rectangle and lines?

Best Regards

 

Florian

florian.johannssen's picture
Joined: Sep 25 2014 - 8:25am
Last seen: 6 years 3 weeks ago

1 Answer:

I ran some tests and by using nested frames with borders, it works with stacked rows.

Report design looks like this:

Report output looks lik this:

This is the sample report template - you can review and test it in the Studio using any Postgres data source:

 
<?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="report-20150504-sample-3" pageWidth="612" pageHeight="792" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="1fe3275c-4ced-4197-979c-9f5ffd79bb93">
    <property name="com.jaspersoft.studio.data.defaultdataadapter" value="JRSrepo"/>
    <property name="ireport.zoom" value="1.0"/>
    <property name="ireport.x" value="0"/>
    <property name="ireport.y" value="0"/>
    <parameter name="Parameter1" class="java.lang.String">
        <defaultValueExpression><![CDATA["10 Things Not To Do On Tax Day - 1. Fib on your taxes and think you’ll pay later. - 2. Call your tax professional for anything other than an extension. - 3. Spend your refund when it’s not in pocket. - 4. Head out for the post office at 4:55pm. - 5. Call the IRS. - 6. Forget to sign your return. - 7. Assume you’ll figure it out later. - 8. Not pay at all. - 9. Fail to take advantage of all of the cool stuff available. - 10. Panic. (http://www.forbes.com/sites/kellyphillipserb/2015/04/15/9-things-not-to-do-on-tax-day/)"]]></defaultValueExpression>
    </parameter>
    <queryString>
        <![CDATA[select 1]]>
    </queryString>
    <field name="?column?" class="java.lang.Integer"/>
    <variable name="split_point" class="java.lang.Integer">
        <variableExpression><![CDATA[new Integer(($P{Parameter1}.length()/3)+$P{Parameter1}.substring($P{Parameter1}.length()/3).indexOf(" "))]]></variableExpression>
    </variable>
    <variable name="split_point2" class="java.lang.Integer">
        <variableExpression><![CDATA[new Integer($P{Parameter1}.substring(0,$P{Parameter1}.length()/3).lastIndexOf(" "))]]></variableExpression>
    </variable>
    <background>
        <band splitType="Stretch"/>
    </background>
    <title>
        <band height="1" splitType="Stretch"/>
    </title>
    <pageHeader>
        <band splitType="Stretch"/>
    </pageHeader>
    <columnHeader>
        <band splitType="Stretch">
            <property name="local_mesure_unitheight" value="pixel"/>
            <property name="com.jaspersoft.studio.unit.height" value="px"/>
        </band>
    </columnHeader>
    <detail>
        <band height="45" splitType="Stretch">
            <property name="local_mesure_unitheight" value="pixel"/>
            <property name="com.jaspersoft.studio.unit.height" value="px"/>
            <frame>
                <reportElement stretchType="RelativeToTallestObject" x="0" y="0" width="570" height="42" uuid="7993ef51-6ebe-4fec-b382-ef4d6c6ecd93">
                    <property name="local_mesure_unitheight" value="pixel"/>
                    <property name="com.jaspersoft.studio.unit.height" value="px"/>
                </reportElement>
                <box>
                    <topPen lineWidth="1.0"/>
                    <leftPen lineWidth="1.0"/>
                    <bottomPen lineWidth="1.0"/>
                    <rightPen lineWidth="1.0"/>
                </box>
                <frame>
                    <reportElement stretchType="RelativeToTallestObject" x="0" y="0" width="300" height="42" uuid="541fe792-7d25-4793-bfd0-3113df9e5615">
                        <property name="local_mesure_unitx" value="pixel"/>
                        <property name="com.jaspersoft.studio.unit.x" value="px"/>
                        <property name="local_mesure_unity" value="pixel"/>
                        <property name="com.jaspersoft.studio.unit.y" value="px"/>
                        <property name="local_mesure_unitwidth" value="pixel"/>
                        <property name="com.jaspersoft.studio.unit.width" value="px"/>
                        <property name="local_mesure_unitheight" value="pixel"/>
                        <property name="com.jaspersoft.studio.unit.height" value="px"/>
                    </reportElement>
                    <box>
                        <topPen lineWidth="1.0"/>
                        <leftPen lineWidth="1.0"/>
                        <bottomPen lineWidth="1.0"/>
                        <rightPen lineWidth="1.0"/>
                    </box>
                    <textField isStretchWithOverflow="true">
                        <reportElement mode="Opaque" x="10" y="10" width="280" height="1" backcolor="#FAF602" uuid="ef3e1934-fb73-46aa-81ea-b9875009f7c6">
                            <property name="local_mesure_unitwidth" value="pixel"/>
                            <property name="com.jaspersoft.studio.unit.width" value="px"/>
                            <property name="local_mesure_unitx" value="pixel"/>
                            <property name="com.jaspersoft.studio.unit.x" value="px"/>
                            <property name="local_mesure_unity" value="pixel"/>
                            <property name="com.jaspersoft.studio.unit.y" value="px"/>
                            <property name="local_mesure_unitheight" value="pixel"/>
                            <property name="com.jaspersoft.studio.unit.height" value="px"/>
                        </reportElement>
                        <textFieldExpression><![CDATA[$P{Parameter1}.substring(0,$V{split_point}.intValue())]]></textFieldExpression>
                    </textField>
                    <line>
                        <reportElement positionType="Float" x="0" y="21" width="300" height="1" uuid="8259aa18-9cfe-41f2-adb6-d017e1f4d226">
                            <property name="local_mesure_unitx" value="pixel"/>
                            <property name="com.jaspersoft.studio.unit.x" value="px"/>
                            <property name="local_mesure_unity" value="pixel"/>
                            <property name="com.jaspersoft.studio.unit.y" value="px"/>
                            <property name="local_mesure_unitheight" value="pixel"/>
                            <property name="com.jaspersoft.studio.unit.height" value="px"/>
                            <property name="local_mesure_unitwidth" value="pixel"/>
                            <property name="com.jaspersoft.studio.unit.width" value="px"/>
                        </reportElement>
                    </line>
                    <textField isStretchWithOverflow="true">
                        <reportElement positionType="Float" mode="Opaque" x="10" y="31" width="280" height="1" backcolor="#52FF03" uuid="c966ef26-8057-4383-8697-183aa026a53d">
                            <property name="local_mesure_unitx" value="pixel"/>
                            <property name="com.jaspersoft.studio.unit.x" value="px"/>
                            <property name="local_mesure_unitwidth" value="pixel"/>
                            <property name="com.jaspersoft.studio.unit.width" value="px"/>
                            <property name="local_mesure_unity" value="pixel"/>
                            <property name="com.jaspersoft.studio.unit.y" value="px"/>
                            <property name="local_mesure_unitheight" value="pixel"/>
                            <property name="com.jaspersoft.studio.unit.height" value="px"/>
                        </reportElement>
                        <textFieldExpression><![CDATA[$P{Parameter1}.substring($V{split_point}.intValue()+1)]]></textFieldExpression>
                    </textField>
                </frame>
                <textField isStretchWithOverflow="true">
                    <reportElement mode="Opaque" x="310" y="10" width="250" height="18" backcolor="#F59FF2" uuid="876f86fd-6283-4c6e-bd4e-556363a92476">
                        <property name="local_mesure_unitwidth" value="pixel"/>
                        <property name="com.jaspersoft.studio.unit.width" value="px"/>
                        <property name="local_mesure_unity" value="pixel"/>
                        <property name="com.jaspersoft.studio.unit.y" value="px"/>
                        <property name="local_mesure_unitheight" value="pixel"/>
                        <property name="com.jaspersoft.studio.unit.height" value="px"/>
                    </reportElement>
                    <textFieldExpression><![CDATA[$P{Parameter1}]]></textFieldExpression>
                </textField>
            </frame>
        </band>
    </detail>
    <columnFooter>
        <band splitType="Stretch"/>
    </columnFooter>
    <pageFooter>
        <band splitType="Stretch"/>
    </pageFooter>
    <summary>
        <band splitType="Stretch"/>
    </summary>
</jasperReport>
tchen's picture
123038
Joined: Feb 27 2008 - 7:33am
Last seen: 1 day 10 hours ago
Feedback