BIRT Exchange Forum: BIRT Exchange Forum -> Michael's BIRT Blog

Jump to content


 

BIRT Poll: To best make a table fill a pdf page before breaking (PL=page layout, PBI=page break interval) set:

PL: auto, PBI: 0PL: fixed, PBI: 0PL: auto, PBI: 1000000PL: fixed, PBI: 1000000
Page 1 of 1

Drop Elements Depending on Output Format

Posted by mwilliams  Icon, 08 March 2013 - 06:34 PM

Sometimes when designing a report, you want to only show certain elements in certain output formats. Not just hide them, but actually drop them, so the bound dataSet doesn't run or for saved processing time. Say you want to drop a certain element from your report when you run your report to the XLS output. To do this, you'd simply name your report element in the property editor, then put the following in your beforeFactory script:

if(reportContext.getOutputFormat() == "xls"){

	reportContext.getDesignHandle().findElement("elementName").drop();

}


Attached Image

This works as you would expect, for most outputs. However, when you try this for pdf, while it does drop the correct element when you run the report in pdf, it also drops the element when you run the report in the web viewer. This is because getOutputFormat returns pdf when you run your report with the web viewer.

Attached Image

Attached Image


Luckily, there is a way around this. You also have access to the HttpServletRequest, so if you use a script like the following, in your beforeFactory, the correct format will be returned.

if(reportContext.getHttpServletRequest().getAttribute("attributeBean").format == "pdf"){
	reportContext.getDesignHandle().findElement("elementName").drop();
}


With this method, we now see that the web viewer is actually HTML and the correct element is dropped from the report.

Attached Image

This solution will only work in open-source BIRT, as the HttpServletRequest is not available in the commercial version. The sample report used in this post can be downloaded here.

Filed in drop, xls, html, pdf, web viewer

Last week in the Forums: PostgreSQL Function Issue, Exporting Charts to XLS, and more...

Posted by mwilliams  Icon, 28 May 2012 - 06:02 AM

This blog series takes a look back at the past week in the forums, recalling how active they were and highlights some of the questions asked that seem to frequent the forums or other interesting topics. Busy, busy, busy! Forum traffic continues to be heavy as we move closer and closer to the half way point. As always, thanks to those users who help answer questions! It is a great help to the community!

The unanswered post, for this past week, is about an encoding issue while running a postgresql function in BIRT. When they run the function in pSQL or pgAdmin, they don't have an issue, just when running the function from BIRT. They get the following error:

22021: invalid byte sequence for encoding "UTF8": 0xf6206f72

If anyone has seen this before or has a suggestion for them to try, please post in the thread!

The next issue I'll discuss is about exporting charts to XLS. The standard BIRT XLS emitter doesn't export images. Since charts are images in the BIRT output, the XLS emitter skips over them. There are several third party emitters created to export XLS outputs. Several of the options available can be found linked in this forum thread!

The last topic I'll discuss is about displaying the series name on top of a bar when optional grouping is used. When you use optional y-series grouping, in your chart, the series identifier you have available to you in the data point functions of the chart script will show you the grouped series, not the original series name. The poster wanted to be able to place the original series name at the top of the bar. An example is provided, in the thread, that shows how you can access the original series name and place it over the appropriate stacked bar.

Again, this is just a small sample of what went through the forums this past week. For more questions and answers that have been posted, check out the forums. As always, if you have a question, feel free to ask it, and if you see a question you know the answer to or have a similar experience to, feel free to post an answer or comment.

Filed in BIRT, BIRT Exchange, forums, reporting, postgresql encoding issue, chart, xls, series name, optional y-series grouping

Page 1 of 1

« May 2013 »

S M T W T F S
1234
567891011
121314151617 18
19202122232425
262728293031

My Picture

0 user(s) viewing

0 Guests
0 member(s)
0 anonymous member(s)

Categories

Search My Blog

Twitter