BIRT API [message #58601] |
Thu, 14 July 2005 23:19  |
Eclipse User |
|
|
|
Originally posted by: zszqcym.yahoo.com.cn
hi!
I'm a chinese.I use birt and eclipse .I want to creat a report in
java code.
My question is :How can I write a new *.rptdisign file by bird's
api ?
eg.Write datasource and dataset's property into a *.rpt in java.
Thank you for your help!
|
|
|
Re: BIRT API [message #59219 is a reply to message #58601] |
Fri, 15 July 2005 21:54  |
Eclipse User |
|
|
|
Greeting,
You could create a report in BIRT API by following the steps in the below.
If you'd like to find out the API docs, please go to Help-> HelpContents
->BIRT Developer Guide->Reference->API Reference -> Report Object Model
API Reference.
Cheers.
Regards,
Nina Li
Actuate Corporation
------------------------------------------------------------ ---------
createReport( ){
//A session handle to manage all open reports
SessionHandle session = DesignEngine.newSession( null );
//Add a session (A report design handle for this report)
ReportDesignHandle reportDesignHandle = session.createDesign( );
//An element factory for creating all BIRT elements
ElementFactory elementFactory = designHandle.getElementFactory( );
//create the necessary elements for the reports
createMasterPages( );
createDataSources( );
createDataSets( );
createReportBody( );
.
.
.
...Output the report...
reportDesignHandle.saveAs( ... + "*.rptdesign" );
}
createMasterPage(){
//A design element handle for managing the Master page
DesignElementHandle masterPage = elementFactory.newSimpleMasterPage(
"Master Page" );
//Add the master page into the report
reportDesignHandle.getMasterPages( ).add( masterPage );
.
.
.
}
createDataSources( ){
//A script data source handle for managing the data source
ScriptDataSourceHandle dataSourceHandle =
elementFactory.newScriptDataSource("Data source");
...Set the property of data source...
//Add the data source into the report
reportDesignHandle.getDataSources( ).add( dataSourceHandle );
}
createDataSets( ){
//A script data set handle for managing the data set
ScriptDataSetHandle dataSetHandle = elementFactory.newScriptDataSet("Data
set");
...Set the property of data set...
//Add the data set into the report
reportDesignHandle.getDataSets( ).add( datasetHandle );
}
createReportBody( ){
//Create the contents of report
createGrid( );
createTable();
createLabel();
.
.
.
}
|
|
|
Powered by
FUDForum. Page generated in 0.03646 seconds