Jasper reports JasperReports:子报表呈现

Jasper reports JasperReports:子报表呈现,jasper-reports,ireport,Jasper Reports,Ireport,我在应用程序中使用带有SpringMVC的JasperReports进行报告。 基本上,我首先在iReport 4.1.1中设计报告,然后通过jasper-view.xml将生成的.jasper文件放在我的类路径中 当请求到来时,控制器将会话中所需的参数放入参数映射并生成报告 在我的主报告中大约有15个子报告。 在所有这些报告中,仅打印符合条件(作为参数传递)的报告(通过带区的“打印时间”选项控制) 我的问题是:如果我的报告不被打印,它是否会被执行(即其中的查询)? 还是干脆跳过 我问这个问题的

我在应用程序中使用带有SpringMVC的JasperReports进行报告。 基本上,我首先在iReport 4.1.1中设计报告,然后通过jasper-view.xml将生成的.jasper文件放在我的类路径中

当请求到来时,控制器将会话中所需的参数放入参数映射并生成报告

在我的主报告中大约有15个子报告。 在所有这些报告中,仅打印符合条件(作为参数传递)的报告(通过带区的“打印时间”选项控制)

我的问题是:如果我的报告不被打印,它是否会被执行(即其中的查询)? 还是干脆跳过

我问这个问题的原因是生成报告需要相当长的时间(大约2秒,据我所知,这对于我的应用程序来说太长了)


谢谢

如果您查看“Jasper Reports”的源代码,逻辑表明“PrintWheenexpression”首先计算,然后填充报告元素(如果要打印)

下面是JRVerticalFiller.java(4.0版)中名为“FillNodeData”的方法,它是这样说的:

private void fillNoData() throws JRException
    {
        if (log.isDebugEnabled() && !noData.isEmpty())
        {
            log.debug("Fill " + fillerId + ": noData");
        }

        noData.evaluatePrintWhenExpression(JRExpression.EVALUATION_DEFAULT);

        if (noData.isToPrint())
        {
            while (noData.getBreakHeight() > pageHeight - bottomMargin - offsetY)
            {
                addPage(false);
            }

            noData.evaluate(JRExpression.EVALUATION_DEFAULT);

            JRPrintBand printBand = noData.fill(pageHeight - bottomMargin - offsetY);

            if (noData.willOverflow() && noData.isSplitPrevented() && isSubreport())
            {
                resolveGroupBoundElements(JRExpression.EVALUATION_DEFAULT, false);
                resolveColumnBoundElements(JRExpression.EVALUATION_DEFAULT);
                resolvePageBoundElements(JRExpression.EVALUATION_DEFAULT);
                scriptlet.callBeforePageInit();
                calculator.initializeVariables(ResetTypeEnum.PAGE, IncrementTypeEnum.PAGE);
                scriptlet.callAfterPageInit();

                addPage(false);

                printBand = noData.refill(pageHeight - bottomMargin - offsetY);
            }

            fillBand(printBand);
            offsetY += printBand.getHeight();

            while (noData.willOverflow())
            {
                resolveGroupBoundElements(JRExpression.EVALUATION_DEFAULT, false);
                resolveColumnBoundElements(JRExpression.EVALUATION_DEFAULT);
                resolvePageBoundElements(JRExpression.EVALUATION_DEFAULT);
                scriptlet.callBeforePageInit();
                calculator.initializeVariables(ResetTypeEnum.PAGE, IncrementTypeEnum.PAGE);
                scriptlet.callAfterPageInit();

                addPage(false);

                printBand = noData.fill(pageHeight - bottomMargin - offsetY);

                fillBand(printBand);
                offsetY += printBand.getHeight();
            }

            resolveBandBoundElements(noData, JRExpression.EVALUATION_DEFAULT);
        }
    }
您需要研究的是子报表的使用如何影响性能和内存使用。看起来主报表中嵌入的子报表太多了。这里有一些来自这个:

子报表是否存在性能问题?

答案取决于您的系统、数据源和报告 设计。子报告中需要注意的几点:

  • 每个子报表执行都可能产生一个新线程(见下文)
  • 随着子报表的执行,将在堆内存中创建更多的对象
关于线程的主题。对Java延续的支持已经得到了改进 作为线程的替代添加。这是使用雅加达 Commons Javaflow库。JasperReports属性: net.sf.jasperreports.subreport.runner.factory可与 以下两种设置:

  • net.sf.jasperreports.engine.fill.JRContinuationSubreportRunnerFactory
  • net.sf.jasperreports.engine.fill.JRThreadSubreportRunnerFactory
