[]
        
(Showing Draft Content)

GrapeCity.Documents.Excel.CustomFunction.IsVolatile

IsVolatile Property

IsVolatile

Gets or sets whether this custom function is volatile.

If this property is true, formulas that call this custom function are recalculated whenever calculation is triggered, even when the arguments have not changed. If it is false, calculation can reuse cached results for repeated calls with the same arguments.

Declaration
public bool IsVolatile { get; set; }
Public Property IsVolatile As Boolean
Examples
CustomFunction function = new NextValueFunction();
bool isVolatile = function.IsVolatile;
Workbook.AddCustomFunction(function, true);
worksheet.Range["A1"].Formula = "=NEXTVALUE()";
object firstValue = worksheet.Range["A1"].Value;
worksheet.Range["A2"].Value = "trigger recalculation";
workbook.Calculate();
object recalculatedValue = worksheet.Range["A1"].Value;

class NextValueFunction : CustomFunction
{
    private int _calculationCount;

    public NextValueFunction()
        : base("NEXTVALUE", FunctionValueType.Number)
    {
        IsVolatile = true;
    }

    public override object Evaluate(object[] arguments, ICalcContext context)
    {
        return (double)++_calculationCount;
    }
}