Click here to Skip to main content
14,875,904 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am implementing an Excel Add-in, in which the requirement is we have to download the data from the Service Layer and display it in the Excel sheet.The user can make some modifications to the data that is displayed in the excel. To track those events I'm using column change event of the data-table as i am using ado.net.

The problem I'm facing is in any one of the cell, I'm giving a formula, say for Example. I have 3 cells A1,B1,C1.

A1 contains 2. B1 contains 3. in C1 I'm giving the formula as =A1+B1, the cell is showing 5 and I'm able to get the value while I'm debugging.

But when I'm updating the cells of A1 & B1 to 5 and 6 the cell C1 is also getting changed but I'm unable to track it.

What I have tried:

Here is the code which I am using

C#
web = new WebClient();
url = string.Format("{0}/DownloadData?parm1={1}&parm2={2}&parm3={3}", baseUrl, userName, _value);

string  response = web.DownloadString(url);

// converting the data to DataTable as the response is XML Format
using (StringReader stringReader = new StringReader(response))
{
    _dsDownloadData = new DataSet();
    _dsDownloadData.ReadXml(stringReader);

}
// I am using column changed event of DataTable to track the changes.
 _dsDownloadData.Tables[1].ColumnChanged += new DataColumnChangeEventHandler(ProductRevenueData_ColumnChanged);

public static void ProductRevenueData_ColumnChanged(object sender, DataColumnChangeEventArgs e)
{
    try
    {
        // Trying to track the changes here
        clsProductUpdateXMLManager.Insert(e.Row, e.Column);

    }
    catch (Exception ex)
    {
        MessageBox.Show("Error", "Error-Window", MessageBoxButtons.OK, MessageBoxIcon.Warning);
        return;
    }
}
Posted
Updated 5-Jun-17 21:35pm

You have to use Worksheet.Change Event (Microsoft.Office.Tools.Excel)[^] instead of ColumnChanged. Note that this event does not occur when cells change during a recalculation!

If you would like to catch cell calculation event use appriopriate Worksheet.Calculate event[^].

Good luck!
   
As I am binding the data table, and I want to get entire data row Information on cell value change. so How can I do it?
   
Comments
Richard Deeming 6-Jun-17 9:15am
   
If you want to reply to a solution, click the "Have a Question or Comment?" button under that solution.

Do not post your comment as a new "solution".

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900