CustomFunction question

I have implemented a bunch of custom functions. An user creates a template spreadsheet with formulas that call these custom functions.

Is it possible to export to an excel file a version of the original template spreadsheet that has all the custom functions calls replaced with their actual values, such that when this spreadsheet is opened in Excel all the calculations that call custom functions are resolved?

So, if in the template the formula for A1 is =TestFunction(10) + 1 and TestFunction(10) returns 10, let’s say, then in the spreadsheet that results from the export I will have in A1 =10 + 1.

If this is not possible - I have the feeling that what I am asking could be difficult to implement :slight_smile: - would it be possible to export the template spreadsheet to a spreadsheet version that contains only computed values?

Thanks

Hi,



Well, we do have Worksheet.Cells.RemoveFormulas() method that will render computed values into the cells instead of formulas, you may try it if it works well for your custom functions also.

E.g

workbook.CalculateFormula(false,…);
workbook.Worksheets[“Report”].Cells.RemoveFormulas();
//…


Thank you.