js怎么把数字金额转换为大写金额
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了js怎么把数字金额转换为大写金额相关的知识,希望对你有一定的参考价值。
参考技术A 百度一下这种写好的js很多 随便选个就可以;我帮你搜了个;function Arabia_to_Chinese(Num)
for(i=Num.length-1;i>=0;i--)
Num = Num.replace(",","")
Num = Num.replace(" ","")
Num = Num.replace("¥","")
if(isNaN(Num))
alert("请检查小写金额是否正确");
return;
part = String(Num).split(".");
newchar = "";
for(i=part[0].length-1;i>=0;i--)
if(part[0].length > 10) alert("位数过大,无法计算");return "";
tmpnewchar = ""
perchar = part[0].charAt(i);
switch(perchar)
case "0": tmpnewchar="零" + tmpnewchar ;break;
case "1": tmpnewchar="壹" + tmpnewchar ;break;
case "2": tmpnewchar="贰" + tmpnewchar ;break;
case "3": tmpnewchar="叁" + tmpnewchar ;break;
case "4": tmpnewchar="肆" + tmpnewchar ;break;
case "5": tmpnewchar="伍" + tmpnewchar ;break;
case "6": tmpnewchar="陆" + tmpnewchar ;break;
case "7": tmpnewchar="柒" + tmpnewchar ;break;
case "8": tmpnewchar="捌" + tmpnewchar ;break;
case "9": tmpnewchar="玖" + tmpnewchar ;break;
switch(part[0].length-i-1)
case 0: tmpnewchar = tmpnewchar +"元" ;break;
case 1: if(perchar!=0)tmpnewchar= tmpnewchar +"拾" ;break;
case 2: if(perchar!=0)tmpnewchar= tmpnewchar +"佰" ;break;
case 3: if(perchar!=0)tmpnewchar= tmpnewchar +"仟" ;break;
case 4: tmpnewchar= tmpnewchar +"万" ;break;
case 5: if(perchar!=0)tmpnewchar= tmpnewchar +"拾" ;break;
case 6: if(perchar!=0)tmpnewchar= tmpnewchar +"佰" ;break;
case 7: if(perchar!=0)tmpnewchar= tmpnewchar +"仟" ;break;
case 8: tmpnewchar= tmpnewchar +"亿" ;break;
case 9: tmpnewchar= tmpnewchar +"拾" ;break;
newchar = tmpnewchar + newchar;
if(Num.indexOf(".")!=-1)
if(part[1].length > 2)
part[1] = part[1].substr(0,2)
for(i=0;i<part[1].length;i++)
tmpnewchar = ""
perchar = part[1].charAt(i)
switch(perchar)
case "0": tmpnewchar="零" + tmpnewchar ;break;
case "1": tmpnewchar="壹" + tmpnewchar ;break;
case "2": tmpnewchar="贰" + tmpnewchar ;break;
case "3": tmpnewchar="叁" + tmpnewchar ;break;
case "4": tmpnewchar="肆" + tmpnewchar ;break;
case "5": tmpnewchar="伍" + tmpnewchar ;break;
case "6": tmpnewchar="陆" + tmpnewchar ;break;
case "7": tmpnewchar="柒" + tmpnewchar ;break;
case "8": tmpnewchar="捌" + tmpnewchar ;break;
case "9": tmpnewchar="玖" + tmpnewchar ;break;
if(i==0)tmpnewchar =tmpnewchar + "角";
if(i==1)tmpnewchar = tmpnewchar + "分";
newchar = newchar + tmpnewchar;
while(newchar.search("零零") != -1)
newchar = newchar.replace("零零", "零");
newchar = newchar.replace("零亿", "亿");
newchar = newchar.replace("亿万", "亿");
newchar = newchar.replace("零万", "万");
newchar = newchar.replace("零元", "元");
newchar = newchar.replace("零角", "");
newchar = newchar.replace("零分", "");
if (newchar.charAt(newchar.length-1) == "元" || newchar.charAt(newchar.length-1) == "角")
newchar = newchar+"整"
return newchar;
看了下没什么大问题本回答被提问者采纳
小写数字自动转换成大写人民币金额两张表怎么在桌面找不同吗?
参考技术A 实现数字变为大写金额方法1-修改单元格格式,设置单元格格式——特殊——中文大写数字。
方法2-NUMBERSTRING函数法,Excel中有很多隐藏的函数。本文中即将介绍一个隐藏函数——NUMBERSTRING,此函数可以方便的实现小写数字到中文大写数字的转化。
方法3:TEXT函数法,语法:TEXT(要转换的数值,格式参数)格式参数为"[dbnum1]":普通大写,如“二百五十九”;格式参数为"[dbnum2]":财务大写,如“柒佰捌拾”;格式参数为"[dbnum3]":阿拉伯数字+单位,如“2百4十9”;
以上是关于js怎么把数字金额转换为大写金额的主要内容,如果未能解决你的问题,请参考以下文章