新手的子报告输出为空白 [英] Output for Subreports is blank for Newbie
问题描述
我正在尝试在 Jaspersoft Studio 5.5中创建子报告。我的表格结构如下:
I'm trying to create Sub Report in Jaspersoft Studio 5.5. My table structure is like below:
DEPT(DEPTNO,DNAME,LOC)
DEPT(DEPTNO, DNAME, LOC)
EMP(EMPNO,ENAME ,SAL,DEPTNO)
EMP(EMPNO, ENAME, SAL, DEPTNO)
主报告名称: MainReport.jrxml
Sub报告名称: SubReport.jrxml
我试过如下。
-
通过传递DeptNo的参数在主报表中创建了一行。
Created one row in the "Main Report" by passing parameter for DeptNo.
现在,从Palette中拖出子报表组件到主报告。
Now, Dragged Subreport component from Palette on to the main report.
从子报告向导中选择创建新报告选项。
Selected "Create a new report" option from "Subreport" wizard.
尝试编写以下查询以从Active Department获取Employees。 问题从此开始。我无法理解如何提供参数以获取父DEPTNO
Tried to write the below query to get Employees from the Active Department. Problem started from here onwards. I could not understand how to supply the parameter to get the parent DEPTNO
从EMP中选择EMPNO,ENAME,SALARY DEPTNO = 10
在上面的代码中,我刚刚硬编码 DEPTNO = 10
以完成查询。 这是我希望专家支持知道如何用参数
In the above code, I've Just hard coded DEPTNO = 10
to complete the query. This is where I want support from experts to know how to replace DEPTNO = 10
with the parameter
推荐答案
假设您有一个带有promted参数的主报表,并且您希望将其传递到子报表,那么在创建子报表时 - 在参数部分 - 您有添加该参数(除了默认值)以使其对子报表可见。
Assuming that you have a main report with a promted parameter and you want to "pass" it to the subreport, when you create the subreport - in the parameters section - you have to add that parameter (in addition to the defaults) in order to make it "visible" to the subreport.
EXTRA:如果活动部门是你从查询中获得的东西(比如说从DEPT中选择deptno,其中active =Y),你应该将THAT VALUE($ F {DEPTNO})作为参数传递给子报告。
然后在子报表查询中,您必须使用参数替换您的硬编码值,如下所示:
Then in the subreport query, you have to replace your hardcoded value with the parameter, something like this:
SELECT EMPNO, ENAME, SALARY
FROM EMP
WHERE DEPTNO = $P{YOUR_PARAMETER}
也许 jaspersoft社区的这个教程可以直观地帮助你。
Maybe this tutorial from jaspersoft community could visually help you.
这篇关于新手的子报告输出为空白的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!