RSS

Category Archives: JasperReport

Alternate Background colour of rows in JasperReport

By: http://sothaticanremember.blogspot.com/

There are few methods to alternate background colour of rows in jasperreport.

Use conditional style.

A conditional style has two elements: a Boolean condition expression and a style. The
style is used only if the condition evaluates to true.

We have following code snippet to get alternating row color.

<style name=”alternateStyle” fontName=”Arial” backcolor=”red”>
<conditionalStyle>
<conditionExpression>
new Boolean($V{REPORT_COUNT}.intValue() % 2 == 0)
</conditionExpression>

<style backcolor=”blue”/>
</conditionalStyle>
</style>

In this example, element with this style will get red backcolor. But the presence of conditional style changes the behaviour and when rendered on an even row, the same element will have blue backcolor.

A conditional style override the properties of parent style.

OR

just put the a rectangle with a different background color and set the printwhenexpression to :

new Boolean(($V{REPORT_COUNT} mod 2) == 0)

OR
Set up a new java.lang.Integer variable called BACKGROUND. Set its Calculation Type to DistinctCount, Reset typeto None, Increment type to None, Variable Expression to a field that will always contain unique values (eg. $F{PortNumber} ), and an Initial Value Expression of new java.lang.Integer(0). That will give you an auto-incrementing variable.

In the Detail section make sure all the existing elements are set to Transparent.

Now in the Detail section of your report create a new Static Text box. Size it to cover the full extents of the detail section. If you are using multiple columns size it to the full extent of just one column. Set its background colour to be whatever you want it to be. Put a single space in the Static Text area.

To make it toggle on and off you use a Print When expression based on your BACKGROUND variable. Set it to be new java.lang.Boolean(($V{BACKGROUND}.intValue() % 2)==1)

Now all you need to do is send it to the back. Under the Format Menu choose the Send to Back option, and your done.

 
Leave a comment

Posted by on July 25, 2014 in JasperReport

 

iReport Install Problem: "Cannot find Java.exe"

By: rubamushtaq

You need to set JDK path in config file.

See below the path that should be something like this..

C:\Program Files (x86)\Jaspersoft\iReport-5.5.0\etc

In the ‘etc’ folder you will find the config file where you have to set the jdkhome like this (jdkhome=”C:\\Program Files\\Java\\jdk1.8″ ).And you have to give jdk path not jre. Do check you have installed jdk.However your mentioned path does not show that to me.

The same question had been asked before and was answered. I would recommend you to first search your question or query before asking so you may not need to wait for the answer.

 

Copy From: http://community.jaspersoft.com/questions/801730/unable-run-ireport-java-error

 
Leave a comment

Posted by on January 23, 2014 in JasperReport

 

Adding Jasperserver as Service in Ubuntu

By Sochinda

After install jasper report server in Ubuntu server, using terminal as bellow:

  • Create file called jasperserver in init.d

#sudo nano /etc/init.d/jasperserver

  • Insert this text:
#!/bin/sh
### BEGIN INIT INFO
# Provides: jasperserver
# Required-Start:
# Required-Stop:
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start JasperServer at boot time
# Description: Enable service provided by JasperServer.
### END INIT INFO

JASPER_HOME="/opt/jasperreports-server-cp-4.2.1"

case "$1" in
 start)
 if [ -f $JASPER_HOME/ctlscript.sh ]; then
 echo "Starting JasperServer"
 $JASPER_HOME/ctlscript.sh start
 fi
 ;;
 stop)
 if [ -f $JASPER_HOME/ctlscript.sh ]; then
 echo "Stopping JasperServer"
 $JASPER_HOME/ctlscript.sh stop
 fi
 ;;
 restart)
 if [ -f $JASPER_HOME/ctlscript.sh ]; then
 echo "Restarting JasperServer"
 $JASPER_HOME/ctlscript.sh restart
 fi
 ;;
 status)
 if [ -f $JASPER_HOME/ctlscript.sh ]; then
 $JASPER_HOME/ctlscript.sh status
 fi
 ;;
 *)
 echo $"Usage: $0 {start|stop|restart|status}"
 exit 1
 ;;
