在iReport中链接子报表,这样他们也可以在Jasper服务器上工作 [英] Linking subreports in iReport so they also work in Jasper server

查看:127
本文介绍了在iReport中链接子报表,这样他们也可以在Jasper服务器上工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

将iReport v4.0.1与Jasperserver v4.1.0配合使用我试图找到将子报表链接到主报表的语法,让我在iReport中进行测试,然后通过存储库浏览器部署到服务器。

Using iReport v4.0.1 with Jasperserver v4.1.0 I'm trying to find a syntax for linking subreports to the main report that lets me test it in iReport then deploy to the server through the repository browser.

对于子报表表达式,iReport中的子报表的默认语法类似于

The default syntax for sub-reports in iReport for the subreport expression is something like

$P{SUBREPORT_DIR} + "mySubReport.jasper"

当您从iReport部署它时,它足够聪明选择它,并建议将其更改为

When you deploy this from iReport it's smart enough to pick this up and suggest changing it to

"repo:mySubReport.jrxml"

,然后将所有子报表部署到主报表的资源文件夹。

and to then deploy all subreports to the Resources folder of the main report.

很棒,但是遗憾的是,它在iReport中编辑文件以保存此更改,这意味着您无法再在iReport中运行报告,而无需手动重新编辑所有子 - 报表表达式 - 这使得测试和部署到服务器的过程真的很痛苦,特别是当报表中有多个子报表时。

That's great, but unfortunately it then edits the file in iReport to save this change which means you can no longer run the report in iReport without manually re-editing all the sub-report expressions - this makes the process of testing and deploying to the server really painful, particularly when there are multiple sub-reports in a report.

我以为我可以最少将$ P {SUBREPORT}的值设置为repo:或My\local\filepath,以至于我只有一个地方可以更改它,但是编译器不喜欢这样做。

I thought I could at least set the value of $P{SUBREPORT} to be "repo:" or "My\local\filepath" so that at least I'd only have one place to change it, but the compiler doesn't like that.

是否有替代结构或表达式将根据您所在的位置正确解析为:* .jrxml或My\local\filepath * .jasper运行报告?

Is there an alternative structure or an expression that will resolve to repo:*.jrxml or My\local\filepath*.jasper correctly depending on where you're running the report from?

推荐答案

最好的解决方案是添加一个额外的参数,如 $ P {IsOnServer} 。将默认值设置为 true 。对于您的子报表表达式,请使用以下命令:

The best solution to this is to add an additional parameter like $P{IsOnServer}. Set the default value to true. For your subreport expression use this:

$P{IsOnServer} ? "repo:mySubReport.jrxml" : "/local/path/to/mySubReport.jasper"

您在iReport中运行报告,系统将提示您输入IsOnServer的值。使它虚伪子报表表达式将解析为您的本地文件。在服务器上,不要定义输入控件。用户永远不会被提示参数(他们甚至不知道它存在),并且将导致所需的repo语法。

When you run the report in iReport, you'll be prompted for the value of IsOnServer. Make it false; the subreport expression will resolve to your local file. On the server, don't define an input control. The users will never be prompted for that parameter (they won't even know it exists), and it will result to the desired 'repo' syntax.

更好的解决方案当然是为了iReport来自动处理...但现在你需要做这样的事情。

An even better solution would of course be for iReport to handle this automatically... but for now you need to do something like this.

这篇关于在iReport中链接子报表,这样他们也可以在Jasper服务器上工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