I would like to create a new Table element with custom style and append it to the current cursor position in the document. I saw that it is possible to get the current position with:
var cursor = DocumentApp.getActiveDocument().getCursor();
that returns a Position object. Position class provides a method to append Text to the current position:
cursor.insertText('ಠ‿ಠ');
but from the documentation I can't see a way to insert a generic Element (a Table in my case) instead of simple text.
On the other hand there is a method of the class Body that allows to append a Table to the end of the document, but it is not possible to specify a custom position.
Somebody can help?
Thanks
Insert a STUB on it, eg.
cursor.insertText('%%MY_TABLE_WILL_GO_HERE%%');
, then continue the function to find this line and place the table.Here's how I've pieced it together. I have a function
createComponentTable
that takes a booleanatCursor
, which if false appends a table at the end of the document, and if true inserts a table at the cursor position.(I also have a function
doAlert(text)
elsewhere that I can turn on/off for debugging.)