9

1 つのパラメーターを受け取る単純なレポートを作成しました。このパラメーターはクエリで使用され、レポート デザイナーで直接実行すると正常に実行されます。ところで、私はこのレポートに JavaScript やスクリプトを使用していません。ここで回答を得るためにスクリプトや JavaScript を使用してパラメーターを渡そうとしている人を見てきましたが、これは私がやっていることではありません。すべてのパラメーターを Java 経由で渡します。引き続き、このレポートではアクティブ/非アクティブなアイテムをリストしています。非アクティブなアイテムをリストする場合は「N」を、アクティブなアイテムをリストする場合は「Y」を渡します。API を介してパラメーターを渡そうとすると、渡した内容に関係なく、常にアクティブなアイテムのリストを取得します。ところで、'Y' は渡されたパラメーターのデフォルト値です。以下のコード) 問題 I' 私が持っているのは、レポートが私が設定したパラメーターを取りたがっていないように見えるということです。はい、渡された変数の値は変更されますが、レポートには変更が反映されません。私のコードは以下です。このリンクのアドバイスとパラメーターの設定方法に従おうとしました。

http://www.eclipsezone.com/eclipse/forums/t67723.html

リンクに移動した場合は、#4 に移動して、実行するタスクのリストを参照してください。これは私が従おうとしたものです。私は何かが欠けているかもしれないと感じています。これがうまくいったら、私が見逃しているものについてアドバイスをいただけますか? どうもありがとう!

-デール

    public class ReportGenerator {
        public static void main(String args[]) throws Exception{
        ReportGenerator rg = new ReportGenerator();
        rg.executeReport("N");
        }


        @SuppressWarnings({ "unchecked", "deprecation" })
        public void executeReport(String activeIndicator) throws EngineException {

        IReportEngine engine=null;
        EngineConfig config = null;

        try{
            config = new EngineConfig( );            
            config.setBIRTHome("C:\\birt-rcp-report-designer-3_7_2\\ReportEngine");
            config.setLogConfig("c:/temp/test", Level.FINEST);
            Platform.startup( config );
            IReportEngineFactory factory = (IReportEngineFactory) Platform.createFactoryObject( IReportEngineFactory.EXTENSION_REPORT_ENGINE_FACTORY );
            engine = factory.createReportEngine( config );        


            IReportRunnable reportDesign = null;
            reportDesign = engine.openReportDesign("C:\\workspace\\SimpleReport\\ReportTemplates\\ItemListingReport.rptdesign"); 
            IRunAndRenderTask task = engine.createRunAndRenderTask(reportDesign);
            IGetParameterDefinitionTask parameterDefinitionTask = engine.createGetParameterDefinitionTask(reportDesign);
            parameterDefinitionTask.evaluateDefaults();
            HashMap<String, String> params = parameterDefinitionTask.getDefaultValues();
            params.put("aIndicator", activeIndicator);
            parameterDefinitionTask.setParameterValues(params);

            ConnectionHelper connectionHelper = new ConnectionHelper();
            task.getAppContext().put("OdaJDBCDriverPassInConnection", connectionHelper.getConnection());

            PDFRenderOption options = new PDFRenderOption();
            options.setOutputFormat("pdf");
            options.setOutputFileName("C:\\workspace\\SimpleReport\\output\\itemListingReport.pdf");

            task.setRenderOption(options);

            task.run();
            task.close();
            engine.destroy();
        } catch (Exception ex) {
            ex.printStackTrace();
        } finally {
            Platform.shutdown();
        }
        }
    }
4

1 に答える 1

11

IRunAndRenderTask でパラメーターを設定する必要があります。

IRunAndRenderTask task =
    engine.createRunAndRenderTask(reportRunnable);
Map< String, Object > birtParams = ...;
task.setParameterValues( birtParams );
于 2012-05-25T08:18:38.560 に答える