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

    <P>I Write These Code: </P>
    <P>    private void Form1_Load(object sender, EventArgs e)<BR>        {<BR>            fpSpread1.AllowUserFormulas = true;</P>
    <P>            fpSpread1.Sheets[0].Cells[2, 2].Value = 12213;<BR>            fpSpread1.Sheets[1].Cells[2, 2].Formula = "Sheet1!C3";</P>
    <P>            using (System.IO.StreamWriter sw = File.AppendText("C:\\1.txt"))<BR>            {<BR>                sw.WriteLine(fpSpread1.Sheets[1].Cells[2, 2].Formula);<BR>            }<BR>        }</P>
    <P>        private void button1_Click(object sender, EventArgs e)<BR>        {<BR>            //fpSpread1.Sheets[1].Cells[2, 2].Formula = "Sheet1!C2";           <BR>            fpSpread1.Sheets[0].AddRows(2, 1);</P>
    <P>            using (System.IO.StreamWriter sw = File.AppendText("C:\\1.txt"))<BR>            {<BR>                sw.WriteLine(fpSpread1.Sheets[1].Cells[2, 2].Formula);<BR>            }<BR>        }</P>
    <P> </P>
    <P> </P>
    <DIV>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?</DIV>
  • Replied 8 September 2017, 2:36 pm EST

    <P>I am not sure what you are asking?</P>
    <P>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...</P>
    <P>    fpSpread1.Sheets[0].Models.Data.Changed += new FarPoint.Win.Spread.Model.SheetDataModelEventHandler(Data_Changed);</P>
    <P>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.</P>
    <P>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.</P>
  • Replied 8 September 2017, 2:36 pm EST

    <DIV>I want to change a cell after the formula. How can I know which cells have changed the formula.</DIV>
    <DIV>What interfaces Spread</DIV></DIV>
  • Replied 8 September 2017, 2:36 pm EST

    <p>Hello,</p><p>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.<br></p><blockquote><p>        void fpSpread1_Change(object sender, ChangeEventArgs e)<br>        {<br>            string _GetFormulaString = fpSpread1.ActiveSheet.GetFormula(e.Row, e.Column);<br>            if (_GetFormulaString != string.Empty)<br>                listBox1.Items.Add(e.Row.ToString() + " &" + e.Column.ToString());<br>        } </p></blockquote><p>Hope this will help you. Thanks. <br></p>
Need extra support?

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

Learn More

Forum Channels