将一个元素(表格)插入光标位置 [英] Insert an element (table) to the cursor position

查看:136
本文介绍了将一个元素(表格)插入光标位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想用自定义样式创建一个新的表格元素并将其附加到文档中当前的光标位置。我看到可以通过以下方式获取当前位置:

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

返回一个Position对象。 Position类提供了一种将Text附加到当前位置的方法:

  cursor.insertText('ಠ‿ಠ'); 

但来自 documentation 我看不到一种插入通用元素(在我的情况下是表格)而不是简单文本的方法。



另一方面,类Body的方法允许将一个Table附加到文档的末尾,但不可能指定自定义位置。



有人可以提供帮助吗?

谢谢

解决方案

在它上面插入一个STUB,例如。 cursor.insertText('%% MY_TABLE_WILL_GO_HERE %%'); ,然后继续找到这一行并放置表格。


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.

这篇关于将一个元素(表格)插入光标位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