jasper子报表未在主报表中打印

时间:2015-04-24 13:12:01

标签: java jasper-reports report javabeans

我有mainreport和subreport,其中主报告是在jasper中打印的,但不是子报告,请参阅下面的子报告代码

<jr:list xmlns:jr="http://jasperreports.sourceforge.net/jasperreports/components" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports/components http://jasperreports.sourceforge.net/xsd/components.xsd" printOrder="Vertical">
                    <datasetRun subDataset="customerOrderList" uuid="38a2e0f4-ae87-42ad-b3b4-61853d9a2e23">
                        <dataSourceExpression><![CDATA[new net.sf.jasperreports.engine.data.JRBeanCollectionDataSource($F{customerOrderList})]]></dataSourceExpression>
                    </datasetRun>
                    <jr:listContents height="39" width="590">
                        <frame>
                            <reportElement x="0" y="0" width="590" height="39" uuid="609e3e45-03f6-48d0-8776-e6e393d0dbaf"/>
                            <subreport>
                                <reportElement x="0" y="0" width="590" height="39" uuid="d4ef2aed-7826-49e5-9bb1-7642cbd01279"/>
                                <subreportExpression><![CDATA["src/main/java/com/crafart/reports/customerOrders.jasper"]]></subreportExpression>
                            </subreport>
                        </frame>
                    </jr:listContents>
                </jr:list>

我调试了代码,发现生成报告没有问题。

我正在传递包含客户详细信息和订单列表的客户订单。我的客户bean的片段

public class Customer {
    private String customerName;
    private List<Order> customerOrderList
}

以及用于生成报告的代码

    List<OrderDeclarationBO> orderDeclarationBOLst = new ArrayList<>();
    orderDeclarationBOLst.add(orderDeclarationBO);
    InputStream in = this.getClass().getResourceAsStream("order.jrxml");
    InputStream jasperIn = this.getClass().getResourceAsStream("order.jasper");
    JasperCompileManager.compileReport(in);
    JasperPrint jasperPrint = JasperFillManager.fillReport(jasperIn, new HashMap<String, Object>(), new JRBeanCollectionDataSource(orderDeclarationBOLst));
    JasperExportManager.exportReportToPdfFile(jasperPrint, "orderInvoice.pdf");

需要帮助,并且不知道打印子报告仍然需要什么。

编辑: - 添加报告的图像,我在子报告中获取空值,并且没有正确对齐

enter image description here

0 个答案:

没有答案