This is a migrated thread and some comments may be shown as answers.

Correctly return ArrayExpression (range of cells) from FunctionBase

1 Answer 91 Views
Spreadsheet
This is a migrated thread and some comments may be shown as answers.
Igor
Top achievements
Rank 1
Igor asked on 01 Apr 2016, 09:37 AM

I created a some function inherited from the FunctionBase: 

public class MyFunc : FunctionBase

And i want to return result into two cells: 

return new ArrayExpression(new RadExpression[,] { { new StringExpression("123"), new StringExpression("321") } });

But when i use my function in spreadsheet, only one cell correctly filled. I expect that will be filled with a range of two cells "123" and "321".

How to correctly fill range of cells from MyFunc?

 

Thank you.

 

1 Answer, 1 is accepted

Sort by
0
Deyan
Telerik team
answered on 06 Apr 2016, 08:48 AM
Hello Igor,

Thank you for contacting us.

When using some function in a cell the result from this function is returned only to the owner cell. That said when you return ArrayExpression it is returned only in the cell that uses your function and not in the neighbouring cells. However, this result may be used by other functions that accept arguments of type array. 

Here are a few examples on using Array expressions. Let's take for instance this expression:
={1, 2, 3; 4, 5, 6}
 This is an array expression with two rows and three columns. On the first row the values are "1", "2" and "3", while on the second the values are "4", "5" and "6".

This expression may be used by different functions. Let's take for instance the INDEX function which returns elements from an array argument. The following function call for example returns the element from the second row and the first column of the array.
=INDEX({1,2,3;4,5,6},2,1))
So the result of the above expression is "4".

The following function call returns the second column from the array argument as another ArrayExpression:
=INDEX({1,2,3;4,5,6},0,2)

 If we need to use the result from this function to sum the elements from the second column we may write the following:
=SUM(INDEX({1,2,3;4,5,6},0,2))
The result from the last expression will be 7 as it sums 2 and 5.

I hope this is helpful. If you have any other questions or concerns please do not hesitate to contact us again.

Regards,
Deyan
the Telerik team
Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
Matthew
Top achievements
Rank 1
commented on 08 Aug 2022, 06:51 PM

How would one use an ArrayExpression to populate multiple cells other than the one the formula is run in?
Nikolay Demirev
Telerik team
commented on 09 Aug 2022, 12:35 PM

Unfortunately, you are referring to a missing feature called Array Formulas. Here is a link to the public item for the feature. Currently, I can not give you any timeframe for implementing it. You could follow the item to receive updates on the matter.

Tags
Spreadsheet
Asked by
Igor
Top achievements
Rank 1
Answers by
Deyan
Telerik team
Share this question
or