【问题标题】:Could not generate BIRT Report using spudsoft-birt-excel-emitters - Error.InvalidEmitterID无法使用 spudsoft-birt-excel-emitters 生成 BIRT 报告 - Error.InvalidEmitterID
【发布时间】:2017-06-05 02:00:15
【问题描述】:

我正在使用 BIRT 运行时引擎 4.2.1 并关注此 link。

1.我已将以下 jar 移至 birt-runtime-4_2_1\ReportEngine\lib 文件夹。 uk.co.spudsoft.birt.emitters.excel_0.8.0.201310230652 commons-codec-1.5 dom4j-1.6.1 poi-3.9-20121203 poi-ooxml-3.9-20121203 poi-ooxml-schemas-3.9-20121203 slf4j-api-1.6.2 stax-api-1.0.1 xmlbeans-2.3.0 2.修改代码使用spudsoft发射器。`public class RunReport {

public static void runReport() throws Exception {

    IReportEngine engine = null;
    EngineConfig config = new EngineConfig();        
    config.setEngineHome("C:/BIRT/BIRT_2_6_1/birt-runtime-4_2_1/birt-runtime-4_2_1/ReportEngine");
     Platform.startup(config);        
    IReportEngineFactory factory = (IReportEngineFactory) Platform
            .createFactoryObject(IReportEngineFactory.EXTENSION_REPORT_ENGINE_FACTORY);        
    engine = factory.createReportEngine(config);
    IReportRunnable design = engine.openReportDesign("C:/reports/csvReport2.rptdesign");
    IRunAndRenderTask task = engine.createRunAndRenderTask(design);     
    IRenderOption options = new RenderOption(); 
    options.setOutputFormat("xls");
    options.setOutputFileName("C:/reports/native.xls");
    options.setEmitterID( "uk.co.spudsoft.birt.emitters.excel.XlsEmitter" );
    task.setRenderOption(options);     
    task.run();
    task.close();

    Platform.shutdown();
    System.out.println("Report Generated Sucessfully!!");
}`

执行报告时出现以下错误。

Jun 05, 2017 9:32:33 AM org.eclipse.birt.report.engine.api.impl.EngineTask setupRenderOption
SEVERE: Error.InvalidEmitterID
org.eclipse.birt.report.engine.api.EngineException: EmitterID uk.co.spudsoft.birt.emitters.excel.XlsEmitter for render option is invalid.
    at org.eclipse.birt.report.engine.api.impl.EngineTask.setupRenderOption(EngineTask.java:2022)
    at org.eclipse.birt.report.engine.api.impl.RunAndRenderTask.doRun(RunAndRenderTask.java:96)
    at org.eclipse.birt.report.engine.api.impl.RunAndRenderTask.run(RunAndRenderTask.java:77)
    at RunReport.runReport(RunReport.java:49)
    at RunReport.main(RunReport.java:58)
Picked up _JAVA_OPTIONS:  -Xmx512M

有没有我遗漏的步骤或配置!

注意:我正在尝试将 spudsoft 发射器与默认发射器一起使用,在打开 excel 时出现错误提示下方。

File format and extension of 'orders.xls' don't match. The file could be corrupted or unsafe. Unless you trust its source, don't open it. Do you want to open it anyway?

【问题讨论】:

    标签: java excel eclipse birt birt-emitter


    【解决方案1】:

    我已经做了一些更改以使其正常工作!

    第一步更改代码 - 将默认 IRenderOption 替换为 EXCELRenderOption

    import org.eclipse.birt.core.framework.Platform;
    import org.eclipse.birt.report.engine.api.*;
    public class RunReport {    
        public static void runReport() throws Exception {        
            IReportEngine engine = null;
            EngineConfig config = new EngineConfig();        
            config.setEngineHome("C:/Projects/My Works Related/BIRT/BIRT_2_6_1/birt-runtime-4_2_1/birt-runtime-4_2_1/ReportEngine");
             Platform.startup(config);        
            IReportEngineFactory factory = (IReportEngineFactory) Platform
                    .createFactoryObject(IReportEngineFactory.EXTENSION_REPORT_ENGINE_FACTORY);        
            engine = factory.createReportEngine(config);
            IReportRunnable design = engine.openReportDesign("C:/Projects/My Works Related/Backup From My System and Proton/Backup from Proton/SEM/rk/rk/birt-runtime-Eclipse _workspace2_6_2/eclipse-reporting-helios-SR2-win32/workSpace/ExecuteCSVReport/reports/csvReport2.rptdesign");
            IRunAndRenderTask task = engine.createRunAndRenderTask(design);     
            EXCELRenderOption excelOptions = new EXCELRenderOption();
            excelOptions.setOutputFormat("xls");
            excelOptions.setOutputFileName("C:/Projects/My Works Related/Backup From My System and Proton/Backup from Proton/SEM/rk/rk/birt-runtime-Eclipse _workspace2_6_2/eclipse-reporting-helios-SR2-win32/workSpace/ExecuteCSVReport/reports/native.xls");
            excelOptions.setEmitterID( "uk.co.spudsoft.birt.emitters.excel.XlsEmitter" );
            task.setRenderOption(excelOptions);     
            task.run();
            task.close();        
            Platform.shutdown();
            System.out.println("Report Generated Sucessfully!!");
        }
        public static void main(String[] args) {
            try {
                runReport();
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }
    

    第二步删除org.eclipse.birt.runtime_4.2.1.v20120918-1113.jar中的poi目录,放在birt-runtime-4_2_1\ReportEngine\lib路径下,解决POI冲突问题。

    【讨论】:

      【解决方案2】:

      看我用你需要的 4.4.2 版本的 spudsoft 发射器;

      excelOptions.setOutputFormat("xls_spudsoft");
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2013-03-12
        • 2013-12-20
        • 1970-01-01
        • 2014-09-26
        相关资源
        最近更新 更多