gpt4 book ai didi

java - iReport 工具中的分组

转载 作者:行者123 更新时间:2023-12-01 04:18:58 26 4
gpt4 key购买 nike

我使用iReport 5.1.0工具进行报表设计。

我当前的报告输出如下:

------------------------------------------------------------
| STUDENT_ID | SUBJECT_NAME | SUBJECT_MARK | STUDENT_NAME |
------------------------------------------------------------
| 1 | Maths | 25 | John |
------------------------------------------------------------
| 1 | English | 35 | John |
------------------------------------------------------------
| 2 | Maths | 30 | James |
------------------------------------------------------------
| 2 | English | 23 | James |
------------------------------------------------------------

但我需要类似的东西,

------------------------------------------------------------
| STUDENT_ID | SUBJECT_NAME | SUBJECT_MARK | STUDENT_NAME |
------------------------------------------------------------
| 1 | Maths | 25 | John |
-------------------------------
| | English | 35 | |
------------------------------------------------------------
| 2 | Maths | 30 | James |
-------------------------------
| | English | 23 | |
------------------------------------------------------------

这是我的 .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="testStudent" language="groovy" pageWidth="792" pageHeight="612" orientation="Landscape" columnWidth="752" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="31359f99-5457-4827-9bdb-e1160fe03bdc">
<property name="ireport.zoom" value="1.0"/>
<property name="ireport.x" value="0"/>
<property name="ireport.y" value="0"/>
<field name="studentId" class="java.lang.String"/>
<field name="studentName" class="java.lang.String"/>
<field name="subjectName" class="java.lang.String"/>
<field name="subjectMark" class="java.lang.String"/>
<background>
<band splitType="Stretch"/>
</background>
<title>
<band height="31" splitType="Stretch">
<staticText>
<reportElement uuid="c04d7e4f-68ce-4519-a96d-8c4ba4dd4bba" x="0" y="0" width="205" height="31"/>
<textElement>
<font size="20" isBold="true"/>
</textElement>
<text><![CDATA[Test Students]]></text>
</staticText>
</band>
</title>
<pageHeader>
<band height="3" splitType="Stretch"/>
</pageHeader>
<columnHeader>
<band height="23" splitType="Stretch">
<staticText>
<reportElement uuid="04cf5bc0-ff69-47e3-af7c-b2702b1d5e90" x="0" y="2" width="100" height="20"/>
<box>
<pen lineWidth="1.0"/>
<topPen lineWidth="1.0"/>
<leftPen lineWidth="1.0"/>
<bottomPen lineWidth="1.0"/>
<rightPen lineWidth="1.0"/>
</box>
<textElement/>
<text><![CDATA[STUDENT_ID]]></text>
</staticText>
<staticText>
<reportElement uuid="b3c3a500-fb03-459f-b600-8ef738b3a795" x="300" y="2" width="100" height="20"/>
<box>
<pen lineWidth="1.0"/>
<topPen lineWidth="1.0"/>
<leftPen lineWidth="1.0"/>
<bottomPen lineWidth="1.0"/>
<rightPen lineWidth="1.0"/>
</box>
<textElement/>
<text><![CDATA[STUDENT_NAME]]></text>
</staticText>
<staticText>
<reportElement uuid="04c057c8-e4cb-4ad9-876f-40ec3af568c4" x="100" y="2" width="100" height="20"/>
<box>
<pen lineWidth="1.0"/>
<topPen lineWidth="1.0"/>
<leftPen lineWidth="1.0"/>
<bottomPen lineWidth="1.0"/>
<rightPen lineWidth="1.0"/>
</box>
<textElement/>
<text><![CDATA[SUBJECT_NAME]]></text>
</staticText>
<staticText>
<reportElement uuid="3f78e926-ed9e-4306-b0d7-cc03243bef4b" x="200" y="2" width="100" height="20"/>
<box>
<pen lineWidth="1.0"/>
<topPen lineWidth="1.0"/>
<leftPen lineWidth="1.0"/>
<bottomPen lineWidth="1.0"/>
<rightPen lineWidth="1.0"/>
</box>
<textElement/>
<text><![CDATA[SUBJECT_MARK]]></text>
</staticText>
</band>
</columnHeader>
<detail>
<band height="21" splitType="Stretch">
<textField>
<reportElement uuid="e15a2c2c-76f7-40bb-bb88-dde1f89ff2d5" x="0" y="0" width="100" height="20"/>
<box>
<pen lineWidth="1.0"/>
<topPen lineWidth="1.0"/>
<leftPen lineWidth="1.0"/>
<bottomPen lineWidth="1.0"/>
<rightPen lineWidth="1.0"/>
</box>
<textElement/>
<textFieldExpression><![CDATA[$F{studentId}]]></textFieldExpression>
</textField>
<textField>
<reportElement uuid="6da8fc6d-918b-4984-b374-57ab8669de80" x="300" y="0" width="100" height="20"/>
<box>
<pen lineWidth="1.0"/>
<topPen lineWidth="1.0"/>
<leftPen lineWidth="1.0"/>
<bottomPen lineWidth="1.0"/>
<rightPen lineWidth="1.0"/>
</box>
<textElement/>
<textFieldExpression><![CDATA[$F{studentName}]]></textFieldExpression>
</textField>
<textField>
<reportElement uuid="827a067f-e2a2-4a2e-a8f0-bf765e6ed241" x="100" y="0" width="100" height="20"/>
<box>
<pen lineWidth="1.0"/>
<topPen lineWidth="1.0"/>
<leftPen lineWidth="1.0"/>
<bottomPen lineWidth="1.0"/>
<rightPen lineWidth="1.0"/>
</box>
<textElement/>
<textFieldExpression><![CDATA[$F{subjectName}]]></textFieldExpression>
</textField>
<textField>
<reportElement uuid="23463a34-0af0-4897-8745-6fe477919a83" x="200" y="0" width="100" height="20"/>
<box>
<pen lineWidth="1.0"/>
<topPen lineWidth="1.0"/>
<leftPen lineWidth="1.0"/>
<bottomPen lineWidth="1.0"/>
<rightPen lineWidth="1.0"/>
</box>
<textElement/>
<textFieldExpression><![CDATA[$F{subjectMark}]]></textFieldExpression>
</textField>
</band>
</detail>
<columnFooter>
<band height="4" splitType="Stretch"/>
</columnFooter>
<pageFooter>
<band height="5" splitType="Stretch"/>
</pageFooter>
<summary>
<band height="4" splitType="Stretch"/>
</summary></jasperReport>

有人可以帮我吗?提前致谢。

最佳答案

enter image description here首先,您应该创建一个数据组。

1.go to report inspector
2.right click on the jrxml name at the top of the report inpector
3.select add report group.
4.input the group name
5. select the object, in your case student_id from the 'group by the following report object'
6. click next
7. Chose add report group header or footer or both if you want to. (in your case i think you should not add report group header or footer)

系统将添加您的报告组。尝试重新生成报告。您还应该取消选中“打印重复值”

关于java - iReport 工具中的分组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19175385/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com