esac

  • Set jasperserver in init.d as execute permission

#sudo chmod +x /etc/init.d/jasperserver

  • Update jserperserver as default service in Ubuntu

#sudo update-rc.d jasperserver defaults

Finally, we can use command as:

#sudo service jasperserver start|stop|restart

Reference from: http://community.jaspersoft.com/questions/541044/auto-start-boot

 
Leave a comment

Posted by on January 13, 2014 in JasperReport, Ubuntu

 

Building Report Server in Jasperreport Server

By: Sochinda Tith

JasperRetport Server

JasperReports Server is a stand-alone and embeddable reporting server. It provides reporting and analytics that can be embedded into a web or mobile application as well as operate as a central information hub for the enterprise by delivering mission critical information on a real-time or scheduled basis to the browser, mobile device, printer, or email inbox in a variety of file formats. JasperReports Server is optimized to share, secure, and centrally manage your Jaspersoft reports and analytic views.

Requirement Download and Install:

  1. JDK/JRE
  2. JasperReport Server
  3. iReport
  4. JasperSoft Studio
  5. Web Service that return as XML (URL Data Access)

JasperReport Preparation

– Go to iReport installed and copy from path: ..\ireport\modules\ext\jasperreports-extensions-3.5.3.jar to JasperReport Server path: ..\apache-tomcat\webapps\jasperserver\WEB-INF\lib\jasperreports-extensions-3.5.3.jar

– Go to file in :..\apache-tomcat\webapps\jasperserver\WEB-INF\classes\jasperreports.properties and copy bellow text pas into this file and save

net.sf.jasperreports.query.executer.factory.xpath2=com.jaspersoft.jrx.query.JRXPathQueryExecuterFactory

– Restart Tomcat

Report Preparation

Create and design report using XML Remote as datasource

And export into Jasper Report Server

You should see a window like this:

Now you can start Jaspersoft Studio. Click the Repository Explorer tab, then select Create a JasperReports Server Connection.

A dialog to insert the server data appears. Fill it in as follows:

  • Name: the name of the connection. You can use any name you want. For this example we will leave the default name: JasperReports Server.
  • URL: the address of the server. The default address is already correct if we are using a local server. For this example the correct address is http://localhost:8080/jasperserver/services/repository.
  • User: the username to access the server. The default for the local server is “jasperadmin”.
  • Password: as with the username, for the local server by default it is “jasperadmin”.

Then click the Test Connection button to test the connection. If everything is working, click Finish.

Now you are connected to the server and you can upload and download reports.

Publishing a Report on JasperReports Server

For this section,  we will use the one created during the tutorial Report Structure in Jaspersoft Studio. Open the report and click the button with a blue arrow in the upper-right corner of the designer. In the opened window you can browse the server directory structure to choose where to place the report. Select the Reports folder as in the image above. Name the report unit you are creating to contain all the files for the report we are uploading (for this example we can use “ColumnsSample”). Then click Next.

In the next step we have to handle the data source. Exporting a report is quite simple, but exporting the data source used to fill the report it isn’t so trivial. For exporting the data source we have three options:

  • Data source from repository: the server will use a data source already there it to fill the report, so we will only need to browse the server until we find the wanted data source.
  • Local data source
  • Don’t use any data source: only the report is exported without any data source connection

We will use the third option, which is the default one, and click Finish. The report is uploaded to the server and, if there are no errors, an appropriate message will be shown.

Call Report from JasperReport Server

Enter in url: http://{hostname}:{port}/jasperserver/flow.html?_flowId=viewReportFlow&reportUnit=/reports/Test/A4Test&standAlone=true&ParentFolderUri=/reports/Test&XML_URL={Webservice Url}

 

 
Leave a comment

Posted by on December 6, 2013 in JasperReport