JasperReports: How to show data in two columns

前端 未结 1 1876
小蘑菇
小蘑菇 2021-01-05 07:38

This is my current jrxml file:




        
相关标签:
1条回答
  • 2021-01-05 07:57

    You should set report's property Print order (printOrder) value as Horizontal and the report's property Columns (columnCount) value as 2.

    enter image description here

    The sample

    The jrxml file:

    <?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="report39" language="groovy" columnCount="2" printOrder="Horizontal" pageWidth="595" pageHeight="842" columnWidth="277" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="8ea55a1a-7e67-4906-b7be-7314b7bfa03d">
        <queryString>
            <![CDATA[SELECT id, name FROM PRODUCT]]>
        </queryString>
        <field name="ID" class="java.lang.Integer"/>
        <field name="NAME" class="java.lang.String"/>
        <detail>
            <band height="61" splitType="Stretch">
                <textField>
                    <reportElement uuid="ea1c8668-6d75-42da-9293-6cfd81297c03" x="0" y="0" width="24" height="61"/>
                    <textElement/>
                    <textFieldExpression><![CDATA[$F{ID}]]></textFieldExpression>
                </textField>
                <textField>
                    <reportElement uuid="652cf497-5bc2-4b62-b47a-23ec135cbfdf" x="24" y="0" width="176" height="61"/>
                    <textElement/>
                    <textFieldExpression><![CDATA[$F{NAME}]]></textFieldExpression>
                </textField>
            </band>
        </detail>
    </jasperReport>
    

    The report's design (in iReport):

    enter image description here

    The result will be (via preview in iReport):

    enter image description here

    0 讨论(0)
提交回复
热议问题