Class FooterSection

FooterSection

フッター セクションを表す要素。Document には通常、最大で 1 つの FooterSection が含まれます。FooterSection には、ListItemParagraph、および Table 要素。ドキュメント構造について詳しくは、Google ドキュメントの拡張ガイドをご覧ください。

メソッド

メソッド戻り値の型概要
appendHorizontalRule()HorizontalRule新しい HorizontalRule を作成して追加します。
appendImage(image)InlineImage指定された画像 blob から新しい InlineImage を作成して追加します。
appendImage(image)InlineImage指定された InlineImage を追加します。
appendListItem(listItem)ListItem指定された ListItem を追加します。
appendListItem(text)ListItem指定されたテキスト コンテンツを含む新しい ListItem を作成して追加します。
appendParagraph(paragraph)Paragraph指定された Paragraph を追加します。
appendParagraph(text)Paragraph指定されたテキスト コンテンツを含む新しい Paragraph を作成して追加します。
appendTable()Table新しい Table を作成して追加します。
appendTable(cells)Table指定された文字列値ごとに TableCell を含む新しい Table を追加します。
appendTable(table)Table指定された Table を追加します。
clear()FooterSection要素の内容をクリアします。
copy()FooterSection現在の要素の分離されたディープコピーを返します。
editAsText()Text編集用に、現在の要素の Text バージョンを取得します。
findElement(elementType)RangeElement要素のコンテンツで、指定された型の子孫を検索します。
findElement(elementType, from)RangeElement要素のコンテンツで、指定された型の子孫を (RangeElement が指定されている)。
findText(searchPattern)RangeElement正規表現を使用して、指定されたテキスト パターンの要素のコンテンツを検索します。
findText(searchPattern, from)RangeElement要素の内容の中から、指定したテキスト パターンから始まるものを検索します。 表示されます。
getAttributes()Object要素の属性を取得します。
getChild(childIndex)Element指定された子インデックスの子要素を取得します。
getChildIndex(child)Integer指定された子要素の子インデックスを取得します。
getImages()InlineImage[]セクションに含まれるすべての InlineImages を取得します。
getListItems()ListItem[]セクションに含まれるすべての ListItems を取得します。
getNumChildren()Integer子の数を取得します。
getParagraphs()Paragraph[]セクションに含まれるすべての ParagraphsListItems を含む)を取得します。
getParent()ContainerElement要素の親要素を取得します。
getTables()Table[]セクションに含まれるすべての Tables を取得します。
getText()String要素のコンテンツをテキスト文字列として取得します。
getTextAlignment()TextAlignmentテキストの配置を取得します。
getType()ElementType要素の ElementType を取得します。
insertHorizontalRule(childIndex)HorizontalRule新しい HorizontalRule を作成して指定されたインデックスに挿入します。
insertImage(childIndex, image)InlineImage指定した画像 blob から InlineImage を作成して、指定された位置に挿入します。 あります。
insertImage(childIndex, image)InlineImage指定された InlineImage を指定されたインデックスに挿入します。
insertListItem(childIndex, listItem)ListItem指定された ListItem を指定されたインデックスに挿入します。
insertListItem(childIndex, text)ListItem指定されたインデックスを含む新しい ListItem を作成して挿入します。 記述できます。
insertParagraph(childIndex, paragraph)Paragraph指定された Paragraph を指定されたインデックスに挿入します。
insertParagraph(childIndex, text)Paragraph指定されたインデックスを含む新しい Paragraph を作成して挿入します。 記述できます。
insertTable(childIndex)Table新しい Table を作成して指定されたインデックスに挿入します。
insertTable(childIndex, cells)Table指定されたセルを含む新しい Table を作成して、指定されたインデックスに挿入します。
insertTable(childIndex, table)Table指定された Table を指定されたインデックスに挿入します。
removeChild(child)FooterSection指定した子要素を削除します。
removeFromParent()FooterSection要素を親から削除します。
replaceText(searchPattern, replacement)Element通常の文字列を使用して、指定したテキスト パターンをすべて、指定した置換文字列に置き換えます。 表します。
setAttributes(attributes)FooterSection要素の属性を設定します。
setText(text)FooterSectionコンテンツを書式なしテキストとして設定します。
setTextAlignment(textAlignment)FooterSectionテキストの配置を設定します。

