I am working on a Excel Web Add-In
using Office.js
. I need to get selected cell's Address
and Value
. Please be clear that here user will select only one cell.
This should happen when user click on cell in worksheet.
I solved my problem by following code
Office.context.document.addHandlerAsync(Office.EventType.DocumentSelectionChanged,
function (eventArgs) {
Excel.run(function (ctx) {
var range = ctx.workbook.getSelectedRange();
range.load(['address', 'values']);
return ctx.sync().then(function () {
showNotification("", range.values[0][0] + " Address:" + range.address);
});
});
});