4

I'm developing a software on Excel as an App for Office, using office.js.

For some part, I'm hooking to a table in the excel to check if its data is changed using following code:

myBinding.addHandlerAsync(Office.EventType.BindingDataChanged, onBindingDataChanged);


function onBindingDataChanged(eventArgs) {
    // eventArgs has just the binding info.
    // I want to have selected cell row and column, and old and new data.
}

Unfortunately the information in eventArgs is not enough for me to detect changes. Worth to mention that for Office.EventType.BindingSelectionChanged, there's lots of usable information such as startRow, startColumn, ....

So my question is: How can I access these information:

  • Changed Row
  • Changed Column
  • Old Data
  • New Data
bryanbraun
  • 3,025
  • 2
  • 26
  • 38
mehrandvd
  • 8,806
  • 12
  • 64
  • 111

1 Answers1

1

I created a excel app too. You could get the current data and compare them with the old data. Then save the new data as the old data.

var oldData = null;

function onBindingDataChanged(eventArgs) {
    var id = eventArgs.binding.id;
    Office.select('bindings#'+id).getDataAsync(handleNewData);
}

function handleNewData(asyncResult) {
    var newData = asyncResult.value;

    if (oldData != null) {
        // detect changes here
    }

    oldData = newData;
);
marcel
  • 2,967
  • 1
  • 16
  • 25
  • I'm binding to a whole table, so keeping the whole table in `oldData` would be so expensive. I want to have just the changed data, not the whole table and detecting changes via comparing the whole table. – mehrandvd Jun 17 '15 at 07:08
  • of what table size we are talking about? maybe you can hold it in the localstorage? When you want to access the old data, you have to save it somewhere... – marcel Jun 17 '15 at 09:03