詳細なドキュメント

appendHorizontalRule()

新しい HorizontalRule を作成して追加します。

HorizontalRule は新しい Paragraph に含まれます。

戻る

HorizontalRule - 新しい横方向のルール。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

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

appendImage(image)

指定された画像 blob から新しい InlineImage を作成して追加します。

この画像は新しい Paragraph に含まれます。

パラメータ

名前説明
imageBlobSource画像データ。

戻る

InlineImage - 追加された画像。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

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

appendImage(image)

指定された InlineImage を追加します。

InlineImage は新しい Paragraph に含まれます。

既存の InlineImage のコピーを追加するときに、このバージョンの appendImage を使用します。

パラメータ

名前説明
imageInlineImage画像データ。

戻る

InlineImage - 追加された画像。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

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

appendListItem(listItem)

指定された ListItem を追加します。

既存の ListItem のコピーを追加するときに、このバージョンの appendListItem を使用します。

パラメータ

名前説明
listItemListItem追加するリストアイテム。

戻る

ListItem - 追加されたリストアイテム。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

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

appendListItem(text)

指定されたテキスト コンテンツを含む新しい ListItem を作成して追加します。

連続するリストアイテムは同じリストの一部として追加されます。

パラメータ

名前説明
textStringリストアイテムのテキスト コンテンツ。

戻る

ListItem - 新しいリストアイテム。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

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

appendParagraph(paragraph)

指定された Paragraph を追加します。

既存の Paragraph のコピーを追加するときに、このバージョンの appendParagraph を使用します。

パラメータ

名前説明
paragraphParagraph追加する段落。

戻る

Paragraph - 追加された段落。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

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

appendParagraph(text)

指定されたテキスト コンテンツを含む新しい Paragraph を作成して追加します。

パラメータ

名前説明
textString段落のテキスト コンテンツ。

戻る

Paragraph - 新しい段落。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

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

appendTable()

新しい Table を作成して追加します。

この方法でも、表の後に空の段落が追加されます。これは、Google ドキュメントでドキュメントが 末尾を表にすることはできません。

戻る

Table - 新しいテーブル。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

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

appendTable(cells)

指定された文字列値ごとに TableCell を含む新しい Table を追加します。

この方法でも、表の後に空の段落が追加されます。これは、Google ドキュメントでドキュメントが 末尾を表にすることはできません。

パラメータ

名前説明
cellsString[][]新しい表に追加する表のセルのテキスト コンテンツ。

戻る

Table - 追加されたテーブル。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

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

appendTable(table)

指定された Table を追加します。

既存の Table のコピーを追加するときに、このバージョンの appendTable を使用します。 この方法でも、表の後に空の段落が追加されます。これは、Google ドキュメントでドキュメントが 末尾を表にすることはできません。

パラメータ

名前説明
tableTable追加するテーブル。

戻る

Table - 追加されたテーブル。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

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

clear()

要素の内容をクリアします。

戻る

FooterSection - 現在の要素。


copy()

現在の要素の分離されたディープコピーを返します。

その要素に含まれている子要素もすべてコピーされます。新しい要素には できます。

戻る

FooterSection - 新しいコピー。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

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

editAsText()

編集用に、現在の要素の Text バージョンを取得します。

editAsText を使用して、要素のコンテンツをリッチテキストとして操作します。editAsText モードでは、テキスト以外の要素(InlineImageHorizontalRule など)は無視されます。

削除されたテキスト範囲に完全に含まれている子要素は要素から削除されます。

var body = DocumentApp.getActiveDocument().getActiveTab().asDocumentTab().getBody();

// Insert two paragraphs separated by a paragraph containing an
// horizontal rule.
body.insertParagraph(0, "An editAsText sample.");
body.insertHorizontalRule(0);
body.insertParagraph(0, "An example.");

// Delete " sample.\n\n An" removing the horizontal rule in the process.
body.editAsText().deleteText(14, 25);

