I'm trying to insert a range of data from a Google Sheet into a Google Doc as a table. I'm successful, but it inserts the table at the very end of the Google Doc, and I can't figure out how to insert it in the middle of the doc at a specific place. I also can't figure out how to have it ignore empty rows in the range so that it doesn't insert a table into the doc with empty rows. Any help is appreciated!
Here's a snippet of my code:
var deviceName = sheet.getRange("C2").getValue();
var parts = sheet.getRange("B14:C28").getValues();
body.replaceText("%DEVICENAME%", deviceName);
var table = body.appendTable(parts);
table.setColumnWidth(0, 200);
table.setColumnWidth(1, 200);