We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Support for arrayformulas

Thread ID:

Created:

Updated:

Platform:

Replies:

145459 Jun 23,2019 03:36 PM UTC Jun 26,2019 09:25 AM UTC WinForms 2
loading
Tags: GridControl
Travis Chambers
Asked On June 23, 2019 03:36 PM UTC

Hi,

In excel I am able to retrieve the top 'n' items in a category based on am adjacent numeric column (I.e. top 10 products sold by revenue made) by combining LARGE, INDEX, and MATCH formulas in a formula array. Is there a way to apply array formulas to a cell in the gridcontrol? If these are not supported, do you know of a way to retrieve top 'n' categories in a custom function?

Any help is greatly appreciated!

Mohanraj Gunasekaran [Syncfusion]
Replied On June 24, 2019 01:56 PM UTC

Hi Travis, 

Thanks for using Syncfusion product. 

By default, GridControl does not have the support for array formulas. Currently, we are analyzing the possibilities to provide the array formula support for our GridControl. So, we will check and update the details on 26th June 2019. 

Regards, 
Mohanraj G 


Jagadeesan Pichaimuthu [Syncfusion]
Replied On June 26, 2019 09:25 AM UTC

Hi Travis, 
  
Thanks for your patience. 
  
Our CalcEngine does have the support to calculate the array formula. To integrate the CalcEngine with our GridControl, you could implement the custom class which should derived from ICalcData. Please refer the following code example and the sample. 
  
C# 
 CalcEngine formulaEngine; 
CustoCalulate calc = new CustoCalulate(this.gridControl1); 
formulaEngine = new CalcEngine(calc); 
  
public class CustoCalulate : ICalcData 
{ 
    GridControl grid; 
    public CustoCalulate(GridControl _grid) 
    { 
        grid = _grid; 
    } 
    public event ValueChangedEventHandler ValueChanged; 
  
    public object GetValueRowCol(int row, int col) 
    { 
        return grid[row, col].CellValue; 
    } 
  
    public void SetValueRowCol(object value, int row, int col) 
    { 
        grid[row, col].FormattedText = value.ToString(); 
    } 
  
    public void WireParentObject() 
    { 
    } 
} 
  
In our sample, array formula should starts with ‘{’ and endswith ‘}’(ex:{=Max(A1:A3/B1:B3)}). Please refer the following code example. 
  
C# 
this.gridControl1.CurrentCellEditingComplete += GridControl1_CurrentCellEditingComplete; 
this.gridControl1.CurrentCellInitializeControlText += GridControl1_CurrentCellInitializeControlText; 
private void GridControl1_CurrentCellInitializeControlText(object sender,GridCurrentCellInitializeControlTextEventArgs e) 
{ 
    if(e.Style.CellType.Equals(GridCellTypeName.FormulaCell) && e.Style.Tag != null) 
    { 
        e.ControlText = e.Style.Tag.ToString(); 
    } 
} 
  
private void GridControl1_CurrentCellEditingComplete(object sender, EventArgs e) 
{ 
    GridCurrentCell cc = this.gridControl1.CurrentCell; 
    GridStyleInfo style = this.gridControl1[cc.RowIndex, cc.ColIndex]; 
    if (style != null && style.CellType.Equals(GridCellTypeName.FormulaCell)) 
    { 
        //To compute the array formula 
        if (style.Text.StartsWith("{=") && style.Text.EndsWith("}")) 
        { 
            style.Tag= style.CellValue; 
            style.FormattedText = formulaEngine.ParseAndComputeFormula(style.Text); 
                    
        } 
    } 
} 
  
  
Please get back to us if you need any further assistance on this. 
  
Regards, 
Jagadeesan 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon