本帖最后由 css207 于 2022-12-15 16:35 编辑
- let
- Text.Crmb = (money as number) as text=>
- if Number.Abs(money) > 10000000000000 then "金额过大,本函数不支持!"
- else if money = 0 then "零元整"
- else [
- cnum="零壹贰叁肆伍陆柒捌玖-万仟佰拾亿仟佰拾万仟佰拾元角分",
- snum = Text.From(Number.Round(Number.Abs(money)*100)),
- len = Text.Length(snum),
- r=(x as number) as text => if x = 0 then Text.Combine({Text.Middle(cnum, Number.FromText(Text.Middle(snum, 0 , 1)), 1),Text.Middle(cnum,26 - len + 0, 1)})
- else Text.Combine({@r(x-1),Text.Combine({Text.Middle(cnum, Number.FromText(Text.Middle(snum, x , 1)), 1),Text.Middle(cnum,26 - len + x, 1)})}),
- r0 = r(len-1),
- r1 = Text.Replace(r0, "零仟", "零"),
- r2 = Text.Replace(r1, "零佰", "零"),
- r3 = Text.Replace(r2, "零拾", "零"),
- r4 = Text.Replace(r3, "零零", "零"),
- r5 = Text.Replace(r4, "零零", "零"),
- r6 = Text.Replace(r5, "零亿", "亿"),
- r7 = Text.Replace(r6, "零万", "万"),
- r8 = Text.Replace(r7, "零元", "元"),
- r9 = Text.Replace(r8, "亿万", "亿"),
- r10 = Text.Replace(r9, "零角", "零"),
- r11 = Text.Replace(r10, "零分", "整"),
- r12 = Text.Replace(r11, "零整", "整"),
- r13 = if money > 0 then r12 else Text.Combine({"负", r12})
- ][r13]
- in
- Text.Crmb
复制代码
|