Friday, 30 October 2015

Replace special character with empty space or dot in a given string(user names) usign regular expressions in Jasper Reports.

Hi Guys,

Hope this helps !






<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 6.0.1.final using JasperReports Library version 6.0.0  -->
<!-- 2015-10-30T01:53:37 -->
<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_11" pageWidth="595" pageHeight="842" whenNoDataType="AllSectionsNoDetail" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="61a0c24d-0d01-45c8-9798-7b1e375005ef">
    <property name="com.jaspersoft.studio.data.defaultdataadapter" value="One Empty Record"/>
    <parameter name="Parameter1" class="java.lang.String" isForPrompting="false">
        <defaultValueExpression><![CDATA["sadakar.pochampalli@xyz.com__123"]]></defaultValueExpression>
    </parameter>
    <parameter name="Parameter2" class="java.lang.String" isForPrompting="false">
        <defaultValueExpression><![CDATA[$P{Parameter1}.toString().replaceAll("[\\W]", ".").replaceAll("_",".")]]></defaultValueExpression>
    </parameter>

    <queryString>
        <![CDATA[]]>
    </queryString>
    <background>
        <band splitType="Stretch"/>
    </background>
    <title>
        <band height="70" splitType="Stretch">
            <textField>
                <reportElement x="0" y="0" width="320" height="30" uuid="f65d6201-4a54-4f04-9540-0d7b1b061bc0"/>
                <textFieldExpression><![CDATA[$P{Parameter1}]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement x="0" y="40" width="320" height="30" uuid="11d43e9d-990e-490c-95b3-faa86c13f52f"/>
                <textFieldExpression><![CDATA[$P{Parameter2}]]></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>

No comments:

Post a Comment