birt java api,关于JAVA报表BIRT API的问题

该楼层疑似违规已被系统折叠 隐藏此楼查看此楼

// 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!

}

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值