I. Description
Scenario Description: the formula of internal rate of return (IRR) is frequently used in the financial statements of feasibility evaluation and analysis. There is no such formula in FR by default, and the calculation of this value is not purely mathematical. Here's how to do achieve that.
II. Ideas
We can create a custom function according to the IRR logic, and then calculate the IRR internal rate of return according to a set of data columns.
III. Operation steps
In general, if you want to carry out secondary development on the basis of finereport designer, we can start the designer by calling FineReport startup class in Eclipse or IDEA, so as to facilitate debugging in the development process and preparation for secondary development.
Note that you need to introduce the jar package under finereport designer. Click Start the Designer in Eclipse for more information.
1. For complete code, please refer to:
2. Compiling custom functions
Put the compiled IRR.classunder WEB-INF, the installation directory of finereport, because IRR.java belongs to package com.fr.function. So IRR.class need to be put in %FR_HOME%\webapps\webroot\WEB-INF\classes\com\fr\function.
3. Registering custom functions
After generating the class of the function, you need to register in the designer to use the function. Open server > function manager and select the IRR.class just defined, as shown in the following figure:
4. Using custom functions
After the user-defined function is registered, it can be used directly when making reports. The usage method is the same as the built-in function.
(1) The effect of IRR formula in Excel
(2) The effect of IRR formula in FR
Template style design:
Preview results:
By comparison, we can know that the formula in FR is more accurate and stable than that in Excel.
Note: It is unusual to fail to calculate the result.