Quantcast
Viewing all 261 articles
Browse latest View live

Parameter in GROUP BY statement - Dynamic grouping

 Thanks Chandu Shekar... Keeping it open for community in my blog site.

Aim :  How to use parameter in GROUP BY statement ? Dynamically group the data in Jasper Studio 6.x

Example works on foodmart database.

JRXML Code :

<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 6.0.0.final using JasperReports Library version 6.0.0  -->
<!-- 2015-02-12T15:41:46 -->
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="case_56816" language="groovy" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="106066b5-8cc4-4e9d-92df-fa60c6cea9da">
    <property name="ireport.zoom" value="1.0"/>
    <property name="ireport.x" value="0"/>
    <property name="ireport.y" value="0"/>
    <property name="ireport.jasperserver.url" value="http://localhost:8082/jasperserver-pro/"/>
    <property name="ireport.jasperserver.report.resource" value="/public/Hummingbird/case_56816/case_56816_files/case_56816_jrxml"/>
    <property name="ireport.jasperserver.reportUnit" value="/public/Hummingbird/case_56816/case_56816"/>
    <property name="com.jaspersoft.studio.data.defaultdataadapter" value="foodmart"/>
    <parameter name="criteria" class="java.lang.String">
        <defaultValueExpression><![CDATA["store"]]></defaultValueExpression>
    </parameter>
    <parameter name="groupBy" class="java.lang.String" isForPrompting="false">
        <defaultValueExpression><![CDATA[($P{criteria} == "store") ? "employee.store_id,employee.department_id":($P{criteria} == "department")?"employee.department_id,employee.store_id":"employee.store_id, employee.department_id"]]></defaultValueExpression>
    </parameter>
   <queryString language="SQL">
        <![CDATA[SELECT
     SUM(employee."salary") AS employee_salary,
     employee."store_id" AS employee_store_id,
     employee."department_id" AS employee_department_id
FROM
     "public"."employee" employee
GROUP BY $P!{groupBy}
LIMIT 5]]>
    </queryString>

    <field name="employee_salary" class="java.math.BigDecimal"/>
    <field name="employee_store_id" class="java.lang.Integer"/>
    <field name="employee_department_id" class="java.lang.Integer"/>
    <title>
        <band height="29" splitType="Stretch">
            <textField>
                <reportElement x="0" y="2" width="555" height="20" uuid="77dffc9a-1996-4f63-b704-fc1f213c4770"/>
                <textFieldExpression><![CDATA[$P{groupBy}]]></textFieldExpression>
            </textField>
        </band>
    </title>
    <columnHeader>
        <band height="20" splitType="Stretch">
            <staticText>
                <reportElement x="0" y="0" width="185" height="20" uuid="3d2abafe-8487-463f-b684-f309e94adb58"/>
                <text><![CDATA[employee_salary]]></text>
            </staticText>
            <staticText>
                <reportElement x="185" y="0" width="185" height="20" uuid="3f4f67b5-ec29-4185-a52a-4099492fdaff"/>
                <text><![CDATA[employee_store_id]]></text>
            </staticText>
            <staticText>
                <reportElement x="370" y="0" width="185" height="20" uuid="c7127794-4406-43e2-a057-acc5314fbf79"/>
                <text><![CDATA[employee_department_id]]></text>
            </staticText>
        </band>
    </columnHeader>
    <detail>
        <band height="21" splitType="Stretch">
            <textField>
                <reportElement x="0" y="0" width="185" height="20" uuid="5aa29ed2-1730-49ce-a4e8-3f5d71862385"/>
                <textFieldExpression><![CDATA[$F{employee_salary}]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement x="185" y="0" width="185" height="20" uuid="b189d5d9-a32c-4ad6-9ae9-47df69ed8da5"/>
                <textFieldExpression><![CDATA[$F{employee_store_id}]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement x="370" y="0" width="185" height="20" uuid="8f691afe-d989-4d72-9c91-70f61a3d500a"/>
                <textFieldExpression><![CDATA[$F{employee_department_id}]]></textFieldExpression>
            </textField>
        </band>
    </detail>
</jasperReport>

Tip : Remove [ and ] from collection parameter in jasper reports

 Hi Folks,

This tip will useful for removing square brackets from collection type parameter in jasper reports.

Parameter Type : java.util.Collection
Lets say your input control values are : USA,INDIA,Canada,England in a drop down & when you execute the report
&
When you display this parameter on the report you will get like this
[ USA,INDIA,Canada,England]

To Convert above to
USA,INDIA,Canada,England

We need to write below expression for the parameter dragged on to the report (i.e., In its Text Field Expression). 

$P{ParameterName}.toString().substring(1,$P{ParameterName}.toString().length()-1 )

Example :  
$P{Country}.toString().substring(1,$P{Country}.toString().length()-1 )

Notes : 
1) Convert collection to String using toString() function.
2) String index starts from 0 and ends with n-1
3) From the string take the sub string excluding 0th index character and last index character

Thank you Harish for R&D.

NOTE : There could be another ways also to achieve the same. 

Conditional colors to Fields in Jasper Studio 6.0.1 - Example sceenshot and JRXML

1) Style
2) Condition-1
3) Condition-2
4) On the Text Field
5) Output
6) JRXML

1) Style

2) Condition-1
3) Condition-2
4)  On the Text Field

5) Output
6) JRXML

<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 6.0.0.final using JasperReports Library version 6.0.0  -->
<!-- 2015-03-06T13:13:06 -->
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="Blank_A4_22" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="ab524a87-197a-4dac-b294-ba81b7cb1409">
    <property name="com.jaspersoft.studio.data.defaultdataadapter" value="foodmart"/>
    <style name="Style1">
        <conditionalStyle>
            <conditionExpression><![CDATA[$F{unitsales}.doubleValue()>=0 && $F{unitsales}.doubleValue()<=1000]]></conditionExpression>
            <style backcolor="#7679B0"/>
        </conditionalStyle>
        <conditionalStyle>
            <conditionExpression><![CDATA[$F{unitsales}.doubleValue()>1000 && $F{unitsales}.doubleValue()<=3000]]></conditionExpression>
            <style backcolor="#EBEDA4"/>
        </conditionalStyle>
    </style>
    <queryString>
        <![CDATA[SELECT c.city, SUM(unit_sales) UnitSales FROM customer c, sales_fact_1997 sf7 WHERE
c.customer_id=sf7.customer_id GROUP BY c.city]]>
    </queryString>
    <field name="city" class="java.lang.String"/>
    <field name="unitsales" class="java.math.BigDecimal"/>
    <background>
        <band splitType="Stretch"/>
    </background>
    <title>
        <band height="32" splitType="Stretch"/>
    </title>
    <pageHeader>
        <band height="35" splitType="Stretch"/>
    </pageHeader>
    <columnHeader>
        <band height="36" splitType="Stretch">
            <staticText>
                <reportElement x="0" y="0" width="278" height="30" uuid="621ecd38-7026-4d55-9afe-6a1fa2c37613"/>
                <text><![CDATA[city]]></text>
            </staticText>
            <staticText>
                <reportElement x="278" y="0" width="277" height="30" uuid="2c237fac-2804-4031-a064-a666b37fd164"/>
                <text><![CDATA[unitsales]]></text>
            </staticText>
        </band>
    </columnHeader>
    <detail>
        <band height="46" splitType="Stretch">
            <textField>
                <reportElement x="0" y="13" width="278" height="30" uuid="a448fd0f-d6b7-45ef-8915-3250c06d178a"/>
                <textFieldExpression><![CDATA[$F{city}]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement style="Style1" mode="Opaque" x="278" y="13" width="277" height="30" uuid="2040c97e-9bd0-4c05-b515-a06f60b315af"/>
                <textFieldExpression><![CDATA[$F{unitsales}]]></textFieldExpression>
            </textField>
        </band>
    </detail>
    <columnFooter>
        <band height="45" splitType="Stretch"/>
    </columnFooter>
    <pageFooter>
        <band height="54" splitType="Stretch"/>
    </pageFooter>
    <summary>
        <band height="42" splitType="Stretch"/>
    </summary>
</jasperReport>

Tips : Playing with variables in Jasper Studio to find percentages, to get the two digits after decimal point & to get the only numeric value from decimal by rounding the value

Software : 
Jasper Design Studio : 6.0.1 Pro
Jasper Server : 6.0.1 Pro

1) Calculating Percentage from java.lang.BigDecimal Types

By default all the numeric fields in report takes java.math.BigDecimal & you can not perform arithmetic  operations like division for calculating percentages. (Alternatively you need to work with the methods from BigDecimal class to get % kind of things)

Find percentage : 
1) Create a variable  of type java.lang.Double
2) Calculation = Nothing
3) Expression :
      $F{Field1}.doubleValue()/$F{Filed2}.doubleValue())*100  

    NOTE : $F{Field1} and $F{Filed2} are of java.math.BigDecimal types .
4) Increment type : None
5) Reset group :  If you are creating variables in any data set & using it in table component give your GROUP Name

6) Drag the variable on to the design area of table component.
7) Double click the variable to open it's  expression
     a) By default you can see it's expression as $V{Variable_1}
     b) Change the variable expression  to
              new DecimalFormat("#.##").format(Double.valueOf($V{Variable_1}))+"%"

2) Two decimal places after floating point for java.math.BigDecimal type values

  $V{Variable_2}.setScale(2, java.math.RoundingMode.HALF_UP)+"%"
This is on dragged variable. Not in the variable directly. The variable initially $V{Variable_2}. Double click it to get it's expression editor

Example: 95.83%

NOTE : 
a) Create a variable of double type for finding %'s .
                   i.e.,
                       Variable Name : VAR_PER_1
                      Expression :  (a.doubleValue()/b.doubleValue()) *100
                      Example : 95.834444123

b)  Now convert the above variable to Decimal type by creating a new variable of type Decimal
                 i.e., Variable Name : VAR_PER_2
                 BigDecimal.valueOf($V{VAR_PER_1})    [Remember it VAR_PER_1]

c) Now get 2 decimal places  by applying   $V{VAR_PER_2}.setScale(2, java.math.RoundingMode.HALF_UP)+"%"


3) Get only  Numeric value as percentage by rounding the decimal places of Double value

Assume you have java.lang.Double type having 45.45 and want to get 46 from it. Then the below expression will help full to you.

Variable_1=45.45                                              of java.lang.Double type
Variable_2= (int) ($V{Variable_1} + 0.5)        of java.lang.Integer type

[i.e., you need to create another variable of integer type and in its expression type cast the double variable to integer]

There could be another ways to solve the same kind of solutions using java expressions but I hope somehow the above tips help full.

Thanks for reading this page & suggestions and improvements to this page are welcome in comments box :-)

:-) SADAKAR POCHAMPALLI :-)
BI DEVELOPER, HYDERABAD, INDIA.

JFree Bar Chart Customization in Jasper iReport - Decrease the size of bars & space between bars

This post will give you quick solution on customizing JFree Bar Chart .
Re-collected the year and half back workout again & here we go.

Software : 

1) Jasper iReport 5.6.1 community
2) Eclipse Luna

Problem Statement : Image-1

1) Decrease the width of the bars
2) Decrease the space b/w bars for a series bar Chart


Solution Image :Image-2


How to do ?

1) Develop your chart & have a preview which looks like image-1.

2) You need to customize the chart using JFree Java code written in Eclipse & get the output in Jar file.

3) Open Eclipse & create a project and then a class. You should import 3 jar files to your project.
   Those are : 1) jasper-reports-<version>.jar 2)jfreechart-<version>.jar & 3)jcommon-<version>.jar

  You can right click the project name and go Build path section and then Add jar files -> click on "Add external jar files " from the location where your jars are avaialbe.

How to get the jar files ?
You can get all the jar files in below jasper server installed location. (i.e., you should be installed jasper server in your local machine).

C:\Jaspersoft\jasperreports-server-6.0\apache-tomcat\webapps\jasperserver-pro\WEB-INF\lib

Alternatively, you can type the names of the jars and download directly from web.



4) Run the code & export to  a jar file. (for exporting Project Name -> Right click - > Export)

 5) Now the downloaded jar file code has to apply on the chart customization.
For that in iReport, Go to Tools-> Options and select the jar file from your system location.


6) Now select the chart to get it's properties on right side properties window.
   search for Customizer Class property. Provide the class name of the Java code along with it's package name.
i.e., for example : com.sadakar.jfree.JFreeBarChartCustomization1

That's all.. Save the report and have a preview. you will get the output as shown in Image-1

NOTE :
When you publish the report to the server you will not get the output as expected. B'z your server doesn't know about the changes you done to the report. For this you need to load your jar file in lib folder of jasper instance. i.e., place the jar file at
C:\Jaspersoft\jasperreports-server-6.0\apache-tomcat\webapps\jasperserver-pro\WEB-INF\lib 
and restart your server.

Exploring the same with Studio 6 community & professional and update this line :-)

 Interesting...!!! Have a question or suggestion ? Drop your feedback in comment box and help community to share knowledge... :-)

Cheers..!!!




CA Clarity PPM now with TIBCOJaspersoft :-) 20 March 2015 Exciting to see how it looks like with PPM Clarity:-)

Conditional colors to the bars of HTML-5 Bar Chart - Applicable on other chart types like Line Chart.

This post is a re-blogging from Jasper WIKI pages on conditional coloring of bars for HTML-5 Bar Chart.


https://community.jaspersoft.com/wiki/dynamically-updating-bar-colors-html5-bar-charts

Quick Output Image :

JRXML: Run this JRXML on foodmart database.

