方法
方法 | 傳回類型 | 簡短說明 |
---|---|---|
getElement() | Element | 取得與這個 RangeElement 相對應的 Element 。 |
getEndOffsetInclusive() | Integer | 取得範圍元素中一部分範圍的結束位置。 |
getStartOffset() | Integer | 取得範圍元素中部分範圍的起始位置。 |
isPartial() | Boolean | 判斷這個範圍元素是涵蓋整個元素,還是所選元素的部分選取範圍。 |
內容詳盡的說明文件
getElement()
取得與這個 RangeElement
相對應的 Element
。
// Log debug information about a range element. Logger.log('Element type: ' + rangeElement.getElement().getType()); if (rangeElement.isPartial()) { Logger.log('The character range begins at ' + rangeElement.getStartOffset()); Logger.log('The character range ends at ' + rangeElement.getEndOffsetInclusive()); } else { Logger.log('The entire range element is included.'); }
Return 鍵
Element
:對應這個RangeElement
的元素
授權
如果指令碼使用這個方法,就必須符合下列一或多個範圍的授權:
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
getEndOffsetInclusive()
取得範圍元素中一部分範圍的結束位置。如果元素是 Text
元素,而 isPartial()
傳回 true
,則偏移量是範圍中最後一個字元之前的字元數 (也就是範圍內最後一個字元的索引);在任何其他情況下,此方法會傳回 -1
。
Return 鍵
Integer
— 針對 Text
元素,範圍中最後一個字元之前的字元數量;對於其他元素,-1
授權
如果指令碼使用這個方法,就必須符合下列一或多個範圍的授權:
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
getStartOffset()
取得範圍元素中部分範圍的起始位置。如果元素是 Text
元素,而 isPartial()
傳回 true
,則偏移量是範圍開始前的字元數 (也就是範圍內第一個字元的索引);在其他情況下,此方法會傳回 -1
。
Return 鍵
Integer
— 針對 Text
元素,範圍開始前的字元數量;對於其他元素,-1
授權
如果指令碼使用這個方法,就必須符合下列一或多個範圍的授權:
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
isPartial()
判斷這個範圍元素是涵蓋整個元素,還是所選元素的部分選取範圍。部分範圍元素的開頭和結尾可分別使用 getStartOffset()
和 getEndOffsetInclusive()
來判斷。
Return 鍵
Boolean
— 如果元素包含部分內容,則為 true
;如果不是元素,則為 false
授權
如果指令碼使用這個方法,就必須符合下列一或多個範圍的授權:
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents