Crystal Reports has been designed as an extensible reporting tool. With respect to formulas, that means that you can develop your own functions to add to the Function Tree box if Crystal Reports doesn t provide one that you need. In Crystal Reports 9 and later, this capability has been enhanced with custom functions that you can create directly in your report, or add to the repository to be shared with other Crystal Reports users (custom functions are covered in Chapter 6).
However, versions of Crystal Reports prior to 9 didn t feature custom functions. Also, in some cases, Custom Functions still may not provide sufficient capabilities for your particular business needs. For these situations, you ll still need to create your own functions that appear in the Formula Editor. Look at an example of the built-in functions that appear under the Additional Functions category.
The functions in this category aren t really built-in. These functions are being supplied to Crystal Reports by user function libraries (UFLs). The UFL is supplied to Crystal Reports by an external dynamic link library developed in another programming language. You can write your own custom functions using a Windows programming language, such as C++ or Visual Basic, and have them appear in this section of the Function Tree box. For example, you could write a function that calculates the number of business days between two dates you supply, excluding any weekends and company holidays that are contained in an external database. Or, you might write a UFL that reads a value from an external piece of proprietary measurement equipment and supplies a value to your report.
The filename that supplies the UFL appears as a category in the Additional Functions list ”you may click the plus sign next to the filename to see the available functions supplied by that file. As with other functions, double-click the function name and supply the necessary arguments inside your formula.
Tip | Although the need for external UFLs is probably greatly reduced by Crystal Reports custom function and repository capabilities, you may still need to use them to connect to external databases, external equipment, or any other capability that is not provided by the Crystal Reports formula language (which is what Crystal Reports custom functions use). Information on creating User Functions Libraries with Visual Basic can be found on this book s web site. Look at www.CrystalBook.com. |