Jump to content
We've recently updated our Privacy Statement, available here ×

how to create mail merge style report using jasper reports


emrizwan

Recommended Posts

I am using ireport 4.0 and want to create mail merge style report.

the required format looks like this

<student id><student name><student address>Dear parent,There is an outstanding balance of <balance_amount> which needs to be paid by <balance_date>....................................................................................................................................................................................................<student id><student name><student address>Dear parent,There is an outstanding balance of <balance_amount> which needs tobe paid by <balance_date>....................................................................................................................................................................................................

 

any ideas, how can i create such report?

 

Link to comment
Share on other sites

  • 4 years later...
  • Replies 2
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Create a Jasper Report and add the Student ID, name, and address with text fields.

The letter part is a text field that renders as HTML and uses the CONCATENATE method.

Finally, add a break at the bottom. 

Here's some code that might explain it better.

<?xml version="1.0" encoding="UTF-8"?><!-- Created with Jaspersoft Studio version 6.8.0.final using JasperReports Library version 6.8.0-2ed8dfabb690ff337a5797129f2cd92902b0c87b  --><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="LUTCF_Completion_Letter" pageWidth="612" pageHeight="792" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="4832581b-c9aa-42db-b376-7b9ca245209a">    <property name="com.jaspersoft.studio.data.sql.tables" value=""/>    <property name="com.jaspersoft.studio.data.defaultdataadapter" value="MyAdapter"/>    <queryString language="SQL">        <![CDATA[sELECT DISTINCT StudentID,         StudentName,         StudentAddress,         CAST(Balance_Amount AS VARCHAR) AS Balance_Amount,        FORMAT(Balance_Date, 'dd/MM/yyyy', 'en-US' ) AS Balance_Date,      FROM Student      WHERE Balance_Amount > 0]]>    </queryString>    <field name="StudentID" class="java.lang.String">        <property name="com.jaspersoft.studio.field.label" value="StudentID"/>    </field>    <field name="StudentName" class="java.lang.String">        <property name="com.jaspersoft.studio.field.label" value="StudentName"/>    </field>    <field name="StudentAddress" class="java.lang.String">        <property name="com.jaspersoft.studio.field.label" value="StudentAddress"/>    </field>    <field name="Balance_Amount" class="java.lang.String">        <property name="com.jaspersoft.studio.field.label" value="Balance_Amount"/>    </field>    <field name="Balance_Date" class="java.lang.String">        <property name="com.jaspersoft.studio.field.label" value="Balance_Date"/>    </field>    <background>        <band splitType="Stretch"/>    </background>    <detail>        <band height="752" splitType="Stretch">            <textField isStretchWithOverflow="true" isBlankWhenNull="true">                <reportElement x="0" y="0" width="470" height="20" uuid="660d2ae4-7781-43f2-958f-7035a9346a9b"/>                <textFieldExpression><![CDATA[$F{StudentID}]]></textFieldExpression>            </textField>            <textField isStretchWithOverflow="true" isBlankWhenNull="true">                <reportElement x="470" y="0" width="100" height="20" uuid="27101190-c567-4cfb-baff-6beee18a862e"/>                <textFieldExpression><![CDATA[$F{StudentName}]]></textFieldExpression>            </textField>            <textField isStretchWithOverflow="true" isBlankWhenNull="true">                <reportElement x="0" y="20" width="470" height="21" uuid="eaf08a93-d076-45b7-934f-2c11db065d01"/>                <textFieldExpression><![CDATA[$F{StudentAddress}]]></textFieldExpression>            </textField>            <textField>                <reportElement x="0" y="100" width="570" height="50" uuid="bb736af9-8159-490c-b054-ea45552e851a"/>                <textElement markup="html"/>                <textFieldExpression><![CDATA[CONCATENATE( "<p>Dear parent,</p><p>There is an outstanding balance of $",           $F{Balance_Amount},           " which needs to be paid by ",           $F{Balance_Date}, ".</p>" )]]>        </textFieldExpression>            </textField>            <break>                <reportElement x="0" y="150" width="570" height="1" uuid="2bb19573-7825-43f9-86be-8a7b5b872815"/>            </break>        </band>    </detail></jasperReport>

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...