Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
Designing Complex Report- DE API
Mknhere
<p>Hi Everyone, </p><p> </p><p>I have the following code to develop the sample/simple birt report , however i would like to have any java sample code for developing complex report with more number of options to implement. </p><p>Can somebody able to help me with this. </p><p> </p><p> </p><p> </p><div>import java.io.IOException;</div><div> </div><div>import org.eclipse.birt.core.exception.BirtException;</div><div>import org.eclipse.birt.core.framework.Platform;</div><div>import org.eclipse.birt.report.engine.api.EngineConfig;</div><div>import org.eclipse.birt.report.engine.api.ReportEngine;</div><div>import org.eclipse.birt.report.model.api.CellHandle;</div><div>import org.eclipse.birt.report.model.api.DesignConfig;</div><div>import org.eclipse.birt.report.model.api.DesignElementHandle;</div><div>import org.eclipse.birt.report.model.api.ElementFactory;</div><div>import org.eclipse.birt.report.model.api.GridHandle;</div><div>import org.eclipse.birt.report.model.api.IDesignEngine;</div><div>import org.eclipse.birt.report.model.api.IDesignEngineFactory;</div><div>import org.eclipse.birt.report.model.api.ImageHandle;</div><div>import org.eclipse.birt.report.model.api.LabelHandle;</div><div>import org.eclipse.birt.report.model.api.ReportDesignHandle;</div><div>import org.eclipse.birt.report.model.api.RowHandle;</div><div>import org.eclipse.birt.report.model.api.SessionHandle;</div><div>import org.eclipse.birt.report.model.api.activity.SemanticException;</div><div> </div><div>import com.ibm.icu.util.ULocale;</div><div> </div><div>/**</div><div>* Simple BIRT Design Engine API (DEAPI) demo.</div><div>*/</div><div> </div><div>public class SimpleCreate</div><div>{</div><div> </div><div>public static void main( String[] args ) throws BirtException</div><div>{</div><div>try</div><div>{</div><div>buildReport( );</div><div>}</div><div>catch ( IOException e )</div><div>{</div><div>e.printStackTrace();</div><div>}</div><div>catch ( SemanticException e )</div><div>{</div><div>e.printStackTrace();</div><div>}</div><div>}</div><div> </div><div>// This function shows how to build a very simple BIRT report with a</div><div>// minimal set of content: a simple grid with an image and a label.</div><div>static void buildReport( ) throws IOException, BirtException</div><div>{</div><div>// Create a session handle. This is used to manage all open designs.</div><div>// Your app need create the session only once.</div><div>// Configure the Engine and start the Platform</div><div> </div><div>System.out.println("Launching report engine");</div><div>// Lancement du moteur de g�n�ration</div><div>DesignConfig config = new DesignConfig();</div><div>config.setBIRTHome("E:BITS WSPCEbirt-runtime-3_7_2birt-runtime-3_7_2ReportEngine");</div><div>Platform.startup(config);</div><div>//DesignConfig config = new DesignConfig( );</div><div> </div><div>//config.setProperty("BIRT_HOME","E:BITS WSPCEbirt-runtime-3_7_2birt-runtime-3_7_2ReportEngine");</div><div>IDesignEngine engine = null;</div><div>try{</div><div> </div><div>Platform.startup(config);</div><div>IDesignEngineFactory factory = (IDesignEngineFactory) Platform</div><div>.createFactoryObject( IDesignEngineFactory.EXTENSION_DESIGN_ENGINE_FACTORY );</div><div>engine = factory.createDesignEngine( config );</div><div> </div><div>}catch( Exception ex){</div><div>ex.printStackTrace();</div><div>} </div><div> </div><div>SessionHandle session = engine.newSessionHandle( ULocale.ENGLISH ) ;</div><div> </div><div>// Create a new report design.</div><div>ReportDesignHandle design = session.createDesign( );</div><div> </div><div>// The element factory creates instances of the various BIRT elements.</div><div>ElementFactory efactory = design.getElementFactory( );</div><div> </div><div>// Create a simple master page that describes how the report will</div><div>// appear when printed.</div><div>//</div><div>// Note: The report will fail to load in the BIRT designer</div><div>// unless you create a master page.</div><div> </div><div>DesignElementHandle element = efactory.newSimpleMasterPage( "Page Master" );</div><div>design.getMasterPages( ).add( element );</div><div> </div><div>// Create a grid and add it to the "body" slot of the report</div><div>// design.</div><div>GridHandle grid = efactory.newGridItem( null, 2 /* cols */, 1 /* row */ );</div><div>design.getBody( ).add( grid );</div><div> </div><div>// Note: Set the table width to 100% to prevent the label</div><div>// from appearing too narrow in the layout view.</div><div>grid.setWidth( "100%" );</div><div> </div><div>// Get the first row.</div><div>RowHandle row = (RowHandle) grid.getRows( ).get( 0 );</div><div> </div><div>// Create an image and add it to the first cell.</div><div>ImageHandle image = efactory.newImage( null );</div><div>CellHandle cell = (CellHandle) row.getCells( ).get( 0 );</div><div>cell.getContent( ).add( image );</div><div>image.setURL( "C:UsersPublicPicturesSample PicturesTulips.jpg" );</div><div> </div><div>// Create a label and add it to the second cell.</div><div>LabelHandle label = efactory.newLabel( null );</div><div>cell = (CellHandle) row.getCells( ).get( 1 );</div><div>cell.getContent( ).add( label );</div><div>label.setText( "Hello, world!" );</div><div> </div><div>// Save the design and close it.</div><div>design.saveAs( "E:BITS WSPCEBIRT RESULTSsample.rptdesign" );</div><div>design.close( );</div><div> </div><div>//viewBIRT();</div><div>System.out.println("Finished");</div><div> </div><div> </div><div>}</div><div> </div><div>private static void viewBIRT() {</div><div>// TODO Auto-generated method stub</div><div>ReportEngine eng = null;</div><div>EngineConfig conf = null;</div><div>conf=new EngineConfig();</div><div>conf.setEngineHome("C:/birt_runtime/birt-runtime-2_1_0/ReportEngine");</div><div> </div><div>}</div><div>}</div><div> </div>
Find more posts tagged with
Comments
There are no comments yet