使用Google Apps脚本获取Google文档中元素的范围 [英] Get the ranges of the elements in a google doc using Google Apps Script

查看:96
本文介绍了使用Google Apps脚本获取Google文档中元素的范围的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

继此{"startIndex": xx, "endIndex": xx},以便可以使用它们在批量更新中?

我有一种感觉,我想念这里很明显的东西.

解决方案

使用Google Docs API和文档ID,您可以创建

Following on from this question - I am now unsure how I might be able to target certain paragraphs or elements within the document when using Google Apps Scripts in order to use the batch update method outlined one would need to find the range of the element that required styling.

If there were 10 empty paragraphs (with content of "\n",) in a document - how would it be possible to target the 8th paragraph and get the range values {"startIndex": xx, "endIndex": xx} relative to the document so they could be used in the batch update?

I have a feeling I am missing something very obvious here.

解决方案

Using Google Docs API and the document ID you can make a documents.get request, which will return you a document resource with a body field which has a content field with all the elements in the document, where you can see the "startIndex" and "endIndex".

这篇关于使用Google Apps脚本获取Google文档中元素的范围的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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