在Crystal Report中写函数将数字转为英文
<P><BR>1.在水晶报表中建立一个转换方法 DecimalToWords</P><P>Function (numbervar decimals)<BR> local stringVar array _smallNumbers := ["ZERO", "ONE", "TWO", "THREE", "FOUR", "FIVE", "SIX", "SEVEN", "EIGHT", <BR> "NINE", "TEN", "ELEVEN", "TWELVE", "THIRTEEN", "FOURTEEN", "FIFTEEN", <BR> "SIXTEEN", "SEVENTEEN", "EIGHTEEN", "NINETEEN"];<BR> local stringVar array _tens := ["", "", "TWENTY", "THIRTY", "FORTY", "FIFTY", "SIXTY", "SEVENTY", "EIGHTY", "NINETY"];<BR> local stringVar array _scaleNumers := ["", "THOUSAND", "MILLION", "BILLION" ];<BR> stringVar combined := _smallNumbers[1];<BR> if decimals <> 0 then <BR> (<BR> numberVar i := 1;<BR> numberVar array digitGroups := [0,0,0,0];</P><P> for i := 1 to 4 step 1 do <BR> (<BR> digitGroups<I> := decimals mod 1000;<BR> decimals := Int(decimals / 1000);<BR> );<BR> stringVar array groupText := ["","","",""];<BR> for i:=1 to 4 step 1 do<BR> (<BR> numberVar hundreds := Int(digitGroups<I> / 100);<BR> numberVar tensUnits := digitGroups<I> mod 100;<BR> if hundreds <> 0 then<BR> (<BR> groupText<I> := groupText<I> + _smallNumbers[hundreds+1] + " HUNDRED";<BR> if tensUnits <> 0 then <BR> groupText<I> := groupText<I> + " ";<BR> ); <BR> numberVar tens := Int(tensUnits / 10);<BR> numberVar units := tensUnits mod 10;<BR> if tens >= 2 then<BR> (<BR> groupText<I> := groupText<I> + _tens[tens+1];<BR> if units <> 0 then<BR> groupText<I> := groupText<I> + "-" + _smallNumbers[units+1];<BR> )<BR> else if tensUnits <> 0 then<BR> groupText<I> := groupText<I> + _smallNumbers[tensUnits +1]<BR> );<BR> combined := groupText[1];<BR> for i:=2 to 4 step 1 do<BR> (<BR> if digitGroups<I> <> 0 then<BR> (<BR> stringVar prefix := groupText<I> + " " + _scaleNumers<I>;<BR> if Length(combined) <> 0 then<BR> prefix := prefix+ " ";<BR> combined := prefix + combined;<BR> );<BR> );<BR> );<BR> combined;</P><P> </P><P> </P><P>2.然后在水晶报表中建一个 公式字段 TotalEg</P><P> DecimalToWords ({#Total}) //其中Total是个汇总字段</P><P> </P><P>3.把上一步建的公式字段TotalEg拖到报表需要的位置</P><P> </P></I></I></I></I></I></I></I></I></I></I></I></I></I></I></I></I><p>[此帖子已被 stone 在 2009-6-24 11:58:57 编辑过]Re:在Crystal Report中写函数将数字转为英文
希望有更详细的程序,可以转换小数点的。Re:在Crystal Report中写函数将数字转为英文
这段函数是可以正常使用,但不支持小数位Re:在Crystal Report中写函数将数字转为英文
是的,写一个貌似很难。您这有现成的吗?页:
[1]