BIRT drop group header property with DOC output type

December 26, 2011

In an earlier post I wrote about the drop property and how to make it look decent when it is used in a table that has border lines set. Now it turns out that the drop property does not work properly when the output type is DOC or XLS.

Drop property result in DOC output
This is what the report from the earlier post looks like with output type set to DOC:

The cells are merged correctly but the headers are not dropped.

Workaround
To work around this issue, I started with removing all grouping headers, then I dragged all fields into the detail section and I added two aggregations: a RUNNINGCOUNT in the Country column that aggregates by the Country grouping and similar a RUNNINGCOUNT in the Manager lastname column that aggregates by the Manager grouping. I set both aggregation fields invisible. The aggregation on the Country grouping looks like this:

Next I set the borders of the grouping columns like this:

And then I added some scripts to the report.
In the report’s Initialize event:

var showTopBorderCountry = "1";
var showTopBorderManager = "1";

In the onCreate event of the Detail row:

if (this.getRowData().getExpressionValue("row[AggCountry]") == "1")
   showTopBorderCountry = "1";
else
   showTopBorderCountry = "0";

if (this.getRowData().getExpressionValue("row[AggManager]") == "1")
   showTopBorderManager = "1";
else
   showTopBorderManager = "0";

In the onCreate event of the Country header cell:

if (showTopBorderCountry == "1"){
    this.getStyle().borderTopColor="Black";
    this.getStyle().borderTopStyle="Solid";
	this.getStyle().borderTopWidth="Thin";
}

In the onCreate event of the Manager header cells:

if (showTopBorderManager == "1"){
    this.getStyle().borderTopColor="Black";
    this.getStyle().borderTopStyle="Solid";
	this.getStyle().borderTopWidth="Thin";
}

Finally, in the visibility property of the header cells, I wrote this expression:

if (row["AggManager"] > 1) true; else false; 

Now the DOC output looks like this:

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.