简体   繁体   English

如何使用JAVA获取Crystal Reports参数名称

[英]How to get crystal reports parameter names with JAVA

I have to create reports dinamically in my Java App. 我必须在Java App中动态创建报告。

I have a CrystalReport's (.rpt) collection so it depends which rpt you select. 我有一个CrystalReport(.rpt)集合,所以它取决于您选择的rpt。 When you select a report I have to create a new Window with requeried parameters from "file.rpt", so I need the parameters names to decide what kind of parameters user should to complete. 选择报告时,我必须使用“ file.rpt”中重新查询的参数创建一个新窗口,因此我需要使用参数名称来确定用户应完成的参数类型。

I was looking in forums and I couldn't find anything. 我在论坛上找东西,但找不到任何东西。

Thanks! 谢谢!

Try this! 尝试这个!

DatabaseController dbController = reportClientDocument.getDatabaseController();
        Tables tables = dbController.getDatabase().getTables();
        ITable table = tables.getTable(0);
        IProcedure command = (IProcedure)table;
        if(table instanceof com.crystaldecisions.sdk.occa.report.data.CommandTable) {

            for (int i=0; i< command.getParameters().size(); i++) {
                ParameterField commandParam = (ParameterField) command.getParameters().get(i);
                String paramName = commandParam.getName();
                String paramType = commandParam.getType().toString().substring(4);
                if(paramType.equalsIgnoreCase("decimal")){
                    paramType = "int";
                }
                paramType = paramType.toLowerCase();
                listOfParameter.put(paramName, paramType);
             }
            return listOfParameter;
        }
    ParameterFieldController paramFieldController = reportClientDoc.getDataDefController().getParameterFieldController();

        for(Entry<String,Object> par : parametros.entrySet()) {
            paramFieldController.setCurrentValue("", par.getKey(), par.getValue()); 
        }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM