How to Tell me AutoChange CellFormular Event

Posted by: heilong05 on 8 September 2017, 2:36 pm EST

  • Posted 8 September 2017, 2:36 pm EST

    I Write These Code: 


        private void Form1_Load(object sender, EventArgs e)
            {
                fpSpread1.AllowUserFormulas = true;


                fpSpread1.Sheets[0].Cells[2, 2].Value = 12213;
                fpSpread1.Sheets[1].Cells[2, 2].Formula = "Sheet1!C3";


                using (System.IO.StreamWriter sw = File.AppendText("C:\\1.txt"))
                {
                    sw.WriteLine(fpSpread1.Sheets[1].Cells[2, 2].Formula);
                }
            }


            private void button1_Click(object sender, EventArgs e)
            {
                //fpSpread1.Sheets[1].Cells[2, 2].Formula = "Sheet1!C2";          
                fpSpread1.Sheets[0].AddRows(2, 1);


                using (System.IO.StreamWriter sw = File.AppendText("C:\\1.txt"))
                {
                    sw.WriteLine(fpSpread1.Sheets[1].Cells[2, 2].Formula);
                }
            }


     


     


    When I form a cell formula automatically change the time. Can you give me an event interface. Let me know which cell the formula changed. Formula into a what?
  • Replied 8 September 2017, 2:36 pm EST

    heilong05,


    I am not sure what you are asking?


    When an add/remove rows/columns operation occurs, the cells (including their formulas) after the insertion/deletion location get moved.  The sheet's data model raises a Changed event indicating the type of operation and range of cells involved.  This is a single event for the entire range being moved.  Their is not an individual event for each formula being moved.  You can attach to this event using code like the following...


        fpSpread1.Sheets[0].Models.Data.Changed += new FarPoint.Win.Spread.Model.SheetDataModelEventHandler(Data_Changed);


    When a cell formula is being moved as part of the add/remove operation, the spreadsheet will automatically modify the formula (if needed) in an attempt to keep the formula referencing the same cell data.  There is no event fired when this automatically modification occurs.


    Note that in your button1_Clicked example, the AddRows operation would move the formula (assinged in Form1_LoaD) from cell C3 to cell C4 but would not modify the formula.  Both before and after the operation, the internal parsed representation of the formula uses relative coordinates (i.e. RowOffset = 0, columnOffset = -1) to reference the adjacent cell to the left.

  • Replied 8 September 2017, 2:36 pm EST

    I want to change a cell after the formula. How can I know which cells have changed the formula.


    What interfaces Spread
  • Replied 8 September 2017, 2:36 pm EST

    Hello,

    You can use the Spread's change event to get to know whether formula has changes in Spread or just the value. Here is the code to achieve the same. Please have a look at the same.

            void fpSpread1_Change(object sender, ChangeEventArgs e)
            {
                string _GetFormulaString = fpSpread1.ActiveSheet.GetFormula(e.Row, e.Column);
                if (_GetFormulaString != string.Empty)
                    listBox1.Items.Add(e.Row.ToString() + " &" + e.Column.ToString());
            }

    Hope this will help you. Thanks.

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels