Jasper reports JasperReports:子报表呈现
我在应用程序中使用带有SpringMVC的JasperReports进行报告。 基本上,我首先在iReport 4.1.1中设计报告,然后通过jasper-view.xml将生成的.jasper文件放在我的类路径中 当请求到来时,控制器将会话中所需的参数放入参数映射并生成报告 在我的主报告中大约有15个子报告。 在所有这些报告中,仅打印符合条件(作为参数传递)的报告(通过带区的“打印时间”选项控制) 我的问题是:如果我的报告不被打印,它是否会被执行(即其中的查询)? 还是干脆跳过 我问这个问题的原因是生成报告需要相当长的时间(大约2秒,据我所知,这对于我的应用程序来说太长了)Jasper reports JasperReports:子报表呈现,jasper-reports,ireport,Jasper Reports,Ireport,我在应用程序中使用带有SpringMVC的JasperReports进行报告。 基本上,我首先在iReport 4.1.1中设计报告,然后通过jasper-view.xml将生成的.jasper文件放在我的类路径中 当请求到来时,控制器将会话中所需的参数放入参数映射并生成报告 在我的主报告中大约有15个子报告。 在所有这些报告中,仅打印符合条件(作为参数传递)的报告(通过带区的“打印时间”选项控制) 我的问题是:如果我的报告不被打印,它是否会被执行(即其中的查询)? 还是干脆跳过 我问这个问题的
谢谢 如果您查看“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);
}
}
您需要研究的是子报表的使用如何影响性能和内存使用。看起来主报表中嵌入的子报表太多了。这里有一些来自这个:
子报表是否存在性能问题?
答案取决于您的系统、数据源和报告
设计。子报告中需要注意的几点:
- 每个子报表执行都可能产生一个新线程(见下文)
- 随着子报表的执行,将在堆内存中创建更多的对象
- net.sf.jasperreports.engine.fill.JRContinuationSubreportRunnerFactory
- net.sf.jasperreports.engine.fill.JRThreadSubreportRunnerFactory
如果您查看“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);
}
}
您需要研究的是子报表的使用如何影响性能和内存使用。看起来主报表中嵌入的子报表太多了。这里有一些来自这个:
子报表是否存在性能问题?
答案取决于您的系统、数据源和报告
设计。子报告中需要注意的几点:
- 每个子报表执行都可能产生一个新线程(见下文)
- 随着子报表的执行,将在堆内存中创建更多的对象
- net.sf.jasperreports.engine.fill.JRContinuationSubreportRunnerFactory
- net.sf.jasperreports.engine.fill.JRThreadSubreportRunnerFactory