What are the valid Style Format Strings for a Repo

2019-01-17 19:50发布

问题:

I am trying to figure out the style string for the Format(Expression as Object, Style as String) function in a Reporting Services expression.

I can't find where these style format strings are documented!

Specifically I am trying to format a Price field to be always 2 decimal places.

ie 1.5 formats to $1.50

回答1:

Format with Currency format string

=Format(Fields!Price.Value, "C")

It will give you 2 decimal places with "$" prefixed.

You can find other format strings on MSDN: Adding Style and Formatting to a ReportViewer Report



回答2:

As mentioned, you can use:

=Format(Fields!Price.Value, "C")

A digit after the "C" will specify precision:

=Format(Fields!Price.Value, "C0")
=Format(Fields!Price.Value, "C1")

You can also use Excel-style masks like this:

=Format(Fields!Price.Value, "#,##0.00")

Haven't tested the last one, but there's the idea. Also works with dates:

=Format(Fields!Date.Value, "yyyy-MM-dd")


回答3:

You can check the schema at http://schemas.microsoft.com/sqlserver/reporting/2005/01/reportdefinition/ReportDefinition.xsd

Search for xsd:complexType name="StyleType"

This will list out all the possible Styles you can use.

Specific to your question however, you can use the Format style.

Format

Specify the data format to use for values that appear in the textbox.

Valid values include Default, Number, Date, Time, Percentage, and Currency.

Link to MSDN: http://msdn.microsoft.com/en-us/library/ms251684(VS.80).aspx



回答4:

Have you tried here?

http://msdn.microsoft.com/en-us/library/ms157406.aspx



回答5:

Give a Format String value of C2 for the value's properties as shown in figure below.



回答6:

This link has the reference you need to customize your own format https://msdn.microsoft.com/en-us/library/0c899ak8.aspx



回答7:

You can set TextBox properties for setting negative number display and decimal places settings.

  1. Right-click the cell and then click Text Box Properties.
  2. Select Number, and in the Category field, click Currency.