How to remove extra space between textfield in JasperReports?

You can use 3 textField elements with isRemoveLineWhenBlank property set to true value. The sample (jrxml file): <?xml version=”1.0″ encoding=”UTF-8″?> <jasperReport .. topMargin=”0″ bottomMargin=”0″> <parameter name=”parameter1″ class=”java.lang.String”> <defaultValueExpression><![CDATA[null]]></defaultValueExpression> </parameter> <parameter name=”parameter2″ class=”java.lang.String”> <defaultValueExpression><![CDATA[null]]></defaultValueExpression> </parameter> <parameter name=”parameter3″ class=”java.lang.String”> <defaultValueExpression><![CDATA[null]]></defaultValueExpression> </parameter> <title> <band height=”102″ splitType=”Stretch”> <textField isBlankWhenNull=”true”> <reportElement x=”163″ y=”9″ width=”100″ height=”20″ isRemoveLineWhenBlank=”true”/> <box> <topPen lineWidth=”1.0″/> <leftPen … Read more

Adding table border in jasperreports

You can add borders with help of GUI designer (iReport, for example) or you can add the box element manually (edit the jrxml file) like in this sample: <textField> <reportElement x=”29″ y=”17″ width=”100″ height=”20″/> <box> <topPen lineWidth=”1.0″/> <leftPen lineWidth=”1.0″/> <bottomPen lineWidth=”1.0″/> <rightPen lineWidth=”1.0″/> </box> <textElement/> <textFieldExpression><![CDATA[$F{field}]]></textFieldExpression> </textField> In iReport you can use “Padding And Borders” … Read more

Jasper Reports Show “Page X of Y” using a single text field

Jaspersoft Studio, 6+ For Jaspersoft Studio v6, or if the first page number is duplicated, try this solution, which uses $V{MASTER_CURRENT_PAGE} and $V{MASTER_TOTAL_PAGE} with an evaluation time of Master. Jaspersoft Studio For other versions of Jaspersoft Studio, try the steps outlined in the subsequent subsections. Create Variable Create a variable as follows: Create a variable … 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=”” xmlns:xsi=”” xsi:schemaLocation=”” 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

Compare current page number with last page number

waited for a long time .. but no reply from Stackoverflow… Anyway i found my solution.. First in your summary band put this line <printWhenExpression><![CDATA[new Boolean($P{REPORT_PARAMETERS_MAP}.put(“LastPageNumber”,$V{PAGE_NUMBER}).equals(“dummyPrintWhen”))]]></printWhenExpression> Remember this above line must be only in the summary band of the report. After that you can compare this parameter at any point of time in your report … Read more

How to sum all values in a column in Jaspersoft iReport Designer?

It is quite easy to solve your task. You should create and use a new variable for summing values of the “Doctor Payment” column. In your case the variable can be declared like this: <variable name=”total” class=”java.lang.Integer” calculation=”Sum”> <variableExpression><![CDATA[$F{payment}]]></variableExpression> </variable> the Calculation type is Sum; the Reset type is Report; the Variable expression is $F{payment}, … Read more

Multiple queries in a single jasper document

It is possible to use execute multiple queries from a single report by using a subDataset and datasetRun. The behaviour is like having one or more subreports embedded into a single report file. Define a subDataset like this: <subDataset name=”dataset1″> <parameter name=”someParam” class=”java.lang.String”/> <queryString><![CDATA[SELECT column1, column2 FROM table1 WHERE column1=$P!{someParam}]]></queryString> <field name=”column1″ class=”java.lang.String”/> <field name=”column2″ … Read more