Jasper ireport first record

Asked

Viewed 404 times

1

My report on Jasper ireport only displays the first record

Code

<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 6.4.0.final using JasperReports Library version 6.4.1  -->
<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="Blank_Letter" pageWidth="612" pageHeight="792" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="c48467be-87c9-4ccb-90b9-fcfa33a9d84f">
    <property name="com.jaspersoft.studio.data.sql.tables" value="YmFuY290ZXN0ZS5jbGllbnRlICwxNSwxNSxlNTU0NDA1OS0xYzI5LTQwMzAtYjVkNC03YTFiYjUzNjMxMWY7"/>
    <property name="com.jaspersoft.studio.data.defaultdataadapter" value="mysqlxampp"/>
    <queryString language="SQL">
        <![CDATA[SELECT * FROM bancoteste.cliente]]>
    </queryString>
    <field name="nome" class="java.lang.String"/>
    <field name="idade" class="java.lang.String"/>
    <field name="codigo" class="java.lang.String"/>
    <background>
        <band splitType="Stretch"/>
    </background>
    <title>
        <band height="79" splitType="Stretch">
            <staticText>
                <reportElement x="230" y="0" width="120" height="30" uuid="d12daa5e-ea80-4790-8af5-25c99f14b6db"/>
                <textElement>
                    <font size="18"/>
                </textElement>
                <text><![CDATA[RELATORIO]]></text>
            </staticText>
        </band>
    </title>
    <pageHeader>
        <band height="35" splitType="Stretch"/>
    </pageHeader>
    <columnHeader>
        <band height="61" splitType="Stretch">
            <staticText>
                <reportElement x="356" y="0" width="100" height="20" uuid="6649fe5c-d657-4d3d-b672-2f44fc082ea3"/>
                <text><![CDATA[codigo]]></text>
            </staticText>
            <staticText>
                <reportElement x="0" y="0" width="100" height="20" uuid="9fef867a-3cbe-4c85-9d4e-daee2441b491"/>
                <text><![CDATA[nome]]></text>
            </staticText>
            <staticText>
                <reportElement x="180" y="0" width="100" height="20" uuid="4be07db8-dd06-4db7-9dae-f2b5712167de"/>
                <text><![CDATA[idade]]></text>
            </staticText>
            <textField>
                <reportElement x="356" y="20" width="100" height="19" uuid="237beee7-de42-446c-b966-26d53164f46a"/>
                <textFieldExpression><![CDATA[$F{codigo}]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement x="0" y="20" width="100" height="19" uuid="487128c2-8ed2-4e64-ad5f-d03e7cf8c5ce"/>
                <textFieldExpression><![CDATA[$F{nome}]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement x="180" y="20" width="100" height="19" uuid="5a4e7139-82d7-462a-b121-466dc8ac0e3c"/>
                <textFieldExpression><![CDATA[$F{idade}]]></textFieldExpression>
            </textField>
        </band>
    </columnHeader>
    <detail>
        <band height="125" splitType="Stretch"/>
    </detail>
    <columnFooter>
        <band height="45" splitType="Stretch"/>
    </columnFooter>
    <pageFooter>
        <band height="54" splitType="Stretch"/>
    </pageFooter>
    <summary>
        <band height="42" splitType="Stretch"/>
    </summary>
</jasperReport>

inserir a descrição da imagem aqui

1 answer

1


This error is occurring because you have placed your fields in the "Header" section, it is correct to put them in "Detail". You move column titles to column header, meaning your Static Texts and textFields are in the part of Detail just below the titles.

That gives a report like this:

+---------------------------------------------------------+
|                      Relatório  (Pg1)                   |
+-----------+----------+----------+-----------------------+
|  Coluna 1 | Coluna 2 | Coluna 3 |       Column Header   |
+-----------+----------+----------+-----------------------+
| TextField |TextField |TextField |                       |
| TextField |TextField |TextField |       Detail          |
| TextField |TextField |TextField |                       |

.... Pg 2

+-----------+----------+----------+-----------------------+
|  Coluna 1 | Coluna 2 | Coluna 3 |       Column Header   |
+-----------+----------+----------+-----------------------+
| TextField |TextField |TextField |                       |
| TextField |TextField |TextField |       Detail          |
| TextField |TextField |TextField |                       |

Or you might want the static texts to be a sort of legend for the data, so you would do so

+----------------------------------------------+----------+
|                 Relatório (Title)            |          |
+----------------------------------------------+----------+
|  Nome: (Static Text) ZZZZZZ (TextField)      |          |
|  Endereço: (Static Text) ZZZZZZ (TextField)  |  Detail  | 

Unless I am mistaken the difference between this Columnheader section and Title is that the first one is repeated on all pages, while Title only appears on the first page.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.