I'm working on some code, mostly just playing around, with the Office-js API (v1.1), trying to do some things. I can take code examples and run them just fine, but I don't know Javascript well enough to know what I'm doing.
I took an example of enumerating tables and am trying to add some things to it, but it's not working and I don't know why. Can anyone help me out here?
The code:
Excel.run(function (ctx) {
var tables = ctx.workbook.tables;
var tableNames = ctx.workbook.tables.load("name");
return ctx.sync().then(function() {
console.log("Tables in workbook:");
if (tables.count = 0) {
console.log("No tables found");
} else {
for (var i = 0; i < tableNames.items.length; i++)
{
console.log(i + ": " + tableNames.items[i].name);
}
}
console.log("------------------------");
});
}).catch(function (error) {
console.log(error);
});
In the console log I get this message:
Tables in workbook:
TypeError: Assignment to read-only properties is not allowed in strict mode
I'm basing this off code found here: http://officesnippetexplorer.azurewebsites.net/#/snippets/excel (select 'Table', and snippet 'Get tables in workbook'). Any help would be greatly appreciated!
Thanks, Zack Barresse