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

Jump to content


 

No Latest Open Poll.

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: Scroll Bars on a Chart, Line Height Issue in PDF, and more...

Posted by mwilliams  Icon, 25 June 2012 - 07:05 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. As expected, the forums are starting to slow a little, over the summer, at least for now. That being said, they're slowing down from a state of high traffic, so there are still many posts coming in, each week. As always, thanks to those users who help answer questions! It is a great help to the community!

The unanswered post, this week, is about scroll bars on a chart. The poster has a gantt chart that they want to have vertical scroll bars on. If anyone has done this or has ideas, please post your suggestions in the thread.

The next topic, for this week, is about line height in PDF. This question comes through the forums often enough. When you set the line height in BIRT to a larger value than the text, all outputs show a larger line height. However, when you try to have a smaller line height, the HTML outputs show this, but PDF does not. The reason that some people tried to reduce the line height was because PDF seemed to show extra spacing between lines. This should be solved in BIRT 3.7, as there is a new line height algorithm for 3.7+. So, if you're using an older version and having issues with line spacing, upgrading will be the easiest option. The next option is probably to edit the pdf emitter.

The last topic, for this week, is about passing multiple values to a report through a parameter. The poster had a HTML select form in their report in a HTML text box that they wanted the user to be able to select multiple values from and submit the form and recall the design passing the multiple selections through their parameter. A sample report is included in the thread that does just that. It passes the current values through the parameter and uses them in the query to limit the dataSet. It also sets them as the selected values in the drop down.

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, gantt chart, scroll bars, pdf, line height, multi-value parameter, HTML select form

Last week in the Forums: "Processing" Bar for PDF Reports, Stacked Bar Chart "Total" Label, and more...

Posted by mwilliams  Icon, 09 April 2012 - 06:49 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. Like I figured, last week, the forum traffic has picked back up, in a big way, this week. As always, thanks to those users who help answer questions! It is a great help to the community!

The unanswered post, from last week, that I'll discuss is about adding a processing bar when generating a PDF report. The poster is wanting to know if there's a way in which they can add a "processing, please wait" bar to let the user know the PDF is still processing. If anyone has experience with this issue or has a suggestion to something that could work, please post in the forum thread!

The next post I'll cover, this week, is about putting the total on top of a stacked bar chart. The poster was wanting to find a way to show the total bar value in a label on the top of a stacked bar, rather than just the individual stacked bar values. An example report design is posted in the thread that shows how script can be used to achieve this, by hiding the label for the bottom series and changing the value of the top series's label to be the sum of the bar.

The last topic we'll cover, from last week, is about truncating a long URL, but keeping the hyperlink. The poster was wanting to know how they could truncate a long URL in their table, for clean design purposes, but still keep the value of the entire URL for the hyperlink. One way to do this is given in the forum thread. It is to use the following script:

var myaction = this.createAction();
myaction.setHyperlink(this.getValue(),"_blank");
this.action = myaction;
this.setDisplayValue(this.getValue().substr(0,20));



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, PDF, progress bar, chart, stacked bar, hyperlink

Last Week in the Forums: SVG Images in PDF, Dropping a Series from a Chart, and more...

Posted by mwilliams  Icon, 12 December 2011 - 04:18 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. The new year is almost here! Just a few more weeks to go in 2011. The forums have been very busy all year and I don't expect them to slow down in these last few weeks. Many great questions and answers are being posted every day. As always, thanks to those users who help answer questions! It is a great help to the community!

The unanswered question for this week is an issue with SVG in PDF. The question is, when a SVG image is created with Adobe Illustrator, it works in the PDF. However, when the SVG is made with Inkscape, they receive an error message like, "Current report item is not supported in this report format." If anyone has experienced this issue with SVG images and PDF, please post your suggestions or solution in this thread!

The next post I'll cover from last week is, dropping a series from a chart. The question was, how do you drop a series from a chart if it's an empty series. A devShare post is linked as an answer. The devShare post shows how to drop a series based on a parameter. So, the only work left to do to solve the poster's question is to determine if the series is empty or not. This can probably be done outside the chart and passed in just like the parameter value in the example. This information can also probably be found out in the afterDataSetFilled function in the chart script.

The last topic for this week is, changing negative numbers to red. The question is, if you have a field of positive and negative numbers, how do you make the negative ones red. The solution provided is to select the data element for the field, and go to the highlight section of the property editor and add a highlight rule.

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, SVG, PDF, chart, drop series, highlight negative numbers

Page 1 of 1

« June 2013 »

S M T W T F S
1
2345678
9101112131415
161718 19 202122
23242526272829
30

My Picture

0 user(s) viewing

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

Categories

Search My Blog

Twitter