关于您的问题:如何将金额使用英文展示
这个我们内置确实暂时不行,但是可以使用自定义脚本实现。脚本实现可以参考这个帖子:
https://help.grapecity.com.cn/pa ... tion?pageId=5972510
我这边大概写了一个,您可以试一下:
- public string ConvertNumberToWords(int number)
- {
- string[] ones = new string[]
- {
- "", "One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine",
- "Ten", "Eleven", "Twelve", "Thirteen", "Fourteen", "Fifteen", "Sixteen",
- "Seventeen", "Eighteen", "Nineteen"
- };
- string[] tens = new string[]
- {
- "", "", "Twenty", "Thirty", "Forty", "Fifty", "Sixty", "Seventy", "Eighty", "Ninety"
- };
- string[] thousands = new string[]
- {
- "", "Thousand", "Million", "Billion", "Trillion"
- };
- if (number == 0)
- {
- return "Zero";
- }
- string words = "";
- if (number < 0)
- {
- words += "Negative ";
- number = Math.Abs(number);
- }
- int index = 0;
- do
- {
- // 取三位数
- int num = number % 1000;
- if (num != 0)
- {
- string word = "";
- if (num >= 100)
- {
- int hundreds = num / 100;
- word += $"{ones[hundreds]} Hundred ";
- num %= 100;
- }
- if (num >= 20)
- {
- int tensDigit = num / 10;
- word += $"{tens[tensDigit]} ";
- num %= 10;
- }
- if (num > 0)
- {
- word += ones[num];
- }
- string str = word.Trim();
- words = $"{str} {thousands[index]} {words}";
- }
- number /= 1000;
- index++;
- } while (number > 0);
- return words.Trim()+ " Dollars Only";
- }
复制代码
我这边做了测试,目前展示正常:
|