如何在Crystal Report中动态切换货币格式

时间:2014-03-24 19:20:56

标签: crystal-reports report crystal-reports-2010

我需要能够在Crystal Report上切换十进制字段的货币格式。如果小数表示百分比,我不希望小数前面的货币符号。我目前无法更改报表后面的DataSet或如何填充它。所以,我想为这个水晶方找到一个解决方案。

我对Crystal Engine的体验有限,所以我想通过报告功能知道这是否可行。报告后面的DataSet有一个布尔值(IsRatePercent),可以在公式中使用它来确定是否应该显示货币符号。

1 个答案:

答案 0 :(得分:2)

最简单的解决方案是使用与字段display string属性关联的条件格式化函数:

If {table.IsRatePercent} Then
   ToText(CurrentFieldValue,"###,###.## %")
Else
   ToText(CurrentFieldValue,"$###,###.##")

另一种选择:

If {table.IsRatePercent} Then
   ToText(CurrentFieldValue, 2, ",", ".") + " %"
Else
   "$" + ToText(CurrentFieldValue, 2, ",", ".")
相关问题