How to give space after every character of a string in jasper reports. I need this functionality to print date according to cheque format. I am new to jasper. Please help me in this.
Asked
Active
Viewed 1,974 times
2 Answers
0
Adding blank to every character
unfortunately Jasperreports doesn't support letter spacing (source)
However you can always use java in text fields to tranform the string and add a blank character after each character.
For example in case you have a field myString
(source for java part):
<textFieldExpression>
<![CDATA[$F{myString}.replace("", " ").trim()]]>
</textFieldExpression>
More specifically on dates
Java also provides nice feature to format a date. You might consider this as you specified you were working with dates.
An example of date formatting :
<variable name="dateFormatter" class="java.text.SimpleDateFormat">
<variableExpression><![CDATA[new java.text.SimpleDateFormat("yyyy-MM-dd")]]></variableExpression>
</variable>
<textFieldExpression>
<![CDATA[$V{dateFormatter}.format($F{myDate})]]>
</textFieldExpression>
See full documentation here

Matthias Beaupère
- 1,731
- 2
- 17
- 44
0
replaceAll() works fine in jasper reports only if RegularExpression is added in the imports. value="com.sun.org.apache.xerces.internal.impl.xpath.regex.RegularExpression"/>
$P{mystring}.replaceAll("", " ").trim()

Nayana
- 1