<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 6.0.0.final using JasperReports Library version 6.0.0  -->
<!-- 2015-03-24T10:39:11 -->
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="HTML5BarChart-CustomiseColors" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="a146894c-9f63-42a0-bd25-21cce326e316">
    <property name="com.jaspersoft.studio.data.sql.tables" value="dGltZV9ieV9kYXkgQVMgLDI1LDc1O3NhbGVzX2ZhY3RfMTk5NyBBUyAsMTg0LDc5Ow=="/>
    <property name="com.jaspersoft.studio.data.defaultdataadapter" value="foodmart"/>
    <queryString language="SQL">
        <![CDATA[SELECT sum(sales_fact_1997.store_sales) as sales,
    time_by_day.the_month
FROM sales_fact_1997
    INNER JOIN time_by_day ON
     time_by_day.time_id = sales_fact_1997.time_id
     GROUP BY the_month, month_of_year
     ORDER BY month_of_year]]>
    </queryString>
    <field name="sales" class="java.math.BigDecimal"/>
    <field name="the_month" class="java.lang.String"/>
    <variable name="Variable_1" class="java.lang.String">
        <variableExpression><![CDATA[DATEFORMAT(new Date(),"MMMMM")]]></variableExpression>
    </variable>
    <background>
        <band splitType="Stretch"/>
    </background>
    <title>
        <band height="79" splitType="Stretch"/>
    </title>
    <summary>
        <band height="358" splitType="Stretch">
            <componentElement>
                <reportElement x="0" y="0" width="555" height="238" uuid="58498ba5-f781-4a59-8db0-70e30d626b77"/>
                <hc:chart xmlns:hc="http://jaspersoft.com/highcharts" xsi:schemaLocation="http://jaspersoft.com/highcharts http://jaspersoft.com/schema/highcharts.xsd" type="Column">
                    <hc:chartSetting name="default">
                        <hc:chartProperty name="chart.zoomType">
                            <hc:propertyExpression><![CDATA["xy"]]></hc:propertyExpression>
                        </hc:chartProperty>
                        <hc:chartProperty name="credits.enabled">
                            <hc:propertyExpression><![CDATA[false]]></hc:propertyExpression>
                        </hc:chartProperty>
                        <hc:chartProperty name="credits.href">
                            <hc:propertyExpression><![CDATA[""]]></hc:propertyExpression>
                        </hc:chartProperty>
                        <hc:chartProperty name="credits.text">
                            <hc:propertyExpression><![CDATA[""]]></hc:propertyExpression>
                        </hc:chartProperty>
                        <hc:chartProperty name="title.text">
                            <hc:propertyExpression><![CDATA[""]]></hc:propertyExpression>
                        </hc:chartProperty>
                        <hc:chartProperty name="yAxis.title.text">
                            <hc:propertyExpression><![CDATA[""]]></hc:propertyExpression>
                        </hc:chartProperty>
                    </hc:chartSetting>
                    <multiAxisData>
                        <multiAxisDataset/>
                        <dataAxis axis="Rows">
                            <axisLevel name="Month">
                                <labelExpression><![CDATA["Level Label expression"]]></labelExpression>
                                <axisLevelBucket order="None" class="java.lang.String">
                                    <bucketExpression><![CDATA[$F{the_month}]]></bucketExpression>
                                    <bucketProperty name="color"><![CDATA[IF($F{the_month}.toString().matches(DATEFORMAT(new Date(),"MMMMM")),"red",IF($F{sales}.intValue() >= 50000,"green","blue"))]]></bucketProperty>
                                </axisLevelBucket>
                            </axisLevel>
                        </dataAxis>
                        <dataAxis axis="Columns"/>
                        <multiAxisMeasure name="Sales" class="java.math.BigDecimal" calculation="Nothing">
                            <labelExpression><![CDATA["Sales"]]></labelExpression>
                            <valueExpression><![CDATA[$F{sales}]]></valueExpression>
                        </multiAxisMeasure>
                    </multiAxisData>
                   <hc:series name="Sales">
                        <hc:contributor name="SeriesItemProperty">
                            <hc:contributorProperty name="color" valueType="Bucket" value="Month.color"/>
                        </hc:contributor>
                    </hc:series>

                </hc:chart>
            </componentElement>
        </band>
    </summary>
</jasperReport>

:-)

Quick Learn : Report Scheduling & Bursting in Jasper Server 6.x with an example scenario

There are numerous posts on scheduling and report bursting in jasper. Even though there were, this article is an outcome of my research & hope will help you to do the same very faster with an end to end example. 

Setup : 

1) Jasper Reports Server Professional 6.0
2) A sample demo Report ( 07g.RevenueDetailReport) - Available only in professional Jasper Server.
3) Email Server : Gmail
(User Name : testjasperreport@gmail.com Password : jasperreports) - these are open for the community people who reads this page.

Aim of the post : 

Schedule a Report and send the output of report to email with attachment & also send success or failure notification email.

Step - 1

To work with email notifications & report bursting we need to work with 2 files.
They are
i)js.quartz.properties
Location of the file :
C:\Jaspersoft\jasperreports-server-6.0\apache-tomcat\webapps\jasperserver-pro\WEB-INF

Configure the mail server

report.scheduler.web.deployment.uri=http://127.0.0.1:8080/jasperserver-pro/

report.scheduler.mail.sender.host=smtp.gmail.com
report.scheduler.mail.sender.username=testjasperreport@gmail.com
report.scheduler.mail.sender.password=jasperreports
report.scheduler.mail.sender.from=testjasperreport@gmail.com
report.scheduler.mail.sender.protocol=smtp
report.scheduler.mail.sender.port=587


If your mail server requires authentication, change below property from false to true as shown in below.

ii) applicationContext-report-scheduling
Location of the file :
C:\Jaspersoft\jasperreports-server-6.0\apache-tomcat\webapps\jasperserver-pro\WEB-INF

 <bean id="reportSchedulerMailSender" class="org.springframework.mail.javamail.JavaMailSenderImpl">
        <property name="host" value="${report.scheduler.mail.sender.host}"/>
        <property name="username" value="${report.scheduler.mail.sender.username}"/>
        <property name="password" value="${report.scheduler.mail.sender.password}"/>
        <property name="protocol" value="${report.scheduler.mail.sender.protocol}"/>
        <property name="port" value="${report.scheduler.mail.sender.port}"/>
        <property name="javaMailProperties">
            <props>
                        <prop key="mail.smtp.auth">true</prop>
        <prop key="mail.smtp.starttls.enable">true</prop>
            </props>
        </property>
    </bean>

NOTE :Restart jasper server once the changes done if it is already running

Step - 2 

Now, lets work with a report and test.
* Professional server is having sample built in reports. Pick one of the report , for instance  pick "07g.RevenueDetailReport"

* Locate this report in the server, right click it find "schedule" option and click on it


Step - 3

* After clicking Schedule option, it will take us to "Schedule Job" jasper page. We call scheduling procedure as job and term it as scheduling jobs for reports.

* Click on "Create Schedule" button  and find the four tabs i) Schedule ii) Parameters iii) Output Options and iv) Notifications

i)  Schedule Tab:

As shown in below image set
a) the date and time of execution
b) Recurrence ( See documentation for the various recurrence in reference
c) Move to Parameters tab.



ii) Parameters Tab :
select the parameters of the report here .. we will get the output in pdf format for the selected input controls
* Fill all the required properties in all of the sections and save the job.

iii)  Output Options 
find the options in the image

iv) Notifications :
Find the information in below image


Click on Save button and give a name to scheduler (job)
Find the all scheduled  jobs ..

OUTPUT : Check it out in email

login to the gamil with below credentials and check the output.
testjasperreport@gmail.com /jasperreports


Opening the 2nd mail : Attachments one

Opening the 1st mail : Notifications mail


Check the output in CC mail :




Solution-2 :  (smtps)

Change below at 1st location. 
file name & location : <Jasper Installed Home>apache-tomcat/webapps/jasperserver/WEB-INF/js.quartz.properties

report.scheduler.web.deployment.uri=http://127.0.0.1:8080/jasperserver-pro/

report.scheduler.mail.sender.host=smtp.gmail.com
report.scheduler.mail.sender.username=testjasperreport@gmail.com
report.scheduler.mail.sender.password=jasperreports
report.scheduler.mail.sender.from=testjasperreport@gmail.com
report.scheduler.mail.sender.protocol=smtps
report.scheduler.mail.sender.port=465
Change below in 2nd location

 <bean id="reportSchedulerMailSender" class="org.springframework.mail.javamail.JavaMailSenderImpl">
        <property name="host" value="${report.scheduler.mail.sender.host}"/>
        <property name="username" value="${report.scheduler.mail.sender.username}"/>
        <property name="password" value="${report.scheduler.mail.sender.password}"/>
        <property name="protocol" value="${report.scheduler.mail.sender.protocol}"/>
        <property name="port" value="${report.scheduler.mail.sender.port}"/>
        <property name="javaMailProperties">
            <props>
                        <prop key="mail.smtps.auth">true</prop>
        <prop key="mail.smtps.starttls.enable">true</prop>
            </props>
        </property>
    </bean>

