问题:我不知道如何在 Jasper Reports 中从 mySQL 数据库中打印多行数据。我想我应该在 jrxml 文件中创建一个循环,但我不知道如何。
基本上,我需要打印数据库中的所有数据。我真的很感谢你们的任何帮助,谢谢。
这是 jrxml 文件中的代码:(我删除了顶部,因为它使我的代码无法在此处完全显示)
<queryString language="SQL">
<![CDATA[select * from employeelist_table]]>
</queryString>
<field name="EMPLOYEE_ID" class="java.lang.Integer"/>
<field name="EMPLOYEE_NAME" class="java.lang.String"/>
<field name="SURNAME" class="java.lang.String"/>
<field name="FIRSTNAME" class="java.lang.String"/>
<field name="MIDDLE_INITIAL" class="java.lang.String"/>
<field name="DEPARTMENT" class="java.lang.String"/>
<field name="POSITION" class="java.lang.String"/>
<field name="GENDER" class="java.lang.String"/>
<field name="BIRTHDATE" class="java.lang.String"/>
<field name="ADDRESS" class="java.lang.String"/>
<field name="CONTACT_NO" class="java.lang.String"/>
<field name="SSS_NO" class="java.lang.String"/>
<field name="BASIC_PAY" class="java.lang.String"/>
<field name="ALLOWANCE" class="java.lang.String"/>
<field name="LEAVE" class="java.lang.String"/>
<field name="NO_WORK" class="java.lang.String"/>
<field name="DAY_RATE" class="java.lang.String"/>
<field name="OVERTIME" class="java.lang.String"/>
<field name="GROSSPAY" class="java.lang.String"/>
<field name="NETPAY" class="java.lang.String"/>
<field name="DAY_ABSENT" class="java.lang.String"/>
<field name="LATE_UNDERTIME" class="java.lang.String"/>
<field name="SSS_PREMIUM" class="java.lang.String"/>
<field name="PHILHEALTH" class="java.lang.String"/>
<field name="WTAX" class="java.lang.String"/>
<field name="RBNI_LOAN" class="java.lang.String"/>
<field name="SSS_LOAN" class="java.lang.String"/>
<field name="TOTAL_DEDUCTION" class="java.lang.String"/>
<background>
<band splitType="Stretch"/>
</background>
<title>
<band height="79" splitType="Stretch">
<image>
<reportElement x="28" y="11" width="255" height="57"/>
<imageExpression><![CDATA["C:\\Users\\Jaybeeh\\Documents\\Computerized_Payroll_System\\src\\computerized_payroll_system\\logo2.jpg"]]></imageExpression>
</image>
<staticText>
<reportElement x="92" y="20" width="159" height="48"/>
<textElement/>
<text><![CDATA[WESTERN COLLEGE, INC. NAIC, CAVITE PAYROLL SUMMARY]]></text>
</staticText>
</band>
</title>
<pageHeader>
<band splitType="Stretch"/>
</pageHeader>
<columnHeader>
<band height="31" splitType="Stretch">
<staticText>
<reportElement x="33" y="2" width="82" height="20"/>
<textElement textAlignment="Center"/>
<text><![CDATA[EMPLOYEE_ID]]></text>
</staticText>
<staticText>
<reportElement x="127" y="2" width="100" height="20"/>
<textElement textAlignment="Center"/>
<text><![CDATA[EMPLOYEE_NAME]]></text>
</staticText>
<staticText>
<reportElement x="240" y="2" width="100" height="20"/>
<textElement textAlignment="Center"/>
<text><![CDATA[DEPARTMENT]]></text>
</staticText>
<staticText>
<reportElement x="354" y="2" width="68" height="20"/>
<textElement textAlignment="Center"/>
<text><![CDATA[BASIC_PAY]]></text>
</staticText>
<staticText>
<reportElement x="432" y="2" width="59" height="20"/>
<textElement textAlignment="Center"/>
<text><![CDATA[SSS_LOAN]]></text>
</staticText>
<staticText>
<reportElement x="501" y="2" width="65" height="20"/>
<textElement textAlignment="Center"/>
<text><![CDATA[RBNI_LOAN]]></text>
</staticText>
<staticText>
<reportElement x="578" y="2" width="48" height="20"/>
<textElement textAlignment="Center"/>
<text><![CDATA[WTAX]]></text>
</staticText>
<staticText>
<reportElement x="639" y="2" width="66" height="20"/>
<textElement textAlignment="Center"/>
<text><![CDATA[GROSSPAY]]></text>
</staticText>
<staticText>
<reportElement x="724" y="2" width="63" height="20"/>
<textElement textAlignment="Center"/>
<text><![CDATA[NETPAY]]></text>
</staticText>
</band>
</columnHeader>
<detail>
<band height="21" splitType="Stretch">
<textField>
<reportElement x="63" y="0" width="29" height="20"/>
<textElement textAlignment="Center"/>
<textFieldExpression><![CDATA[$F{EMPLOYEE_ID}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="127" y="0" width="100" height="20"/>
<textElement textAlignment="Center"/>
<textFieldExpression><![CDATA[$F{EMPLOYEE_NAME}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="240" y="0" width="100" height="20"/>
<textElement textAlignment="Center"/>
<textFieldExpression><![CDATA[$F{DEPARTMENT}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="354" y="0" width="68" height="20"/>
<textElement textAlignment="Center"/>
<textFieldExpression><![CDATA[$F{BASIC_PAY}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="432" y="0" width="59" height="20"/>
<textElement textAlignment="Center"/>
<textFieldExpression><![CDATA[$F{SSS_LOAN}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="501" y="0" width="65" height="20"/>
<textElement textAlignment="Center"/>
<textFieldExpression><![CDATA[$F{RBNI_LOAN}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="578" y="0" width="48" height="20"/>
<textElement textAlignment="Center"/>
<textFieldExpression><![CDATA[$F{WTAX}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="639" y="0" width="66" height="20"/>
<textElement textAlignment="Center"/>
<textFieldExpression><![CDATA[$F{GROSSPAY}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="724" y="0" width="63" height="20"/>
<textElement textAlignment="Center"/>
<textFieldExpression><![CDATA[$F{NETPAY}]]></textFieldExpression>
</textField>
</band>
</detail>
<columnFooter>
<band splitType="Stretch"/>
</columnFooter>
<pageFooter>
<band splitType="Stretch"/>
</pageFooter>
<summary>
<band splitType="Stretch"/>
</summary>