Free Support Forum - aspose.com

Aspose.Cells.Net

Hi,

I have some custom formulae which I am calculating through Aspose.Cells.Net. How do I return Excel error values from my Aspose.Cells.ICustomFunction.CalculateCustomFunction implementation if the cell contains errors ? Like equivalent of #N/A,#Value etc.

Thanks,
Behzad Samadianpour

Hi,

Thanks for your posting and using Aspose.Cells.

Since ICustomFunction interface returns object of type object, therefore you can simply return a string.

For example see the following code.

C#

   public class CustomFunction :   ICustomFunction
{
    <span class="code-keyword">public</span> object CalculateCustomFunction(string functionName, <span class="code-object">System</span>.Collections.ArrayList paramsList, <span class="code-object">System</span>.Collections.ArrayList contextObjects)
    {
        <span class="code-keyword">return</span> <font color="#FF0000"><b>"#N/A"</b></font>;
    }</pre><br>