and the remaining procedure of setting mail is same

NOTE (Additional Notes): 
If we use Microsoft Exchange mail Services, then we need to add one more line in the applicationContext-report-scheduling.xml

      <props>
            <prop key="mail.smtp.auth">true</prop>
            <prop key="mail.smtp.starttls.enable">true</prop>
            <prop key="mail.smtp.starttls.required">true</prop>
        </props>

Resources 

Find More information at below sites : 

1)  http://stackoverflow.com/questions/9683679/email-not-sent-in-jasper-report-scheduling
2) https://mdahlman.wordpress.com/2011/09/28/emailing-reports-from-jasperreports-server/
3) http://community.jaspersoft.com/wiki/configuring-report-scheduler
4) https://community.jaspersoft.com/documentation/tibco-jasperreports-server-installation-guide-community-edition/v60/configuring-report

Tip : Removing Meta data of exported or scheduled or e-mail bursted jasper report : Or Changing the report pdf export meta data for Adobe Reader application

This post will give you the quick information on removing or user given pdf application name for jasper reports when open in applications like "Adobe reader".

Generally when you export the report output and open the same pdf file(s) using applications like "Adobe Reader" you can find the application name of the pdf by going "File-> Properties".

By default  the application name for the exported report in pdf format is : Jasper Reports Library 6.0

Now, the question is how to remove this or supply user name ? ( can be a developer name or email sender name)

I must say thanks to  Carlos ( A community guy) for asking me to explore and work this in Jasper. (I love doing experimenting and find something as like you).

This is as simple as one can do very easily in 2 to 3 steps and explained below( but for the 1st attempt one might get conflicts & here is the helping hand for you).

Software used : Jasper Studio 6.x and Jasper Server 6.x, Postgre SQL for simple report testing.

CASE-1 : With a Name supplied for the report 
Step 1: 
Open the report in studio and go to the properties of report
Outline -> Click on Report Name -> Find the properties of the Reports -> Find for the properties in the list and click on Add properties.

Now, add this property
Property Name: net.sf.jasperreports.export.pdf.metadata.creator
Value : Carlos Natividade

Now save the report and run (publish/schedule/email burst) and export it to pdf.

Test 1 : Exporting from studio and checking in Adobe reader properties (application name)
Test 2 : Exporting from Jasper Server and checking the file from Adobe reader properties (application name)
Test 3 : Scheduling the report in the JasperServer - output of scheduled report format is pdf and test by downloading it and checking the file from Adobe reader properties (application name)
Test 4: Email bursted report in pdf format - download the report and check the file from Adobe reader properties (application name)

In all the cases we get the application name with Carlos Natividade.

For your quick reference find the below sample output opened in "Adobe Reader Application"


CASE-II : Don't want to print any name for exported pdf when open in application like "Adobe"
Repeat the CASE-I procedure but simply ignore the value for the property.
Sample output image :


Looking for similar kind of properties to apply, please refer below reference link and play around with the properties. 

A sample JRXML which runs on postgresql foodmart database: (Looking for ready available JRXML - Copy paste below entire code in a opened Jasper Report and test it)

<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 6.0.1.final using JasperReports Library version 6.0.0  -->
<!-- 2015-03-31T01:45:40 -->
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="&quot;&quot;" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="6d836bdc-d774-45c5-8e2c-5431bdf1f892">
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="foodmart_db"/>
<property name="net.sf.jasperreports.export.pdf.metadata.creator" value="Carlos Natividade"/>
<property name="ireport.jasperserver.url" value="http://localhost:8080/jasperserver-pro/"/>
<property name="ireport.jasperserver.user" value="superuser"/>
<property name="ireport.jasperserver.report.resource" value="/Explore/RemovalOfMetaData_files/main_jrxml"/>
<property name="ireport.jasperserver.reportUnit" value="/Explore/RemovalOfMetaData"/>
<queryString language="SQL">
<![CDATA[SELECT * FROM customer LIMIT 10]]>
</queryString>
<field name="customer_id" class="java.lang.Integer"/>
<field name="account_num" class="java.lang.Long"/>
<field name="lname" class="java.lang.String"/>
<field name="fname" class="java.lang.String"/>
<field name="mi" class="java.lang.String"/>
<field name="address1" class="java.lang.String"/>
<field name="address2" class="java.lang.String"/>
<field name="address3" class="java.lang.String"/>
<field name="address4" class="java.lang.String"/>
<field name="city" class="java.lang.String"/>
<field name="state_province" class="java.lang.String"/>
<field name="postal_code" class="java.lang.String"/>
<field name="country" class="java.lang.String"/>
<field name="customer_region_id" class="java.lang.Integer"/>
<field name="phone1" class="java.lang.String"/>
<field name="phone2" class="java.lang.String"/>
<field name="birthdate" class="java.sql.Date"/>
<field name="marital_status" class="java.lang.String"/>
<field name="yearly_income" class="java.lang.String"/>
<field name="gender" class="java.lang.String"/>
<field name="total_children" class="java.lang.Integer"/>
<field name="num_children_at_home" class="java.lang.Integer"/>
<field name="education" class="java.lang.String"/>
<field name="date_accnt_opened" class="java.sql.Date"/>
<field name="member_card" class="java.lang.String"/>
<field name="occupation" class="java.lang.String"/>
<field name="houseowner" class="java.lang.String"/>
<field name="num_cars_owned" class="java.lang.Integer"/>
<field name="fullname" class="java.lang.String"/>
<background>
<band splitType="Stretch"/>
</background>
<title>
<band height="28" splitType="Stretch"/>
</title>
<columnHeader>
<band height="33" splitType="Stretch">
<textField>
<reportElement x="0" y="0" width="141" height="30" uuid="fee430bb-49ac-4209-8e03-9e4e38b40c0f">
<property name="local_mesure_unity" value="pixel"/>
<property name="com.jaspersoft.studio.unit.y" value="px"/>
</reportElement>
<textFieldExpression><![CDATA["Customer ID"]]></textFieldExpression>
</textField>
<textField>
<reportElement x="141" y="0" width="141" height="30" uuid="35f79e2f-6669-454d-995a-e4697edbabae">
<property name="com.jaspersoft.studio.unit.y" value="px"/>
</reportElement>
<textFieldExpression><![CDATA["Account Number"]]></textFieldExpression>
</textField>
<textField>
<reportElement x="282" y="0" width="141" height="30" uuid="ad4be3cf-c3cd-489f-8bef-275cefe87e14">
<property name="com.jaspersoft.studio.unit.y" value="px"/>
</reportElement>
<textFieldExpression><![CDATA["Last Name"]]></textFieldExpression>
</textField>
<textField>
<reportElement x="430" y="0" width="124" height="30" uuid="67609fe5-b3bf-48e8-b1de-6e807e5759f2">
<property name="com.jaspersoft.studio.unit.y" value="px"/>
</reportElement>
<textFieldExpression><![CDATA["First Name"]]></textFieldExpression>
</textField>
</band>
</columnHeader>
<detail>
<band height="32" splitType="Stretch">
<textField>
<reportElement x="0" y="0" width="141" height="30" uuid="40ea0517-5729-4d45-bbca-5ba4b9f727d4"/>
<textFieldExpression><![CDATA[$F{customer_id}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="141" y="0" width="138" height="30" uuid="95c30bfc-3933-4d41-b748-8d1bae7f894a"/>
<textFieldExpression><![CDATA[$F{account_num}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="279" y="0" width="138" height="30" uuid="3bf1e187-5105-41fa-a95b-5abcb66fe4b4"/>
<textFieldExpression><![CDATA[$F{lname}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="417" y="0" width="138" height="30" uuid="17271741-98ff-4e32-ad8a-6792020574de"/>
<textFieldExpression><![CDATA[$F{fname}]]></textFieldExpression>
</textField>
</band>
</detail>

</jasperReport>


Reference:

http://jasperreports.sourceforge.net/config.reference.html#net.sf.jasperreports.export.pdf.metadata.creator

Dates in Jasper iReport or Jasper Studio


1) Current Date (java.util.Date )
   new Date()

2) Yesterday (java.lang.String )
  new SimpleDateFormat("yyyy-MM-dd").format(new Date().getTime() - 1* 24 * 60 * 60 * 1000)

3) Year (java.lang.String or java.lang.Integer)
new SimpleDateFormat("yyyy").format($P{CurrentDate})

4) Month - (java.lang.String or java.lang.Integer)
new SimpleDateFormat("MM").format($P{CurrentDate})

NOTE : All are parameter expressions 


Output:


JRXML

<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 6.0.0.final using JasperReports Library version 6.0.0  -->
<!-- 2015-04-02T11:41:40 -->
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="Dates" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="a16f4b6d-d5e0-4149-a914-a9c6f9a2e3f7">
    <property name="com.jaspersoft.studio.data.defaultdataadapter" value="One Empty Record"/>
    <import value="org.apache.commons.lang.time.*"/>
    <parameter name="CurrentDate" class="java.util.Date">
        <defaultValueExpression><![CDATA[new Date()]]></defaultValueExpression>
    </parameter>
    <parameter name="YesterDay" class="java.lang.String" isForPrompting="false">
        <defaultValueExpression><![CDATA[ new SimpleDateFormat("yyyy-MM-dd").format(new Date().getTime() - 1* 24 * 60 * 60 * 1000)]]></defaultValueExpression>
    </parameter>
    <parameter name="Year" class="java.lang.String" isForPrompting="false">
        <parameterDescription><![CDATA[]]></parameterDescription>
        <defaultValueExpression><![CDATA[new SimpleDateFormat("yyyy").format($P{CurrentDate})]]></defaultValueExpression>
    </parameter>
    <parameter name="Month" class="java.lang.String" isForPrompting="false">
        <defaultValueExpression><![CDATA[new SimpleDateFormat("MM").format($P{CurrentDate})]]></defaultValueExpression>
    </parameter>
    <queryString>
        <![CDATA[]]>
    </queryString>
    <background>
        <band splitType="Stretch"/>
    </background>
    <title>
        <band height="130" splitType="Stretch">
            <textField>
                <reportElement x="180" y="0" width="100" height="30" uuid="a2b61b2f-e891-415e-b49e-e6c4d4fe62fe"/>
                <textElement textAlignment="Left" verticalAlignment="Middle"/>
                <textFieldExpression><![CDATA[$P{CurrentDate}]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement x="180" y="30" width="100" height="30" uuid="2732b9cc-8dcc-4a64-9da6-2ca5273ff95b"/>
                <textElement textAlignment="Left" verticalAlignment="Middle"/>
                <textFieldExpression><![CDATA[$P{YesterDay}]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement x="180" y="60" width="100" height="30" uuid="a19d13b2-ef38-4e9f-a0c7-9bd78d6b7968"/>
                <textElement textAlignment="Left" verticalAlignment="Middle"/>
                <textFieldExpression><![CDATA[$P{Year}]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement x="180" y="90" width="100" height="30" uuid="3f2ee16c-a9eb-4530-a274-e806a11a1d91"/>
                <textElement textAlignment="Left" verticalAlignment="Middle"/>
                <textFieldExpression><![CDATA[$P{Month}]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement x="80" y="0" width="100" height="30" uuid="6449e356-b6db-4a93-8b4a-f60aa1b66ae0"/>
                <textElement textAlignment="Left" verticalAlignment="Middle"/>
                <textFieldExpression><![CDATA["Current Date"]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement x="80" y="30" width="100" height="30" uuid="ca7a0a48-71cd-4551-9214-127e7a60966b"/>
                <textElement textAlignment="Left" verticalAlignment="Middle"/>
                <textFieldExpression><![CDATA["Yesterday"]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement x="80" y="60" width="100" height="30" uuid="a85e016c-eec8-41f4-82f5-f9ff189712be"/>
                <textElement textAlignment="Left" verticalAlignment="Middle"/>
                <textFieldExpression><![CDATA["Year"]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement x="80" y="90" width="100" height="30" uuid="07aba093-af79-4752-a6fd-07e4a0bb90bf"/>
                <textElement textAlignment="Left" verticalAlignment="Middle"/>
                <textFieldExpression><![CDATA["Month"]]></textFieldExpression>
            </textField>
        </band>
    </title>
</jasperReport>

You may be interested in exploring below

1) Date Parameters in iReport Designer OR Date Input Controls in JasperServer Repository 

2) Dates in Jasper iReport - Expression for default values and couting the number of months b/w given two dates. 

3) Jasper Server Calendar Date input control date fomat change - Change date format from yy-mm-dd to mm/dd/yyyy 

4) Date input control default value in jasper iReport - Giving date value in default expression. 

5)  Easy way of Substracting,Adding Months or Days from parameter date in Jasper studio or iReport : Ex : Substracting 2 months from current date




Tip : Convert Decimal to Integer and change its pattern using java expression on a text field in Jasper Studio 6.x or iReport 5.x (Or) Combine text with field value for dynamic space in Jasper Reports

This tip will be useful in below scenarios with Jasper Reports

Sometimes you may need to combine Text with a value coming from database field .
Generally you take two fields for this. Text field for printing text and Filed for field value and set pattern for it and adjust the positions of these two fields. But what if your value dynamically changes.

That is some times you may get 2 digit integer and sometimes you may get 5 digit integer. Do you really get dynamic space b/w two fields ( Text field and Database field).

Problem Image : 




Solution : 
Combine text with field using java expression

1) Get the integer value first by rounding.
 (Generally a double have type java.math.BigDecimal in report tool)
(int) ( $F{sales} + 0.5)

2) Get the comma separated integer from above integer using below syntax
NumberFormat.getIntegerInstance().format(<Integer Value>)

3) Combining both steps 1 & 2

Orders : 70 for $19,436 (Now there will not be any space when combining text with field value)

Example : 
"invoices for"+""+"\$"+ NumberFormat.getIntegerInstance().format((int) ( $F{sales} + 0.5))


NOTE: 
1) In Jasper reports do display $ sign in an expression one should use backslash character combined in double quotes ( i.e., "\$")

I hope this helps someone :-)

Cheers..!!


Tip : JFree Bar Chart Customization in Jasper Reports: Moving Bar Itemlabels ( some times values will not fully apper for -ve highest bars)

This post will provide you the code snippets to write in customizer method for JFree Bar Chart in
Jasper Reports

1) Remove space between 2 or  more series within a category.
2) Remove space between 2 or more categories for chart
3)  Remove horizontal and vertical grid lines for bar chart.
4) Fix overlapping of the highest -Ve bar value with category label. 
5) Fixed width for the bars

Problem Image : 


Solution Image :



/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
/**
 *
 * @author SADAKAR POCHAMPALLI
 */

package com.sadakar.jfree;
import net.sf.jasperreports.engine.JRAbstractChartCustomizer;
import net.sf.jasperreports.engine.JRChart;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.plot.CategoryPlot;
import org.jfree.chart.renderer.category.BarRenderer;
import org.jfree.chart.axis.CategoryAxis;

import org.jfree.chart.labels.ItemLabelPosition;
import org.jfree.chart.labels.ItemLabelAnchor;
import org.jfree.ui.TextAnchor;

import org.jfree.util.UnitType;

public class JFree extends JRAbstractChartCustomizer{
@Override
public void customize(JFreeChart chart, JRChart jasperChart){
CategoryPlot categoryPlot=chart.getCategoryPlot();
BarRenderer renderer=(BarRenderer)categoryPlot.getRenderer();

//The space between 2 series within a category is controlled by the attribute itemMargin
renderer.setItemMargin(-0.5);
categoryPlot.setRenderer(renderer);

//The space between 2 categories is controlled by the categoryMargin attribute of the CategoryAxis //for the plot
 CategoryAxis domainAxis = categoryPlot.getDomainAxis();
 domainAxis.setCategoryMargin(0.3f);


// -Ve bar Item Labels positions - Below lines of code will not cut down the item label for the biggest //value of bar
//renderer.setSeriesNegativeItemLabelPosition(0, new //ItemLabelPosition(ItemLabelAnchor.OUTSIDE11,TextAnchor.BASELINE_CENTER));

renderer.setItemLabelAnchorOffset(0.1);
renderer.setBaseItemLabelsVisible(true);
renderer.setMaximumBarWidth(0.01);


categoryPlot.setRangeGridlinesVisible(false);
categoryPlot.setDomainGridlinesVisible(false);


}
}

You may be interested in similar posts in this site. 

1) JFree Bar Chart Customization in Jasper iReport - Decrease the size of bars & space between bars

2) JFree Line Chart Cusomization in Jasper iReport. Line to Dashed-line, line width,gap in the dashed lines

3) JFree Meter chart customization in Jasper iReport-- Removing values from the meter

4) JFree Bar Chart Customization in iReport.. Category axis labels overlapping is removed


TIP : Handle divide by zero expression in Jasper Reports

CASE : 
0/0 or
23/0

In general,
something/zero will results infinity and causes to divide by zero error in jasper reports. We can handle to have expression value as 0 when denominator is zero.

Example :

$F{number_of_sales}.intValue()==0?0:$F{unit_sales}.intValue()/$F{number_of_sales}.intValue()

Ternary operator usage in Jasper Reports.

NOTE : If you fields are Decimal types, you need to work with methods.

Will update this page for decimals.


:-)

Creating Oracle JNDI or Actian Pervasive(PSQL) database JNDI connections in Jasper Server 6.X

Software : 
Oracle 11g , Jasper Server 6.0

Aim : To run the stored procedures. Below are the possibilities that may stop you to run the reports developed using SP.
1) Read Only databases when running SP reports in Jasper Server.
2) No Query executor for PLSQL(Not discussed in this post).

UPDATED with new content  :  16th April 2015Creating Actian Pervasive(PSQL) database JNDI connection in Jasper Server. 


Oracle JNDI connection creation : 

Step 1 : jdbc driver 

Copy the ojdb6.jar file to lib folder of tomact
Location of lib : C:\Jaspersoft\jasperreports-server-6.0\apache-tomcat\lib

NOTE: jdbc driver differs from Oracle version to version. Choose the suitable one in your case.

Step 2 :Add below lines of jdbc resource code in context.xml file

File location : 
C:\Jaspersoft\jasperreports-server-6.0\apache-tomcat\webapps\jasperserver-pro\META-INF

   <Resource name="jdbc/oracledev" auth="Container" type="javax.sql.DataSource"
        maxActive="100" maxIdle="30" maxWait="10000"
        username="myusername" password="mypassword" 
        driverClassName="oracle.jdbc.OracleDriver"
        validationQuery="SELECT 1 FROM DUAL"
        testOnBorrow="true"
        url="jdbc:oracle:thin:@171.13.0.34:1523/mySID"

        factory="com.jaspersoft.jasperserver.tomcat.jndi.JSBasicDataSourceFactory"/>

IMP NOTE : 
I've got errors while giving url string  ( after oracle Port there should be forward slash but not colon).
For example :

Correct url string : url="jdbc:oracle:thin:@171.13.0.34:1523/mySID"
Wrong url string : url="jdbc:oracle:thin:@171.13.0.34:1523:mySID"

Explained at : 
http://community.jaspersoft.com/questions/851811/error-while-creating-oracle-jndi-connection-jasper-server#comment-811806

Step 3 :  Refer the resource added in step 2 in web.xml file 

File llocation : 
C:\Jaspersoft\jasperreports-server-6.0\apache-tomcat\webapps\jasperserver-pro\WEB-INF

  <resource-ref>
    <description>Excers DEV database</description>
    <res-ref-name>jdbc/oracledev</res-ref-name>
    <res-type>javax.sql.DataSource</res-type>
    <res-auth>Container</res-auth>
  </resource-ref>

Step 4 : 

Do all the changes from step-1 to step-3 by stopping the server.
Start or Restart the jasper server.

Create a folder and add a Data source of type JNDI and give name . In this example it is jdbc/oracledev and then click on Test button.

That's all we have to do to connect jdbc as JNDI in jasper server.


Actian Pervasive(PSQL) database JNDI creation in Jasper Server 

I'd like to share how I created a JNDI connection for pervasive db in Jasper Server.

1) Add pervasive database jar files to tomcat lib folder. 
Location of lib folder : C:\Jaspersoft\jasperreports-server-5.6.1\apache-tomcat\lib
JDBC diver file names : i) jpscs.jar ii) pvjdbc2.jar and iii) pvjdbc2x.jar 
NOTE : Add all the 3 jar files to the lib folder. (these 3 jar files are the JDBC drivers for pervasive db). 

2) Add resource code in context.xml file 
C:\Jaspersoft\jasperreports-server-6.0\apache-tomcat\webapps\jasperserver-pro\META-INF\context.xml

<Resource name="jdbc/pervasiveDB" auth="Container" type="javax.sql.DataSource"
        maxActive="100" maxIdle="30" maxWait="10000"
        username="myUserName" password="myPassword
        driverClassName="com.pervasive.jdbc.v2.Driver"
        validationQuery="SELECT 1"
        testOnBorrow="true"
        url="jdbc:pervasive://11.0.1.11:1283/pervasiveDB"
        factory="com.jaspersoft.jasperserver.tomcat.jndi.JSBasicDataSourceFactory"/>

3) Refer the above created resource in web.xml file (Optional)

C:\Jaspersoft\jasperreports-server-6.0\apache-tomcat\webapps\jasperserver-pro\WEB-INF\web.xml
<resource-ref>
    <description>Pervasive pervasiveDB database</description>
    <res-ref-name>jdbc/pervasiveDB</res-ref-name>
    <res-type>javax.sql.DataSource</res-type>
    <res-auth>Container</res-auth>
  </resource-ref>

4) Restart the Jasper Server
5) Create a datasource of type JNDI in Jasper Server by providing the JNDI name as jdbc/pervasiveDB and test the connection. 

References Pervasive db: 


Refer these links :
http://community.jaspersoft.com/questions/525672/postgresql-jasper-reporting-server-error

http://community.jaspersoft.com/wiki/how-add-new-jndi-connection-tomcat

http://community.jaspersoft.com/wiki/jndi-datasource-update-trouble-cannot-create-jdbc-driver-class-connect-url-null

https://community.jaspersoft.com/wiki/connecting-jasperreports-server-your-database

http://www.microdeveloper.com/html/JNDI_Orcl_Tomcat1p.html

http://community.jaspersoft.com/wiki/data-source-troubleshooting

