将文本均匀分割为2列

时间:2015-04-14 16:05:42

标签: jasper-reports

我有一个很长的文字(一般销售条件),我试图弄清楚如何将它分成两个高度相同的列。 该文本不是静态的,因此无论何时需要更改(例如客户特定文本)都可以更改,因此我无法手动拆分。 使用2列页面格式我设法让Jasper一次填充一列,但我的客户不希望2列具有不同的高度。 有人能帮助我吗?

我使用的是Jaspersoft Studio 6.0.3。

编辑:这是模板源

<?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="Ordine" columnCount="2" pageWidth="595" pageHeight="842" columnWidth="287" leftMargin="10" rightMargin="10" topMargin="10" bottomMargin="25" isSummaryWithPageHeaderAndFooter="true" uuid="65c3fc9b-084e-43e8-8495-f967c93cc50b">
    <property name="com.jaspersoft.studio.data.defaultdataadapter" value="Ordine Datasource"/>
    <property name="com.jaspersoft.studio.unit." value="pixel"/>
    <property name="com.jaspersoft.studio.unit.pageHeight" value="inch"/>
    <property name="com.jaspersoft.studio.unit.pageWidth" value="inch"/>
    <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"/>
    <style name="Crosstab_CH" mode="Opaque" backcolor="rgba(255, 255, 255, 0.0)">
        <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="Crosstab_CG" mode="Opaque" backcolor="rgba(255, 255, 255, 0.0)">
        <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="Crosstab_CT" mode="Opaque" backcolor="rgba(255, 255, 255, 0.0)">
        <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="Crosstab_CD" mode="Opaque" backcolor="rgba(255, 255, 255, 0.0)">
        <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="Crosstab 1_CH" mode="Opaque" backcolor="rgba(255, 255, 255, 0.0)">
        <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="Crosstab 1_CG" mode="Opaque" backcolor="rgba(255, 255, 255, 0.0)">
        <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="Crosstab 1_CT" mode="Opaque" backcolor="rgba(255, 255, 255, 0.0)">
        <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="Crosstab 1_CD" mode="Opaque" backcolor="rgba(255, 255, 255, 0.0)">
        <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_TH" mode="Opaque" backcolor="rgba(255, 255, 255, 0.0)">
        <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="rgba(255, 255, 255, 0.0)">
        <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="rgba(255, 255, 255, 0.0)">
        <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="rgba(255, 255, 255, 0.0)">
        <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="rgba(255, 255, 255, 0.0)">
        <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="rgba(255, 255, 255, 0.0)">
        <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="rgba(255, 255, 255, 0.0)">
        <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="rgba(255, 255, 255, 0.0)">
        <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="rgba(255, 255, 255, 0.0)">
        <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 3_TH" mode="Opaque" backcolor="rgba(255, 255, 255, 0.0)">
        <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 3_CH" mode="Opaque" backcolor="rgba(255, 255, 255, 0.0)">
        <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 3_TD" mode="Opaque" backcolor="rgba(255, 255, 255, 0.0)">
        <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 4_TH" mode="Opaque" backcolor="rgba(255, 255, 255, 0.0)">
        <box>
            <pen lineWidth="0.5" lineColor="rgba(0, 0, 0, 0.5019608)"/>
            <topPen lineWidth="0.5" lineColor="rgba(0, 0, 0, 0.5019608)"/>
            <leftPen lineWidth="0.5" lineColor="rgba(0, 0, 0, 0.5019608)"/>
            <bottomPen lineWidth="0.5" lineColor="rgba(0, 0, 0, 0.5019608)"/>
            <rightPen lineWidth="0.5" lineColor="rgba(0, 0, 0, 0.5019608)"/>
        </box>
    </style>
    <style name="Table 4_CH" mode="Opaque" backcolor="rgba(255, 255, 255, 0.0)">
        <box>
            <pen lineWidth="0.5" lineColor="rgba(0, 0, 0, 0.5019608)"/>
            <topPen lineWidth="0.5" lineColor="rgba(0, 0, 0, 0.5019608)"/>
            <leftPen lineWidth="0.5" lineColor="rgba(0, 0, 0, 0.5019608)"/>
            <bottomPen lineWidth="0.5" lineColor="rgba(0, 0, 0, 0.5019608)"/>
            <rightPen lineWidth="0.5" lineColor="rgba(0, 0, 0, 0.5019608)"/>
        </box>
    </style>
    <style name="Table 4_TD" mode="Opaque" backcolor="rgba(255, 255, 255, 0.0)">
        <box>
            <pen lineWidth="0.5" lineColor="rgba(0, 0, 0, 0.5019608)"/>
            <topPen lineWidth="0.5" lineColor="rgba(0, 0, 0, 0.5019608)"/>
            <leftPen lineWidth="0.5" lineColor="rgba(0, 0, 0, 0.5019608)"/>
            <bottomPen lineWidth="0.5" lineColor="rgba(0, 0, 0, 0.5019608)"/>
            <rightPen lineWidth="0.5" lineColor="rgba(0, 0, 0, 0.5019608)"/>
        </box>
    </style>
    <subDataset name="Dataset Spedizioni" uuid="9502f1d6-9de4-4b21-beee-448949826f41">
        <property name="com.jaspersoft.studio.data.defaultdataadapter" value="Ordine Datasource"/>
        <queryString language="xPath">
            <![CDATA[/ordine/tempi_consegna/spedizione]]>
        </queryString>
        <field name="collezione" class="java.lang.String">
            <fieldDescription><![CDATA[collezione]]></fieldDescription>
        </field>
        <field name="capi" class="java.lang.String">
            <fieldDescription><![CDATA[capi]]></fieldDescription>
        </field>
        <field name="valore" class="java.lang.String">
            <fieldDescription><![CDATA[valore]]></fieldDescription>
        </field>
        <field name="consegna" class="java.lang.String">
            <fieldDescription><![CDATA[consegna]]></fieldDescription>
        </field>
    </subDataset>
    <parameter name="PAGES" class="java.lang.Integer" isForPrompting="false">
        <parameterDescription><![CDATA[Number of pages of the complete document]]></parameterDescription>
        <defaultValueExpression><![CDATA[0]]></defaultValueExpression>
    </parameter>
    <parameter name="TOT_PAGES" class="java.lang.Integer" isForPrompting="false">
        <parameterDescription><![CDATA[Total number of pages of the complete document]]></parameterDescription>
        <defaultValueExpression><![CDATA[0]]></defaultValueExpression>
    </parameter>
    <queryString language="xPath">
        <![CDATA[/]]>
    </queryString>
    <field name="riepilogo_classe_collezione" class="java.lang.String">
        <fieldDescription><![CDATA[collezione]]></fieldDescription>
    </field>
    <field name="termine" class="java.lang.String">
        <fieldDescription><![CDATA[termine]]></fieldDescription>
    </field>
    <field name="importo_caparra" class="java.lang.Integer">
        <fieldDescription><![CDATA[/ordine/importo_caparra]]></fieldDescription>
    </field>
    <field name="data_caparra" class="java.lang.String">
        <fieldDescription><![CDATA[/ordine/data_caparra]]></fieldDescription>
    </field>
    <field name="tot_pezzi" class="java.lang.Integer">
        <fieldDescription><![CDATA[/ordine/corpo_ordine/tot_pezzi]]></fieldDescription>
    </field>
    <field name="tot_prezzo" class="java.lang.Float">
        <fieldDescription><![CDATA[/ordine/corpo_ordine/tot_prezzo]]></fieldDescription>
    </field>
    <field name="numero_ordine" class="java.lang.String">
        <fieldDescription><![CDATA[/ordine/testata_colonna/nordine]]></fieldDescription>
    </field>
    <field name="perc_caparra" class="java.lang.String">
        <fieldDescription><![CDATA[/ordine/perc_caparra]]></fieldDescription>
    </field>
    <field name="cgv" class="java.lang.String">
        <fieldDescription><![CDATA[/ordine/cgv]]></fieldDescription>
    </field>
    <variable name="TOTALE_PREZZO" class="java.lang.String">
        <variableExpression><![CDATA[SUBSTITUTE(FIXED($F{tot_prezzo},2,true),",",".")]]></variableExpression>
        <initialValueExpression><![CDATA[SUBSTITUTE(FIXED($F{tot_prezzo},2,true),",",".")]]></initialValueExpression>
    </variable>
    <background>
        <band splitType="Stretch"/>
    </background>
    <pageHeader>
        <band height="242" splitType="Stretch">
            <property name="local_mesure_unitheight" value="pixel"/>
            <property name="com.jaspersoft.studio.unit.height" value="px"/>
            <subreport>
                <reportElement x="0" y="0" width="575" height="220" uuid="9af9bfdd-49fa-493d-a426-1143aa5afe10">
                    <property name="local_mesure_unitheight" value="pixel"/>
                    <property name="com.jaspersoft.studio.unit.height" value="px"/>
                </reportElement>
                <dataSourceExpression><![CDATA[((net.sf.jasperreports.engine.data.JRXmlDataSource) $P{REPORT_DATA_SOURCE}).dataSource("/")]]></dataSourceExpression>
                <subreportExpression><![CDATA["Test Header.jasper"]]></subreportExpression>
            </subreport>
            <staticText>
                <reportElement isPrintRepeatedValues="false" mode="Transparent" x="0" y="230" width="575" height="12" isPrintInFirstWholeBand="true" backcolor="#FFFFFF" uuid="3068ac8d-30a2-465b-92f9-9f4b37b8341f">
                    <property name="local_mesure_unitheight" value="pixel"/>
                    <property name="com.jaspersoft.studio.unit.height" value="px"/>
                    <property name="local_mesure_unity" value="pixel"/>
                    <property name="com.jaspersoft.studio.unit.y" value="px"/>
                    <printWhenExpression><![CDATA[$V{PAGE_NUMBER} == 1]]></printWhenExpression>
                </reportElement>
                <textElement textAlignment="Center" verticalAlignment="Middle">
                    <font fontName="Times New Roman" size="6" pdfFontName="Times-Roman"/>
                </textElement>
                <text><![CDATA[CONDIZIONI GENERALI DI VENDITA]]></text>
            </staticText>
        </band>
    </pageHeader>
    <detail>
        <band height="20" splitType="Stretch">
            <property name="com.jaspersoft.studio.layout" value="com.jaspersoft.studio.editor.layout.HorizontalRowLayout"/>
            <property name="local_mesure_unitheight" value="pixel"/>
            <property name="com.jaspersoft.studio.unit.height" value="px"/>
            <textField isStretchWithOverflow="true">
                <reportElement key="" mode="Transparent" x="0" y="0" width="280" height="20" isPrintWhenDetailOverflows="true" forecolor="#000000" backcolor="#FFFFFF" uuid="560b6965-4658-4cc8-ad80-a9da918b3dfd">
                    <property name="local_mesure_unitheight" value="pixel"/>
                    <property name="com.jaspersoft.studio.unit.height" value="px"/>
                </reportElement>
                <textElement textAlignment="Justified" verticalAlignment="Top" rotation="None" markup="none">
                    <font fontName="Times New Roman" size="5" isBold="false" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Times-Roman" pdfEncoding="Cp1252" isPdfEmbedded="false"/>
                    <paragraph lineSpacing="Fixed" lineSpacingSize="6.0"/>
                </textElement>
                <textFieldExpression><![CDATA[$F{cgv}]]></textFieldExpression>
            </textField>
        </band>
    </detail>
    <columnFooter>
        <band height="5">
            <property name="local_mesure_unitheight" value="pixel"/>
            <property name="com.jaspersoft.studio.unit.height" value="px"/>
        </band>
    </columnFooter>
    <pageFooter>
        <band height="12">
            <textField>
                <reportElement x="365" y="0" width="185" height="12" uuid="aaf52d54-2ce4-43b0-a2e7-ad24fdc93008">
                    <property name="local_mesure_unitheight" value="pixel"/>
                    <property name="com.jaspersoft.studio.unit.height" value="px"/>
                </reportElement>
                <textElement textAlignment="Right" verticalAlignment="Bottom">
                    <font fontName="Times New Roman" size="7" pdfFontName="Times Roman"/>
                </textElement>
                <textFieldExpression><![CDATA["Pag. " + ($P{PAGES} + $V{PAGE_NUMBER})]]></textFieldExpression>
            </textField>
        </band>
    </pageFooter>
    <lastPageFooter>
        <band height="12">
            <property name="local_mesure_unitheight" value="pixel"/>
            <property name="com.jaspersoft.studio.unit.height" value="px"/>
            <textField>
                <reportElement x="365" y="0" width="185" height="12" uuid="21d83b11-43c6-42e1-83d2-47f8e5b0dc56">
                    <property name="local_mesure_unitheight" value="pixel"/>
                    <property name="com.jaspersoft.studio.unit.height" value="px"/>
                    <property name="local_mesure_unity" value="pixel"/>
                    <property name="com.jaspersoft.studio.unit.y" value="px"/>
                </reportElement>
                <textElement textAlignment="Right" verticalAlignment="Bottom">
                    <font fontName="Times New Roman" size="7" pdfFontName="Times Roman"/>
                </textElement>
                <textFieldExpression><![CDATA["Pag. " + ($P{PAGES} + $V{PAGE_NUMBER})]]></textFieldExpression>
            </textField>
        </band>
    </lastPageFooter>
    <summary>
        <band height="30" splitType="Stretch">
            <property name="local_mesure_unitheight" value="pixel"/>
            <property name="com.jaspersoft.studio.unit.height" value="px"/>
            <subreport>
                <reportElement stretchType="RelativeToTallestObject" x="0" y="0" width="575" height="30" uuid="5d9c20d8-b014-47f7-8176-788c90ae79c8"/>
                <parametersMapExpression><![CDATA[(new java.util.HashMap()).put("TOT_PAGES", $P{TOT_PAGES})]]></parametersMapExpression>
                <subreportParameter name="TOT_PAGES">
                    <subreportParameterExpression><![CDATA[$P{TOT_PAGES}]]></subreportParameterExpression>
                </subreportParameter>
                <dataSourceExpression><![CDATA[((net.sf.jasperreports.engine.data.JRXmlDataSource) $P{REPORT_DATA_SOURCE}).dataSource("/ordine/tempi_consegna/spedizione")]]></dataSourceExpression>
                <subreportExpression><![CDATA["Test CGV Tabella.jasper"]]></subreportExpression>
            </subreport>
        </band>
    </summary>
</jasperReport>

模板数据源是一个xml

0 个答案:

没有答案