Class TextFinder

TextFinder

在範圍、工作表或試算表中尋找或取代文字。也可以指定搜尋選項。

方法

方法傳回類型簡短說明
findAll()Range[]傳回符合搜尋條件的所有儲存格。
findNext()Range傳回符合搜尋條件的下一個儲存格。
findPrevious()Range傳回符合搜尋條件的前一個儲存格。
getCurrentMatch()Range傳回符合搜尋條件的目前儲存格。
ignoreDiacritics(ignoreDiacritics)TextFinder如果為 true,則設定搜尋時忽略變音符號;否則搜尋時會比對變音符號。
matchCase(matchCase)TextFinder如果 true,則設定搜尋功能,完全比對搜尋文字的大小寫;否則搜尋功能預設為不區分大小寫。
matchEntireCell(matchEntireCell)TextFinder如果 true 為 true,則設定搜尋條件為符合整個儲存格內容;否則搜尋條件預設為部分相符。
matchFormulaText(matchFormulaText)TextFinder如果為 true,則設定搜尋功能,傳回公式文字中顯示的相符項目; 否則系統會根據公式儲存格顯示的值進行搜尋。
replaceAllWith(replaceText)Integer以指定文字取代所有相符項目。
replaceWith(replaceText)Integer以指定文字取代目前相符儲存格中的搜尋文字,並傳回取代次數。
startFrom(startRange)TextFinder設定搜尋作業,在指定儲存格範圍後立即開始搜尋。
useRegularExpression(useRegEx)TextFinder如果 true,則設定搜尋功能將搜尋字串解讀為規則運算式;否則搜尋功能會將搜尋字串解讀為一般文字。

內容詳盡的說明文件

findAll()

傳回符合搜尋條件的所有儲存格。

回攻員

Range[]:所有相符的儲存格。

授權

使用這個方法的指令碼需要下列一或多個範圍的授權:

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

findNext()

傳回符合搜尋條件的下一個儲存格。

回攻員

Range:下一個相符的儲存格,如果沒有先前的相符項目,則為 null

授權

使用這個方法的指令碼需要下列一或多個範圍的授權:

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

findPrevious()

傳回符合搜尋條件的前一個儲存格。

回攻員

Range:前一個相符的儲存格,如果沒有前一個相符的儲存格,則為 null

授權

使用這個方法的指令碼需要下列一或多個範圍的授權:

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

getCurrentMatch()

傳回符合搜尋條件的目前儲存格。

回攻員

Range:目前的相符儲存格,或 null (如果沒有其他相符項目)。

授權

使用這個方法的指令碼需要下列一或多個範圍的授權:

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

ignoreDiacritics(ignoreDiacritics)

如果為 true,則設定搜尋時忽略變音符號;否則搜尋時會比對變音符號。變音符號是標示,例如重音符號或下加符號,寫在字母上方或下方時,表示發音與未標示或標示不同的相同字母不同。

參數

名稱類型說明
ignoreDiacriticsBoolean搜尋時是否要考慮變音符號。

回攻員

TextFinder:用於串連的文字尋找器。

授權

使用這個方法的指令碼需要下列一或多個範圍的授權:

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

matchCase(matchCase)

如果 true,則設定搜尋功能,完全比對搜尋文字的大小寫;否則搜尋功能預設為不區分大小寫。

參數

名稱類型說明
matchCaseBoolean比對時是否區分大小寫。

回攻員

TextFinder:用於串連的文字尋找器。

授權

使用這個方法的指令碼需要下列一或多個範圍的授權:

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

matchEntireCell(matchEntireCell)

如果 true 為 true,則設定搜尋條件為符合整個儲存格內容;否則搜尋條件預設為部分相符。

參數

名稱類型說明
matchEntireCellBoolean是否符合整個儲存格。

回攻員

TextFinder:用於串連的文字尋找器。

授權

使用這個方法的指令碼需要下列一或多個範圍的授權:

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

matchFormulaText(matchFormulaText)

如果為 true,則設定搜尋功能,傳回公式文字中顯示的相符項目; 否則系統會根據公式儲存格顯示的值進行搜尋。

參數

名稱類型說明
matchFormulaTextBoolean搜尋是否會檢查公式文字。

回攻員

TextFinder:用於串連的文字尋找器。

授權

使用這個方法的指令碼需要下列一或多個範圍的授權:

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

replaceAllWith(replaceText)

以指定文字取代所有相符項目。傳回已取代的出現次數,這可能與相符儲存格的數量不同。

參數

名稱類型說明
replaceTextString取代相符儲存格中文字的文字。

回攻員

Integer:取代的出現次數。

授權

使用這個方法的指令碼需要下列一或多個範圍的授權:

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

replaceWith(replaceText)

以指定文字取代目前相符儲存格中的搜尋文字,並傳回取代次數。

參數

名稱類型說明
replaceTextString取代目前相符儲存格內容的文字。

回攻員

Integer:取代的出現次數。

授權

使用這個方法的指令碼需要下列一或多個範圍的授權:

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

startFrom(startRange)

設定搜尋作業,在指定儲存格範圍後立即開始搜尋。

參數

名稱類型說明
startRangeRange搜尋應從哪個儲存格範圍開始。

回攻員

TextFinder:用於串連的文字尋找器。

授權

使用這個方法的指令碼需要下列一或多個範圍的授權:

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

useRegularExpression(useRegEx)

如果 true,則設定搜尋功能將搜尋字串解讀為規則運算式;否則搜尋功能會將搜尋字串解讀為一般文字。如要進一步瞭解如何使用規則運算式,請參閱「 尋找及取代」支援頁面。

參數

名稱類型說明
useRegExBoolean是否將搜尋字串解讀為規則運算式。

回攻員

TextFinder:用於串連的文字尋找器。

授權

使用這個方法的指令碼需要下列一或多個範圍的授權:

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets