如何使用JAVA获取Crystal报表参数名称 [英] How to get crystal reports parameter names with JAVA

查看:409
本文介绍了如何使用JAVA获取Crystal报表参数名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须在我的Java应用程序中以dinamically的方式创建报告。



我有一个CrystalReport的(.rpt)集合,所以它取决于你选择哪个rpt。当你选择一个报表时,我必须从file.rpt中创建一个带有请求的参数的新窗口,所以我需要参数名来决定用户应该完成什么样的参数。



我在论坛中找不到任何东西。



谢谢!

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

for(int i = 0; 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;
}


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!

解决方案

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

这篇关于如何使用JAVA获取Crystal报表参数名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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