BIRT in a desktop application
Asked Answered
T

6

10

Did someone ever used a BIRT report in a desktop application. I'm comming from the .NET environment and there you can use Crystal Reports to show reports in desktop apps. Is this possible with BIRT too, without having to set up a server environment?

Can you give me some advice how to reach this goal?

Thanks in advance.

Terminus answered 28/10, 2008 at 13:9 Comment(0)
C
5

If your desktop application is written using the Eclipse Rich Client Platform (RCP) it is trivial to add reporting. All you need to do is add the org.eclipse.birt.viewer plugin and then use it.

Here is an article that explains it: http://digiassn.blogspot.com/2008/08/birt-launch-birt-rcp-application.html

Contribution answered 30/4, 2009 at 0:29 Comment(0)
T
4

There is a BIRT run-time that allows you to generate reports from the command line. Read this article. That will allow you to use BIRT without a server. Originally noted here as an answer to my own question.

Torrence answered 19/11, 2008 at 17:43 Comment(0)
A
2

Yes, it is possible. I used it in a project I did about 1-2 years ago so I'll have to get back to you with the details. (Though things might have changed since then)

Here are the plugins I needed:

<?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>
Agamogenesis answered 28/10, 2008 at 13:12 Comment(0)
R
1

Yes, it is possible. Here is some general description. I've used Birt in server environment though as far as I know there's a RenderContext interface through which you render your reports in the way you want.

Responsible answered 28/10, 2008 at 13:15 Comment(0)
S
0

It is possible and you can easily create a preview of the report in a JeditorPane, you have to download BIRT Runtime and then you can try with the example code posted in this post on Eclipse forum.

Scabious answered 2/9, 2011 at 18:44 Comment(0)
B
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());
    }
}

}

Bedlamite answered 10/1, 2014 at 7:14 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.