该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
// Your app need create the session only once.
//Configure the Engine and start the Platform
DesignConfig config = new DesignConfig( );
config.setProperty("BIRT_HOME", "C:/BIRT/birt-runtime-2_1_1");
IDesignEngine engine = null;
try{
Platform.startup( config );
IDesignEngineFactory factory = (IDesignEngineFactory) Platform
.createFactoryObject( IDesignEngineFactory.EXTENSION_DESIGN_ENGINE_FACTORY );
engine = factory.createDesignEngine( config );
}catch( Exception ex){
ex.printStackTrace();
}
SessionHandle session = engine.newSessionHandle( ULocale.ENGLISH ) ;
// Create a new report design.
ReportDesignHandle design = session.createDesign( );
// The element factory creates instances of the various BIRT elements.
ElementFactory factory = design.getElementFactory( );
// Create a simple master page that describes how the report will
// appear when printed.
//
// Note: The report will fail to load in the BIRT designer
// unless you create a master page.
DesignElementHandle element = factory.newSimpleMasterPage( "Page Master" ); //$NON-NLS-1$
design.getMasterPages( ).add( element );
// Create a grid and add it to the "body" slot of the report
// design.
GridHandle grid = factory.newGridItem( null, 2 /* cols */, 1 /* row */ );
design.getBody( ).add( grid );
// Note: Set the table width to 100% to prevent the label
// from appearing too narrow in the layout view.
grid.setWidth( "100%" ); //$NON-NLS-1$
// Get the first row.
RowHandle row = (RowHandle) grid.getRows( ).get( 0 );
// Create an image and add it to the first cell.
ImageHandle image = factory.newImage( null );
CellHandle cell = (CellHandle) row.getCells( ).get( 0 );
cell.getContent( ).add( image );
image.setURL( "\"http://www.eclipse.org/birt/phoenix/tutorial/basic/multichip-4.jpg\"" );
// Create a label and add it to the second cell.
LabelHandle label = factory.newLabel( null );
cell = (CellHandle) row.getCells( ).get( 1 );
cell.getContent( ).add( label );
label.setText( "Hello, world!" ); //$NON-NLS-1$
// Save the design and close it.
design.saveAs( "c:/tmp/sample.rptdesign" ); //$NON-NLS-1$
design.close( );
System.out.println("Finished");
// We're done!
}
}