方法
方法 | 傳回類型 | 簡短說明 |
---|---|---|
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.'); }
回攻員
Element
:與此 RangeElement
對應的元素
授權
使用這個方法的指令碼必須取得以下一或多個範圍的授權:
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
getEndOffsetInclusive()
取得範圍元素中部分範圍的結尾位置。如果元素是 Text
元素且 isPartial()
傳回 true
,則偏移值是指範圍內最後一個字元之前的字元數 (也就是範圍內最後一個字元的索引);在其他情況下,這個方法會傳回 -1
。
回攻員
Integer
— 如果是 Text
元素,則為範圍中最後一個字元前的字元數量;如果是其他元素,則為 -1
授權
使用這個方法的指令碼必須取得以下一或多個範圍的授權:
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
getStartOffset()
取得範圍元素中部分範圍的起始位置。如果元素是 Text
元素且 isPartial()
傳回 true
,則偏移值是指範圍開頭之前的字元數 (也就是範圍內第一個字元的索引);在其他情況下,這個方法會傳回 -1
。
回攻員
Integer
:如果是 Text
元素,則為範圍開頭前的字元數;如果是其他元素,則為 -1
授權
使用這個方法的指令碼必須取得以下一或多個範圍的授權:
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
isPartial()
決定這個範圍元素要涵蓋整個元素還是局部選取的元素字元。部分範圍元素範圍的開始和結尾可分別使用 getStartOffset()
和 getEndOffsetInclusive()
來決定。
回攻員
Boolean
- 如果部分包含元素,則為 true
;如果不是,則為 false
授權
使用這個方法的指令碼必須取得以下一或多個範圍的授權:
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents