Sunday, March 16, 2014

Split String in Crystal Report Using Formula using any character (|,,<,>)

Unformatted String stored in database:
CustomerID:1020 |type:Current|City:Karachi|Country:Pakistan
The code should be written inside the formulae editor
 Create a new formula name it whatever you like 
e.g @formatString 
formulae field to display  the formatted string after splitting is given below:


stringVar array stringArray := split({Tablename.toFormatedField},"|");
Local numberVar i;
Local stringVar outputFormattedString := ""; 

For i:=1 to Count(stringArray) do(

outputFormattedString := outputFormattedString + stringArray[i] + Chr(10)

);
outputFormattedString
The outputString is :
CustomerID:1020
type:Current
City:Karachi
Country:Pakistan

1 comment: