How do i use Birt in a Java Project? [message #701667] |
Mon, 25 July 2011 08:22  |
Eclipse User |
|
|
|
hello,
i want to create a birt report with a simple java application.
i found some code examples on the internet but my problem is, how do i use the classes and methods?
i thought there would be a libary (jar-file) which i have to include,
but there is not (or i just did not found it)
is there an other way how to include the classes and methods which i need to create a birt report in a java project?
thx!
|
|
|
|
(no subject) [message #701784 is a reply to message #701783] |
Mon, 25 July 2011 11:21  |
Eclipse User |
|
|
|
BTW the code sample was for BIRT 3.7.
Jason
On 7/25/2011 11:20 AM, Jason Weathersby wrote:
> To build a simple Java application just add the jars from the
> reportruntime download to your classpath. If you are using Eclipse to
> build the application use these steps.
> 1 - download the birt runtime
> 2 - create a new java project in Eclipse
> 3 - right click on the project in the Package view and select Build
> Path->configure build path.
> 4 - Select the libraries tab and click on the add external Jars.
> 5 - Add all the jars from the birtruntime download/reportengine/lib
> directory.
> 6 - create your class. For example look at the following.
>
> package REAPI;
>
>
>
> import java.util.logging.Level;
>
> import org.eclipse.birt.core.framework.Platform;
> import org.eclipse.birt.report.engine.api.EXCELRenderOption;
> import org.eclipse.birt.report.engine.api.EngineConfig;
> import org.eclipse.birt.report.engine.api.EngineConstants;
> import org.eclipse.birt.report.engine.api.EngineException;
> import org.eclipse.birt.report.engine.api.HTMLRenderOption;
> 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.PDFRenderOption;
>
>
> public class RunAndRenderTask {
>
> public void runReport() throws EngineException
> {
>
> IRunAndRenderTask task=null;
> IReportEngine engine=null;
> EngineConfig config = null;
>
> try{
> config = new EngineConfig( );
> config.setLogConfig("c:/dwn", Level.SEVERE);
> Platform.startup( config );
>
> IReportEngineFactory factory = (IReportEngineFactory) Platform
> .createFactoryObject(
> IReportEngineFactory.EXTENSION_REPORT_ENGINE_FACTORY );
> engine = factory.createReportEngine( config );
>
>
> IReportRunnable design = null;
> //Open the report design
>
> design = engine.openReportDesign("Reports/TopNPercent.rptdesign");
> task = engine.createRunAndRenderTask(design);
> task.setParameterValue("Top Count", (new Integer(5)));
> task.validateParameters();
>
>
> HTMLRenderOption options = new HTMLRenderOption();
> options.setImageDirectory("./");
> options.setOutputFileName("output/resample/out.html");
> options.setOutputFormat("html");
>
>
> task.setRenderOption(options);
> task.run();
> task.close();
> engine.destroy();
> }catch( Exception ex){
> ex.printStackTrace();
> }
> Platform.shutdown( );
> System.out.println("Finished");
>
> }
>
>
> /**
> * @param args
> */
> public static void main(String[] args) {
> try
> {
>
> RunAndRenderTask ex = new RunAndRenderTask( );
> ex.runReport();
>
> System.exit(0);
>
> }
> catch ( Exception e )
> {
> e.printStackTrace();
> }
> }
> }
>
>
> A couple of extras to note. The openReportDesign method in the above
> example is looking for a report named TopNPercent.rptdesign in a folder
> in the project named Reports. You could specify the complete path to a
> report instead. The output file out.html is generating the report in a
> folder in the project named output. A full path could have been used as
> well. Finally, if you want to the code to run multiple reports only
> start up the platform once and just create new task for each report.
>
> Jason
>
>
> On 7/25/2011 8:22 AM, fixed-term.georgios.mavridis wrote:
>> hello,
>>
>> i want to create a birt report with a simple java application.
>>
>> i found some code examples on the internet but my problem is, how do i
>> use the classes and methods?
>>
>> i thought there would be a libary (jar-file) which i have to include,
>> but there is not (or i just did not found it)
>>
>> is there an other way how to include the classes and methods which i
>> need to create a birt report in a java project?
>>
>> thx!
>
|
|
|
Powered by
FUDForum. Page generated in 0.03806 seconds