Insert an element (table) at the cursor position

I would like to create a new table element with a custom style and add it to the current cursor position in the document. I saw that you can get the current position with:

var cursor = DocumentApp.getActiveDocument().getCursor(); 

which returns a Position object. The position class provides a method for adding text to the current position:

 cursor.insertText('ΰ² β€Ώΰ² '); 

but from the documentation, I see no way to insert a common element (a table in my case) instead of plain text.

On the other hand, there is a method of the Body class that allows you to add a table to the end of the document, but you cannot specify a custom position.

Can anybody help?

thanks

+2
source share
1 answer

Insert into it STUB, for example. cursor.insertText('%%MY_TABLE_WILL_GO_HERE%%'); , then continue the function to find this row and place the table.

0
source

Source: https://habr.com/ru/post/1236926/


All Articles