戻る

Text - 現在の要素のテキスト バージョン


findElement(elementType)

要素のコンテンツで、指定された型の子孫を検索します。

パラメータ

名前説明
elementTypeElementType検索する要素のタイプ。

戻る

RangeElement - 検索要素の位置を示す検索結果。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

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

findElement(elementType, from)

要素のコンテンツで、指定された型の子孫を (RangeElement が指定されている)。

var body = DocumentApp.getActiveDocument().getActiveTab().asDocumentTab().getBody();

// Define the search parameters.
var searchType = DocumentApp.ElementType.PARAGRAPH;
var searchHeading = DocumentApp.ParagraphHeading.HEADING1;
var searchResult = null;

// Search until the paragraph is found.
while (searchResult = body.findElement(searchType, searchResult)) {
  var par = searchResult.getElement().asParagraph();
  if (par.getHeading() == searchHeading) {
    // Found one, update and stop.
    par.setText('This is the first header.');
    return;
  }
}

パラメータ

名前説明
elementTypeElementType検索する要素のタイプ。
fromRangeElement検索元の検索結果。

戻る

RangeElement - 検索要素の次の位置を示す検索結果。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

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

findText(searchPattern)

正規表現を使用して、指定されたテキスト パターンの要素のコンテンツを検索します。

以下の JavaScript 正規表現機能の一部は、完全にはサポートされていません。 キャプチャ グループとモード修飾子を使用します。

指定した正規表現のパターンが、テキスト ブロックごとに個別に照合される 返されます。

パラメータ

名前説明
searchPatternString検索するパターン

戻る

RangeElement - 検索テキストの位置を示す検索結果。テキストがない場合は null マッチ

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

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

findText(searchPattern, from)

要素の内容の中から、指定したテキスト パターンから始まるものを検索します。 表示されます。

以下の JavaScript 正規表現機能の一部は、完全にはサポートされていません。 キャプチャ グループとモード修飾子を使用します。

指定した正規表現のパターンが、テキスト ブロックごとに個別に照合される 返されます。

パラメータ

名前説明
searchPatternString検索するパターン
fromRangeElement検索元の検索結果

戻る

RangeElement - 検索テキストの次の位置を示す検索結果。それ以外の場合は null マッチ

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

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

getAttributes()

要素の属性を取得します。

その結果は、各有効な要素属性のプロパティを含むオブジェクトとなり、 プロパティ名は、DocumentApp.Attribute 列挙型の項目に対応しています。

var doc = DocumentApp.getActiveDocument();
var documentTab = doc.getActiveTab().asDocumentTab();
var body = documentTab.getBody();

// Append a styled paragraph.
var par = body.appendParagraph('A bold, italicized paragraph.');
par.setBold(true);
par.setItalic(true);

// Retrieve the paragraph's attributes.
var atts = par.getAttributes();

// Log the paragraph attributes.
for (var att in atts) {
  Logger.log(att + ":" + atts[att]);
}

戻る

Object - 要素の属性。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

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

getChild(childIndex)

指定された子インデックスの子要素を取得します。

var body = DocumentApp.getActiveDocument().getActiveTab().asDocumentTab().getBody();

// Obtain the first element in the tab.
var firstChild = body.getChild(0);

// If it's a paragraph, set its contents.
if (firstChild.getType() == DocumentApp.ElementType.PARAGRAPH) {
  firstChild.asParagraph().setText("This is the first paragraph.");
}

パラメータ

名前説明
childIndexInteger取得する子要素のインデックス。

戻る

Element - 指定されたインデックスの子要素。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

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

getChildIndex(child)

指定された子要素の子インデックスを取得します。

パラメータ

名前説明
childElementインデックスを取得する子要素。

戻る

Integer - 子インデックス。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

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

getImages()

セクションに含まれるすべての InlineImages を取得します。

戻る

InlineImage[] - セクション画像。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

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

getListItems()

セクションに含まれるすべての ListItems を取得します。

戻る

ListItem[] - セクション リストの項目。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

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

getNumChildren()

子の数を取得します。

var body = DocumentApp.getActiveDocument().getActiveTab().asDocumentTab().getBody();

// Log the number of elements in the tab.
Logger.log("There are " + body.getNumChildren() +
    " elements in the tab's body.");

戻る

Integer - 子の数。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

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

getParagraphs()

セクションに含まれるすべての ParagraphsListItems を含む)を取得します。

戻る

Paragraph[] — セクションの段落。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

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

getParent()

要素の親要素を取得します。

親要素には現在の要素が含まれます。

戻る

ContainerElement - 親要素。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

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

getTables()

セクションに含まれるすべての Tables を取得します。

戻る

Table[] - セクション テーブル。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

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

getText()

要素のコンテンツをテキスト文字列として取得します。

戻る

String - テキスト文字列としての要素の内容

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

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

getTextAlignment()

テキストの配置を取得します。使用できるアライメントのタイプは、DocumentApp.TextAlignment.NORMALDocumentApp.TextAlignment.SUBSCRIPTDocumentApp.TextAlignment.SUPERSCRIPT です。

戻る

TextAlignment - テキストの配置のタイプ。テキストに複数の種類のテキストが含まれている場合は null またはテキストの配置が設定されていない場合は、

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

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

getType()

要素の ElementType を取得します。

getType() を使用して、指定された要素の正確な型を特定します。

var doc = DocumentApp.getActiveDocument();
var documentTab = doc.getActiveTab().asDocumentTab();
var body = documentTab.getBody();

// Obtain the first element in the active tab's body.

var firstChild = body.getChild(0);

// Use getType() to determine the element's type.
if (firstChild.getType() == DocumentApp.ElementType.PARAGRAPH) {
  Logger.log('The first element is a paragraph.');
} else {
  Logger.log('The first element is not a paragraph.');
}

戻る

ElementType - 要素のタイプ。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

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

insertHorizontalRule(childIndex)

新しい HorizontalRule を作成して指定されたインデックスに挿入します。

HorizontalRule は新しい Paragraph に含まれます。

パラメータ

名前説明
childIndexInteger要素を挿入するインデックス。

戻る

HorizontalRule - 新しい横方向のルール。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

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

insertImage(childIndex, image)

指定した画像 blob から InlineImage を作成して、指定された位置に挿入します。 あります。

パラメータ

名前説明
childIndexInteger要素を挿入するインデックス。
imageBlobSource画像データ。

戻る

InlineImage - 挿入されるインライン画像。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

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

insertImage(childIndex, image)

指定された InlineImage を指定されたインデックスに挿入します。

この画像は新しい Paragraph に含まれます。

パラメータ

名前説明
childIndexInteger要素を挿入するインデックス。
imageInlineImage挿入する画像。

戻る

InlineImage - 挿入されるインライン画像。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

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

insertListItem(childIndex, listItem)

指定された ListItem を指定されたインデックスに挿入します。

パラメータ

名前説明
childIndexInteger挿入するインデックス。
listItemListItem挿入するリストアイテム。

戻る

ListItem - 挿入されたリストアイテム。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

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

insertListItem(childIndex, text)

指定されたインデックスを含む新しい ListItem を作成して挿入します。 記述できます。

パラメータ

名前説明
childIndexInteger挿入するインデックス。
textStringリストアイテムのテキスト コンテンツ。

戻る

ListItem - 新しいリストアイテム。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

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

insertParagraph(childIndex, paragraph)

指定された Paragraph を指定されたインデックスに挿入します。

パラメータ

名前説明
childIndexInteger挿入するインデックス。
paragraphParagraph挿入する段落。

戻る

Paragraph - 挿入される段落。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

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

insertParagraph(childIndex, text)

指定されたインデックスを含む新しい Paragraph を作成して挿入します。 記述できます。

パラメータ

名前説明
childIndexInteger挿入するインデックス。
textString段落のテキスト コンテンツ。

戻る

Paragraph - 新しい段落。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

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

insertTable(childIndex)

新しい Table を作成して指定されたインデックスに挿入します。

パラメータ

名前説明
childIndexInteger挿入するインデックス。

戻る

Table - 新しいテーブル。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

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

insertTable(childIndex, cells)

指定されたセルを含む新しい Table を作成して、指定されたインデックスに挿入します。

パラメータ

名前説明
childIndexInteger挿入するインデックス。
cellsString[][]新しい表に追加する表のセルのテキスト コンテンツ。

戻る

Table - 新しいテーブル。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

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

insertTable(childIndex, table)

指定された Table を指定されたインデックスに挿入します。

パラメータ

名前説明
childIndexInteger挿入するインデックス。
tableTable挿入するテーブル。

戻る

Table - 挿入されたテーブル。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

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

removeChild(child)

指定した子要素を削除します。

パラメータ

名前説明
childElement削除する子要素。

戻る

FooterSection - 現在の要素。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

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

removeFromParent()

要素を親から削除します。

var doc = DocumentApp.getActiveDocument();
var documentTab = doc.getActiveTab().asDocumentTab()
var body = documentTab.getBody();

// Remove all images in the active tab's body.
var imgs = body.getImages();
for (var i = 0; i < imgs.length; i++) {
  imgs[i].removeFromParent();
}

戻る

FooterSection - 削除された要素。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

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

replaceText(searchPattern, replacement)

通常の文字列を使用して、指定したテキスト パターンをすべて、指定した置換文字列に置き換えます。 表します。

検索パターンは、JavaScript 正規表現オブジェクトではなく、文字列として渡されます。 そのため、パターン内でバックスラッシュをエスケープする必要があります。

このメソッドは、Google の RE2 標準版を使用します。 式ライブラリを使用して、サポートされている構文を制限します。

指定した正規表現のパターンが、テキスト ブロックごとに個別に照合される 返されます。

var body = DocumentApp.getActiveDocument().getActiveTab().asDocumentTab().getBody();

// Clear the text surrounding "Apps Script", with or without text.
body.replaceText("^.*Apps ?Script.*$", "Apps Script");

パラメータ

名前説明
searchPatternString検索する正規表現パターン
replacementString置換として使用するテキスト

戻る

Element - 現在の要素

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

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

setAttributes(attributes)

要素の属性を設定します。

指定する属性パラメータは、各プロパティ名がアイテムのアイテムである DocumentApp.Attribute 列挙値。各プロパティ値は新しい値になります。 適用されました。

var doc = DocumentApp.getActiveDocument();
var documentTab = doc.getActiveTab().asDocumentTab();
var body = documentTab.getBody();

// Define a custom paragraph style.
var style = {};
style[DocumentApp.Attribute.HORIZONTAL_ALIGNMENT] =
    DocumentApp.HorizontalAlignment.RIGHT;
style[DocumentApp.Attribute.FONT_FAMILY] = 'Calibri';
style[DocumentApp.Attribute.FONT_SIZE] = 18;
style[DocumentApp.Attribute.BOLD] = true;

// Append a plain paragraph.
var par = body.appendParagraph('A paragraph with custom style.');

// Apply the custom style.
par.setAttributes(style);

パラメータ

名前説明
attributesObject要素の属性。

戻る

FooterSection - 現在の要素。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

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

setText(text)

コンテンツを書式なしテキストとして設定します。

注: 既存の内容は消去されます。

パラメータ

名前説明
textString新しいテキスト コンテンツ。

戻る

FooterSection - 現在の要素。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

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

setTextAlignment(textAlignment)

テキストの配置を設定します。使用できるアライメントのタイプは、DocumentApp.TextAlignment.NORMALDocumentApp.TextAlignment.SUBSCRIPTDocumentApp.TextAlignment.SUPERSCRIPT です。

// Make the entire first paragraph in the active tab be superscript.
var documentTab = DocumentApp.getActiveDocument().getActiveTab().asDocumentTab();
var text = documentTab.getBody().getParagraphs()[0].editAsText();
text.setTextAlignment(DocumentApp.TextAlignment.SUPERSCRIPT);

パラメータ

名前説明
textAlignmentTextAlignment適用するテキスト配置のタイプ

戻る

FooterSection - 現在の要素

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

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

サポート終了のメソッド