Blank subreport in Jasper Reports
        Posted  
        
            by Andy Chapman
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Andy Chapman
        
        
        
        Published on 2010-04-02T01:55:01Z
        Indexed on 
            2010/04/02
            2:03 UTC
        
        
        Read the original article
        Hit count: 789
        
Hi all, I'm trying to launch a report that I created in iReport which contains a main report and a subreport. In iReport, the subreport launches fine and contains data, however when I try to launch it from within my java code, the subreport is blank.
What I've done so far:
I have a String parameter in the main report called "SUBREPORT" that is used to define the path to the subreport. E.g. value: "E:\java\ReportLauncher\reports\test_subreport1.jasper"
The subreport expression in the main report is set to: $P{SUBREPORT}
The subreport connection expression is: $P{REPORT_CONNECTION}
I also have a subreport parameter defined called "INVOICE_NUMBER" that is set to $F{InviInvNo}, which maps to a field in the main report.
In my java code, I have:
HashMap<String, Object> paramHash = new HashMap();
paramHash.put("INVOICE_NUMBER", invoiceID);
paramHash.put("REPORT_CONNECTION", this.conn);
paramHash.put("SUBREPORT", subReportPath);
JasperPrint jasperprint = JasperFillManager.fillReport(this.reportPath, paramHash, this.conn);
The main report is created fine and is populated. The subreport area however is blank. Any thoughts for what I'm doing wrong?
Thanks in advance, Andy.
© Stack Overflow or respective owner