My question may be a little hard to explain, but hopefully someone knows how to help! The co-op that I live in uses
And the Doc before the table has been inserted
In the Google Doc script editor I have this script.
function addTable() {
try {
let doc = DocumentApp.getActiveDocument();
let spread = SpreadsheetApp.openById("1xxxxxxxxxxxxxxxxxxxxxxxxxxA");
let sheet = spread.getSheetByName("Sheet1");
let values = sheet.getDataRange().getDisplayValues();
let body = doc.getBody();
let paras = body.getParagraphs();
let index = paras.findIndex( para => para.findText("{{table1}}"));
index = body.getChildIndex(paras[index]);
body.insertTable(index,values);
paras[index].removeFromParent();
}
catch(err) {
console.log(err);
}
}
The Doc after running the script
Reference