We're using Excel JS API to get changed on worksheets.
Is there an event to get new named cells?
The only way that I see is to store the named cell collection (using NamedItemCollection) & compare it whenever we detect a change to worksheet.
For the moment I've implemented a function that gets all named cell with address and store them.
var namedItemsColl : NamedCell[] = [];
const namedItems : Excel.NamedItemCollection = ctx.workbook.names.load('items');
await ctx.sync();
for (let i = 0; i < namedItems.items.length; i++) {
var it= namedItems.items[i].getRange().load('address');
await ctx.sync();
var namedCell : NamedCell = new NamedCell;
namedCell.name = namedItems.items[i].name;
namedCell.range = it.address;
namedItemsColl.push(namedCell);
}
Each time I get a change, I get the named cells collection again and compare it to the store one.
But that takes around 5s each time only to get the entire collection (with 1000 named cells).
Thanks