8

这是我当前的 jrxml 文件:

<?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="report1" language="groovy" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="18199607-277f-4e05-b2ba-be2f5d89e7d5">
<property name="ireport.zoom" value="1.0"/>
<property name="ireport.x" value="0"/>
<property name="ireport.y" value="0"/>
<queryString>
    <![CDATA[SELECT
 language.`id` AS language_id,
 language.`name` AS language_name
FROM
 `language` language]]>
</queryString>
<field name="language_id" class="java.lang.Long"/>
<field name="language_name" class="java.lang.String"/>
<title>
    <band height="20" splitType="Stretch">
        <staticText>
            <reportElement uuid="662306ce-d3df-4306-b320-e89a92485da3" x="0" y="0" width="555" height="20"/>
            <textElement textAlignment="Center" verticalAlignment="Middle">
                <font size="14" isBold="true" isItalic="true" isUnderline="true" isStrikeThrough="false"/>
            </textElement>
            <text><![CDATA[Languages]]></text>
        </staticText>
    </band>
</title>
<detail>
    <band height="41" splitType="Stretch">
        <textField>
            <reportElement uuid="1f1d2c1a-bafd-4095-9c7a-e0a48c20a82f" x="23" y="14" width="231" height="20"/>
            <textElement/>
            <textFieldExpression><![CDATA[$F{language_name}]]></textFieldExpression>
        </textField>
        <textField>
            <reportElement uuid="1f1d2c1a-bafd-4095-9c7a-e0a48c20a82f" x="301" y="14" width="235" height="20"/>
            <textElement/>
            <textFieldExpression><![CDATA[$F{language_name}]]></textFieldExpression>
        </textField>
        <textField>
            <reportElement uuid="52cb1ba3-4bdd-4b18-877e-0c40f70d073d" x="0" y="14" width="23" height="20"/>
            <textElement/>
            <textFieldExpression><![CDATA[$F{language_id}]]></textFieldExpression>
        </textField>
        <textField>
            <reportElement uuid="52cb1ba3-4bdd-4b18-877e-0c40f70d073d" x="278" y="14" width="23" height="20"/>
            <textElement/>
            <textFieldExpression><![CDATA[$F{language_id}]]></textFieldExpression>
        </textField>
    </band>
</detail>
</jasperReport>

这是我的输出:

在此处输入图像描述

我需要这个:

在此处输入图像描述

那么如何在列表的两列中显示数据。

4

1 回答 1

22

您应该将报表的属性打印顺序( printOrder ) 值设置为Horizo ​​ntal ,并将报表的属性Columns ( columnCount ) 值设置为2

在此处输入图像描述

样品

jrxml文件:

<?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>

报告的设计(在iReport中):

在此处输入图像描述

结果将是(通过iReport中的预览):

在此处输入图像描述

于 2013-10-08T19:24:03.423 回答