BIRT csv发射器插件错误:未设置必需参数Initiator

时间:2014-06-19 07:17:11

标签: java birt birt-emitter

我在this plugin的文档中实现了示例,但我有一个例外,说明错过了参数Initiator。我根本没有看到这个参数。 我的代码是:

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.util.logging.Level;
import org.eclipse.birt.core.exception.BirtException;
import org.eclipse.birt.core.framework.Platform;
import org.eclipse.birt.report.engine.api.EngineConfig;
import org.eclipse.birt.report.engine.api.IReportEngine;
import org.eclipse.birt.report.engine.api.IReportEngineFactory;
import org.eclipse.birt.report.engine.api.IReportRunnable;
import org.eclipse.birt.report.engine.api.IRunAndRenderTask;
import org.eclipse.birt.report.engine.emitter.csv.CSVRenderOption;

public class RunExport {
    static void runReport() throws FileNotFoundException, BirtException {
        String resourcePath = "C:\\Users\\hpsa\\workspace\\My Reports\\";
        FileInputStream fs = new FileInputStream(resourcePath + "new_report_1.rptdesign");
        IReportEngine engine = null;
        EngineConfig config = new EngineConfig();
        config.setLogConfig("C:\\birtre\\", Level.FINE);
        config.setResourcePath(resourcePath);
        Platform.startup(config);
        IReportEngineFactory factory = (IReportEngineFactory) Platform.createFactoryObject(IReportEngineFactory.EXTENSION_REPORT_ENGINE_FACTORY);
        engine = factory.createReportEngine(config);
        engine.changeLogLevel(Level.FINE);
        IReportRunnable design = engine.openReportDesign(fs);
        IRunAndRenderTask task = engine.createRunAndRenderTask(design);
        CSVRenderOption csvOption = new CSVRenderOption();
        String format = CSVRenderOption.OUTPUT_FORMAT_CSV;
        csvOption.setOutputFormat(format);
        csvOption.setOutputFileName("newBIRTcsv.csv");
        csvOption.setShowDatatypeInSecondRow(true);
        csvOption.setExportTableByName("SecondTable");
        csvOption.setDelimiter("\t");
        csvOption.setReplaceDelimiterInsideTextWith("-");
        task.setRenderOption(csvOption); 
        task.setEmitterID("org.eclipse.birt.report.engine.emitter.csv");
        task.run();
        task.close();
        Platform.shutdown();
        System.out.println("Report Generated Successfully!!");

    }

    public static void main(String[] args) {
        try {
            runReport();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

我有一个例外:

org.eclipse.birt.report.engine.api.impl.ParameterValidationException: Required parameter Initiator is not set.
    at org.eclipse.birt.report.engine.api.impl.EngineTask.validateAbstractScalarParameter(EngineTask.java:803)
    at org.eclipse.birt.report.engine.api.impl.EngineTask.access$0(EngineTask.java:789)
    at org.eclipse.birt.report.engine.api.impl.EngineTask$ParameterValidationVisitor.visitScalarParameter(EngineTask.java:706)
    at org.eclipse.birt.report.engine.api.impl.EngineTask$ParameterVisitor.visit(EngineTask.java:1531)
    at org.eclipse.birt.report.engine.api.impl.EngineTask.doValidateParameters(EngineTask.java:692)
    at org.eclipse.birt.report.engine.api.impl.RunAndRenderTask.doRun(RunAndRenderTask.java:95)
    at org.eclipse.birt.report.engine.api.impl.RunAndRenderTask.run(RunAndRenderTask.java:77)
    at com.demshin.RunExport.runReport(RunExport.java:44)
    at com.demshin.RunExport.main(RunExport.java:54)

  [1]: https://code.google.com/a/eclipselabs.org/p/csv-emitter-birt-plugin/

我试图在csvOption中找到这个参数,但没有类似的东西。 我做错了什么?

1 个答案:

答案 0 :(得分:2)

它不是发射器的参数。此异常表示名为" Initiator"的报告参数。在报告中定义" new_report_1.rptdesign"及其属性" required"检查。

例如,编辑报告设计,禁用" required"对于此参数,请改为设置默认值。