I'm developing a Word Add-in (Word API + Office.js) where i am working with content controls, I am trying to read the table content inside a content control where I need remove the empty rows Sample: I have this table inside a content control I have to remove the blank rows
I tried the below code to read the table content but getting undefined error at reading table
function checktable() {
Word.run(function (context) {
// Queue a command to get the current selection and then
// create a proxy range object with the results.
var contentControls = context.document.contentControls.getByTag('control').getFirst();
context.load(contentControls,'tables');
return context.sync()
.then(function () {
var table;
// Get the longest word from the selection.
if (contentControls.tables.items.length === 0) {
document.getElementById('lblstatus').innerText += "No Tables found";
}
else {
document.getElementById('lblstatus').innerText += " Tables found";
table = contentControls.tables.getFirstOrNullObject();
}
context.load(table, 'values');
})
.then(context.sync)
.then(function () {
var Tablevaules = table.values;
// Queue a command to highlight the search results.
document.getElementById('lblstatus').innerText += element + ":" + "Successs";
});
})
.catch(errorHandler);
}
Please let me know whether any other way to achieve this functionality or is it possible using office js