Reporting Services [SSRS]表达式的有效样式格式字符串是什么?

Jon*_*son 38 formatting reporting-services

我试图找出Reporting Services表达式中格式(表达为对象,样式为字符串)函数的样式字符串.

我找不到记录这些样式格式字符串的位置!

具体来说,我试图将价格字段格式化为总是2位小数.

即1.5格式到1.50美元

dan*_*die 38

格式为货币格式字符串

=Format(Fields!Price.Value, "C")
Run Code Online (Sandbox Code Playgroud)

它会给你2个小数位,前缀为"$".

您可以在MSDN上找到其他格式字符串:向ReportViewer报表添加样式和格式


Pet*_*hia 34

如上所述,您可以使用:

=Format(Fields!Price.Value, "C")
Run Code Online (Sandbox Code Playgroud)

"C"后面的数字将指定精度:

=Format(Fields!Price.Value, "C0")
=Format(Fields!Price.Value, "C1")
Run Code Online (Sandbox Code Playgroud)

你也可以使用像这样的Excel风格的面具:

=Format(Fields!Price.Value, "#,##0.00")
Run Code Online (Sandbox Code Playgroud)

没有测试过最后一个,但有想法.也适用于日期:

=Format(Fields!Date.Value, "yyyy-MM-dd")
Run Code Online (Sandbox Code Playgroud)

  • 谢谢彼得!我需要在小数点后最多显示4个位置,所以我能够使用你建议的掩码.=格式(字段!rate.Value,"$ ###,###,## 0.00 ##") (2认同)