リストアイテムを表す要素。ListItem
は、リスト ID に関連付けられた Paragraph
です。ListItem
には、Equation
要素、Footnote
要素、HorizontalRule
要素、InlineDrawing
要素、InlineImage
要素、PageBreak
要素、Text
要素を含めることができます。ドキュメント構造について詳しくは、Google ドキュメント拡張ガイドをご覧ください。
ListItems
に改行文字を含めることはできません。改行文字(「\n」)は、改行文字(「\r」)に変換されます。
同じリスト ID を持つ ListItems
は同じリストに属し、それに応じて番号が付けられます。特定のリストの ListItems
は、ドキュメント内で隣接する必要はありません。また、同じ親要素を持つ必要もありません。次の例のように、同じリストに属する 2 つのアイテムは、連続した番号付けを維持しながら、ドキュメント内の任意の場所に存在します。
var body = DocumentApp.getActiveDocument().getBody(); // Append a new list item to the body. var item1 = body.appendListItem('Item 1'); // Log the new list item's list ID. Logger.log(item1.getListId()); // Append a table after the list item. body.appendTable([ ['Cell 1', 'Cell 2'] ]); // Append a second list item with the same list ID. The two items are treated as the same list, // despite not being consecutive. var item2 = body.appendListItem('Item 2'); item2.setListId(item1);
Methods
詳細なドキュメント
addPositionedImage(image)
指定された画像 blob から新しい PositionedImage
を作成して挿入します。
パラメータ
名前 | 型 | 説明 |
---|---|---|
image | BlobSource | エンコーダから |
リターン
PositionedImage
- 配置された新しい画像
承認
この方法を使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
appendHorizontalRule()
新しい HorizontalRule
を作成して追加します。
リターン
HorizontalRule
- 新しい水平ルール
承認
この方法を使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
appendInlineImage(image)
指定されたイメージ blob から新しい InlineImage
を作成して追加します。
パラメータ
名前 | 型 | 説明 |
---|---|---|
image | BlobSource | エンコーダから |
リターン
InlineImage
- 追加画像
承認
この方法を使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
appendInlineImage(image)
指定した InlineImage
を追加します。
パラメータ
名前 | 型 | 説明 |
---|---|---|
image | InlineImage | エンコーダから |
リターン
InlineImage
- 追加画像
承認
この方法を使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
appendPageBreak()
新しい PageBreak
を作成して追加します。
注: PageBreaks
を TableCells
内に含めることはできません。
現在の要素が表のセルに含まれている場合、例外がスローされます。
リターン
PageBreak
- 新しい改ページ要素
承認
この方法を使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
appendPageBreak(pageBreak)
指定した PageBreak
を追加します。
注: PageBreaks
を TableCells
内に含めることはできません。
現在の要素が表のセルに含まれている場合、例外がスローされます。
パラメータ
名前 | 型 | 説明 |
---|---|---|
pageBreak | PageBreak | 追加する |
リターン
PageBreak
- 追加する改ページ要素
承認
この方法を使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
appendText(text)
appendText(text)
clear()
copy()
editAsText()
現在の要素の Text
バージョンを取得し、編集します。
要素のコンテンツをリッチテキストとして操作するには、editAsText
を使用します。editAsText
モードでは、テキスト以外の要素(InlineImage
や HorizontalRule
など)は無視されます。
削除したテキスト範囲内に完全に含まれる子要素は、要素から削除されます。
var body = DocumentApp.getActiveDocument().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)
要素の内容を対象に、指定されたタイプの子孫を検索します。
パラメータ
名前 | 型 | 説明 |
---|---|---|
elementType | ElementType | 検索する要素のタイプ |
リターン
RangeElement
- 検索要素の位置を示す検索結果
承認
この方法を使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
findElement(elementType, from)
指定された RangeElement
から、指定された型の子孫の要素の内容を検索します。
// Get the body section of the active document. var body = DocumentApp.getActiveDocument().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; } }
パラメータ
名前 | 型 | 説明 |
---|---|---|
elementType | ElementType | 検索する要素のタイプ |
from | RangeElement | クリックします。 |
リターン
RangeElement
- 検索要素の次の位置を示す検索結果
承認
この方法を使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
findText(searchPattern)
正規表現を使用して、指定されたテキスト パターンについて要素の内容を検索します。
JavaScript の正規表現機能のサブセット(キャプチャ グループやモード修飾子など)は完全にはサポートされていません。
指定された正規表現パターンは、現在の要素に含まれている各テキスト ブロックと個別に照合されます。
パラメータ
名前 | 型 | 説明 |
---|---|---|
searchPattern | String | 検索するパターンを指定します |
リターン
RangeElement
- 検索テキストの位置を示す検索結果。一致するものがない場合は null
承認
この方法を使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
findText(searchPattern, from)
指定された検索結果から、指定されたテキスト パターンの要素コンテンツを検索します。
JavaScript の正規表現機能のサブセット(キャプチャ グループやモード修飾子など)は完全にはサポートされていません。
指定された正規表現パターンは、現在の要素に含まれている各テキスト ブロックと個別に照合されます。
パラメータ
名前 | 型 | 説明 |
---|---|---|
searchPattern | String | 検索するパターンを指定します |
from | RangeElement | クリックします。 |
リターン
RangeElement
- 検索テキストの次の位置を示す検索結果。一致するものがない場合は null
承認
この方法を使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
getAlignment()
HorizontalAlignment
を取得します。
リターン
HorizontalAlignment
- アライメント
承認
この方法を使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
getAttributes()
要素の属性を取得します。
その結果、各有効な要素属性のプロパティを含むオブジェクトが返されます。各プロパティ名は、DocumentApp.Attribute
列挙型のアイテムに対応しています。
var body = DocumentApp.getActiveDocument().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)
指定された子インデックスの子要素を取得します。
// Get the body section of the active document. var body = DocumentApp.getActiveDocument().getBody(); // Obtain the first element in the document. 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."); }
パラメータ
名前 | 型 | 説明 |
---|---|---|
childIndex | Integer | 取得する子要素のインデックス |
リターン
Element
- 指定されたインデックスの子要素
承認
この方法を使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
getChildIndex(child)
getGlyphType()
getHeading()
ParagraphHeading
を取得します。
リターン
ParagraphHeading
- 見出し
承認
この方法を使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
getIndentEnd()
終了インデントをポイント単位で取得します。
リターン
Number
- 終了インデント(ポイント単位)
承認
この方法を使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
getIndentFirstLine()
1 行目のインデントをポイント単位で取得します。
リターン
Number
- 最初の行のインデント(ポイント単位)
承認
この方法を使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
getIndentStart()
開始インデントを取得します。
リターン
Number
- 開始インデント
承認
この方法を使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
getLineSpacing()
行間隔をポイント単位で取得します。
リターン
Number
- 行間隔(ポイント単位)
承認
この方法を使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
getLinkUrl()
リンクの URL を取得します。
リターン
String
- リンクの URL。要素内にこの属性に複数の値が含まれている場合は null。
承認
この方法を使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
getListId()
リスト ID を取得します。
リターン
String
- リスト ID
承認
この方法を使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
getNestingLevel()
リストアイテムのネスト レベルを取得します。
デフォルトでは、リストアイテムのネスト レベルは 0 です。ネスト レベルにより、リストアイテムで使用されるグリフが決まります。
リターン
Integer
- ネスト レベル
承認
この方法を使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
getNextSibling()
getNumChildren()
子の数を取得します。
// Get the body section of the active document. var body = DocumentApp.getActiveDocument().getBody(); // Log the number of elements in the document. Logger.log("There are " + body.getNumChildren() + " elements in the document body.");
リターン
Integer
- 子の数
承認
この方法を使用するスクリプトには、次の 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
getPositionedImage(id)
イメージの ID で PositionedImage
を取得します。
パラメータ
名前 | 型 | 説明 |
---|---|---|
id | String | 画像 ID |
リターン
PositionedImage
- 配置された画像
承認
この方法を使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
getPositionedImages()
段落に固定されているすべての PositionedImage
オブジェクトを取得します。
リターン
PositionedImage[]
- 配置されたイメージのリスト
承認
この方法を使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
getPreviousSibling()
getSpacingAfter()
要素の後のスペースをポイント単位で取得します。
リターン
Number
- 要素の後のスペース(ポイント単位)
承認
この方法を使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
getSpacingBefore()
要素の前のスペースをポイント単位で取得します。
リターン
Number
- 要素の前のスペース(ポイント単位)
承認
この方法を使用するスクリプトには、次の 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.NORMAL
、DocumentApp.TextAlignment.SUBSCRIPT
、DocumentApp.TextAlignment.SUPERSCRIPT
です。
リターン
TextAlignment
- テキストの配置のタイプ。テキストに複数の種類のテキストの配置が含まれる場合、またはテキストの配置が設定されていない場合は null
承認
この方法を使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
getType()
要素の ElementType
を取得します。
特定の要素の正確なタイプを特定するには、getType()
を使用します。
var body = DocumentApp.getActiveDocument().getBody(); // Obtain the first element in the document 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
を作成して挿入します。
パラメータ
名前 | 型 | 説明 |
---|---|---|
childIndex | Integer | 要素を挿入するインデックス |
リターン
HorizontalRule
- 新しい水平ルールの要素
承認
この方法を使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
insertInlineImage(childIndex, image)
指定されたインデックスで、指定された画像 blob から新しい InlineImage
を作成して挿入します。
パラメータ
名前 | 型 | 説明 |
---|---|---|
childIndex | Integer | 要素を挿入するインデックス |
image | BlobSource | エンコーダから |
リターン
InlineImage
- 挿入されるインライン画像要素
承認
この方法を使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
insertInlineImage(childIndex, image)
指定された InlineImage
を指定されたインデックスに挿入します。
パラメータ
名前 | 型 | 説明 |
---|---|---|
childIndex | Integer | 要素を挿入するインデックス |
image | InlineImage | エンコーダから |
リターン
InlineImage
- 挿入されるインライン画像要素
承認
この方法を使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
insertPageBreak(childIndex)
指定されたインデックスに新しい PageBreak
を作成して挿入します。
注: PageBreaks
を TableCells
内に含めることはできません。
現在の要素が表のセルに含まれている場合、例外がスローされます。
パラメータ
名前 | 型 | 説明 |
---|---|---|
childIndex | Integer | 要素を挿入するインデックス |
リターン
PageBreak
- 新しい改ページ要素
承認
この方法を使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
insertPageBreak(childIndex, pageBreak)
指定された PageBreak
を指定されたインデックスに挿入します。
注: PageBreaks
を TableCells
内に含めることはできません。
現在の要素が表のセルに含まれている場合、例外がスローされます。
パラメータ
名前 | 型 | 説明 |
---|---|---|
childIndex | Integer | 要素を挿入するインデックス |
pageBreak | PageBreak | ページを挿入 |
リターン
PageBreak
- 挿入された改ページ要素
承認
この方法を使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
insertText(childIndex, text)
insertText(childIndex, text)
isAtDocumentEnd()
isLeftToRight()
左から右の設定を取得します。
リターン
Boolean
- 左から右の設定
承認
この方法を使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
merge()
要素を、上の同じタイプの兄弟要素と結合します。
結合できるのは、同じ ElementType
の要素のみです。現在の要素に含まれるすべての子要素は、前の兄弟要素に移動します。
現在の要素がドキュメントから削除されます。
var body = DocumentApp.getActiveDocument().getBody(); // Example 1: Merge paragraphs // Append two paragraphs to the document. var par1 = body.appendParagraph('Paragraph 1.'); var par2 = body.appendParagraph('Paragraph 2.'); // Merge the newly added paragraphs into a single paragraph. par2.merge(); // Example 2: Merge table cells // Create a two-dimensional array containing the table's cell contents. var cells = [ ['Row 1, Cell 1', 'Row 1, Cell 2'], ['Row 2, Cell 1', 'Row 2, Cell 2'] ]; // Build a table from the array. var table = body.appendTable(cells); // Get the first row in the table. var row = table.getRow(0); // Get the two cells in this row. var cell1 = row.getCell(0); var cell2 = row.getCell(1); // Merge the current cell into its preceding sibling element. var merged = cell2.merge();
リターン
ListItem
- 結合された要素。
承認
この方法を使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
removeChild(child)
removeFromParent()
要素を親から削除します。
var body = DocumentApp.getActiveDocument().getBody(); // Remove all images in the document body. var imgs = body.getImages(); for (var i = 0; i < imgs.length; i++) { imgs[i].removeFromParent(); }
リターン
ListItem
- 削除された要素。
承認
この方法を使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
removePositionedImage(id)
画像の ID で PositionedImage
を削除します。
パラメータ
名前 | 型 | 説明 |
---|---|---|
id | String |
リターン
Boolean
- 指定した画像が削除されたかどうか
承認
この方法を使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
replaceText(searchPattern, replacement)
正規表現を使用して、指定したテキスト パターンをすべて指定した置換文字列に置き換えます。
検索パターンは、JavaScript 正規表現オブジェクトではなく、文字列として渡されます。そのため、パターン内のバックスラッシュをエスケープする必要があります。
このメソッドは Google の RE2 正規表現ライブラリを使用します。このライブラリにより、サポートされている構文が制限されます。
指定された正規表現パターンは、現在の要素に含まれている各テキスト ブロックと個別に照合されます。
var body = DocumentApp.getActiveDocument().getBody(); // Clear the text surrounding "Apps Script", with or without text. body.replaceText("^.*Apps ?Script.*$", "Apps Script");
パラメータ
名前 | 型 | 説明 |
---|---|---|
searchPattern | String | 検索する正規表現パターンを |
replacement | String | 置換として使用するテキストです。 |
リターン
Element
- 現在の要素
承認
この方法を使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
setAlignment(alignment)
HorizontalAlignment
を設定します。
パラメータ
名前 | 型 | 説明 |
---|---|---|
alignment | HorizontalAlignment | 水平方向の配置 |
リターン
ListItem
- 現在の要素
承認
この方法を使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
setAttributes(attributes)
要素の属性を設定します。
指定する 属性パラメータは、各プロパティ名が DocumentApp.Attribute
列挙型のアイテム、各プロパティ値が、適用される新しい値であるオブジェクトである必要があります。
var body = DocumentApp.getActiveDocument().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);
パラメータ
名前 | 型 | 説明 |
---|---|---|
attributes | Object | 要素の属性。 |
リターン
ListItem
- 現在の要素。
承認
この方法を使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
setGlyphType(glyphType)
setHeading(heading)
ParagraphHeading
を設定します。
パラメータ
名前 | 型 | 説明 |
---|---|---|
heading | ParagraphHeading | 見出し |
リターン
ListItem
- 現在の要素
承認
この方法を使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
setIndentEnd(indentEnd)
setIndentFirstLine(indentFirstLine)
setIndentStart(indentStart)
setLeftToRight(leftToRight)
setLineSpacing(multiplier)
setLinkUrl(url)
setListId(listItem)
リスト ID を設定します。
リスト ID は、指定された ListItem
と同じ値に設定されます。2 つの ListItems
は同じリストのメンバーとして扱われます。
パラメータ
名前 | 型 | 説明 |
---|---|---|
listItem | ListItem | 使用するリスト ID を持つリスト アイテム |
リターン
ListItem
- 現在の要素
承認
この方法を使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
setNestingLevel(nestingLevel)
setSpacingAfter(spacingAfter)
setSpacingBefore(spacingBefore)
setText(text)
リストアイテムのコンテンツをテキストとして設定します。
注: 既存の内容は消去されます。
パラメータ
名前 | 型 | 説明 |
---|---|---|
text | String | 新しいテキスト コンテンツが |
承認
この方法を使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
setTextAlignment(textAlignment)
テキストの配置を設定します。使用可能なアライメントのタイプは、DocumentApp.TextAlignment.NORMAL
、DocumentApp.TextAlignment.SUBSCRIPT
、DocumentApp.TextAlignment.SUPERSCRIPT
です。
// Make the entire first paragraph be superscript. var text = DocumentApp.getActiveDocument().getBody().getParagraphs()[0].editAsText(); text.setTextAlignment(DocumentApp.TextAlignment.SUPERSCRIPT);
パラメータ
名前 | 型 | 説明 |
---|---|---|
textAlignment | TextAlignment | 適用するテキストの配置の種類 |
リターン
ListItem
- 現在の要素
承認
この方法を使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents