Crystal Report如何将数字转换为文本(逐字逐句)

时间:2018-04-01 13:45:19

标签: crystal-reports

只是一个简单的问题,因为我无法在谷歌或此论坛的任何地方找到它, 我们可以在Crystal Report中逐字拼写数字吗?请参考以下示例:

使用ToWords功能,1257美元拼写为一千二百五十七。我希望得到一个五个七(所以它拼写一字一行)。

提前谢谢你。非常感谢任何帮助!

1 个答案:

答案 0 :(得分:0)

您可以使用ToWords功能来实现此目的。

这里有更多帮助

enter image description here

编辑---------------------------------------------- ----------------

假设您在详细信息部分中放置了数据:

创建公式Initialze

共享Stringvar x:=" &#34 ;;

将此公式放在详细信息部分的开头

再创建一个公式display以根据需要显示数据。

Numbervar i;
Shared Stringvar x;
Stringvar array a:=["1","2","3","4","5","6","7","8","9","0"];


//if database field is integer then convert to string, but by seeing your data database field seems to be string
for i:=1 to length(Right(databasefield,Length("databasefield")-1)) do
(
IF Right(databasefield,Length("databasefield")-1)[i] = a[1] Then
(
x:=x+"ONE"+" "
)
Else IF Right(databasefield,Length("databasefield")-1)[i] = a[2] Then
(
x:=x+"TWO"+" "
)
Else IF Right(databasefield,Length("databasefield")-1)[i] = a[3] Then
(
x:=x+"THREE"+" "
)
Else IF Right(databasefield,Length("databasefield")-1)[i] = a[4] Then
(
x:=x+"FOUR"+" "
)
Else IF Right(databasefield,Length("databasefield")-1)[i] = a[5] Then
(
x:=x+"FIVE"+" "
)
Else IF Right(databasefield,Length("databasefield")-1)[i] = a[6] Then
(
x:=x+"SIX"+" "
)
Else IF Right(databasefield,Length("databasefield")-1)[i] = a[7] Then
(
x:=x+"SEVEN"+" "
)
Else IF Right(databasefield,Length("databasefield")-1)[i] = a[8] Then
(
x:=x+"EIGHT"+" "
)
Else IF Right(databasefield,Length("databasefield")-1)[i] = a[9] Then
(
x:=x+"NINE"+" "
)
Else IF Right(databasefield,Length("databasefield")-1)[i] = a[10] Then
(
x:=x+"ZERO"+" "
)

);
x;

经过测试的解决方案,让我知道它是怎么回事。