I am trying to iterate through tables in Excel using office js
Here is the code sample(same as one in the docs here https://github.com/OfficeDev/office-js-docs/blob/master/reference/excel/tablecollection.md):
Excel.run(function (ctx) {
var tables = ctx.workbook.tables;
tables.load('items');
return ctx.sync().then(function() {
console.log("tables Count: " + tables.count);
for (var i = 0; i < tables.items.length; i++)
{
console.log(tables.items[i].name);
}
});
}).catch(function(error) {
console.log("Error: " + error);
if (error instanceof OfficeExtension.Error) {
console.log("Debug info: " + JSON.stringify(error.debugInfo));
}
});
Get the number of tables.
Excel.run(function (ctx) {
var tables = ctx.workbook.tables;
tables.load('count');
return ctx.sync().then(function() {
console.log(tables.count);
});
}).catch(function(error) {
console.log("Error: " + error);
if (error instanceof OfficeExtension.Error) {
console.log("Debug info: " + JSON.stringify(error.debugInfo));
}
});
The code works correctly on windows Excel 2016 but on Mac Excel 2016 both code samples throw an error of type: "General Exception", and error location: "TableCollection.count"