Wednesday 8 June 2011

Crystal Report ( Display Numbers in Indian Currency Format )

The Following are the steps to display the numbers in Indian Currency format :-

Step  1:- Right click on the text object which you want to display in Indian currency format. 


Step  2:- Select  Format object and then click on common 


Step  3:- On the right side of display string click on X2 button.  


Step  4:- Write this code in that 
               Totext({Field Name},"##,##,##,##,##,##,##,##,##,##0.00",2)                 


Step  5:- Click on Save and Close 


Step  6:- OK



The Following are the steps to display the numbers in Indian Currency Words :-



Step  1:-Click on Field explorer and Right click on the Formula Field select New. 

Step  2:- Name the Formula Field and Click OK

Step  3:- Now write the following code

numbervar RmVal:=0; 
numbervar Amt:=0; 
numbervar pAmt:=0; 
stringvar Inwards :=" ";
numbervar totalAmt;
totalAmt := Sum ({Field Name});
Amt := totalAmt;

if Amt >= 10000000 then
    RmVal := truncate(Amt/10000000); 
if RmVal = 1 then 
    Inwards := Inwards + " " + towords(RmVal,0) + " crore" 
else 
    if RmVal > 1 then 
        InWords := Inwards + " " + towords(RmVal,0) + " crores";
Amt := Amt - Rmval * 10000000;

RmVal := 0;
if Amt >= 100000 then 
    RmVal := truncate(Amt/100000); 
if RmVal = 1 then 
    InWords := Inwards + " " + towords(RmVal,0) + " lakh"
Else
    If RmVal > 1 then 
        InWords := Inwards + " " + ToWords(RmVal,0) + " Lakhs";
Amt := Amt - Rmval * 100000;

RmVal := 0;
if Amt >= 1000 then 
    RmVal := truncate(Amt/1000);
if RmVal =1 then 
    Inwords := Inwards + " " + towords(RmVal,0) + "Thousand"
Else
    if RmVal > 1 then 
        InWords := Inwards + " " + towords(RmVal,0) + "thousand ";
Amt := Amt - RmVal * 1000;
        
if Amt > 0 then 
    InWords := Inwards + "  " + towords(truncate(Amt),0);

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

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

UPPERCASE(Inwards) 

Step  4:- Click on Save and Close             

Step  5:- OK


Done


5 comments:

  1. Hi
    I have follow above step for indian currency format for RDLC but i am not getting result. can you please explain more.

    Becoz i got error on
    "Totext({Field Name},"##,##,##,##,##,##,##,##,##,##0.00",2)"

    Totext not a valid syntax.

    http://satasiyakalpesh.blogspot.com/
    So please help me for the same.

    ReplyDelete
  2. i think it's better way then long code....

    Dim cn As Control
    Dim CInfo As New CultureInfo(CultureInfo.CurrentCulture.IetfLanguageTag)
    'Dim Prc As String = "10000"
    'Response.Write(Convert.ToDecimal(Prc).ToString("C", CInfo))
    'Response.Write(Convert.ToDecimal(Prc).ToString("N", CInfo))
    For Each cn In Me.TableLayoutPanel1.Controls
    If TypeOf cn Is Label Then
    Dim x As Double
    If Double.TryParse(cn.Text, x) = True Then
    Me.ToolTip1.SetToolTip(cn, Convert.ToDecimal(x).ToString("N", CInfo))
    Else
    Me.ToolTip1.SetToolTip(cn, cn.Text)
    End If

    End If
    Next

    ReplyDelete
    Replies
    1. https://www.codeproject.com/Answers/1162511/How-to-convert-decimal-amount-like-number-to-word#answer2

      Delete
  3. thanks a lot for sharing this.Saved me a lot of time Extremely Grateful!!!

    ReplyDelete