View Categories

Use functions in expressions

< 1 min read

Built-in function

Stimulsoft Reports has many built-in functions that you can use. These functions are accessible directly from the data dictionary and within the expression editor. Examples of built-in functions and their usage are:

{Trim(MyString)}

Also

{Trim(MyDataSource, MyDataColumn)}

In either case, the trim function removes leading and trailing spaces from the results displayed in the report.

.NET Framework method

In addition to built-in functions, you can use available .NetFramework methods. For string expressions, you can use any of the following examples:

{MyString.Trim()} // remove leading and trailing spaces

{“Test”.ToUpper()} // converts the value to uppercase “TEST”

{MyString.Length} // returns the length of the string - if the value of MyString is "Test", the method returns 4

For formulas, you can use any of the following examples:

{Math.Round(MyValue, 2)} // Round the value to 2 decimal places

{Math.Sqrt(MyValue)} // returns the square root of MyValue

{MyValue.ToString() + "times"} // Convert number to string and add word "times" -

                         // if MyValue is 5, this will return "5 times"

There is no limit to the number of framework methods you can access. If it can be used within .NET for the type you are using in your report, you can use it without any restrictions.