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 : Nov 16th 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

SpreadsheetGrid event when a cell is recalculated?

Thread ID:

Created:

Updated:

Platform:

Replies:

123302 Mar 6,2016 12:06 AM UTC Mar 10,2016 09:35 AM UTC WPF 8
loading
Tags: SfSpreadsheet
Jeffrey Kesselman
Asked On March 6, 2016 12:06 AM UTC

I need to catch an event when a cell changes its value, the trick is I need to do it even if the cell "contents" are a formula that returns a value.

What can I listen for?

Jeffrey Kesselman
Replied On March 6, 2016 03:46 AM UTC

Okay I found an event on SpreadsheetGrid called spreadsheet.ActiveGrid.ValueChanged 
However hooking that does not seem to generate callbacks.

Is there something else I need to do to enable it besides setting it like this:
spreadsheet.ActiveGrid.ValueChanged += ActiveGrid_ValueChanged;

Kanimozhi Bharathi [Syncfusion]
Replied On March 7, 2016 12:39 PM UTC

Hi Jeffrey Kesselman,

Thank you for contacting Syncfusion Support.

 When the cell value is changed in Worksheet ,  you can invoke CellValueChanged Event of ActiveSheet like below code example,

spreadsheet.ActiveSheet.CellValueChanged += ActiveSheet_CellValueChanged;

void ActiveSheet_CellValueChanged(object sender, Syncfusion.XlsIO.Implementation.CellValueChangedEventArgs e)

{

    //throw new NotImplementedException();
}


Please refer the UG link to know “how to access the worksheets in the workbook”:  http://help.syncfusion.com/wpf/sfspreadsheet/working-with-sfspreadsheet#working-with-worksheet


Regards
Kanimozhi B

Jeffrey Kesselman
Replied On March 7, 2016 03:39 PM UTC

Thank you!

Kanimozhi Bharathi [Syncfusion]
Replied On March 8, 2016 10:10 AM UTC

Hi Jeffrey Kesselman,
We will be happy to assist you always.
Regards
Kanimozhi B

Jeffrey Kesselman
Replied On March 8, 2016 05:25 PM UTC

Im having an issue with using this...

I have Cell F5 = "2" , cell F6 = "3"  and cell F7 = "=F5+f6"

When I change F6 = "5" I get a callback for that change in value, but I do not get a callback for F7 change its calculated value.

Is there some other event I can hook to know when calculated values change?  Or is there a way, when i know F6 has changed, to ask "what are all the cells dependent on this cell"?

Thanks

JK

Kanimozhi Bharathi [Syncfusion]
Replied On March 9, 2016 01:10 PM UTC

Hi Jeffrey Kesselman,

Currently we do not have any event to notify the dependent cell value changes. . However you can get the list of cells dependent on the cell when the value in particular cell changes by looping the PrecedentCells of Formula Engine in CellValueChanged Event like below code example

void ActiveSheet_CellValueChanged(object sender, Syncfusion.XlsIO.Implementation.CellValueChangedEventArgs e)

{

    var grid = Spreadsheet.ActiveGrid;

    var family = FormulaEngine.GetSheetFamilyItem(grid);

    var cellref = family.GetTokenForGridModel(grid) + GridRangeInfo.GetAlphaLabel(grid.CurrentCell.ColumnIndex) + grid.CurrentCell.RowIndex;

    //To get the dependent cell

    if (grid.FormulaEngine.PrecedentCells.ContainsKey(cellref) &&

            grid.FormulaEngine.PrecedentCells[cellref] != null)

    {

        Calculatedependentcell(cellref);

        var dependentcelllist = list;   //Dependentcelllist

    }

           

}

public void Calculatedependentcell(string precedentCell)

{

    var grid = Spreadsheet.ActiveGrid;



    if (grid.FormulaEngine.PrecedentCells[precedentCell] == null) return;


    var ht = (Hashtable)((Hashtable)grid.FormulaEngine.PrecedentCells[precedentCell]).Clone();

    foreach (var o in ht.Keys)

    {

        var s1 = o as string;


        var row = grid.FormulaEngine.RowIndex(s1);

        var col = grid.FormulaEngine.ColumnIndex(s1);

        var cell = GridRangeInfo.GetAlphaLabel(col) + row;

        if (s1 != null)

        {

            list.Add(s1);

            Calculatedependentcell(s1);//recursive call            

        }

    }

}



We have also prepared a sample based on your requirement, please find the link

Sample:  http://www.syncfusion.com/downloads/support/directtrac/general/ze/sfspreadsheet_(2)1406909263

Regards
Kanimozhi B

Jeffrey Kesselman
Replied On March 9, 2016 06:46 PM UTC

Wonderful, thank you again!

Kanimozhi Bharathi [Syncfusion]
Replied On March 10, 2016 09:35 AM UTC

Hi Jeffrey Kesselman,

We will be happy to assist you always.

Regards
Kanimozhi B

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.

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

;