Creating a table using the BIRT Design API [message #191749] |
Mon, 25 September 2006 05:46 |
Eclipse User |
|
|
|
Originally posted by: christian.hochmuth.informatik.tu-chemnitz.de
Hi,
I want to create a BIRT report containing a table dynamically. The
number of columns and rows depends on the data to be formatted in the
table. So my first idea was to write a method expecting the table header
as a String array and table data as a two-dimensional array that returns
a ReportDesignHandle object. I managed to create the table as you can
see in the code below, but I do not know how to fill the table cells
with data.
Does anybody know how to proceed? Any advice is welcome! Should I try
using an rptdesgin file instead of generating the report dynamically?
public static ReportDesignHandle createTableReport(String[] tableHeader,
Object[][] tableData) throws NameException, ContentException,
SemanticException {
int cols = tableHeader.length;
int rows = tableData.length;
DesignConfig designConfig = new DesignConfig();
SessionHandle session = new
DesignEngine(designConfig).newSessionHandle(ULocale.getDefau lt());
ReportDesignHandle design = session.createDesign();
ElementFactory elementFactory = design.getElementFactory();
DesignElementHandle element = elementFactory.newSimpleMasterPage("Page
Master"); //$NON-NLS-1$
design.getMasterPages().add(element);
GridHandle grid = elementFactory.newGridItem(null, cols, rows);
design.getBody().add(grid);
grid.setWidth("100%"); //$NON-NLS-1$
TableHandle table = elementFactory.newTableItem(null);
table.setWidth("100%");
SlotHandle columnsSlot = table.getColumns();
for(int columnIndex = 0; columnIndex < cols; columnIndex++) {
ColumnHandle column = elementFactory.newTableColumn();
columnsSlot.add(column);
}
design.getBody().add(table);
//
// this is where I get stuck
//
return design;
}
|
|
|
Powered by
FUDForum. Page generated in 0.04355 seconds