xt.document.bindings.addFromSelectionAsync(
                        Office.BindingType.Table, { id: app.bindingID },
                        function (asyncResult) {
                            if (asyncResult.status === Office.AsyncResultStatus.Failed) {
                                app.showNotification('Error binding data');
                            } else {
                                window.location.href = '../Home/Home.html';
                            }
                        }
                    );
                }
            }
        );
    }

    function bindToExistingData() {
        Office.context.document.bindings.addFromSelectionAsync(
            Office.BindingType.Matrix,
            { id: app.bindingID },
            function (result) {
                var isValid = (result.status == Office.AsyncResultStatus.Succeeded) &&
                    visualization.isValidRowAndColumnCount(
                        result.value.rowCount, result.value.columnCount);
                if (isValid) {
                    window.location.href = '../Home/Home.html';
                } else {
                    app.showNotification('Invalid data selected',
                        'Please make a different selection, and ensure that you selected ' +
                        'a table or range with ' + visualization.rowAndColumnRequirementText);
                }
            }
        );
    }
})();