English 中文(简体)
您如何设置参数并将其传送到 BIRT 报告设计师通过 BIRT API 创建的 BIRT 报告?
原标题:How do you set and pass a parameter to a BIRT report created by the BIRT Report Designer through the BIRT API?

我创建了一个简单的报告, 使用单一参数。 当直接在报告设计师中执行时, 此参数在查询中被使用, 并且执行罚款 。 这样我就不会为本报告使用 javascript 或任何脚本 。 我在这里见过一些人试图使用脚本和/ 或 javascripts 来通过参数来解答答案, 但这不是我正在做的。 我通过 java 将我的所有参数都通过。 继续, 在报告中我正在列出活跃/ 不活跃的项目 。 我通过 N 来列出不活动的项目和 Y 来列出活动的项目 。 当我试图通过 API 的参数时, 我总是会得到一个活动项目的列表, 不管我通过了什么 。 以 Y 为方式, 我试图遵循此链接的提示以及如何设定参数 。

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();
        }
        }
    }
最佳回答

您需要设置 IRunandRender Task 上的参数 :

IRunAndRenderTask task =
    engine.createRunAndRenderTask(reportRunnable);
Map< String, Object > birtParams = ...;
task.setParameterValues( birtParams );
问题回答

暂无回答




相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签