这是我的主报告,
<?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="evesi" pageWidth="612" pageHeight="792" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="471c8550-938b-4019-830e-286b34811300">
<property name="ireport.zoom" value="1.0"/>
<property name="ireport.x" value="0"/>
<property name="ireport.y" value="14"/>
<parameter name="SUBREPORT_DIR" class="java.lang.String" isForPrompting="false">
<defaultValueExpression><![CDATA["/home/johnson3yo/Desktop/shop/"]]></defaultValueExpression>
</parameter>
<field name="name" class="java.lang.String"/>
<field name="order_id" class="java.lang.Integer"/>
<field name="address" class="java.lang.String"/>
<field name="total" class="java.lang.Double"/>
<field name="bill" class="java.util.List"/>
<background>
<band splitType="Stretch"/>
</background>
<title>
<band height="164" splitType="Stretch">
<staticText>
<reportElement x="10" y="10" width="304" height="37" forecolor="#246858" uuid="9dd22c2e-4f0e-4e17-b66c-6e43c308645c"/>
<textElement>
<font size="24" isBold="false"/>
</textElement>
<text><![CDATA[Eves Intimate Secrets]]></text>
</staticText>
<staticText>
<reportElement x="10" y="47" width="125" height="16" uuid="2e4a5f77-56ff-4979-8404-c73cc8c34550"/>
<text><![CDATA[Eves intimate Secrets]]></text>
</staticText>
<staticText>
<reportElement x="10" y="63" width="174" height="15" uuid="0f5eb627-bc10-43d0-b87d-3381edcbee65"/>
<text><![CDATA[12 , ashimowu street new garage,]]></text>
</staticText>
<staticText>
<reportElement x="10" y="78" width="125" height="20" uuid="90545a25-a158-44f1-b630-a86cb78c0d6c"/>
<text><![CDATA[Gbagada, Lagos]]></text>
</staticText>
<staticText>
<reportElement x="236" y="47" width="131" height="16" uuid="325293e5-15ce-4084-a300-242b0f88748a"/>
<text><![CDATA[Phone: 07033999903]]></text>
</staticText>
<staticText>
<reportElement x="236" y="63" width="145" height="15" uuid="1333ae12-a572-45c6-bbd3-9e498d56b545"/>
<text><![CDATA[email : cecetay@yahoo.com]]></text>
</staticText>
<staticText>
<reportElement x="10" y="105" width="100" height="12" uuid="74c188c2-679b-4ae4-8dd0-2ac768d58149"/>
<textElement>
<font isBold="true"/>
</textElement>
<text><![CDATA[Bill To]]></text>
</staticText>
<line>
<reportElement x="8" y="119" width="127" height="1" uuid="2d0fb77a-7354-4b72-80d5-c4c64703dc16"/>
</line>
<textField>
<reportElement x="10" y="120" width="100" height="14" uuid="674822c4-4581-4d55-9610-1bef0cb11778"/>
<textFieldExpression><![CDATA[$F{name}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="10" y="136" width="532" height="20" uuid="2bce4c17-2c9b-421c-a58a-9534c357f158"/>
<textFieldExpression><![CDATA[$F{address}]]></textFieldExpression>
</textField>
<staticText>
<reportElement x="425" y="58" width="62" height="20" uuid="27f557b4-a13c-4537-b483-2cb94b47f56a"/>
<textElement>
<font isBold="true"/>
</textElement>
<text><![CDATA[Invoice ID: ]]></text>
</staticText>
<textField>
<reportElement x="487" y="58" width="70" height="20" uuid="f889fe45-7105-4c60-b898-8429cfdf73ca"/>
<textFieldExpression><![CDATA[$F{order_id}]]></textFieldExpression>
</textField>
</band>
</title>
<columnHeader>
<band height="63" splitType="Stretch">
<line>
<reportElement x="0" y="29" width="572" height="1" uuid="c1e7c778-6964-4970-bab8-b1b6f353888e"/>
</line>
<line>
<reportElement x="0" y="61" width="572" height="1" uuid="adda9536-ac6b-4bc9-8977-2ad5eb93c2e8"/>
</line>
<staticText>
<reportElement x="8" y="42" width="100" height="19" backcolor="#B9B4B4" uuid="67bc9761-4166-4625-8e3b-2b4226adef3b"/>
<textElement>
<font isBold="true"/>
</textElement>
<text><![CDATA[Product ID]]></text>
</staticText>
<staticText>
<reportElement x="121" y="41" width="260" height="20" uuid="50fe75ee-6277-48d9-a73e-cc1afe846c66"/>
<textElement>
<font isBold="true"/>
</textElement>
<text><![CDATA[Description]]></text>
</staticText>
<staticText>
<reportElement x="487" y="42" width="85" height="20" uuid="fb5e1e4c-dace-400f-b000-9f79e0c522f1"/>
<textElement>
<font isBold="true"/>
</textElement>
<text><![CDATA[Subtotal]]></text>
</staticText>
<staticText>
<reportElement x="394" y="41" width="78" height="20" uuid="ddfce14f-1831-4fa9-a129-689da1e3852d"/>
<textElement>
<font isBold="true"/>
</textElement>
<text><![CDATA[Quantity]]></text>
</staticText>
<line>
<reportElement x="110" y="29" width="1" height="33" uuid="a4f6f739-6696-4f9b-8ea1-8a7c70bb32ce"/>
</line>
<line>
<reportElement x="381" y="30" width="1" height="31" uuid="c38bd33d-afb2-463e-a728-667a6ff4c4aa"/>
</line>
<line>
<reportElement x="472" y="29" width="1" height="32" uuid="35c36066-6a4c-489b-88ef-366c77b18ed0"/>
</line>
</band>
</columnHeader>
<detail>
<band height="125" splitType="Stretch">
<subreport>
<reportElement positionType="Float" x="0" y="31" width="573" height="94" isRemoveLineWhenBlank="true" backcolor="#99CCFF" uuid="6e710ad6-a1d4-4b74-ae4c-d77876c00540"/>
<dataSourceExpression><![CDATA[new net.sf.jasperreports.engine.data.JRBeanCollectionDataSource($F{bill})]]></dataSourceExpression>
<subreportExpression><![CDATA[$P{SUBREPORT_DIR} + "evis_sub.jasper"]]></subreportExpression>
</subreport>
<line>
<reportElement x="0" y="30" width="572" height="1" uuid="d1f64c93-036b-4c01-8eab-7cd8d0026f88"/>
</line>
</band>
</detail>
<columnFooter>
<band height="45" splitType="Stretch">
<staticText>
<reportElement x="394" y="0" width="55" height="15" uuid="51b56685-cc07-4d40-8bc5-124a0af1e879"/>
<textElement>
<font isBold="true"/>
</textElement>
<text><![CDATA[Total : ]]></text>
</staticText>
<textField>
<reportElement x="487" y="0" width="86" height="15" uuid="703dd885-5abb-49f8-97b5-5b0375b8e2ea"/>
<textFieldExpression><![CDATA[$F{total}]]></textFieldExpression>
</textField>
<staticText>
<reportElement x="472" y="0" width="15" height="15" uuid="1433cb13-240e-4d3a-a6f0-931be5304b37"/>
<textElement>
<font isStrikeThrough="true"/>
</textElement>
<text><![CDATA[N]]></text>
</staticText>
</band>
</columnFooter>
<pageFooter>
<band height="54" splitType="Stretch"/>
</pageFooter>
我的子报告
<?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="evis_sub" pageWidth="612" pageHeight="792" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="47d9fb1f-6f51-47de-ae10-cbda6893b33b">
<property name="ireport.zoom" value="1.0"/>
<property name="ireport.x" value="0"/>
<property name="ireport.y" value="0"/>
<field name="product_id" class="java.lang.Integer"/>
<field name="product_name" class="java.lang.String"/>
<field name="quantity" class="java.lang.Integer"/>
<field name="subtotal" class="java.lang.Double"/>
<background>
<band splitType="Stretch"/>
</background>
<pageHeader>
<band height="35" splitType="Stretch"/>
</pageHeader>
<columnHeader>
<band height="61" splitType="Stretch"/>
</columnHeader>
<detail>
<band height="125" splitType="Stretch">
<textField>
<reportElement x="0" y="0" width="100" height="20" uuid="030a551c-95ee-4255-92d8-63cf63febc05"/>
<textFieldExpression><![CDATA[$F{product_id}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="100" y="0" width="100" height="20" uuid="94349085-07e0-4c8b-830b-7f42924fbe30"/>
<textFieldExpression><![CDATA[$F{product_name}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="200" y="0" width="100" height="20" uuid="6140e690-916a-48ca-8884-05b6b2344622"/>
<textFieldExpression><![CDATA[$F{quantity}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="300" y="0" width="100" height="20" uuid="24b6c9a2-c64f-4fc9-87bb-56522aa393c7"/>
<textFieldExpression><![CDATA[$F{subtotal}]]></textFieldExpression>
</textField>
</band>
</detail>
我的bean工厂类,bean被填充但是,主报告类字段显示但是子报告列表没有显示,请帮助,我已经长了一些白头发试图解决这个问题
List<InvoiceDTO> iList = new getData();
String masterReportFileName = "/home/johnson3yo/Desktop/shop/evesi.jrxml";
String subReportFileName = "/home/johnson3yo/Desktop/shop/evis_sub.jrxml";
JRBeanCollectionDataSource beanColDataSource = new JRBeanCollectionDataSource(iList);
JasperReport jasperMasterReport = JasperCompileManager .compileReport(masterReportFileName);
JasperReport jasperSubReport = JasperCompileManager .compileReport(subReportFileName);
Map<String, Object> parameters = new HashMap<String, Object>();
parameters.put("subreportParameter", jasperSubReport);
JasperPrint jp = JasperFillManager.fillReport(jasperMasterReport, parameters, beanColDataSource);
byte[] val = JasperExportManager.exportReportToPdf(jp);
答案 0 :(得分:0)
我能够通过将jrxml编译为jasper来解决它,愚蠢的我。