I’m processing workbooks that could have user defined functions (UDF) in the formulas and I will have no knowledge of these UDF’s. In order to ensure that cell values are up to date, I’m calling Workbook.CalculateFormula and handling UDF’s by returning the current cell value similar to the following:
private class CustomFunction : ICustomFunction
public object CalculateCustomFunction(string functionName, ArrayList paramsList, ArrayList contextObjects)
var cell = contextObjects as Cell;
<span style="color:blue;">return</span> cell?.Value; }
This will likely work fine when the formula is simple, e.g. “=SomeUdf()”, but would work incorrectly if the formula does anything more complicated such as “=SomeUdf() + 2”. Ideally, I would like to just retain the current cell value if the cell has a formula with a UDF.