http://stackoverflow.com/questions/18192521/ora-12505-tnslistener-does-not-currently-know-of-sid-given-in-connect-descript


Cheers..!!!

Update : URL string properties : 
http://commons.apache.org/proper/commons-dbcp/configuration.html

Limit number of rows on Table component at report level in Jasper Studio 6.x or iReport - usage of REPORT_MAX_COUNT parameter for table

This post will guide you on below things
1) How to limit the number of rows on table component at report level.
2) How to work with REPORT_MAX_COUNT
3) How to export Excel output to two tabs(sheets)

USE CASE : 
Data set(SQL) returns N number of rows. Display top 10 rows in one sheet & All rows(including top 10 rows) in another sheet.

BENEFITS
1) Used 1 SQL query on two table components.
2) Limiting the rows to display on table components at report level ( not in SQL level).
3) Increase the performance of report (SQL query hits db only once)
4) Save time & provide value added solutions to client.

Solution Steps: 

1)Take two groups (or summary band) to keep two table components & create a dataset.
  (Use page break & ignore pagination property checked).
2) Make these two table components to use the created dataset.
3) Jump into the report XML code and write the code for first table component.
i.e., (Search for 1st table component code in XML editor)

<jr:table xmlns:jr="http://jasperreports.sourceforge.net/jasperreports/components" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports/components http://jasperreports.sourceforge.net/xsd/components.xsd">

<datasetRun subDataset="E2E Inventory" uuid="f7d1fb44-409b-4dee-a200-e78f49ed1bbf">

<datasetParameter name="REPORT_MAX_COUNT">
     <datasetParameterExpression><![CDATA[new Integer(10)]]>          </datasetParameterExpression>
</datasetParameter>

<connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]>  </connectionExpression>
</datasetRun>

4) Save the report & preview it on server then export to Excel. (use excel related properties to export into multiple sheets with it's names).


Excel Export properties (Add below properties to report - right click report & find properties).
net.sf.jasperreports.export.xls.sheet.names.1Top 10 Rows
net.sf.jasperreports.export.xls.sheet.names.2All Items
net.sf.jasperreports.page.break.no.paginationapply
net.sf.jasperreports.export.xls.ignore.cell.border      false

IMP NOTE : 
The procedure is useful when you do not have any calculated fields on table component.
Click here to find another post on limiting number of rows on table component with calculated fileds.

limit the number of rows after adding a calculated field on table component & remove all empty cells

USE CASE : 
Find a percentage field on table component and limit the rows to top 10
i.e., There is a field "A" of Double type then find the percentage field of A and then limit to top 10.
% filed = A/Total_Of_A

In this case we can't apply REPORT_MAX_COUNT parameter to table & to it's dataset.(b'z we have a calculated field of percentage .. The summation variable "Total_Of_A" adding all the values of A but not only 10 values.

Here are the solution steps. 
1) Take a variable(Total_Of_Field_A)and find the summation of column A.
2) Add a new cell(header, detail and footer cells) to the table component and take a text field in Detail cell and in it's expression write A/$V{Total_Of_Field_A}
3) The above calculation returns the calculated filed on table component.
4) Now select all the fields and go to print when expression commonly and write $V{REPORT_COUNT}<11 which will returns only top 10 rows.
5) Issue : Though you get top 10 rows you will be finding all empty cells of whole table data.
6) Remove border for all the cells. ( i.e., to the Column cells in Detail band of table ) and provide border only to text fields.

In this way one can easily write report limiting to 10 rows using table component at report level.

References :
1) http://community.jaspersoft.com/sites/all/libraries/pdf.js/web/viewer.html?file=http://community.jaspersoft.com/system/files/documentation/jasperreports-ultimate-guide-3v2.pdf#page=75

2) http://community.jaspersoft.com/wiki/jasperreports-built-parameter-reportmaxcount-and-interactive-jive-sort-feature


If you like the article click on g+ button  :-)

Cheers..!!!




Actian Pervasive database connection in Jasper iReport 5.6 / iReport Pro 5.6

This post will give you quick overview on installing Actain Pervasive database drivers in iReport 5.x version

1) In iReport 5.x , Go to "Tools" then "Options" then Click On Classpath
2) Locate all the 3 drivers and check them.
3) Go to your database connections window and provide the driver class, jdbc URL & username, password.

Quick Images : 
1) Drivers Installation 

2) Database connection 



Visit below links to download the pervasive database drivers
http://www.pervasive.com/database/Home/Products/PSQLv11.aspx
http://www.dbschema.com/pervasive-jdbc-driver.html


Other way to install Pervasive drivers explained
Follow the steps explained in below link :
http://community.jaspersoft.com/wiki/connecting-ireport-pervasive-datasource

Do you find it useful ? Click g+ and share to community.

Thank you. 

Tip : custom pattern for decimal values for a field in Jasper iReport 5.x or Jasper Design Studio 6.x - Useful when exporting the report to Excel

This post will give you the tip of handling custom pattern for decimal values for a field values in Jasper reports at report level.

Even Though, you can handle it from SQL level some time we may not get handy with SQL for quick development of reports.

Problem Statement : 
If the decimal field value is 45.8900 then get the value as 45.890 (###0.###)
If the decimal field value is 5.0000 or 0.0000 then get it as 5 or 0 (###0)
The output pattern should be same on Jasperserver page output and when export to excel. 


USE CASE EXAMPLE : 

Let us assume your result of SQL query is as below

Sales
0.0000
23.9300
0.0000
5.0000
5.0000
6.9300
8.9400
9.1950

Final output in on Jasperserver web page & when export to Excel should be as follows. 

Sales
0
23.430
0
5
5
6.930
8.940
9.195

Without providing any pattern on filed you will get output as below 
On Jasper Server page output
0.0000
23.9300
0.0000
5.0000
5.0000
6.9300
8.9400
9.1950

When export to Excel ( You will get dots if the value is 0 or 5 and this should be avoided)
.
23.93
.
5.
5.
6.93
8.94
9.195


If you apply default pattern available on filed then the output on Jasperserver page and in Excel export would be as below 
pattern applied on field value is : ###0.000

0.000
23.930
0.000
5.000
5.000
6.930
8.940
9.195

Now, How to overcome the situation to get the output as shown below in both Jasperserver page and in excel export. 

0
23.430
0
5
5
6.930
8.940
9.195

Solution : 
Select the text field and in it's expression editor write expression as below

($F{Sales}-(int)$F{Sales}!=0)?new DecimalFormat("####0.000").format($F{Sales}):new DecimalFormat("####0").format($F{Sales}) 


General Example 
---------------------------------------------------------------------
double d = 77.7;
if((d-(int)d)!=0)
    
double d = 77.7;
if((d-(int)d)!=0)
    System.out.println("decimal value is there");
else
    System.out.println("decimal value is not there");
----------------------------------------------------------------------

That's all we have  to write custom pattern for decimal values. If the value is like 5.0000 then ignore all zeros and get only 5 and if the value is like 54.8970 then get get 54.897

I hope this helps someone :-)

Did you find it helpful ? Hit the g+ share button and let us spread it for community.

References:
http://stackoverflow.com/questions/15963895/how-to-check-if-a-double-value-has-no-decimal-part

Cheers..!!!

- Sadakar Pochampalli















Tip : Change port number for postgresql server installed with Jasper Server (CE or EE)


What will happen if you install two professional versions of Jasperserver in your local machine.

Let say 5.6 and 6.0.1 and first installed version is 5.6 & later installed version is 6.0.1

First server takes 5432 as port for postgres and 8080 for tomcat and the next server takes 5433 and 8080(sometimes 8081) ports respectively for postgres and tomcat.

If want to make the 6.0.1 Jaspers postgres to make use 5432 as default one you need to change the port number in postgresql.conf file.

File location : C:\Jaspersoft\jasperreports-server-6.0.1\postgresql\data

Once the changes done, restart of japsers postgresql is required.

Find the below image :



Business Analyst best practices to follow while converting reports from other platform to Enterprise TIBCO Jasper soft platform.

Hello Analysts ...!!!!

This post will quickly gives idea for Business Analysts (and content writers) on converting enterprise Business Intelligence projects from other platforms to Enterprise TIBCOJaspersoft platform.


Questionnaires that usually comes in while talking about TIBCOJaspersoft BI platform. 

1) What is Enterprise TIBCOJaspersoft Business Intelligence ?

