Skip to main content



      Home
Home » Archived » BIRT » Creating a table using the BIRT Design API
Creating a table using the BIRT Design API [message #191749] Mon, 25 September 2006 05:46
Eclipse UserFriend
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;
}
Previous Topic:Isolate the Error from the generated HTML output
Next Topic:PDF FONTS - DOES IT WORK?
Goto Forum:
  


Current Time: Wed Jun 18 12:12:36 EDT 2025

Powered by FUDForum. Page generated in 0.05165 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top