Spread for WPF supports circular references in formulas, which occur when a formula directly or indirectly references its own cell. Circular references are often used to perform iterative calculations to converge on an optimal value.
To enable iterative calculations for circular references in a workbook, you can set the Iterative property of the CalculationEngine class to true. Additionally, you can also use the MaximumIterations property to specify the maximum number of iterations for the calculation and the MaximumChange property to define the maximum allowable change between iterations.
Here is an example of how to create a circular reference using cell A1. The formula “=A1*3” is applied to cell C1, while the formula “=B1+C1” is assigned to cell A1. In this scenario, cell A1 calculates the sum of the values in cells B1 and C1, and cell C1 references A1 and returns the result back to A1. This configuration creates a circular reference as soon as A1's value is calculated. Additionally, the maximum number of calculation iterations is set to 5, allowing the result to be recalculated multiple times to achieve an optimal value.