Referencing cells with values from array formulas doesn't seem to work

Unless I am missing something obvious, why does this program display #Recursive Reference! instead of 2:

using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using Aspose.Cells;

namespace TestAspose
{
class Program
{
static void Main(string[] args)
{
// Procedure1();
// Procedure2();

Procedure5();
Console.WriteLine(“Done!”);
Console.ReadKey();
}


private static void Procedure5()
{
Workbook workbook = new Workbook();
Worksheet worksheet = workbook.Worksheets[0];

//Get the cells collection in the sheet
Cells cells = worksheet.Cells;
cells[“A1”].SetArrayFormula("=myarrayfunc()", 1, 5);
workbook.CalculateFormula(false, new CustomFunction());
Console.WriteLine(cells[“B1”].Value);
}

}

public class CustomFunction : ICustomFunction
{

public object CalculateCustomFunction(string functionName, System.Collections.ArrayList paramsList, System.Collections.ArrayList contextObjects)
{

if (functionName.ToLower().Equals(“myarrayfunc”))
{
return new object[] {1, 2, 3, 4, 5};
}

return null;
}
}
}

Hi,

Thank for providing us sample code and details.

After an initial test, I can notice the issue as you mentioned. It does work fine with single valued or normal formulas using Cell.Formula attribute (see the topic: http://www.aspose.com/docs/display/cellsnet/Using+ICustomFunction+feature ) but does not work with array formulas, may be a limitation for custom functions. It looks like a limitation with Custom functions regarding ArrayFormulas, but we have to sort it out soon.

I have logged a ticket with an id: CELLSNET-40777. We will look into it soon.

Thank you.

Thank you for looking into this, and also thank you for all the other answers.

Hi,

Please download and try the latest fix: Aspose.Cells for .NET v7.2.2.2.

And if you want to return array, please return object[][]. If the value is
number, please return double value not int value.

The fix works.

Thank you!

Hi,

Thanks for your feedback.

It’s good to know that your issue is resolved now. If you face any other problem, please feel free to post, we will help you asap.

The issues you have found earlier (filed as CELLSNET-40777) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by aspose.notifier.