简体   繁体   中英

Unable to get instance of subReport of jasper report in program

if (jrDetailObj instanceof JRDesignSubreport) {
\\codes 
}

can anyone please tell me how to get the instance of sub report from jasper

Assuming from the code in your question that you have already found the JrDesignSubreport object, you just need to call getExpression() to get the path to the file and then load it into a JasperDesign object.

I think the code below should do it, provided that your subreport expression is just a simple path to the design and not an expression that needs to be evaluated.

if (jrDetailObj instanceof JRDesignSubreport) {
    String subReportExpression = ((JRDesignSubreport)jrDetailObj).getExpression().getText();
    JasperDesign subReport  = JRXmlLoader.load(subReportExpression);
}

是GenericJon,但是当尝试在Excel工作表中打印详细信息时,我们试图获取JRDesignSubreport的实例,而不是仅重现它的实例,因此它不会为子报告打印值

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM