Jaspersoft BI Tools

iReport,Jaspersoft Design Studio,Jaspersoft Server, Schema Workbench,Analysis,Dashboards, Self Service BI, Domains,Topics,Ad-Hoc Reports, Jaspersoft ETL, Embedding BI,HTML-5 charts, Fusion Charts,JFree Charts,Drill down reports , Drill down Dashboards,Visualize.js, Performance Tuning, D3 Charts, Jaspersoft Customization

Thursday, July 06, 2017

Tips : Dates Calculations - Current Month, Previous Month, Next Months (add or substract 1 month, first date of months, day name, day number 0,1..6) in Jasper Reports

It is always fun playing with date related calculations in Jasper reports.

Here is another use case to find out below shown(2nd Image) dates in Jasper Reports.

Sample Design : (Click on image to get best view of content)


Sample Output: (Click on image to get best view of content)




Example Developed in : Jaspersoft Studio Professional 6.4
(NOTE: If you get any error while doing copy paste the below JRXML code, just replace the very first line of xml from other jrxml opened in your studio).


NOTE : 
Analise the calculations in Parameters ( In some cases, we can develop the same using variables)

JRXML : Developed in 6.4 Pro  (Copy - Paste below code in a JRXML opened in your studio)

<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 6.4.0.final using JasperReports Library version 6.4.1  -->
<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="Previous and Next Months" pageWidth="1000" pageHeight="842" whenNoDataType="AllSectionsNoDetail" columnWidth="960" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="be22b853-8ecd-45d5-993a-456ecbf2733b">
    <property name="com.jaspersoft.studio.data.defaultdataadapter" value="One Empty Record"/>
    <property name="com.jaspersoft.studio.unit." value="pixel"/>
    <property name="com.jaspersoft.studio.unit.pageHeight" value="pixel"/>
    <property name="com.jaspersoft.studio.unit.pageWidth" value="pixel"/>
    <property name="com.jaspersoft.studio.unit.topMargin" value="pixel"/>
    <property name="com.jaspersoft.studio.unit.bottomMargin" value="pixel"/>
    <property name="com.jaspersoft.studio.unit.leftMargin" value="pixel"/>
    <property name="com.jaspersoft.studio.unit.rightMargin" value="pixel"/>
    <property name="com.jaspersoft.studio.unit.columnWidth" value="pixel"/>
    <property name="com.jaspersoft.studio.unit.columnSpacing" value="pixel"/>
    <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="/EarthlySystems/Previous_and_Next_Months_files/main_jrxml"/>
    <property name="ireport.jasperserver.reportUnit" value="/EarthlySystems/Previous_and_Next_Months"/>
    <import value="org.apache.commons.lang.time.*"/>
    <parameter name="Date" class="java.util.Date">
        <defaultValueExpression><![CDATA[new Date()]]></defaultValueExpression>
    </parameter>
    <parameter name="PreviousMonthDate" class="java.util.Date" isForPrompting="false">
        <defaultValueExpression><![CDATA[DateUtils.addMonths($P{Date},-1)]]></defaultValueExpression>
    </parameter>
    <parameter name="NextMonthDate" class="java.util.Date" isForPrompting="false">
        <defaultValueExpression><![CDATA[DateUtils.addMonths($P{Date},1)]]></defaultValueExpression>
    </parameter>
    <parameter name="FirstDateOfCurrentMonth" class="java.lang.String" isForPrompting="false">
        <defaultValueExpression><![CDATA[new SimpleDateFormat("MM/dd/yyyy").format(java.util.Date.parse(MONTH($P{Date}) + "/1/" + YEAR($P{Date})))]]></defaultValueExpression>
    </parameter>
    <parameter name="FirstDayOfCurrentMonth" class="java.lang.String" isForPrompting="false">
        <defaultValueExpression><![CDATA[new SimpleDateFormat("EEE").format(java.util.Date.parse(MONTH($P{Date}) + "/1/" + YEAR($P{Date})))]]></defaultValueExpression>
    </parameter>
    <parameter name="FirstDateOfPreviousMonth" class="java.lang.String" isForPrompting="false">
        <defaultValueExpression><![CDATA[new SimpleDateFormat("MM/dd/yyyy").format(java.util.Date.parse(MONTH($P{PreviousMonthDate}) + "/1/" + YEAR($P{PreviousMonthDate})))]]></defaultValueExpression>
    </parameter>
    <parameter name="FirstDayOfPreviousMonth" class="java.lang.String" isForPrompting="false">
        <defaultValueExpression><![CDATA[new SimpleDateFormat("EEE").format(java.util.Date.parse(MONTH($P{PreviousMonthDate}) + "/1/" + YEAR($P{PreviousMonthDate})))]]></defaultValueExpression>
    </parameter>
    <parameter name="FirstDateOfNextMonth" class="java.lang.String" isForPrompting="false">
        <defaultValueExpression><![CDATA[new SimpleDateFormat("MM/dd/yyyy").format(java.util.Date.parse(MONTH($P{NextMonthDate}) + "/1/" + YEAR($P{NextMonthDate})))]]></defaultValueExpression>
    </parameter>
    <parameter name="FirstDayOfNextMonth" class="java.lang.String" isForPrompting="false">
        <defaultValueExpression><![CDATA[new SimpleDateFormat("EEE").format(java.util.Date.parse(MONTH($P{NextMonthDate}) + "/1/" + YEAR($P{NextMonthDate})))]]></defaultValueExpression>
    </parameter>
    <parameter name="CurrentDateFirstDayValueString" class="java.lang.String" isForPrompting="false">
        <parameterDescription><![CDATA[]]></parameterDescription>
        <defaultValueExpression><![CDATA[$P{FirstDayOfCurrentMonth}.equals("Sun") ? "0":
$P{FirstDayOfCurrentMonth}.equals("Mon") ? "1" :
$P{FirstDayOfCurrentMonth}.equals("Tue") ? "2" :
$P{FirstDayOfCurrentMonth}.equals("Wed") ? "3" :
$P{FirstDayOfCurrentMonth}.equals("Thu") ? "4" :
$P{FirstDayOfCurrentMonth}.equals("Fri") ? "5" :
$P{FirstDayOfCurrentMonth}.equals("Sat") ? "6" : "100"]]></defaultValueExpression>
    </parameter>
    <parameter name="CurrentDateFirstDayValueInteger" class="java.lang.Integer" isForPrompting="false">
        <parameterDescription><![CDATA[]]></parameterDescription>
        <defaultValueExpression><![CDATA[Integer.parseInt($P{CurrentDateFirstDayValueString})]]></defaultValueExpression>
    </parameter>
    <parameter name="PreviousMonthFirstDayValueString" class="java.lang.String" isForPrompting="false">
        <parameterDescription><![CDATA[]]></parameterDescription>
        <defaultValueExpression><![CDATA[$P{FirstDayOfPreviousMonth}.equals("Sun") ? "0":
$P{FirstDayOfPreviousMonth}.equals("Mon") ? "1" :
$P{FirstDayOfPreviousMonth}.equals("Tue") ? "2" :
$P{FirstDayOfPreviousMonth}.equals("Wed") ? "3" :
$P{FirstDayOfPreviousMonth}.equals("Thu") ? "4" :
$P{FirstDayOfPreviousMonth}.equals("Fri") ? "5" :
$P{FirstDayOfPreviousMonth}.equals("Sat") ? "6" : "100"]]></defaultValueExpression>
    </parameter>
    <parameter name="PerviousMonthFirstDayValueInteger" class="java.lang.Integer" isForPrompting="false">
        <parameterDescription><![CDATA[]]></parameterDescription>
        <defaultValueExpression><![CDATA[Integer.parseInt($P{PreviousMonthFirstDayValueString})]]></defaultValueExpression>
    </parameter>
    <parameter name="NextMonthFirstDayValueString" class="java.lang.String" isForPrompting="false">
        <parameterDescription><![CDATA[]]></parameterDescription>
        <defaultValueExpression><![CDATA[$P{FirstDayOfNextMonth}.equals("Sun") ? "0":
$P{FirstDayOfNextMonth}.equals("Mon") ? "1" :
$P{FirstDayOfNextMonth}.equals("Tue") ? "2" :
$P{FirstDayOfNextMonth}.equals("Wed") ? "3" :
$P{FirstDayOfNextMonth}.equals("Thu") ? "4" :
$P{FirstDayOfNextMonth}.equals("Fri") ? "5" :
$P{FirstDayOfNextMonth}.equals("Sat") ? "6" : "100"]]></defaultValueExpression>
    </parameter>
    <parameter name="NextMonthFirstDayValueInteger" class="java.lang.Integer" isForPrompting="false">
        <parameterDescription><![CDATA[]]></parameterDescription>
        <defaultValueExpression><![CDATA[Integer.parseInt($P{NextMonthFirstDayValueString})]]></defaultValueExpression>
    </parameter>
    <queryString>
        <![CDATA[]]>
    </queryString>
    <background>
        <band splitType="Stretch"/>
    </background>
    <title>
        <band height="175" splitType="Stretch">
            <textField>
                <reportElement x="100" y="0" width="100" height="30" uuid="686f531e-d1c4-44ef-884d-378f2a36fc1e"/>
                <textElement verticalAlignment="Middle">
                    <font size="11" isBold="true"/>
                </textElement>
                <textFieldExpression><![CDATA[$P{Date}]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement x="100" y="30" width="100" height="30" uuid="5ca971f8-a82e-4cd2-97b5-9e1e8055e59f">
                    <property name="com.jaspersoft.studio.unit.width" value="pixel"/>
                </reportElement>
                <textElement verticalAlignment="Middle">
                    <font size="11" isBold="true"/>
                </textElement>
                <textFieldExpression><![CDATA[$P{PreviousMonthDate}]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement x="100" y="60" width="100" height="30" uuid="6f1e9e0c-16f7-4ff1-b14f-21d1da654222"/>
                <textElement verticalAlignment="Middle">
                    <font size="11" isBold="true"/>
                </textElement>
                <textFieldExpression><![CDATA[$P{NextMonthDate}]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement x="0" y="0" width="100" height="30" uuid="16e4c44e-16c8-477e-a31d-f8fe7582ae7f"/>
                <textElement verticalAlignment="Middle">
                    <font size="11" isBold="true"/>
                </textElement>
                <textFieldExpression><![CDATA["Current Date"]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement x="0" y="30" width="100" height="30" uuid="0b313be3-2ed2-4f90-933b-cbc57673ea69"/>
                <textElement verticalAlignment="Middle">
                    <font size="11" isBold="true"/>
                </textElement>
                <textFieldExpression><![CDATA["Previous Month"]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement x="0" y="60" width="100" height="30" uuid="a2585866-90c0-4b59-b68a-509247a5927e"/>
                <textElement verticalAlignment="Middle">
                    <font size="11" isBold="true"/>
                </textElement>
                <textFieldExpression><![CDATA["Next Month"]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement x="390" y="0" width="100" height="30" uuid="09a6c4ad-4b9a-43be-a05e-bc57a5b18bf9"/>
                <textElement verticalAlignment="Middle">
                    <font size="11" isBold="true"/>
                </textElement>
                <textFieldExpression><![CDATA[$P{FirstDateOfCurrentMonth}]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement x="230" y="0" width="160" height="30" uuid="b67025b7-8677-4a3f-8f8d-1162bf7d26e3"/>
                <textElement verticalAlignment="Middle">
                    <font size="11" isBold="true"/>
                </textElement>
                <textFieldExpression><![CDATA["First Date of Current Month"]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement x="670" y="0" width="100" height="30" uuid="421e66b1-d745-4117-bee0-0af184eaca3d"/>
                <textElement verticalAlignment="Middle">
                    <font size="11" isBold="true"/>
                </textElement>
                <textFieldExpression><![CDATA[$P{FirstDayOfCurrentMonth}]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement x="510" y="0" width="160" height="30" uuid="d180e9ba-ae84-4b94-9b51-43648bba475a"/>
                <textElement verticalAlignment="Middle">
                    <font size="11" isBold="true"/>
                </textElement>
                <textFieldExpression><![CDATA["First Day of Current Month"]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement x="230" y="30" width="160" height="30" uuid="7157a773-e62f-4e0c-9f03-4696a30a9136"/>
                <textElement verticalAlignment="Middle">
                    <font size="11" isBold="true"/>
                </textElement>
                <textFieldExpression><![CDATA["First Date of Previous Month"]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement x="390" y="30" width="100" height="30" uuid="3d3ed51e-f5f0-4892-9c42-ae52ef3b7651"/>
                <textElement verticalAlignment="Middle">
                    <font size="11" isBold="true"/>
                </textElement>
                <textFieldExpression><![CDATA[$P{FirstDateOfPreviousMonth}]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement x="510" y="30" width="160" height="30" uuid="b384ade7-ea31-45ec-a756-82c37b8f6e02"/>
                <textElement verticalAlignment="Middle">
                    <font size="11" isBold="true"/>
                </textElement>
                <textFieldExpression><![CDATA["First Day of Previous Month"]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement x="670" y="30" width="100" height="30" uuid="4990802a-be00-4306-91f6-1a5e50c4bc98"/>
                <textElement verticalAlignment="Middle">
                    <font size="11" isBold="true"/>
                </textElement>
                <textFieldExpression><![CDATA[$P{FirstDayOfPreviousMonth}]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement x="230" y="60" width="160" height="30" uuid="87c32b3a-5794-4853-b5de-129f0273b839"/>
                <textElement verticalAlignment="Middle">
                    <font size="11" isBold="true"/>
                </textElement>
                <textFieldExpression><![CDATA["First Date of Next  Month"]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement x="390" y="60" width="100" height="30" uuid="5d12680a-5c90-4b9f-af78-c41df1c5167d"/>
                <textElement verticalAlignment="Middle">
                    <font size="11" isBold="true"/>
                </textElement>
                <textFieldExpression><![CDATA[$P{FirstDateOfNextMonth}]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement x="510" y="60" width="160" height="30" uuid="c981572c-6f18-4eb9-a7b9-d875d19f26ca"/>
                <textElement verticalAlignment="Middle">
                    <font size="11" isBold="true"/>
                </textElement>
                <textFieldExpression><![CDATA["First Day of Next  Month"]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement x="670" y="60" width="100" height="30" uuid="77c38b0a-3206-4767-9519-0e497db7cbe0"/>
                <textElement verticalAlignment="Middle">
                    <font size="11" isBold="true"/>
                </textElement>
                <textFieldExpression><![CDATA[$P{FirstDayOfNextMonth}]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement x="770" y="0" width="80" height="30" uuid="259b0efd-cf1c-4963-a4e3-1785d602d59c"/>
                <textElement textAlignment="Left" verticalAlignment="Middle">
                    <font size="11" isBold="true"/>
                </textElement>
                <textFieldExpression><![CDATA[$P{CurrentDateFirstDayValueInteger}]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement x="770" y="30" width="80" height="30" uuid="f10baf74-a727-48d9-bfcf-1b6d3452736f"/>
                <textElement textAlignment="Left" verticalAlignment="Middle">
                    <font size="11" isBold="true"/>
                </textElement>
                <textFieldExpression><![CDATA[$P{PerviousMonthFirstDayValueInteger}]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement x="770" y="60" width="80" height="30" uuid="71be88e2-4893-41d5-bef4-6bbdb4cb7c6a"/>
                <textElement textAlignment="Left" verticalAlignment="Middle">
                    <font size="11" isBold="true"/>
                </textElement>
                <textFieldExpression><![CDATA[$P{NextMonthFirstDayValueInteger}]]></textFieldExpression>
            </textField>
            <textField hyperlinkType="ReportExecution" hyperlinkTarget="Blank">
                <reportElement x="139" y="126" width="281" height="30" uuid="7d969a03-940c-4081-8210-d90686c0ae5c"/>
                <textElement>
                    <font size="14"/>
                </textElement>
                <textFieldExpression><![CDATA["Previous Month"]]></textFieldExpression>
                <hyperlinkParameter name="_report">
                    <hyperlinkParameterExpression><![CDATA["/EarthlySystems/Previous_and_Next_Months"]]></hyperlinkParameterExpression>
                </hyperlinkParameter>
                <hyperlinkParameter name="Date">
                    <hyperlinkParameterExpression><![CDATA[$P{PreviousMonthDate}]]></hyperlinkParameterExpression>
                </hyperlinkParameter>
                <hyperlinkParameter name="DayReturnValueInteger">
                    <hyperlinkParameterExpression><![CDATA[$P{PerviousMonthFirstDayValueInteger}]]></hyperlinkParameterExpression>
                </hyperlinkParameter>
            </textField>
            <textField hyperlinkType="ReportExecution" hyperlinkTarget="Blank">
                <reportElement x="440" y="126" width="281" height="30" uuid="64116c95-e582-476e-b5ca-fe88e26c7d77"/>
                <textElement>
                    <font size="14"/>
                </textElement>
                <textFieldExpression><![CDATA["Next  Month"]]></textFieldExpression>
                <hyperlinkParameter name="_report">
                    <hyperlinkParameterExpression><![CDATA["/EarthlySystems/Previous_and_Next_Months"]]></hyperlinkParameterExpression>
                </hyperlinkParameter>
                <hyperlinkParameter name="Date">
                    <hyperlinkParameterExpression><![CDATA[$P{NextMonthDate}]]></hyperlinkParameterExpression>
                </hyperlinkParameter>
                <hyperlinkParameter name="DayReturnValueInteger">
                    <hyperlinkParameterExpression><![CDATA[$P{NextMonthFirstDayValueInteger}]]></hyperlinkParameterExpression>
                </hyperlinkParameter>
            </textField>
        </band>
    </title>
    <pageHeader>
        <band height="35" splitType="Stretch"/>
    </pageHeader>
    <columnHeader>
        <band height="61" splitType="Stretch"/>
    </columnHeader>
    <detail>
        <band height="125" splitType="Stretch"/>
    </detail>
    <columnFooter>
        <band height="45" splitType="Stretch"/>
    </columnFooter>
    <pageFooter>
        <band height="54" splitType="Stretch"/>
    </pageFooter>
    <summary>
        <band height="42" splitType="Stretch"/>
    </summary>
</jasperReport>


I hope it helps some one in community.!

Cheers.!
Sadakar Pochampalli

Wednesday, July 05, 2017

Jaspersoft 6.4 : New download Information page- Quick difference between CE & EE

Jaspersoft 6.4 Highlights

  • Extended dashboard authoring for hyperlinking, formatting, and editing
  • Granular admin exporting control
  • Built-in support for popular technologies like Salesforce and PhantomJS
  • Updated interface for designing charts in Jaspersoft Studio

Read Detailed Highlights here : Click this link

Tip : replaceAll method to remove extra & in a field text in Jasper Reports

This expression in Jasper reports is useful for a text that need to get into a new line whenever an & occurs but the problem is though the text gets into a new line it is displaying an extra & on output. 

Hence, using another replaceAll function from core java for field object we can overcome getting extra &.


Sample Expression:
 $F{ProjectDescription}.replaceAll("lt;br&gt;", "<br>" ).replaceAll("&","")

Tip Credits: Nimmana

Wednesday, June 14, 2017

Oracle XE listener issue fixing when changing Windows 10 system/computer name


Change the host name with your computer name or localhost in below two files
listener.ora and
tnsnames.ora

Navigation path to the files :
C:\oraclexe\app\oracle\product\11.2.0\server\network\ADMIN

Now, from the windows services, restart OracleXETNSListener and try connecting to XE SID as shown in below image.

Username : sys , Password : tiger (that is given at the time of installation)

Default password is : sysdba for sys user to connect to xe




The reason for changing host name in my case : 
Recently, I have changed the windows 10  system name and from that point of time, I didn't start oracle db in local but today when I started the oracle db and the listener, the connection for xe SID with sys/tiger credentials not worked.

listener.ora

SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
      (SID_NAME = PLSExtProc)
      (ORACLE_HOME = C:\oraclexe\app\oracle\product\11.2.0\server)
      (PROGRAM = extproc)
    )
    (SID_DESC =
      (SID_NAME = CLRExtProc)
      (ORACLE_HOME = C:\oraclexe\app\oracle\product\11.2.0\server)
      (PROGRAM = extproc)
    )
  )

LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))
      (ADDRESS = (PROTOCOL = TCP)(HOST = INISAH)(PORT = 1521))
    )
  )

DEFAULT_SERVICE_LISTENER = (XE)


tnsnames.ora
XE =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = INISAH)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = XE)
    )
  )

EXTPROC_CONNECTION_DATA =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))
    )
    (CONNECT_DATA =
      (SID = PLSExtProc)
      (PRESENTATION = RO)
    )
  )

ORACLR_CONNECTION_DATA =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))
    )
    (CONNECT_DATA =
      (SID = CLRExtProc)
      (PRESENTATION = RO)
    )
  )


Tuesday, June 13, 2017

High Charts (HTML-5) Horizontal Bar Chart (Column Chart) advanced properties in jasper reports

Horizontal Bar Chart advanced properties

plotOptions.series.dataLabels.align = right
plotOptions.series.dataLabels.color=white
series.dataLabels.enabled=true
series.dataLabels.format={point.y:.1f}%
tooltip.valueDecimals=new Integer(2)
tooltip.valueSuffix=%



Sample output

Sample JRXML (Supported version : 6.2 Pro or later)
<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 6.2.0.final using JasperReports Library version 6.2.0  -->
<!-- 2017-06-14T01:55:03 -->
<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="Bar Chart" pageWidth="1000" pageHeight="842" columnWidth="960" leftMargin="20" rightMargin="20" topMargin="50" bottomMargin="20" uuid="9078ded8-657e-41b9-8a90-552bcd773149">
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="sumtotal_anjan"/>
<property name="com.jaspersoft.studio.data.sql.tables" value=""/>
<property name="com.jaspersoft.studio.unit." value="pixel"/>
<property name="ireport.jasperserver.url" value="http://localhost:8081/jasperserver-pro/"/>
<property name="ireport.jasperserver.user" value="superuser"/>
<property name="ireport.jasperserver.report.resource" value="/Work/Bar_Chart_for_blog_files/main_jrxml"/>
<property name="ireport.jasperserver.reportUnit" value="/Work/Bar_Chart_for_blog"/>
<queryString>
<![CDATA[SELECT productDescription, buyprice FROM classicmodels.products limit 10]]>
</queryString>
<field name="productDescription" class="java.lang.String">
<fieldDescription><![CDATA[]]></fieldDescription>
</field>
<field name="buyprice" class="java.math.BigDecimal">
<fieldDescription><![CDATA[]]></fieldDescription>
</field>
<background>
<band splitType="Stretch"/>
</background>
<summary>
<band height="542">
<componentElement>
<reportElement x="0" y="0" width="960" height="542" uuid="40b3d848-171b-4e69-97f5-4f1d8868a7c3"/>
<hc:chart xmlns:hc="http://jaspersoft.com/highcharts" xsi:schemaLocation="http://jaspersoft.com/highcharts http://jaspersoft.com/schema/highcharts.xsd" type="Bar">
<hc:chartSetting name="default">
<hc:chartProperty name="chart.zoomType">
<hc:propertyExpression><![CDATA["xy"]]></hc:propertyExpression>
</hc:chartProperty>
<hc:chartProperty name="colors">
<hc:propertyExpression><![CDATA[java.util.Arrays.asList("#FF0000","#434348","#90ed7d","#f7a35c","#8085e9","#f15c80","#e4d354","#2b908f","#f45b5b","#91e8e1")]]></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="plotOptions.series.dataLabels.align" value="right"/>
<hc:chartProperty name="plotOptions.series.dataLabels.color" value="#FFFFFF"/>
<hc:chartProperty name="series.dataLabels.enabled" value="true"/>
<hc:chartProperty name="series.dataLabels.format" value="{point.y:.1f}%"/>
<hc:chartProperty name="title.text">
<hc:propertyExpression><![CDATA[""]]></hc:propertyExpression>
</hc:chartProperty>
<hc:chartProperty name="tooltip.useHTML">
<hc:propertyExpression><![CDATA[Boolean.TRUE]]></hc:propertyExpression>
</hc:chartProperty>
<hc:chartProperty name="tooltip.valueDecimals">
<hc:propertyExpression><![CDATA[new Integer(2)]]></hc:propertyExpression>
</hc:chartProperty>
<hc:chartProperty name="tooltip.valuePrefix">
<hc:propertyExpression><![CDATA[""]]></hc:propertyExpression>
</hc:chartProperty>
<hc:chartProperty name="tooltip.valueSuffix">
<hc:propertyExpression><![CDATA["%"]]></hc:propertyExpression>
</hc:chartProperty>
<hc:chartProperty name="xAxis.scrollbar.enabled" value="true"/>
<hc:chartProperty name="yAxis.title.text">
<hc:propertyExpression><![CDATA[""]]></hc:propertyExpression>
</hc:chartProperty>
</hc:chartSetting>
<multiAxisData>
<multiAxisDataset/>
<dataAxis axis="Rows">
<axisLevel name="Level1">
<labelExpression><![CDATA["Level Label expression"]]></labelExpression>
<axisLevelBucket class="java.lang.String">
<bucketExpression><![CDATA[$F{productDescription}]]></bucketExpression>
</axisLevelBucket>
</axisLevel>
</dataAxis>
<dataAxis axis="Columns"/>
<multiAxisMeasure name="Measure1" class="java.lang.Double" calculation="Nothing">
<labelExpression><![CDATA["Description"]]></labelExpression>
<valueExpression><![CDATA[$F{buyprice}]]></valueExpression>
</multiAxisMeasure>
</multiAxisData>
<hc:series name="Measure1"/>
</hc:chart>
</componentElement>
</band>
</summary>
</jasperReport>

Thursday, June 08, 2017

Tip : Adding email hyperlink on text field in Jasper Reports

Hi,

Do get the email box opened on clicking of email type field in report output, it is required to
set below on the field/string type variable in cross tab.

Link Target = Self
Link Type = Reference
Hyperlink Reference Expression = "mailto:"+$V{EmpEmail} where EmpEmail is the string type of variable in cross tab (or it can be any text field on bands or table component)

Example : 2 : "mailto:"+$F{employeeEmail}



Reference: 
https://stackoverflow.com/questions/27239882/how-to-add-email-hyperlink-in-ireport


Thanks
Sadakar

Wednesday, June 07, 2017

Tip : Adding Text/Static Text labels in Cross Tab Header in Jasper Reports

Hello Folks,

When you design a cross tab in jasper reports, by default the cross tab header will not allow you to resize the dragged text fields or static fields to give row group label names. To overcome this

Do as shown in below

Select the "cross tab header" from its outline, and add "Free Layout" from "Arrange In Container" .




Now, drag and drop text field in tot the container, now the header supports adjusting widths of text fields. 




Reference : 
https://stackoverflow.com/questions/37742859/how-to-add-row-header-to-crosstab

Monday, June 05, 2017

Tip: Calculate, first date of the given date , the day of the first date and return 0,1,2,3... for Sun, Mon, Tue,Wed and etc. in Jasper Reports

Calculate, first date of the given date , the day of the first date and return 0,1,2,3... for Sun, Mon, Tue,Wed and etc.



JRXML : Copy paste below code in a JRXML file and preview the report.
(Supports in 6.x CE & Pro Studio)

<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 6.3.1.final using JasperReports Library version 6.3.1  -->
<!-- 2017-06-05T22:43:54 -->
<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="demo_calendar" columnCount="7" printOrder="Horizontal" pageWidth="1500" pageHeight="612" orientation="Landscape" whenNoDataType="AllSectionsNoDetail" columnWidth="211" leftMargin="11" rightMargin="11" topMargin="10" bottomMargin="10" uuid="32abf871-39b8-4cc7-b03c-d950a55e2bfb">
 <property name="com.jaspersoft.studio.data.sql.tables" value=""/>
 <property name="com.jaspersoft.studio.data.defaultdataadapter" value="foodmart"/>
 <property name="com.jaspersoft.studio.unit." value="pixel"/>
 <property name="ireport.jasperserver.url" value="http://localhost:8081/jasperserver-pro/"/>
 <property name="ireport.jasperserver.user" value="superuser"/>
 <property name="ireport.jasperserver.report.resource" value="/Work/EarthlySystem/Reports/CalenderReport_files/main_jrxml"/>
 <property name="ireport.jasperserver.reportUnit" value="/Work/EarthlySystem/Reports/CalenderReport"/>
 <style name="Style1" forecolor="#050505">
  <conditionalStyle>
   <conditionExpression><![CDATA[$F{id}.intValue()%7==1]]></conditionExpression>
   <style forecolor="#FA0702"/>
  </conditionalStyle>
 </style>
 <parameter name="Date" class="java.util.Date">
  <defaultValueExpression><![CDATA[new Date()]]></defaultValueExpression>
 </parameter>
 <parameter name="FirstDateOfMonth" class="java.lang.String" isForPrompting="false">
  <defaultValueExpression><![CDATA[new SimpleDateFormat("MM/dd/yyyy").format(java.util.Date.parse(MONTH($P{Date}) + "/1/" + YEAR($P{Date})))]]></defaultValueExpression>
 </parameter>
 <parameter name="FirstDayOfMonth" class="java.lang.String" isForPrompting="false">
  <defaultValueExpression><![CDATA[new SimpleDateFormat("EEE").format(java.util.Date.parse(MONTH($P{Date}) + "/1/" + YEAR($P{Date})))]]></defaultValueExpression>
 </parameter>
 <parameter name="DayReturnValueString" class="java.lang.String" isForPrompting="false">
  <parameterDescription><![CDATA[]]></parameterDescription>
  <defaultValueExpression><![CDATA[$P{FirstDayOfMonth}.equals("Sun") ? "0":
$P{FirstDayOfMonth}.equals("Mon") ? "1" :
$P{FirstDayOfMonth}.equals("Tue") ? "2" :
$P{FirstDayOfMonth}.equals("Wed") ? "3" :
$P{FirstDayOfMonth}.equals("Thu") ? "4" :
$P{FirstDayOfMonth}.equals("Fri") ? "5" :
$P{FirstDayOfMonth}.equals("Sat") ? "6" : "100"]]></defaultValueExpression>
 </parameter>
 <parameter name="DayReturnValueInteger" class="java.lang.Integer" isForPrompting="false">
  <parameterDescription><![CDATA[]]></parameterDescription>
  <defaultValueExpression><![CDATA[Integer.parseInt($P{DayReturnValueString})]]></defaultValueExpression>
 </parameter>
 <queryString>
  <![CDATA[select 1 as One]]>
 </queryString>
 <field name="one" class="java.lang.Integer"/>
 <title>
  <band height="180">
   <textField pattern="MMMM d, yyyy">
    <reportElement x="330" y="0" width="190" height="30" uuid="21293131-3839-43aa-b449-b19867eee2da"/>
    <textElement textAlignment="Left" verticalAlignment="Middle">
     <font size="12" isBold="true"/>
    </textElement>
    <textFieldExpression><![CDATA[$P{Date}]]></textFieldExpression>
   </textField>
   <staticText>
    <reportElement mode="Opaque" x="844" y="30" width="210" height="31" forecolor="#000000" backcolor="#FFFFFF" uuid="81be3ac1-c1c1-4573-86a7-67c891288f1c">
     <property name="com.jaspersoft.studio.unit.y" value="pixel"/>
    </reportElement>
    <box>
     <pen lineWidth="1.0" lineColor="#B1B5B4"/>
    </box>
    <textElement textAlignment="Center" verticalAlignment="Middle">
     <font size="14" isBold="true"/>
    </textElement>
    <text><![CDATA[Thursday]]></text>
   </staticText>
   <staticText>
    <reportElement mode="Opaque" x="1055" y="30" width="210" height="31" forecolor="#000000" backcolor="#FFFFFF" uuid="9442d83e-3726-4db9-8746-04b2fea1449b">
     <property name="com.jaspersoft.studio.unit.y" value="pixel"/>
     <property name="com.jaspersoft.studio.unit.width" value="pixel"/>
    </reportElement>
    <box>
     <pen lineWidth="1.0" lineColor="#B1B5B4"/>
    </box>
    <textElement textAlignment="Center" verticalAlignment="Middle">
     <font size="14" isBold="true"/>
    </textElement>
    <text><![CDATA[Friday]]></text>
   </staticText>
   <staticText>
    <reportElement mode="Opaque" x="1266" y="30" width="210" height="31" forecolor="#000000" backcolor="#FFFFFF" uuid="edc883b5-0e35-4e17-8a45-56efc9dacf6a">
     <property name="com.jaspersoft.studio.unit.y" value="pixel"/>
     <property name="com.jaspersoft.studio.unit.width" value="pixel"/>
    </reportElement>
    <box>
     <pen lineWidth="1.0" lineColor="#B1B5B4"/>
    </box>
    <textElement textAlignment="Center" verticalAlignment="Middle">
     <font size="14" isBold="true"/>
    </textElement>
    <text><![CDATA[Saturday]]></text>
   </staticText>
   <textField>
    <reportElement x="330" y="30" width="190" height="30" uuid="ca304690-d49b-4280-8c75-8fd1451bd59f"/>
    <textElement verticalAlignment="Middle">
     <font size="12" isBold="true"/>
    </textElement>
    <textFieldExpression><![CDATA[new SimpleDateFormat("MM/dd/yyyy").format(java.util.Date.parse(MONTH(NOW( )) + "/1/" + YEAR(NOW())))]]></textFieldExpression>
   </textField>
   <textField>
    <reportElement x="330" y="61" width="190" height="30" uuid="5d27b8b2-76cf-4eed-8486-6644f5a2c77c"/>
    <textElement verticalAlignment="Middle">
     <font size="12" isBold="true"/>
    </textElement>
    <textFieldExpression><![CDATA[$P{FirstDateOfMonth}]]></textFieldExpression>
   </textField>
   <textField>
    <reportElement x="330" y="90" width="190" height="30" uuid="66294bd1-0841-4c2a-b33a-928a0cb1aa0a"/>
    <textElement>
     <font size="12" isBold="true"/>
    </textElement>
    <textFieldExpression><![CDATA[$P{FirstDayOfMonth}]]></textFieldExpression>
   </textField>
   <textField>
    <reportElement x="330" y="120" width="190" height="30" uuid="83fa6364-da26-4578-beaf-58932abc6aab"/>
    <textElement>
     <font size="12" isBold="true"/>
    </textElement>
    <textFieldExpression><![CDATA[$P{DayReturnValueString}]]></textFieldExpression>
   </textField>
   <textField>
    <reportElement x="330" y="150" width="190" height="30" uuid="e341926d-38a0-40e7-b4a6-9232352a7247"/>
    <textElement>
     <font size="12" isBold="true"/>
    </textElement>
    <textFieldExpression><![CDATA[$P{DayReturnValueInteger}]]></textFieldExpression>
   </textField>
   <textField>
    <reportElement x="0" y="30" width="330" height="30" uuid="132ad66e-8839-4c41-8e00-9d77cf0ad6b8"/>
    <textElement verticalAlignment="Middle">
     <font size="12" isBold="true"/>
    </textElement>
    <textFieldExpression><![CDATA["First Date Of Month In TEXT field"]]></textFieldExpression>
   </textField>
   <textField>
    <reportElement x="0" y="60" width="330" height="30" uuid="166e5bec-db19-4a56-a335-470008c8094c"/>
    <textElement verticalAlignment="Middle">
     <font size="12" isBold="true"/>
    </textElement>
    <textFieldExpression><![CDATA["First Date Of Month from Parameter Calcualtion"]]></textFieldExpression>
   </textField>
   <textField>
    <reportElement x="0" y="91" width="330" height="30" uuid="dfd0e3d3-1641-4380-984f-0066d8a9112c"/>
    <textElement verticalAlignment="Middle">
     <font size="12" isBold="true"/>
    </textElement>
    <textFieldExpression><![CDATA["Day Name of First Date Of Month"]]></textFieldExpression>
   </textField>
   <textField>
    <reportElement x="0" y="120" width="330" height="30" uuid="d64905e0-2d87-415f-acab-3747492a2071"/>
    <textElement verticalAlignment="Middle">
     <font size="12" isBold="true"/>
    </textElement>
    <textFieldExpression><![CDATA["Retruning 0,1,2... for Sun, Mon, Tue, ...."+"as a String"]]></textFieldExpression>
   </textField>
   <textField>
    <reportElement x="0" y="150" width="330" height="30" uuid="99f5b0f5-cefb-449b-9edb-e444e4afa5d5"/>
    <textElement verticalAlignment="Middle">
     <font size="12" isBold="true"/>
    </textElement>
    <textFieldExpression><![CDATA["Retruning 0,1,2... for Sun, Mon, Tue, ...."+"as an Integer"]]></textFieldExpression>
   </textField>
   <textField>
    <reportElement x="0" y="0" width="330" height="30" uuid="09477045-1a0c-4c25-8776-715036b8c726"/>
    <textElement verticalAlignment="Middle">
     <font size="12" isBold="true"/>
    </textElement>
    <textFieldExpression><![CDATA["Date Entered"]]></textFieldExpression>
   </textField>
  </band>
 </title>
</jasperReport>

Tuesday, May 09, 2017

Jaspersoft Custom Reports Testing Scenarios and Areas


Below are the few common Jasper Reports Testing Scenarios 

General Browser UI
1) Verify the end-user is able to login with the credentials
For example: biuser/biuser
2) Verify report layout as per the mock-up
3) Verify the title of the report – preferable to keep at top middle of the report.
4) Verify the logo of the customer/client – preferable to keep left top of the report. 
5) Verify page number is displayed on the report and is in sequence
6) Verify font, font size of headers and of text consistent throughout the report 
7) Verify tooltip on the report wherever asked to provide
8) Verify report generated date and time.
9) Verify hyperlinks are working fine. 
10) Verify spell check on the report. 
11) Verify numeric values are left aligned and text is right aligned and test padding is applied for them. 
12) Verify pattern (or separator) for numeric values. 
13) Verify report left and right alignments. 
14) Verify NOTE is present wherever asked to provide. 
15) Verify report user guide is added as a PDF or Word as hyperlink to download the file. 
Excel Export 
1) Verify logos are exported to excel.
2) Verify font family and size is same as per the report design. 
3) Verify type of columns for numeric and date fields. Some user may apply formulas or functions in exported excel sheets. 
4) Verify for no empty rows and no empty columns. 
5) Verify exported excel file name should match with the report name. 
Filters testing: 
1) Verify for mandatory filters
2) Verify if the report has cascading filters
3) Verify filters values are in sorted order. 
4) No Data Display message 