2) Where one can find information on TIBCOJaspersoft BI platform ?

3) What are the features of TIBCOJaspersoft Business Intelligence ?

4) How Enterprise TIBCOJaspersoft BI platform differ from other Enterprise BI platforms in the Market ?

5) What is the cost of TIBCOJaspersoft BI product(s) & official support ?

6) Is there any mechanism to migrate projects from other to jasper ?

7) What are the products & functionality of each tool product ?

8) How easy to convert reports/dashboards/analysis/analytics/ETL solutions from other plat form to TIBCOJaspersoft plat form ?

9)  Does TIBCOJaspersoft supports responsive visualizations ? (i.e., Mobile Intelligence)

10) Does TIBCOJaspersoft supports BigData technologies ?

There could be other questions that comes into mind.
(Share your question in comments section so that we can get to know more information to this article).


1) What is Enterprise TIBCOJaspersoft Business Intelligence ? 

Jaspersoft product has started as an opensource BI technology and it still in releases timely. Along with opensource edition(or community edition) it also offers it's enterprise edition with Advanced features over community edition like multi tenancy, OLAP analysis , ad-hoc reporting and etc. 


2) Where one can find information on TIBCOJaspersoft BI platform ?

One can visit the TIBCO jaspersoft official website at http://www.jaspersoft.com/ to know more about it. 
It also has community website & the url is : http://community.jaspersoft.com/


3) What are the features of TIBCOJaspersoft Business Intelligence ? 

TIBCOJaspersoft BI suite has below features 

a) Enterprise Reports 
b) Enterprise Dashboards
c) Enterprise Analysis Tools
d) Enterprise Ad-hoc reporting tools.
e) Enterprise Embedding Business Intelligence.
f) Enterprise security features. 
g) Enterprise Mobile BI. 


4) How Enterprise TIBCOJaspersoft BI platform differ from other Enterprise BI platforms in the Market ?

* Every organization/firm needs reports/dashboards for tracking its business day to day to take better decisions. 
* There are "N" number of Enterprise BI tools available in the market but why do we need to chose this means 

firstly , as it as an open source suite its enterprise edition  is cheaper than any other enterprise BI platform.

secondly, it has powerful enterprise features as explained in point-3 which you might not find in other enterprise BI suite. 

last but not the least, Jaspersoft is in very active stage with new technologies such as HTML-5, D-3 , BigData and in it's every new release one can find these type of features as how business intelligence is moving with data world. 



5) What is the cost of TIBCOJaspersoft BI product(s) & official support ?

One must contact TIBCOJaspersoft to know pricing.
Contact link : http://www.jaspersoft.com/contact-us 

Costing differ from edition to edition and number of licenses 

( Editions of Jaspersoft : Community, Reporting, AWS(Amazon Web Services), Professional & Enterprise). 


6) Is there any mechanism to migrate projects from other to jasper ? 

No, there is no a mechanism to migrate projects from other to Jasper. 

Redesign / Re writing Jaspersoft realted code to convert from other platform to Jspersoft is required. 

For example : A report developed in Pentaho or Crystal can not be loaded in Jaspersoft. We have to develop the fresh report by taking the previous platform as a reference. 


7) What are the products & functionality of each product ? 

Jaspersoft offers all the BI implementation community and enterprise products .
They are 

1) Jaspersoft Professional Design Studio - For Reports Development 
2) Jaspersoft Enterprise Business Intelligence Server 
3) Jaspersoft ETL - For Data Integration & data warehousing services 
4) Jaspersoft Schema work bench - For OLAP functionality 
5) Jaspersoft libraries - For third party intelligence of Jasper reports. 
6) Jaspersoft Visualize.js - For Embedding BI
7) Jaspersoft Mobile BI Server. - For Mobile Intelligence 


8) How easy to convert reports/dashboards/analysis/analytics/ETL solutions from other plat form to TIBCOJaspersoft plat form ? 

* Based on project size it can be determined .
* Example : 
Assume one needs to convert reports from "X" platform to Jspersoft paltform . 

i) Classify the reports into low, medium & complex or high complex. 
    a) low level : plain reports with minimum functionality.
    b) Medium level : Graphical Reports with parameters & report level calculations. 
    c) Complex level : a) + b) with lots of report components in it and features like drill downs, drill 
                                   backs and etc. 

ii) Time Estimation : 
    a) plain reports conversion : 10 to 20 hours
    b) medium level reports conversion : 20 to 40 hours
    c) complex level reports conversion : 40 to 100 hours ( might vary). 

iii) Resource allocation : 
Again this depends on project size and dedicated Jaspesoft BI professionals. 

Example : Conversion of 10 medium level reports 

A minimum of 25 business days and a maximum of 50 business days is required to convert 10 medium level enterprise  reports with 1 Jaspersoft BI professional. 
     

9)  Does TIBCOJaspersoft supports responsive visualizations ? (i.e., Mobile Intelligence)
Yes, it supports from 5.6 version.
One can see the responsiveness of Jasper solutions in Mobile /ipad/laptop or desktop.

10) Does TIBCOJaspersoft supports BigData technologies ?
Yes, it supports bigData technologies.
Examples : One can have the reporting system with MogoDB.


Jasper soft Official Support portal : 
Once you have the product in hand, you can have official jaspersoft support at
https://support.jaspersoft.com/user/login?destination=support-my

One can request for
a) Threads related to development of BI solutions.
b) Training program
c) license information
d) Enterprise editions downloads and etc.


I believe, I have covered at least minimum points & have missed few..

Readers of this post encouraged to add your findings in comments box and let the community know ..

Thank you for reading this article.


- Sadakar Pochampalli (21st May 2015)

Classifications of Reports in Jaspersoft BI - Desktop reporting and Server side reporting

Hi folks,

This post will talk about the classifications & complexities involved in Jasper reports.

Hope readers of this post find something useful when proposing a report system to a customer.

1) Desktop Reports ( Types of reports can be developed using iReport or Jasper Studio ): 

1) Plain tabular reports
2) Cross tabular reports
3) Reports having sub reports
4) Graphical reports
5) Drill down reports
6) Majorly excel/pdf exported reports ( Tabular or Graphical with tabular).
7) Map reports
8) Widget reports
9) Domain based reports
10) Plain textual reports(text,images,html reports).

2) Server side Reports ( On-Fly reporting):
11) Ad-hoc reports(Domain/Topic based)
12) Ad-hoc reports(OLAP- Cubes based)
13) Legacy analysis reporting

Complexities of development:
1) Low complexity
2) Medium complexity
3) High complexity

Data sources & queries categorization:
RDBMS
1) Simple SQL with less joins
2) Complex SQL with more joins
3) Simple & complex stored procedures

Languages supported by Jaspersoft:
1) Groovy script
2) Java script
3) Java

----------------------------------------------------



Viewing all 261 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>