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, March 15, 2018

Tip: group count variable calculation in jasper reports

Hi,

Group count calculation can be done as follows in jasper reports.

Scenario : 
Report Design:
<GroupNumber>  <GroupBand>
                             <detailband>

Example: 
   IamGroupValue1
         row1_value
         row2_value
         row3_value
2    IamGroupValue2
       row1_value
       row2_value
  IamGroupValue2
      row1_value
      row2_value
      row3_value
      row4_value
...
...
...

Steps:
1) Create your group (lets say Group1 , give the field value by which you want to group by)
2) Observe variables - there it creates a variable called "Group1_Count"
3) Create a new variable of Integer type , let say : groupCount
4) Give below expression for the groupCount variable
      $V{Group1_COUNT} == 1 ? ($V{groupCount} + 1) : $V{groupCount}
5) Put Increment Type= [Group]Group1 and Reset Type =Report and Initial Value=1
6) Pull this variable onto the group header where you want to get it.
7) Run the report observe the group count in output.

Calculation Image: 

Reference : 
https://stackoverflow.com/questions/17480184/how-to-show-the-number-of-group


Sunday, March 11, 2018

Tip : Text only background color in jasper reports with style tag

Hi,

To get the text only background with given color in jasper text elements, write below code.

"<style backcolor=\"yellow\">Hello .! My background color is yellow </style>"

Importantly , give MarkUp=Styled in the TextField properties

Click on image to get better view: 


Sample output:


Example JRXML:  (Studio 6.4 professional version)

<?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="Blank_A4_1" pageWidth="595" pageHeight="842" whenNoDataType="AllSectionsNoDetail" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="01d3505b-1aa3-468b-ae16-491d8c5ceb57">
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="One Empty Record"/>
<queryString>
<![CDATA[]]>
</queryString>
<background>
<band splitType="Stretch"/>
</background>
<title>
<band height="79" splitType="Stretch">
<textField>
<reportElement x="0" y="0" width="555" height="79" uuid="1a620294-fdcf-42f3-8fc3-66548fc72941"/>
<box>
<topPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
<leftPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
<bottomPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
<rightPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
</box>
<textElement textAlignment="Center" verticalAlignment="Middle" markup="styled">
<font size="14"/>
</textElement>
<textFieldExpression><![CDATA["<style backcolor=\"yellow\">Hello .! My background color is yellow </style>"]]></textFieldExpression>
</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>

Reference: 
https://community.jaspersoft.com/questions/514115/setting-textelement-background-color-style-tag