Wednesday, March 29, 2017

JFree Statcked Bar Chart Example in Jasper Design Studio

This is a quick re-visit of JFree Stacked Bar chart in Jasper.

Query Format : 
select * from 
(
(
SELECT 
'Store Sales' as Sales, 
date(t.the_date) as date,
SUM(sf7.Store_sales) as SalesFact
FROM sales_fact_1997 sf7  JOIN time_by_day t 
ON sf7.time_id=t.time_id GROUP BY Sales,the_date ORDER BY date
limit 25
)

UNION
(
SELECT 
'Unit Sales' as Sales,
date(t.the_date) as date,
SUM(sf7.unit_sales) as SalesFact  
FROM sales_fact_1997 sf7  JOIN time_by_day t 
ON sf7.time_id=t.time_id GROUP BY Sales,the_date ORDER BY date
limit 25
)
) a ORDER BY a.date

Query Output:
Sales          date          salesfact

"Unit Sales";"2012-01-01";348.0000
"Store Sales";"2012-01-01";706.3400
"Unit Sales";"2012-01-02";635.0000
"Store Sales";"2012-01-02";1304.5300
"Store Sales";"2012-01-03";1294.1200
"Unit Sales";"2012-01-03";589.0000
"Unit Sales";"2012-01-04";20.0000
"Store Sales";"2012-01-04";42.8700
"Store Sales";"2012-01-05";1987.1900
"Unit Sales";"2012-01-05";966.0000


