How to avoid of missing cell’s border when a record is separated between 2 pages?

You can put the staticText element without text behind the textField element. You should set stretchType property with RelativeToTallestObject value and isPrintWhenDetailOverflows property with true value. The sample: <detail> <band height=”20″ splitType=”Stretch”> <staticText> <reportElement stretchType=”RelativeToTallestObject” x=”0″ y=”0″ width=”100″ height=”20″ isPrintWhenDetailOverflows=”true”/> <box> <leftPen lineWidth=”1.0″/> <bottomPen lineWidth=”1.0″/> <rightPen lineWidth=”1.0″/> </box> <textElement/> <text><![CDATA[]]></text> </staticText> <textField> <reportElement stretchType=”RelativeToTallestObject” x=”0″ … Read more

iReport external font

Here is my working sample. The font definition file (I dig it from the font’s jar file): <?xml version=”1.0″ encoding=”UTF-8″?> <fontFamilies> <fontFamily name=”Arial”> <normal><![CDATA[fonts/arial.ttf]]></normal> <bold><![CDATA[fonts/arialbd.ttf]]></bold> <italic><![CDATA[fonts/ariali.ttf]]></italic> <boldItalic><![CDATA[fonts/arialbi.ttf]]></boldItalic> <pdfEncoding><![CDATA[Identity-H]]></pdfEncoding> <pdfEmbedded><![CDATA[false]]></pdfEmbedded> </fontFamily> </fontFamilies> The jar file is in the application’s classpath. And here is my java code: String defaultPDFFont = “Arial”; JRProperties.setProperty(“net.sf.jasperreports.awt.ignore.missing.font”, “true”); JRProperties.setProperty(“net.sf.jasperreports.default.font.name”, defaultPDFFont); JasperReport jasperReport … Read more

How to pass main report data source to subreport (JasperReports)?

You can pass datasource via the built-in REPORT_DATA_SOURCE parameter. The example: <subreport> <reportElement x=”261″ y=”25″ width=”200″ height=”100″/> <dataSourceExpression><![CDATA[$P{REPORT_DATA_SOURCE}]]></dataSourceExpression> <subreportExpression><![CDATA[$P{SUBREPORT_DIR} + “subreport.jasper”]]></subreportExpression> </subreport> You can create new instance of datasource based on variable, parameter or field. The sample: <variable name=”HeadingsCollection” class=”java.util.Collection” calculation=”System”> <initialValueExpression><![CDATA[new java.util.ArrayList()]]></initialValueExpression> </variable> … <subreport> <reportElement x=”0″ y=”0″ width=”515″ height=”20″/> <subreportParameter name=”ReportTitle”> <subreportParameterExpression><![CDATA[$P{ReportTitle}]]></subreportParameterExpression> </subreportParameter> … Read more

Group several same value field into a single cell

You can use this sample: <?xml version=”1.0″ encoding=”UTF-8″?> <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=”year_sum_quarter” language=”groovy” pageWidth=”595″ pageHeight=”842″ columnWidth=”555″ leftMargin=”20″ rightMargin=”20″ topMargin=”20″ bottomMargin=”20″> <property name=”ireport.zoom” value=”1.0″/> <property name=”ireport.x” value=”0″/> <property name=”ireport.y” value=”0″/> <queryString> <![CDATA[]]> </queryString> <field name=”year” class=”java.lang.Integer”/> <field name=”month” class=”java.lang.String”/> <field name=”sum” class=”java.lang.Integer”/> <field name=”q” class=”java.lang.Integer”/> <variable name=”yearSum” class=”java.lang.Integer” resetType=”Group” resetGroup=”yearGroup” calculation=”Sum”> <variableExpression><![CDATA[$F{sum}]]></variableExpression> </variable> <variable … Read more

How do I compile jrxml to get jasper?

There are three ways to compile jrxml to jasper. You can do direct compile via compile button (hammer logo) on iReport designer. You can use ant to compile as shown in the Ant Compile Sample. <target name=”compile1″> <mkdir dir=”./build/reports”/> <jrc srcdir=”./reports” destdir=”./build/reports” tempdir=”./build/reports” keepjava=”true” xmlvalidation=”true”> <classpath refid=”runClasspath”/> <include name=”**/*.jrxml”/> </jrc> </target> Below is the report … Read more

Style a text field in JasperReports

Yes, you can apply style for textField elements. iReport using The sample of report’s template: <jasperReport ..> <style name=”ColoredField” style=”Default” forecolor=”#FF0000″> <conditionalStyle> <style/> </conditionalStyle> </style> … <detail> <band height=”52″ splitType=”Stretch”> <!–Using the style declared in this template–> <textField> <reportElement key=”textWithStyle” style=”ColoredField” mode=”Opaque” x=”0″ y=”10″ width=”100″ height=”20″/> <textElement/> <textFieldExpression><![CDATA[$F{TASKS_SERIES}]]></textFieldExpression> </textField> <!–Basic formatting (set font and indent) … Read more

Change text field data color (Foreground color) based on condition in JasperReports

You can use Conditional styles for solving this issue. The sample: <style name=”ZFieldStyle”> <conditionalStyle> <conditionExpression><![CDATA[$F{Z} < $F{Y}]]></conditionExpression> <style forecolor=”#000000″/> </conditionalStyle> <conditionalStyle> <conditionExpression><![CDATA[$F{Z}>$F{X}]]></conditionExpression> <style forecolor=”#FF0000″/> </conditionalStyle> </style> … <field name=”X” class=”java.lang.Integer”/> <field name=”Y” class=”java.lang.Integer”/> <field name=”Z” class=”java.lang.Integer”/> … <textField> <reportElement style=”ZFieldStyle” x=”200″ y=”0″ width=”100″ height=”20″/> <textElement/> <textFieldExpression><![CDATA[$F{Z}]]></textFieldExpression> </textField>