Evaluate Custom Function

Posted by: xgsoftware on 8 September 2017, 3:08 pm EST

  • Posted 8 September 2017, 3:08 pm EST

      we use farpoint spread for winFrom 5.0 in our system, and there is a requirement in our system,we define a lot of custom function that inhert from FuntionInfo, and  we override the Evaluate function with declaration like this:
      public override object Evaluate(object[] args)
        //get data from database
    we set a lot of function in the active sheet cells (for example there are 100 custom function and 20 build in function in the active sheet,the build in funtion such as Sum(A1:B3),the range A1:B3 are filled with custom function) , the active sheet's calculation mode is set to Atuo beacause will want the build in function will recalcuate when we change the custom function, however when I change the custom function or custom function's arguments in a cell, not only the changed function will recalculate,but also all of the custom function will recalcualte,so the performance are unacceptable beacuase many of them are get data from database, is there any way that just recalculate the changing cell's funtion and build in function when we change the funtion in a cell (the other cells with custom function are not going to recalculate),we found another overload of Evaluate function with the declaration like this: 
      public override object Evaluate(object[] args,object context)
    but the context does not have any valuable information in it,if the context can include infomation describle what cause the Evaluate calling, then we can solve it.


  • Replied 8 September 2017, 3:08 pm EST


    When AutoCalculation = true (which is the default) and a cell's formula (or value) is changed then the formula for that cell and the formulas for all dependent cells are automatically recalculated. Cells that are not dependent on the changed cell are not automatically recalculated. Without examining your source code or debugging your application, I can not say why all your formulas are recalculating when you change a single cell's formula. One possible reason would be that your application is calling the RecalculateAll method to perform a manually recalculation of all formulas. Another possible reason is that all your formulas are somehow dependent (directly or indirectly) on the changed cell. We would need more information (e.g. source code or executable) from you to determine the reason.

    In the overloaded method Evaluate(object[] args, object context), the context argument provides the cell location where the formula is being evaluated. This is need by some built-in functions. For example, the built-in ROW and COL functions called with no arguments will return the row and column index of the cell where the formula is being evaluated.

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels