0

我从这个插件的文档中实现了这个例子,但是我有一个异常指出参数 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 中找到这个参数,但没有类似的东西。我究竟做错了什么?

4

1 回答 1

2

它不是发射器的参数。此异常意味着在报告“new_report_1.rptdesign”中定义了名为“Initiator”的报告参数,并检查了其属性“required”。

例如编辑报告设计,禁用此参数的“必需”并设置默认值。

于 2014-06-19T07:23:21.170 回答