Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » BIRT » AmountinWords Feature in Birt
AmountinWords Feature in Birt [message #224672] Tue, 13 March 2007 15:28 Go to next message
Eclipse UserFriend
Originally posted by: harikrishnan_j2003.rediffmail.com

Sir,

I am designing a Invoice Report where i have to convert the
Final Amount in Words for instance 1200 as One Thousand and Two Hundred
Only.Is There is any builtin Function or any other way to achieve
this.kindly help


Thankyou
Harikrishnan J.
Re: AmountinWords Feature in Birt [message #224807 is a reply to message #224672] Tue, 13 March 2007 17:30 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: jasonweathersby.alltel.net

Harikrishnan wrote:
> Sir,
>
> I am designing a Invoice Report where i have to convert the
> Final Amount in Words for instance 1200 as One Thousand and Two Hundred
> Only.Is There is any builtin Function or any other way to achieve
> this.kindly help
>
>
> Thankyou
> Harikrishnan J.
>
>
>
I got this example from
http://javascript.about.com/library/bltoword.htm
Attached is a report that takes a float parameter that uses this
function to convert.

Jason

<?xml version="1.0" encoding="UTF-8"?>
<!-- Written by Eclipse BIRT 2.0 -->
<report xmlns="http://www.eclipse.org/birt/2005/design" version="3.2.6"
id="1">
<property name="createdBy">Eclipse BIRT Designer Version
2.1.2.v20070205-1728 Build &lt;20070205-1728></property>
<property name="units">in</property>
<property name="comments">Copyright (c) 2006 &lt;&lt;Your Company
Name here>></property>
<parameters>
<scalar-parameter name="NewParameter" id="4">
<property name="valueType">static</property>
<property name="dataType">float</property>
<property name="controlType">text-box</property>
<property name="defaultValue">1000</property>
<structure name="format">
<property name="category">Unformatted</property>
</structure>
</scalar-parameter>
</parameters>
<page-setup>
<simple-master-page name="Simple MasterPage" id="2">
<page-footer>
<text id="3">
<property name="contentType">html</property>
<text-property
name="content"><![CDATA[<value-of>new Date()</value-of>]]></text-property>
</text>
</page-footer>
</simple-master-page>
</page-setup>
<body>
<data id="5">
<list-property name="boundDataColumns">
<structure>
<property name="name">data item</property>
<expression name="expression">// Convert numbers to
words
// copyright 25th July 2006, by Stephen Chapman http://javascript.about.com
// permission to use this Javascript on your web page is granted
// provided that all of the code (including this copyright notice) is
// used exactly as shown (you can change the numbering system if you wish)

// American Numbering System
var th = ['','thousand','million', 'billion','trillion'];

// uncomment this line for English Number System
// var th = ['','thousand','million', 'milliard','billion'];


var dg = ['zero','one','two','three','four',
'five','six','seven','eight','nine'];
var tn = ['ten','eleven','twelve','thirteen',
'fourteen','fifteen','sixteen', 'seventeen','eighteen','nineteen'];
var tw = ['twenty','thirty','forty','fifty',
'sixty','seventy','eighty','ninety'];
function toWords(s){
//s = s.replace(/[\, ]/g,'');
if (s != String(parseFloat(s))) return 'not a number';
s=String(parseFloat(s));
var x = s.indexOf('.');
if (x == -1) x = s.length;
if (x > 15) return 'too big';
var n = s.split('');
var str = '';
var sk = 0;
for (var i=0;
i &lt; x;
i++) {if ((x-i)%3==2) {if (n[i] == '1') {str += tn[Number(n[i+1])] + ' ';
i++;
sk=1;
} else if (n[i]!=0) {str += tw[n[i]-2] + ' ';
sk=1;
}} else if (n[i]!=0) {str += dg[n[i]] +' ';
if ((x-i)%3==0) str += 'hundred ';
sk=1;
} if ((x-i)%3==1) {if (sk) str += th[(x-i-1)/3] + ' ';
sk=0;
}} if (x != s.length) {
var y = s.length;
str += 'point ';
for (var i=x+1;
i&lt;y;
i++) str += dg[n[i]] +' ';
} return str.replace(/\s+/g,' ');
}

xyz = toWords(params["NewParameter"]);</expression>
<property name="dataType">any</property>
</structure>
</list-property>
<property name="resultSetColumn">data item</property>
</data>
</body>
</report>
Re: AmountinWords Feature in Birt [message #230669 is a reply to message #224807] Tue, 27 March 2007 09:41 Go to previous message
Eclipse UserFriend
Originally posted by: harikrishnan_j2003.rediffmail.com

Sir,


Thankyou for your Answer it works well.


Thankyou
Harikrishnan J.
Previous Topic:Change XML file path in XML Data Source/Set
Next Topic:MYSQL Connection Refused
Goto Forum:
  


Current Time: Sat Jul 27 15:52:31 GMT 2024

Powered by FUDForum. Page generated in 0.03891 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top