Chart Design : 

Final Output:


JRXML Code : 

Jasper Design Studio Version : Professional 6.3 (If you are using CE studio code may not work)

<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 6.3.0.final using JasperReports Library version 6.3.0  -->
<!-- 2017-03-30T02:48:52 -->
<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="BarChartCustomization_XAxisLabels" pageWidth="800" pageHeight="842" columnWidth="760" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="9e71469d-a266-48ee-9989-9c4913b1190f">
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="foodmart"/>
<property name="com.jaspersoft.studio.data.sql.tables" value=""/>
<property name="com.jaspersoft.studio.unit." value="pixel"/>
<queryString>
<![CDATA[select * from 
(
(
SELECT 
'Store Sales' as Sales, 
date(t.the_date) as date,
SUM(sf7.Store_sales) as SalesFact
FROM sales_fact_1997 sf7  JOIN time_by_day t 
ON sf7.time_id=t.time_id GROUP BY Sales,the_date ORDER BY date
limit 5
)

UNION
(
SELECT 
'Unit Sales' as Sales,
date(t.the_date) as date,
SUM(sf7.unit_sales) as SalesFact  
FROM sales_fact_1997 sf7  JOIN time_by_day t 
ON sf7.time_id=t.time_id GROUP BY Sales,the_date ORDER BY date
limit 5
)
) a ORDER BY a.date]]>
</queryString>
<field name="sales" class="java.lang.String"/>
<field name="date" class="java.sql.Date"/>
<field name="salesfact" class="java.math.BigDecimal"/>
<background>
<band splitType="Stretch"/>
</background>
<summary>
<band height="360" splitType="Stretch">
<stackedBarChart>
<chart evaluationTime="Report">
<reportElement x="0" y="0" width="760" height="360" uuid="f13a44b1-bb8f-49b9-8bd8-4b048ef7e26d"/>
<chartTitle/>
<chartSubtitle/>
<chartLegend/>
</chart>
<categoryDataset>
<categorySeries>
<seriesExpression><![CDATA[$F{sales}]]></seriesExpression>
<categoryExpression><![CDATA[$F{date}.toString()]]></categoryExpression>
<valueExpression><![CDATA[$F{salesfact}]]></valueExpression>
</categorySeries>
</categoryDataset>
<barPlot>
<plot labelRotation="60.0">
<seriesColor seriesOrder="0" color="#BF6B83"/>
<seriesColor seriesOrder="1" color="#129D10"/>
</plot>
<itemLabel/>
<categoryAxisFormat labelRotation="60.0">
<axisFormat/>
</categoryAxisFormat>
<valueAxisFormat>
<axisFormat/>
</valueAxisFormat>
</barPlot>
</stackedBarChart>
</band>
</summary>
</jasperReport>

Wednesday, March 22, 2017

TIBCO Jaspersoft Online demo server (https://mobiledemo.jaspersoft.com/jasperserver-pro/)


Are you a community customer ?
Is your 30-day trail license expired for studio and server ?
Do you want to learn or explore TIBCO jaspersoft Studio Professional features ?
Do you want to learn Enterprise server features (limited in demo as end user) ?
Did you ask your folks to explore self service BI ?
Did you ask your folks to explore self service Dashboards ?

Here you go with Online demo server. You can evaluate TIBCO jasperserver as an end user.

Copy paste or click on below URL
https://mobiledemo.jaspersoft.com/jasperserver-pro/

UserName/Password : joeuser/joeuser


Exploring Self Service BI with Ad-Hoc Views 
Sample Example : Sales Trend By State 

Connecting to this demo server in Studio : 

Exploring out of the examples : 
Viewing the same in server


This way, a new customer or migrating customer or a community folk who wants to explore jasper can dig the enterprise features.

As this server is accessible only with enduser permissions, if you want to explore security side you can refer to the documentation at http://community.jaspersoft.com/documentation?version=33331


- Sadakar Pochampalli 

Thursday, March 09, 2017

MySQL workbench - table data import and export procedure

This is a redistribution of import and export features of MySQL workbench.


6.5.1 Table Data Export and Import Wizard


https://dev.mysql.com/doc/workbench/en/wb-admin-export-import-table.html



he wizard is accessible from the object browser's context menu by right-clicking on a table and choose either Table Data Export Wizard orTable Data Import Wizard.
Figure 6.14 Table Data Wizards: Open
Table Data Wizards: Open

Table Data Export Wizard

Export table data to either a JSON or CSV file. The following example exports the sakila.actor table to a CSV file.
Figure 6.15 Table Data Export: Source
Table Data Export: Source

Figure 6.16 Table Data Export: CSV Configuration
Table Data Export: Configuration

Figure 6.17 Table Data Export: Results
Table Data Export: Results

Table Data Import Wizard

Import table data from either a JSON or CSV file. The following example imports the sakila.actor table from a CSV file.
Figure 6.18 Table Data Import: CSV Source
Table Data Import: CSV Source

Figure 6.19 Table Data Import: Destination Table
Table Data Import: Destination Table

Figure 6.20 Table Data Import: CSV Configuration
Table Data Import: CSV Configuration

Note
The Encoding field should correspond with your CSV file.
Figure 6.21 Table Data Import: Results
Table Data Import: Results