Wednesday 4 July 2012

How to display currency in Indian Format & In words too, using formula in Crystal Report


The headache is to display currency/number in Indian format while using Foreign English language. Now you don't need to suffer from this headache. You can display the currency in Indian Format by using below said code. There are two formula written over here; one is for figure & second one is for words.


Write below said formula in formula editor field with proper field name. Here, I used "{@FieldName}  ; ", you have to replaced the actual name with this one.




//You can use below said code to your report part;


CStr({@FieldName}, "##,##,##,###.##")


//To write in words, use below said code;


numbervar RmVal:=0;
numbervar Amt:=0;
numbervar pAmt:=0;
stringvar InWords :="Rupees ";


Amt := {@FieldName}  ;




if Amt > 10000000 then RmVal := truncate(Amt/10000000);
if Amt = 10000000 then RmVal := 1;


   if RmVal = 1 then
        InWords := InWords + " " + towords(RmVal,0) + " crore"
   else
        if RmVal > 1 then InWords := InWords + " " + towords(RmVal,0) + " crores";




    Amt := Amt - Rmval * 10000000;


    if Amt > 100000 then RmVal := truncate(Amt/100000);
    if Amt = 100000 then RmVal := 1;


    if RmVal = 1 then
        InWords := InWords + " " + towords(RmVal,0) + " lakhs"
    Else
        If RmVal > 1 then InWords := InWords + " " + ToWords(RmVal,0) + " Lakhs";


        Amt := Amt - Rmval * 100000;


        if Amt > 0 then InWords := InWords + " " + towords(truncate(Amt),0);


        pAmt := (Amt - truncate(Amt)) * 100;


        if pAmt > 0 then
            InWords := InWords + " and " + towords(pAmt,0) + " paisa only"
        else
            InWords := InWords + " only";


        ProperCase(InWords)

No comments:

Post a Comment