默认情况下 net.sf.jasperreports.engine.fill.JRThreadSubreportRunnerFactory是 使用,但是如果 net.sf.jasperreports.engine.fill.JRContinuationSubreportRunnerFactory 设置后,将使用Javaflow方法填充报告 而不是线程。如果选择此选项,则雅加达 Commons Javaflow jar必须包含在应用程序类路径中。 这个jar可以在JasperReport报告的lib目录中找到 项目分发包。jasperreports-javaflow.properties 文件说明了如何在实际应用程序中设置此属性 实施在中处理不同查询的其他备选方案 相同的报告是List元素和子数据集的用法


如果您查看“Jasper Reports”的源代码,逻辑表明“PrintWheenexpression”首先计算,然后填充报告元素(如果要打印)

下面是JRVerticalFiller.java(4.0版)中名为“FillNodeData”的方法,它是这样说的:

private void fillNoData() throws JRException
    {
        if (log.isDebugEnabled() && !noData.isEmpty())
        {
            log.debug("Fill " + fillerId + ": noData");
        }

        noData.evaluatePrintWhenExpression(JRExpression.EVALUATION_DEFAULT);

        if (noData.isToPrint())
        {
            while (noData.getBreakHeight() > pageHeight - bottomMargin - offsetY)
            {
                addPage(false);
            }

            noData.evaluate(JRExpression.EVALUATION_DEFAULT);

            JRPrintBand printBand = noData.fill(pageHeight - bottomMargin - offsetY);

            if (noData.willOverflow() && noData.isSplitPrevented() && isSubreport())
            {
                resolveGroupBoundElements(JRExpression.EVALUATION_DEFAULT, false);
                resolveColumnBoundElements(JRExpression.EVALUATION_DEFAULT);
                resolvePageBoundElements(JRExpression.EVALUATION_DEFAULT);
                scriptlet.callBeforePageInit();
                calculator.initializeVariables(ResetTypeEnum.PAGE, IncrementTypeEnum.PAGE);
                scriptlet.callAfterPageInit();

                addPage(false);

                printBand = noData.refill(pageHeight - bottomMargin - offsetY);
            }

            fillBand(printBand);
            offsetY += printBand.getHeight();

            while (noData.willOverflow())
            {
                resolveGroupBoundElements(JRExpression.EVALUATION_DEFAULT, false);
                resolveColumnBoundElements(JRExpression.EVALUATION_DEFAULT);
                resolvePageBoundElements(JRExpression.EVALUATION_DEFAULT);
                scriptlet.callBeforePageInit();
                calculator.initializeVariables(ResetTypeEnum.PAGE, IncrementTypeEnum.PAGE);
                scriptlet.callAfterPageInit();

                addPage(false);

                printBand = noData.fill(pageHeight - bottomMargin - offsetY);

                fillBand(printBand);
                offsetY += printBand.getHeight();
            }

            resolveBandBoundElements(noData, JRExpression.EVALUATION_DEFAULT);
        }
    }
您需要研究的是子报表的使用如何影响性能和内存使用。看起来主报表中嵌入的子报表太多了。这里有一些来自这个:

子报表是否存在性能问题?

答案取决于您的系统、数据源和报告 设计。子报告中需要注意的几点:

  • 每个子报表执行都可能产生一个新线程(见下文)
  • 随着子报表的执行,将在堆内存中创建更多的对象
关于线程的主题。对Java延续的支持已经得到了改进 作为线程的替代添加。这是使用雅加达 Commons Javaflow库。JasperReports属性: net.sf.jasperreports.subreport.runner.factory可与 以下两种设置:

  • net.sf.jasperreports.engine.fill.JRContinuationSubreportRunnerFactory
  • net.sf.jasperreports.engine.fill.JRThreadSubreportRunnerFactory
默认情况下 net.sf.jasperreports.engine.fill.JRThreadSubreportRunnerFactory是 使用,但是如果 net.sf.jasperreports.engine.fill.JRContinuationSubreportRunnerFactory 设置后,将使用Javaflow方法填充报告 而不是线程。如果选择此选项,则雅加达 Commons Javaflow jar必须包含在应用程序类路径中。 这个jar可以在JasperReport报告的lib目录中找到 项目分发包。jasperreports-javaflow.properties 文件说明了如何在实际应用程序中设置此属性 实施在中处理不同查询的其他备选方案 相同的报告是List元素和子数据集的用法