<?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="null" language="groovy" pageWidth="555" pageHeight="802" columnWidth="555" leftMargin="0" rightMargin="0" topMargin="0" bottomMargin="0" uuid="478ce75d-1606-47d2-88eb-f8079f50c69b">
<parameter name="SUBREPORT_DIR" class="java.lang.String" isForPrompting="false">
<defaultValueExpression><![CDATA["D:\\newpackage\\"]]></defaultValueExpression>
</parameter>
<parameter name="MEMBER_CERTIFICATE_PARAM_SUB" class="java.lang.Integer" isForPrompting="false">
<defaultValueExpression><![CDATA[Integer.parseInt($P{MEMBER_CERTIFICATE_PARAM_MAIN})]]></defaultValueExpression>
</parameter>
<parameter name="MEMBER_CERTIFICATE_PARAM_MAIN" class="java.lang.String">
<defaultValueExpression><![CDATA[]]></defaultValueExpression>
</parameter>
<queryString>
<![CDATA[SELECT * FROM table_name WHERE atr = $P{MEMBER_CERTIFICATE_PARAM_SUB}]]>
</queryString>
<field name="national_id_number" class="java.lang.String"/>
<field name="national_pin_number" class="java.lang.String"/>
<field name="contact_email" class="java.lang.String"/>
<field name="biometric_member_number" class="java.lang.String"/>
<title>
<band height="74" splitType="Stretch">
<subreport>
<reportElement x="0" y="0" width="555" height="72" uuid="2cee9cb2-abe3-4739-9b64-ec405bf9912b"/>
<connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
<subreportExpression><![CDATA["D:\\DOCUMENTS\\NetBeansProjects\\NhifHeader\\src\\nhifheader\\PotraitNhifHeader\\PortraitNhifHeader.jasper"]]></subreportExpression>
</subreport>
</band>
</title>
<pageHeader>
<band height="56" splitType="Stretch">
<textField>
<reportElement x="529" y="13" width="26" height="15" uuid="1d23b617-b659-4f87-acfd-e07b54913ccd"/>
<textFieldExpression><![CDATA[$F{national_pin_number}]]></textFieldExpression>
</textField>
<staticText>
<reportElement x="367" y="13" width="173" height="15" uuid="e02099fe-b171-4a24-bb15-195a046921c8"/>
<textElement>
<font isBold="true"/>
</textElement>
<text><![CDATA[Personal Identification Number:]]></text>
</staticText>
<componentElement>
<reportElement x="0" y="1" width="240" height="30" uuid="311343bc-7e09-4658-8a1e-810fe91d1a3f"/>
<jr:Code39 xmlns:jr="http://jasperreports.sourceforge.net/jasperreports/components" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports/components http://jasperreports.sourceforge.net/xsd/components.xsd" textPosition="bottom">
<jr:codeExpression><![CDATA[$F{biometric_member_number}]]></jr:codeExpression>
</jr:Code39>
</componentElement>
<staticText>
<reportElement x="367" y="0" width="31" height="15" uuid="fefca1d6-a90f-4dba-996c-1c00883eba1c"/>
<textElement>
<font isBold="true"/>
</textElement>
<text><![CDATA[Date]]></text>
</staticText>
<textField pattern="MMMMM dd, yyyy">
<reportElement x="398" y="0" width="142" height="20" uuid="c3c68a84-f1d6-43c9-9c83-8b5eaacd6c38"/>
<textFieldExpression><![CDATA[new java.util.Date()]]></textFieldExpression>
</textField>
<line>
<reportElement x="0" y="33" width="555" height="1" forecolor="#E6DAC3" backcolor="#E6DAC3" uuid="003310a9-85b0-447a-bc29-8f97f0006c1d"/>
</line>
<staticText>
<reportElement x="2" y="35" width="553" height="20" uuid="5d8caf66-df88-403d-b96a-1ba2d0e84087"/>
<textElement textAlignment="Center"/>
<text><![CDATA[This is to certify that person shown herein is a member of NHIF: National Hospital Insurance Fund]]></text>
</staticText>
<frame>
<reportElement mode="Opaque" x="179" y="1" width="172" height="21" forecolor="#C0C0C0" backcolor="#C0C0C0" uuid="63309c64-53a9-41e7-b490-fa5278230357"/>
<staticText>
<reportElement mode="Transparent" x="33" y="0" width="113" height="20" forecolor="#000000" backcolor="#000000" uuid="ca2b9d0e-5260-4fb3-9f20-308a4349852e"/>
<textElement>
<font size="12" isBold="true"/>
</textElement>
<text><![CDATA[Member Certificate]]></text>
</staticText>
</frame>
</band>
</pageHeader>
<detail>
<band height="67" splitType="Stretch">
<subreport>
<reportElement x="0" y="0" width="555" height="66" uuid="27c682e0-71b6-4232-8a7a-9efaad62240f"/>
<subreportParameter name="MEMBER_CERTIFICATE_PARAM_MAIN">
<subreportParameterExpression><![CDATA[$P{MEMBER_CERTIFICATE_PARAM_MAIN}]]></subreportParameterExpression>
</subreportParameter>
<subreportParameter name="MEMBER_CERTIFICATE_PARAM_SUB">
<subreportParameterExpression><![CDATA[$P{MEMBER_CERTIFICATE_PARAM_SUB}]]></subreportParameterExpression>
</subreportParameter>
<subreportParameter name="SUBREPORT_DIR">
<subreportParameterExpression><![CDATA[$P{SUBREPORT_DIR}]]></subreportParameterExpression>
</subreportParameter>
<connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
<subreportExpression><![CDATA["D:\\MemberCertificate\\MemberCertificateAddress.jasper"]]></subreportExpression>
</subreport>
</band>
<band height="68">
<subreport>
<reportElement x="0" y="0" width="555" height="67" uuid="169130d8-125e-45c4-b455-4cdced7665d1"/>
<subreportParameter name="MEMBER_CERTIFICATE_PARAM_MAIN">
<subreportParameterExpression><![CDATA[$P{MEMBER_CERTIFICATE_PARAM_MAIN}]]></subreportParameterExpression>
</subreportParameter>
<subreportParameter name="MEMBER_CERTIFICATE_PARAM_SUB">
<subreportParameterExpression><![CDATA[$P{MEMBER_CERTIFICATE_PARAM_SUB}]]></subreportParameterExpression>
</subreportParameter>
<subreportParameter name="SUBREPORT_DIR">
<subreportParameterExpression><![CDATA[$P{SUBREPORT_DIR}]]></subreportParameterExpression>
</subreportParameter>
<connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
<subreportExpression><![CDATA["D:\\MemberCertificate\\MemberCertificateInfo.jasper"]]></subreportExpression>
</subreport>
</band>
<band height="56">
<subreport>
<reportElement x="0" y="0" width="555" height="55" uuid="f36d8a91-96b9-44fc-a393-bbc5752b5316"/>
<subreportParameter name="MEMBER_CERTIFICATE_PARAM_MAIN">
<subreportParameterExpression><![CDATA[$P{MEMBER_CERTIFICATE_PARAM_MAIN}]]></subreportParameterExpression>
</subreportParameter>
<subreportParameter name="MEMBER_CERTIFICATE_PARAM_SUB">
<subreportParameterExpression><![CDATA[$P{MEMBER_CERTIFICATE_PARAM_SUB}]]></subreportParameterExpression>
</subreportParameter>
<subreportParameter name="SUBREPORT_DIR">
<subreportParameterExpression><![CDATA[$P{SUBREPORT_DIR}]]></subreportParameterExpression>
</subreportParameter>
<connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
<subreportExpression><![CDATA["D:\\MemberCertificate\\MemberCertificateIsuranceObligation.jasper"]]></subreportExpression>
</subreport>
</band>
</detail>
</jasperReport>
我有一份JasperReports的报告,其中有几个子报告。我在我的NetBeans中使用iReport插件。我已将相同的整数参数类型传递给所有子报表以及主报表。主报表有两个参数,一个启用了提示选项,类型为字符串。另一个将参数作为字符串并将其转换为整数Integer.parseInt($P{MEMBER_CERTIFICATE_PARAM_MAIN})
(这可以在所有子报告中找到)。这就是我总是传递参数的方式。但是当我运行此报告时,我会收到以下错误。
错误填充打印...错误评估表达式: 源文本:Integer.parseInt($ P {MEMBER_CERTIFICATE_PARAM_MAIN})net.sf.jasperreports.engine.fill.JRExpressionEvalException:评估表达式时出错: 源文本:net.sf.jasperreports.engine.fill.JREvaluator.evaluate中的Integer.parseInt($ P {MEMBER_CERTIFICATE_PARAM_MAIN})(JREvaluator.java:244) 在net.sf.jasperreports.engine.fill.JRCalculator.evaluate(JRCalculator.java:591) 在net.sf.jasperreports.engine.fill.JRCalculator.evaluate(JRCalculator.java:559) 在net.sf.jasperreports.engine.fill.JRFillDataset.setFillParameterValues(JRFillDataset.java:994) 在net.sf.jasperreports.engine.fill.JRFillDataset.setParameterValues(JRFillDataset.java:635) 在net.sf.jasperreports.engine.fill.JRBaseFiller.setParameters(JRBaseFiller.java:1280) 在net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:900) 在net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:845) 在net.sf.jasperreports.engine.fill.JRFiller.fill(JRFiller.java:87) 在net.sf.jasperreports.engine.JasperFillManager.fill(JasperFillManager.java:446) 在net.sf.jasperreports.engine.JasperFillManager.fill(JasperFillManager.java:276) 在net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:745) 在com.jaspersoft.ireport.designer.compiler.IReportCompiler.run(IReportCompiler.java:891) 在org.openide.util.RequestProcessor $ Task.run(RequestProcessor.java:1443) 在org.netbeans.modules.openide.util.GlobalLookup.execute(GlobalLookup.java:68) at org.openide.util.lookup.Lookups.executeWith(Lookups.java:303)at org.openide.util.RequestProcessor $ Processor.run(RequestProcessor.java:2058) java.lang.NumberFormatException:所造成空 在java.lang.Integer.parseInt(Integer.java:542)java.lang.Integer.parseInt(Integer.java:615)
答案 0 :(得分:2)
问题是你宣布了
<parameter name="MEMBER_CERTIFICATE_PARAM_SUB"...>
,默认值
<defaultValueExpression><![CDATA[Integer.parseInt($P{MEMBER_CERTIFICATE_PARAM_MAIN})]]></defaultValueExpression>
甚至在声明$P{MEMBER_CERTIFICATE_PARAM_MAIN}
之前。事实证明,文件正在从头开始读取,所有表达式在读取时都在评估。在评估"MEMBER_CERTIFICATE_PARAM_SUB"
报告时,我不知道$P{MEMBER_CERTIFICATE_PARAM_MAIN}
是什么。
答案 1 :(得分:0)
<?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="null" language="groovy" pageWidth="555" pageHeight="802" columnWidth="555" leftMargin="0" rightMargin="0" topMargin="0" bottomMargin="0" uuid="478ce75d-1606-47d2-88eb-f8079f50c69b">
<property name="ireport.zoom" value="1.0"/>
<property name="ireport.x" value="0"/>
<property name="ireport.y" value="0"/>
<parameter name="SUBREPORT_DIR" class="java.lang.String" isForPrompting="false">
<defaultValueExpression><![CDATA["D:\\DOCUMENTS\\NetBeansProjects\\BranchHeader\\src\\PortraitBranchHeader\\newpackage\\"]]></defaultValueExpression>
</parameter>
<parameter name="MEMBER_CERTIFICATE_PARAM_MAIN" class="java.lang.String">
<defaultValueExpression><![CDATA[]]></defaultValueExpression>
</parameter>
<parameter name="MEMBER_CERTIFICATE_PARAM_SUB" class="java.lang.Integer" isForPrompting="false">
<defaultValueExpression><![CDATA[Integer.parseInt($P{MEMBER_CERTIFICATE_PARAM_MAIN})]]></defaultValueExpression>
</parameter>
<queryString>
<![CDATA[SELECT npi.national_id_number, npi.national_pin_number, npi.contact_email, npi.biometric_member_number
FROM (SELECT snpi.nhif_persons_identity_serial, snpi.person_identity_number, snpi.biometric_member_number,
snpi.national_id_number, snpi.national_pin_number, snpi.national_nhif_number, snpi.address_physical,
snpi.contact_address, snpi.contact_telephone, snpi.contact_mobile, snpi.address_district, snpi.marital_status,
snpi.gender, snpi.first_name, snpi.middle_name, snpi.last_name, snpi.date_registered, snpi.contact_email
FROM nhif_persons_identities snpi
WHERE snpi.nhif_persons_identity_serial = $P{MEMBER_CERTIFICATE_PARAM_SUB}) npi]]>
</queryString>
<field name="national_id_number" class="java.lang.String"/>
<field name="national_pin_number" class="java.lang.String"/>
<field name="contact_email" class="java.lang.String"/>
<field name="biometric_member_number" class="java.lang.String"/>
<background>
<band splitType="Stretch"/>
</background>
<title>
<band height="74" splitType="Stretch">
<subreport>
<reportElement x="0" y="0" width="555" height="72" uuid="2cee9cb2-abe3-4739-9b64-ec405bf9912b"/>
<connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
<subreportExpression><![CDATA["D:\\DOCUMENTS\\NetBeansProjects\\NhifHeader\\src\\nhifheader\\PotraitNhifHeader\\PortraitNhifHeader.jasper"]]></subreportExpression>
</subreport>
</band>
</title>
<pageHeader>
<band height="56" splitType="Stretch">
<textField>
<reportElement x="529" y="13" width="26" height="15" uuid="1d23b617-b659-4f87-acfd-e07b54913ccd"/>
<textFieldExpression><![CDATA[$F{national_pin_number}]]></textFieldExpression>
</textField>
<staticText>
<reportElement x="367" y="13" width="173" height="15" uuid="e02099fe-b171-4a24-bb15-195a046921c8"/>
<textElement>
<font isBold="true"/>
</textElement>
<text><![CDATA[Personal Identification Number:]]></text>
</staticText>
<componentElement>
<reportElement x="0" y="1" width="240" height="30" uuid="311343bc-7e09-4658-8a1e-810fe91d1a3f"/>
<jr:Code39 xmlns:jr="http://jasperreports.sourceforge.net/jasperreports/components" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports/components http://jasperreports.sourceforge.net/xsd/components.xsd" textPosition="bottom">
<jr:codeExpression><![CDATA[$F{biometric_member_number}]]></jr:codeExpression>
</jr:Code39>
</componentElement>
<staticText>
<reportElement x="367" y="0" width="31" height="15" uuid="fefca1d6-a90f-4dba-996c-1c00883eba1c"/>
<textElement>
<font isBold="true"/>
</textElement>
<text><![CDATA[Date]]></text>
</staticText>
<textField pattern="MMMMM dd, yyyy">
<reportElement x="398" y="0" width="142" height="20" uuid="c3c68a84-f1d6-43c9-9c83-8b5eaacd6c38"/>
<textFieldExpression><![CDATA[new java.util.Date()]]></textFieldExpression>
</textField>
<line>
<reportElement x="0" y="33" width="555" height="1" forecolor="#E6DAC3" backcolor="#E6DAC3" uuid="003310a9-85b0-447a-bc29-8f97f0006c1d"/>
</line>
<staticText>
<reportElement x="2" y="35" width="553" height="20" uuid="5d8caf66-df88-403d-b96a-1ba2d0e84087"/>
<textElement textAlignment="Center"/>
<text><![CDATA[This is to certify that person shown herein is a member of NHIF: National Hospital Insurance Fund]]></text>
</staticText>
<frame>
<reportElement mode="Opaque" x="179" y="1" width="172" height="21" forecolor="#C0C0C0" backcolor="#C0C0C0" uuid="63309c64-53a9-41e7-b490-fa5278230357"/>
<staticText>
<reportElement mode="Transparent" x="33" y="0" width="113" height="20" forecolor="#000000" backcolor="#000000" uuid="ca2b9d0e-5260-4fb3-9f20-308a4349852e"/>
<textElement>
<font size="12" isBold="true"/>
</textElement>
<text><![CDATA[Member Certificate]]></text>
</staticText>
</frame>
</band>
</pageHeader>
<detail>
<band height="67" splitType="Stretch">
<subreport>
<reportElement x="0" y="0" width="555" height="66" uuid="27c682e0-71b6-4232-8a7a-9efaad62240f"/>
<subreportParameter name="MEMBER_CERTIFICATE_PARAM_MAIN">
<subreportParameterExpression><![CDATA[$P{MEMBER_CERTIFICATE_PARAM_MAIN}]]></subreportParameterExpression>
</subreportParameter>
<subreportParameter name="MEMBER_CERTIFICATE_PARAM_SUB">
<subreportParameterExpression><![CDATA[$P{MEMBER_CERTIFICATE_PARAM_SUB}]]></subreportParameterExpression>
</subreportParameter>
<subreportParameter name="SUBREPORT_DIR">
<subreportParameterExpression><![CDATA[$P{SUBREPORT_DIR}]]></subreportParameterExpression>
</subreportParameter>
<connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
<subreportExpression><![CDATA["D:\\DOCUMENTS\\NetBeansProjects\\MemberCertificate11212017\\src\\MemberCertificate\\MemberCertificateAddress.jasper"]]></subreportExpression>
</subreport>
</band>
<band height="68">
<subreport>
<reportElement x="0" y="0" width="555" height="67" uuid="169130d8-125e-45c4-b455-4cdced7665d1"/>
<subreportParameter name="MEMBER_CERTIFICATE_PARAM_MAIN">
<subreportParameterExpression><![CDATA[$P{MEMBER_CERTIFICATE_PARAM_MAIN}]]></subreportParameterExpression>
</subreportParameter>
<subreportParameter name="MEMBER_CERTIFICATE_PARAM_SUB">
<subreportParameterExpression><![CDATA[$P{MEMBER_CERTIFICATE_PARAM_SUB}]]></subreportParameterExpression>
</subreportParameter>
<subreportParameter name="SUBREPORT_DIR">
<subreportParameterExpression><![CDATA[$P{SUBREPORT_DIR}]]></subreportParameterExpression>
</subreportParameter>
<connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
<subreportExpression><![CDATA["D:\\DOCUMENTS\\NetBeansProjects\\MemberCertificate11212017\\src\\MemberCertificate\\MemberCertificateInfo.jasper"]]></subreportExpression>
</subreport>
</band>
<band height="56">
<subreport>
<reportElement x="0" y="0" width="555" height="55" uuid="f36d8a91-96b9-44fc-a393-bbc5752b5316"/>
<subreportParameter name="MEMBER_CERTIFICATE_PARAM_MAIN">
<subreportParameterExpression><![CDATA[$P{MEMBER_CERTIFICATE_PARAM_MAIN}]]></subreportParameterExpression>
</subreportParameter>
<subreportParameter name="MEMBER_CERTIFICATE_PARAM_SUB">
<subreportParameterExpression><![CDATA[$P{MEMBER_CERTIFICATE_PARAM_SUB}]]></subreportParameterExpression>
</subreportParameter>
<subreportParameter name="SUBREPORT_DIR">
<subreportParameterExpression><![CDATA[$P{SUBREPORT_DIR}]]></subreportParameterExpression>
</subreportParameter>
<connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
<subreportExpression><![CDATA["D:\\DOCUMENTS\\NetBeansProjects\\MemberCertificate11212017\\src\\MemberCertificate\\MemberCertificateIsuranceObligation.jasper"]]></subreportExpression>
</subreport>
</band>
</detail>
<pageFooter>
<band height="54" splitType="Stretch">
<frame>
<reportElement mode="Opaque" x="0" y="18" width="555" height="20" forecolor="#E6DAC3" backcolor="#E6DAC3" uuid="7f256e6e-c72d-4b8b-ad82-acb84e711f34"/>
<staticText>
<reportElement x="3" y="1" width="59" height="19" uuid="209e1c39-a38d-4b3a-a095-95662b9707e5"/>
<textElement>
<font size="10" isBold="true"/>
</textElement>
<text><![CDATA[Disclaimer :]]></text>
</staticText>
<staticText>
<reportElement x="62" y="1" width="493" height="19" uuid="3465db13-94ed-4a12-bb82-96732d370a8a"/>
<textElement>
<font size="10" isBold="false"/>
</textElement>
<text><![CDATA[This is an auto generated Certificate and does not require signature]]></text>
</staticText>
</frame>
</band>
</pageFooter>
<summary>
<band height="42" splitType="Stretch"/>
</summary>
</jasperReport>
Egan Wolf Idea完美无缺。我刚刚在子报表参数之前声明了主报表参数!