Wednesday, February 22, 2012

Indian rupee format in crystal reports

Method-1:
Step-1 : Create new formula and go-on with editor
Step-2 : Copy the following formula and paste it in the coding part  
                      Cstr({FieldName},"##,##,##,##0.00") or CStr({FieldName}, "##,##,##,###.##") 
 
ie., {FieldName}-- The Amount Field Name

Method-2 :
Step-1 : Create new formula and go-on with editor
Step-2 : Copy the following formula and paste it in the coding part  


                      StringVar Amt;
                      StringVar s;
                      NumberVar N;
                      Amt:=Replace(Totext({FieldName}),",","");
                      s:=left(Amt,len(Amt)-3);
                      N:=len(s);
                      Select N
                      case 4:
                      left(s,1)&","& right(s,3) & ".00"
                      case 5:
                      left(s,2)&","& right(s,3)& ".00"
                      case 6:
                      left(s,1)&","& mid(s,2,2) & "," & right(s,3)& ".00"
                      case 7:
                      left(s,2)&","& mid(s,3,2) & "," & right(s,3)& ".00"
                      case 8:
                      left(s,1)&","& mid(s,3,2) & "," & mid(s,6,2) & "," & right(s,3)& ".00"
                      case 9:
                      left(s,2)&","& mid(s,3,2) & "," & mid(s,6,2) & "," & right(s,3)& ".00"
                     default:
                      s; 

ie., {FieldName}-- The Amount Field Name