using This I am adding new row in table how can I give value to its cells
await Word.run(async (context) => {
const selection = context.document.getSelection();
selection.load('parentTableCellOrNullObject');
await context.sync();
if (!selection.isNull && !selection.parentTableCellOrNullObject.isNull) {
const parentCell = selection.parentTableCellOrNullObject;
const parentRow = parentCell.parentRow;
parentRow.insertRows(Word.InsertLocation.after, 1);
await context.sync();
console.log('Table row added after the selected row.');
} else {
console.log('Selection is not inside a table cell.');
}
});
You add the values as an additional parameter on the
insertRowmethod. See insertRow. Alternatively, you can assign values to the row with the TableRow.values property.You have made several StackOverflow questions in the last few days which indicate that you are making basic mistakes with the Office JavaScript APIs. Please make more of an effort to read the reference documentation before you post questions on StackOverflow.