开发者

Custom Number Format in Crystal Report !

How can i format quantity value in crystal report like if the value is 5, then just show as 5. If the value is 5.25, then show as 5.25. So which format should i use开发者_运维技巧 for that?

Thanks.


Right-click on the element and go into the formatting menu. I think what you want will be an option.


Instead of displaying it as a numeric value, write a function, MyStr$, which converts to string depending on whether the number is integer or not. BTW, a good way to check for integrality is a test of the form:

ABS(x -Truncate(x)) < EPS

where EPS is a small value, like 0.001 (depending on the accuracy you need, increase or decrease this)


Use this "conditional format formula":

If Truncate(CurrentFieldValue) = CurrentFieldValue
    Then
        0
    Else
        Length(ToText(ToNumber(StrReverse(ToText(Abs(CurrentFieldValue) - Truncate(Abs(CurrentFieldValue)),8,"",""))) / 10,0,""))

Go to the numeric report field, rightclick, choose "Format Field", choose "Number" tab, click "Customize" button. Put the formula above in the format formula ("X+2" button) for the format options "Decimals" and "Rounding".

BTW: In the formula you'll notice the number 8. This is the maximum expected number of decimals; if you think you'll encounter more decimals in your report then simply change 8 to a higher number.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