問題:我不知道如何在Jasper Reports中從我的mySQL數據庫打印多行數據。我想我應該在jrxml文件中創建一個循環,但我不知道如何。如何在Jasper Report中打印多行數據
基本上,我需要打印我的數據庫中的所有數據。 我真的很感謝你們的幫助,謝謝。
這裏是在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>
你可以從[JasperReports Ultimate Guide]開始(http://jasperreports.sourceforge.net/JasperReports-Ultimate-Guide-3.pdf)。示例是[here](http://jasperreports.sourceforge.net/sample.reference.html) –