Correctly return ArrayExpression (range of cells) from FunctionBase

2 posts, 0 answers
  1. Igor
    Igor avatar
    2 posts
    Member since:
    Mar 2016

    Posted 01 Apr Link to this post

    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.

     

  2. Deyan
    Admin
    Deyan avatar
    135 posts

    Posted 06 Apr Link to this post

    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.
  3. UI for WPF is Visual Studio 2017 Ready
Back to Top