10

有人曾经在桌面应用程序中使用过 BIRT 报告吗?我来自 .NET 环境,您可以使用 Crystal Reports 在桌面应用程序中显示报表。BIRT 也可以做到这一点,而无需设置服务器环境吗?

你能给我一些建议如何实现这个目标吗?

提前致谢。

4

6 回答 6

5

如果您的桌面应用程序是使用 Eclipse Rich Client Platform (RCP) 编写的,那么添加报告是很简单的。您需要做的就是添加 org.eclipse.birt.viewer 插件然后使用它。

这是一篇解释它的文章:http: //digiassn.blogspot.com/2008/08/birt-launch-birt-rcp-application.html

于 2009-04-30T00:29:07.413 回答
4

有一个 BIRT 运行时允许您从命令行生成报告。阅读这篇文章。这将允许您在没有服务器的情况下使用 BIRT。最初在这里注明是对我自己的问题的回答

于 2008-11-19T17:43:27.460 回答
2

对的,这是可能的。我在大约 1-2 年前做的一个项目中使用了它,所以我必须向您提供详细信息。(尽管从那时起事情可能会发生变化)

这是我需要的插件:

<?xml version="1.0" encoding="UTF-8"?>
<classpath>
    <classpathentry kind="src" path="src"/>
    <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
    <classpathentry kind="var" path="JUNIT_HOME/junit.jar" sourcepath="JUNIT_SRC_HOME/junitsrc.zip"/>
    <classpathentry kind="lib" path="lib/log4j-1.2.14.jar"/>
    <classpathentry kind="lib" path="lib/swt.jar"/>
    <classpathentry kind="con" path="SWT_CONTAINER"/>
    <classpathentry kind="lib" path="org.eclipse.birt.chart_2.1.2.v20070205-1728.jar"/>
    <classpathentry kind="lib" path="org.eclipse.birt.chart.device.extension_2.1.2.v20070205-1728.jar"/>
    <classpathentry kind="lib" path="org.eclipse.birt.chart.device.swt_2.1.1.v20070205-1728.jar"/>
    <classpathentry kind="lib" path="org.eclipse.birt.chart.engine_2.1.2.v20070205-1728.jar" sourcepath="C:/Programme/eclipse/plugins/org.eclipse.birt.chart.source_2.2.0.v20070209/src"/>
    <classpathentry kind="lib" path="org.eclipse.birt.chart.engine.extension_2.1.2.v20070205-1728.jar"/>
    <classpathentry kind="lib" path="org.eclipse.birt.chart.runtime_2.1.2.v20070205-1728.jar"/>
    <classpathentry kind="lib" path="org.eclipse.birt.core_2.1.2.v20070205-1728.jar"/>
    <classpathentry kind="lib" path="org.eclipse.emf.common_2.2.1.v200609210005.jar"/>
    <classpathentry kind="lib" path="org.eclipse.emf.ecore_2.2.1.v200609210005.jar"/>
    <classpathentry kind="lib" path="org.eclipse.emf.ecore.xmi_2.2.1.v200609210005.jar"/>
    <classpathentry kind="lib" path="js.jar"/>
    <classpathentry kind="lib" path="com.ibm.icu_3.4.5.jar"/>
    <classpathentry kind="lib" path="org.eclipse.birt.chart.ui_2.1.1.v20070205-1728.jar"/>
    <classpathentry kind="lib" path="org.eclipse.birt.chart.ui.extension_2.1.2.v20070205-1728.jar"/>
    <classpathentry kind="lib" path="lib/hsqldb.jar"/>
    <classpathentry kind="output" path="bin"/>
</classpath>
于 2008-10-28T13:12:15.310 回答
1

对的,这是可能的。是一些一般性的描述。我已经在服务器环境中使用过 Birt,但据我所知,有一个 RenderContext 接口,您可以通过该接口以您想要的方式呈现您的报告。

于 2008-10-28T13:15:45.647 回答
0

这是可能的,您可以轻松地在 JeditorPane 中创建报告的预览,您必须下载 BIRT Runtime,然后您可以尝试在 Eclipse 论坛上发布此帖子中的示例代码。

于 2011-09-02T18:44:06.480 回答
0
package com.passport;

import java.io.FileOutputStream;
import java.util.Collection;
import java.util.Iterator;


import org.eclipse.birt.core.framework.Platform;
import org.eclipse.birt.report.engine.api.EngineConfig;
import org.eclipse.birt.report.engine.api.IGetParameterDefinitionTask;
import org.eclipse.birt.report.engine.api.IParameterDefnBase;
import org.eclipse.birt.report.engine.api.IRenderOption;
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.api.RenderOption;

public class EngineReport {
    private static final long serialVersionUID = 1L;       
    private IReportEngine engine=null; 
    private EngineConfig engineconfig = null;
    private IReportEngineFactory factory = null;
    private String sourceReport;
    private String locationReport;
    private String reportRealPath = "";

public static void main(String[] args){
    EngineReport engineReport = new EngineReport();
    engineReport.save("src/com/passport/report.rptdesign","c:/tmp/rep.doc");
}

private void save(String sourceReport, String locationReport) {

    this.sourceReport = sourceReport;
    this.locationReport = locationReport;
    IReportRunnable design = null;
    IRenderOption options = null;
    try {
        String reportFormat = locationReport.substring(locationReport.lastIndexOf('.')+1);
        sourceReport = "src/com/passport/report.rptdesign";
        if ((sourceReport != null && (sourceReport.length() > 0)) ) {

            engineconfig = new EngineConfig();
            reportRealPath = "";  
            Platform.startup(engineconfig);
            factory = (IReportEngineFactory) Platform.createFactoryObject(IReportEngineFactory.EXTENSION_REPORT_ENGINE_FACTORY);            
            engine = factory.createReportEngine(engineconfig);
            design = engine.openReportDesign(reportRealPath+sourceReport);          
            IRunAndRenderTask task = engine.createRunAndRenderTask(design);     

            IGetParameterDefinitionTask taskParam = engine.createGetParameterDefinitionTask( design );
            Collection<?> params = taskParam.getParameterDefns( false );
            String paramName = null;
            Iterator<?> iterOuter = params.iterator( );
            while ( iterOuter.hasNext( ) ) {
                IParameterDefnBase param = (IParameterDefnBase) iterOuter.next( );
                paramName = param.getName( );                   
                if (paramName.equalsIgnoreCase("PR_SOME_PARAM")) {
                    task.setParameterValue(paramName,"someparam");
                }                   
                else if (paramName.equalsIgnoreCase("PR_SOME_PARAM_2")) {
                    task.setParameterValue(paramName,"someparam2");
                }
            }               
            options = new RenderOption();           
            options.setOutputFormat(reportFormat);

            FileOutputStream fos = new FileOutputStream(locationReport);
            options.setOutputStream(fos);
            task.setRenderOption(options);
            task.run();
            task.close();
            engine.destroy();
            fos.close();

        }
    } catch(Exception e) {
        System.out.println(e.toString());
    }
}

}

于 2014-01-10T07:14:26.270 回答