Formulas
There are several types of expressions in a Report Builder report:
Formulas added by a developer with a specific formula name
Formulas representing field content or other field properties, such as conditional formatting
Static elements, for example header labels
All fields, contents and conditional formulas in Report Builder are stored as a formula. Even if a static text elements are added to a line, Report Builder will create a formula instance named "Formula???" where the three question marks represent a unique number.
The advantage of this approach is that all kinds of expressions are in a unique directory at one spot that is easy to find. On the other hand, if reports are maintained and changed over time, such automatically generated formulas may not be used anymore but they are not automatically deleted from the report. This may leave a lot of dead report and unknown business logic in the report file. Depending on settings in Ice Porter at the time of conversion, unused formulas might be excluded in the target report.
The following list explains how expression details are converted to equivalent codes in Stimulsoft Reports.Net:
Simple Expressions
Static text is wrapped up in formulas in Report Builder without the developer's notice. When a text element is added to an empty report, Report Builder will automatically create an expression named Formula1. When converting such expressions to Stimulsoft Reports.Net, all simple expressions are ignored. They will not be converted as a full individual expression. Instead, the static text is ported directly to the appropriate item, for example a background text caption. The formula wrapper is then ignored during conversion.
Formulas
All expressions from the source report are converted from the Report Builder syntax to C# syntax in Stimulsoft Reports.Net. Many functions from Report Builder have equivalent functions in the target environment, which is actually able to interface with the entire .NET Framework. Specific functions embedded into Stimulsoft Reports.Net should be seen as an addition or simplification to the high-level functions available in .NET. However, compared to other reporting engines, such as Crystal Reports, the number of internal functions is quite low.
Stimulsoft Reports.Net relies on C# syntax and the .NET Framework for all expressions. This provides great flexibility but it also adds complexity in some areas. In order to use extended date functions of the .NET Framework, the assemblies have to be referenced in the report and the namespaces have to be defined in order to not fully qualify all function names. Compared to other, more extensive and integrated function libraries, expressions in Stimulsoft Reports.Net are way more powerful but they are not as easy and straightforward and might be confusing for people that are not used to Microsoft .NET.
Most formulas in a Report Builder report are bound to elements listed above. Hence, they will not show up as an explicit expression in Stimulsoft Reports.Net, but become part of a property of the report items. Only if reports are ported with all formulas or for expressions in Report Builder not named like "FormulaXXX", a corresponding function is added to the target report.
Stimulsoft Reports.Net doesn't have its own formulas section in the report designer. In order to add a user-defined expression to the report, it has to be added as C# code directly to the report file on the code tab - which looks very similar C# source code files. Such user-defined expressions are added to one region by Ice Porter, as shown in the following screenshot for the TestAbc() function.
All function calls that can be used in Report Builder are mapped to one of the Stimulsoft Reports.Net functions or native functions in the .NET Framework, if possible. A lot of functions have been replicated and wrapped up as custom functions that are part of the IcePorterTemplate.mrt file. This way, the nature of expressions in Report Builder is preferred and not moved to object-oriented syntax.
There may be slight differences between expression syntax in the code section of Stimulsoft Reports.Net reports and embedded expressions that are used within a data field or to conditionally hide something in the report. In order to use functionality from the namespaces Math, StiFunctionsDate and StiFunctionsString, the namespace has to be added as a prefix to the function call. This is automatically done by Ice Porter during conversion and marked for all relevant functions below. Inside the Stimulsoft Reports.Net designer and on a field level, these prefixes are not required because the namespaces are automatically added by Stimulsoft Reports.Net.
Print Functions
Source expression | Target expression | Comments |
---|---|---|
PageNumber() | CurrentPrintPage | See warning about Page references **1) |
TotalPages() | TotalPageCount | See warning about Page references **1) |
ReportFileName() | "[ReportFileName]" | ToDo 3018: This is not supported by Stimulsoft Reports.Net and it will not be automatically resolved by Ice Porter. |
ReportDevice() | "[ReportDevice]" | ToDo 3018: This is not supported by Stimulsoft Reports.Net and it will not be automatically resolved by Ice Porter. |
ReportDriver() | "[ReportDriver]" | ToDo 3018: This is not supported by Stimulsoft Reports.Net and it will not be automatically resolved by Ice Porter. |
ReportPort() | "[ReportPort]" | ToDo 3018: This is not supported by Stimulsoft Reports.Net and it will not be automatically resolved by Ice Porter. |
Date Functions
Source expression | Target expression | Comments |
---|---|---|
CurrentDate() | Today |
|
CurrentTime() | Time |
|
DateAddDay() | DateAddDay() |
|
DateConstruct() | DateConstruct() |
|
DateDay() | Day() | Namespace StiFunctionsDate |
DateHour() | Hour() | Namespace StiFunctionsDate |
DateIFF() | DateIFF() |
|
DateMinute() | Minute() | Namespace StiFunctionsDate |
DateMonth() | Month() | Namespace StiFunctionsDate |
DateMonthBegin() | DateMonthBegin() |
|
DateMonthEnd() | DateMonthEnd() |
|
DateSecond() | Second() | Namespace StiFunctionsDate |
DateToStr() | DateToStr() |
|
DateToStrPicture() | Format() | Namespace String |
DateYear() | Year() | Namespace StiFunctionsDate |
WeekDay() | Weekday() | Namespace StiFunctionsDate |
Number Functions
Source expression | Target expression | |
---|---|---|
NumberAbsolute() | Abs() | Namespace Math |
NumberCountryFmt() | Format() | Namespace String, formatting string is {0:n} |
NumberIFF() | NumberIFF() |
|
NumberMod() |
| Replaced with the modulo operator. NumberMod(param0, param1) will become param0 % param1 |
NumberRound() | Round() | Namespace Math |
NumberToCurrency() | Format() | Namespace String, formatting string is {0:c} |
NumberToStr() | NumberToStr() |
|
NumberToStrPicture() | Format() | Namespace String |
NumberTruncate() | NumberTruncate() |
|
Power() | Pow() | Namespace Math |
String Functions
Source expression | Target expression | Comments |
---|---|---|
StrCase() | StrCase() |
|
StrCompare() | Compare() | Namespace String |
StrIFF() | StrIFF() |
|
StrLeft() | StrLeft() |
|
StrLength() | Length() | Namespace StiFunctionsStrings |
StrLower() | ToLowerCase() | Namespace StiFunctionsStrings |
StrLTrim() | StrLTrim() |
|
StrMid() | Substring() | Namespace StiFunctionsStrings |
StrPad() | StrPad() |
|
StrProper() | ToProperCase() | Namespace StiFunctionsStrings |
StrRepeat() | StrRepeat() |
|
StrReplace() | StrReplace() |
|
StrRight() | StrRight() |
|
StrRTrim() | StrRTrim() |
|
StrScan() | StrScan() |
|
StrSpaces() |
| Replaced with native C# syntax. StrSpaces(5) will become new String( param0 ) |
StrTabSeparate() | Replace() | Namespace StiFunctionsStrings |
StrToDate() | Parse() | Namespace DateTime |
StrToNumber() | Parse() | Namespace Double |
StrTranslate() | Translate() |
|
StrTrim() | Trim() | Namespace StiFunctionsStrings |
StrUpper() | ToUpperCase() | Namespace StiFunctionsStrings |
Aggregate Functions
Source expression | Target expression | Comments |
---|---|---|
Average() | Avg() |
|
Count() | Count() |
|
Maximum() | Max() |
|
Minimum() | Min() |
|
ReportAverage() | Avg() |
|
ReportCount() | Count() |
|
ReportMaximum() | Max() |
|
ReportMinimum() | Min() |
|
ReportSum() | Sum() |
|
Sum() | Sum() |
|
Cross Tab Functions
Source expression | Target expression | Comments |
---|---|---|
XTabGetColCount() |
| Conversion of Cross Tabs is not supported by Ice Porter. |
XTabGetColHeadings() |
|
|
XTabGetRowCount() |
|
|
XTabGetRowHeadings() |
|
|
StrTabColSuppress() |
|
|
StrTabRowSuppress() |
|
|
Comments and Footnotes
PageNumber and TotalPageCount may lead to unexpected field sizing when used within an expression. In Stimulsoft Reports.Net, all page numbering information is filled in a second pass once the report has been rendered. The field width is determined during the first pass. If the field expression contains any references to page numbering, dynamically field metrics are calculated based on the expression content, not the evaluated expression result. This may lead to unexpected sizing because initially, fields containing page references are calculated with their expression content.
For example, if there is a field with smaller width and word-wrap accidentally set to true that has the following formula:
This is likely to span several lines when not using a replacement for PageNumber.
Instead of using PageNumber, Stimulsoft support recommends using CurrentPrintPage which is said to be safe to use. CurrentPrintPage is an internal variable, like PageNumberTrough, but does not understand the page segments and doesn't work in sub-reports. For TotalPageCount, warning 2036 will be logged because word-wrapping is disregarded.
Last updated