How to get crystal reports parameter names with JAVA

断了今生、忘了曾经 提交于 2020-01-06 08:19:06

问题


I have to create reports dinamically in my Java App.

I have a CrystalReport's (.rpt) collection so it depends which rpt you select. 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.

I was looking in forums and I couldn't find anything.

Thanks!


回答1:


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;
        }



回答2:


    ParameterFieldController paramFieldController = reportClientDoc.getDataDefController().getParameterFieldController();

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


来源:https://stackoverflow.com/questions/12915472/how-to-get-crystal-reports-parameter-names-with-java

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!