Java Crystal Report SDK - 报表和子报告
我正在尝试使用 Java 中的 Crystal Report SDK 生成一个由主报表和子报表组成的报表.
I'm trying to generate a report using Crystal Report SDK in Java composed by a main report and a subreport.
我只想在我的存储过程返回某些内容时生成报告,为此我手动执行 proc 并仅在我的 ResultSet != null 时启动报告生成.
I do want to generate the report only if there is something returns by my stored procedure and for doing that I execute the proc manually and launch the report generation only if my ResultSet != null.
但是,我的子报表必须通过 Crystal 生成.
But, my subreport has to be generated through Crystal.
- 我将 setTablesDatasource() 方法用于我的主报告以使用我的 ResultSet
- 对于我的子报告:
_ 我使用 setTableslocation() 获取值并通过水晶生成报告
_ I use the setTableslocation() for getting the values and generating the report through crystal
_ 我在子报表的 ParameterFieldController 中设置了所有需要的参数.
_ I set all the parameters needed in the ParameterFieldController of my subreport.
但是,我在控制台中收到此错误:
However, I'm getting this error in my console :
缺少参数值.---- 错误代码:-2147217394 错误代码名称:missingParameterValueError
Missing parameter values.---- Error code:-2147217394 Error code name:missingParameterValueError
即使子报表的参数设置正确.
Even though the subreport's parameters are correctly setted.
如果我生成我的报告时没有子报告或报告并且不需要参数,那么生成就可以了.
If I generate my report with no subreport or with report and no needed parameter, the generation is just fine.
我是否以错误的方式设置参数?
Am I setting my parameters in a wrong way ?
推荐答案
在尝试了很多东西来集成我的子报表而不使用另一个 ResultSet 之后,这里是设置子报表参数的方法:
After trying a lot of stuff for integrating my subreport without using another ResultSet, here is the way for setting the parameters for the subreport :
您必须使用主报表的 ParameterFieldController 而不是子报表的...逻辑.
You have to use the ParameterFieldController of the main report and not the one of the subreport... Logic.
ParameterFieldController paramFieldController =rptClientDoc.getDataDefController().getParameterFieldController();paramFieldController.setCurrentValue(subreport_name, parameter_name,参数值);
ParameterFieldController paramFieldController = rptClientDoc.getDataDefController().getParameterFieldController(); paramFieldController.setCurrentValue(subreport_name, parameter_name, parameter_value);
现在,它工作得很好!
相关文章