
本記事では、Google Apps ScriptでGoogleドキュメントに対して使うことができるDocumentAppという処理の一覧表を用意しました。Googleの公式ドキュメントは英語なので、分かりづらいところもありますので、みなさんがそこで挫折しないように日本語で内容が把握できるようになっています。
DocumentAppの概要
DocumentAppとは、Google Apps ScriptでGoogleドキュメントに対する操作を行うコードですが、DocumentAppに用意されているメソッドでは、次のような操作を行うことができます。
- ドキュメントファイルの作成
- アクセス権限の編集
- ドキュメントファイルの修正
クラス名一覧
※クリックすると対象場所にジャンプします
インターフェイス
Element |
列挙型一覧
Attribute | ElementType | FontFamily(非推奨) |
GlyphType | HorizontalAlignment | ParagraphHeading |
PositionedLayout | TextAlignment | VerticalAlignment |
※クリックすると対象場所にジャンプします
クラス別メソッド名一覧
Class Body
Bodyクラスはドキュメントボディを制御するクラスで、ドキュメントボディはListItem、Paragraph、Table、TableOfContentsによって構成されています。ドキュメント構造についての詳しい情報は、はドキュメント構造(未実装)をご確認下さい。
概ねヘッダー、フッター等を除くドキュメントの内容がドキュメントボディ部分となります。
appendHorizontalRule | HorizontalRule | |
appendImage | InlineImage | 画像を追加 |
appendListItem | ListItem | リストを追加 |
appendPageBreak | PageBreak | ページ区切りを追加 |
appendParagraph | Paragraph | 段落を追加 |
appendTable | Table | 表を追加 |
clear | Body | 要素の内容をクリアする |
copy | Body | 要素の内容をコピーする |
editAsText | Text | 編集するために要素の内容をテキスト形式で取得 |
findElement | RangeElement | |
findText | RangeElement | |
getAttributes | Object | 要素の属性を取得 |
getChild | Element | |
getChildIndex | Integer | |
getHeadingAttributes | Object | |
getImages | InlineImage[] | 全てのインライン画像を配列で取得 |
getListItems | ListItem[] | 全てのリストを配列で取得 |
getMarginBottom | Number | 下余白をポイント単位で取得 |
getMarginLeft | Number | 左余白をポイント単位で取得 |
getMarginRight | Number | 右余白をポイント単位で取得 |
getMarginTop | Number | 上余白をポイント単位で取得 |
getNumChildren | Integer | 子要素数を取得 |
getPageHeight | Number | ページの高さをポイント単位で取得 |
getPageWidth | Number | ページの幅をポイント単位で取得 |
getParagraphs | Paragraph[] | 段落を配列で取得(リストを含む) |
getParent | ContainerElement | 親要素を取得 |
getTables | Table[] | 全ての表を取得 |
getText | String | 要素のテキストを取得 |
getTextAlignment | TextAlignment | テキスト揃えを取得 |
getType | ElementType | 要素タイプを取得 |
insertHrizontalRule | HorizontalRule | |
insertImage | InlineImage | 画像を挿入 |
insertListItem | ListItem | リストを挿入 |
insertPageBreak | PageBreak | |
insertParagraph | Paragraph | 段落を挿入 |
insertTable | Table | 表を挿入 |
removeChild | Body | 子要素を削除 |
replaceText | Element | テキストを置き換え |
setAttributes | Body | 要素の属性を設定 |
setHeadingAttributes | Body | |
setMarginBottom | Body | 下余白をポイント単位で設定 |
setMarginLeft | Body | 左余白をポイント単位で設定 |
setMarginRight | Body | 右余白をポイント単位で設定 |
setMarginTop | Body | 上余白をポイント単位で設定 |
setPageHeight | Body | ページの高さをポイント単位で設定 |
setPageWidth | Body | ページの幅をポイント単位で設定 |
setText | Body | 文字を入力 |
setTextAlignment | Body | テキスト揃えを設定 |
Class Bookmark
メソッド名 | タイプ | 簡単な説明 |
getId | String | ブックマークのIDを取得 |
getPosition | Position | ブックマークの位置を取得 |
remove | void | ブックマークを削除 |
Class ContainerElement
メソッド名 | タイプ | 簡単な説明 |
asBody | Body | |
asEquation | Equation | |
asFooterSection | FooterSection | |
asFootnoteSection | FooternoteSection | |
asHeaderSection | HeaderSection | |
asListItem | ListItem | |
asParagraph | Paragraph | |
asTable | Table | |
asTableCell | TableCell | |
asTableOfContents | TableOfContents | |
asTableRow | TableRow | |
clear | ContainerElement | |
copy | ContainerElement | |
editAsText | Text | |
findElement | RangeElement | |
findText | RangeElement | |
getAttributes | Object | |
getChild | Element | |
getChildIndex | Integer | |
getLinkUrl | String | |
getNextSibling | Element | |
getNumChildren | Integer | |
getParent | ContainerElement | |
getPreviousSibling | Element | |
getText | String | |
getTextAlignment | TextAlignment | |
getType | ElementType | |
merge | ContainerElement | |
removeFromParent | ContainerElement | |
replaceText | Element | |
setAttributes | ContainerElement | |
setLinkUrl | ContainerElement | |
setTextAlignment | ContainerElement |
Class Document
メソッド名 | タイプ | 簡単な説明 |
addBookmark | Bookmark | |
addEditor | Document | |
addEditors | Document | |
addFooter | FooterSection | |
addHeader | HeaderSection | |
addNamedRange | NamedRange | |
addViewer | Document | |
addViewers | Document | |
getAs | Blob | |
getBlob | Blob | |
getBody | Body | |
getBookmark | Bookmark | |
getBookmarks | Bookmark[] | |
getCursor | Position | |
getEditors | User[] | |
getFooter | FooterSection | |
getFootnotes | FootNote[] | |
getHeader | HeaderSection | |
getId | String | |
getLanguage | String | |
getName | String | ドキュメントファイルのタイトルを取得 |
getNamedRangeById | NamedRange | |
getNamedRanges | NamedRange[] | |
getSelection | Range | |
getSupportedLanguageCodes | String[] | |
getUrl | String | |
getViewers | User[] | |
newPosition | Position | |
newRange | RangeBuilder | |
removeEditor | Document | |
removeVisitor | Document | |
saveAndClose | void | |
setCursor | Document | |
setLanguage | Document | |
setName | Document | |
setSelection | Document |
Class DocumentApp
メソッド名 | タイプ | 簡単な説明 |
create | Document | |
getActiveDocument | Document | |
getUi | Ui | |
openById | Document | |
openByUrl | Document |
Class Element
メソッド名 | タイプ | 簡単な説明 |
asBody | Body | |
asEquation | Equation | |
asEquationFunction | EquationFunction | |
asEquationFunctionArgumentSeparator | EquationFunctionArgumentSeparator | |
asEquationSymbol | EquationSymbol | |
asFooterSection | FooterSection | |
asFootnote | Footnote | |
asFootnoteSection | FootnoteSection | |
asHeaderSection | HeaderSection | |
asHorizontalRule | HorizontalRule | |
asInlineDrawing | InlineDrawing | |
asInlineImage | InlineImage | |
asListItem | ListItem | |
asPageBreak | PageBreak | |
asParagraph | Paragraph | |
asTable | Table | |
asTableCell | TableCell | |
asTableOfContents | TableOfContents | |
asTableRow | TableRow | |
asText | Text | |
copy | Element | |
getAttributes | Object | |
getNextSibling | Element | |
getParent | ContainerElement | |
getPreviousSibling | Element | |
getType | ElementType | |
isAtDocumentEnd | Boolean | |
merge | Element | |
removeFromParent | Element | |
setAttributes | Element |
Class Equation
メソッド名 | タイプ | 簡単な説明 |
clear | Equation | |
copy | Equation | |
editAsText | Text | |
findElement | RangeElement | |
findText | RangeElement | |
getAttributes | Object | |
getChild | Element | |
getChildIndex | Integer | |
getLinkUrl | String | |
getNextSibling | Element | |
getNumChildren | Integer | |
getParent | ContainerElement | |
getPreviousSibling | Element | |
getText | String | |
getTextAlignment | TextAlignment | |
getType | ElementType | |
isAtDocumentEnd | Boolean | |
merge | Equation | |
removeFromParent | Equation | |
replaceText | Element | |
setAttributes | Equation | |
setLinkUrl | Equation | |
setTextAlignment | Equation |
Class EquationFunction
メソッド名 | タイプ | 簡単な説明 |
clear | Equation | |
copy | Equation | |
editAsText | Text | |
findElement | RangeElement | |
findText | RangeElement | |
getAttributes | Object | |
getChild | Element | |
getChildIndex | Integer | |
getCode | String | |
getLinkUrl | String | |
getNextSibling | Element | |
getNumChildren | Integer | |
getParent | ContainerElement | |
getPreviousSibling | Element | |
getText | String | |
getTextAlignment | TextAlignment | |
getType | ElementType | |
isAtDocumentEnd | Boolean | |
merge | Equation | |
removeFromParent | Equation | |
replaceText | Element | |
setAttributes | Equation | |
setLinkUrl | Equation | |
setTextAlignment | Equation |
Class EquationFunctionArgumentSeparator
メソッド名 | タイプ | 簡単な説明 |
copy | EquationFunctionArgumentSeparator | |
getAttributes | Object | |
getNextSibling | Element | |
getParent | ContainerElement | |
getPreviousSibling | Element | |
getType | ElementType | |
isAtDocumentEnd | Boolean | |
merge | Equation | |
removeFromParent | Equation | |
setAttributes | Equation |
Class EquationSymbol
メソッド名 | タイプ | 簡単な説明 |
copy | EquationSymbol | |
getAttributes | Object | |
getCode | String | |
getNextSibling | Element | |
getParent | ContainerElement | |
getPreviousSibling | Element | |
getType | ElementType | |
isAtDocumentEnd | Boolean | |
merge | Equation | |
removeFromParent | Equation | |
setAttributes | Equation |
メソッド名 | タイプ | 簡単な説明 |
appendHorizontalRule | HorizontalRule | |
appendImage | InlineImage | |
appendListItem | ListItem | |
appendParagraph | Paragraph | |
appendTable | Table | |
clear | Equation | |
copy | Equation | |
editAsText | Text | |
findElement | RangeElement | |
findText | RangeElement | |
getAttributes | Object | |
getChild | Element | |
getChildIndex | Integer | |
getImages | InlineImage[] | |
getListItems | ListItem[] | |
getNumChildren | Integer | |
getParagraphs | paragraph[] | |
getParent | ContainerElement | |
getTables | Table[] | |
getText | String | |
getTextAlignment | TextAlignment | |
getType | ElementType | |
insertHorizontalRule | HorizontalRule | |
insertImage | InlineImage | |
insertListItem | ListItem | |
insertParagraph | Paragraph | |
insertTable | Table | |
removeChild | FooterSection | |
removeFromParent | FooterSection | |
replaceText | Element | |
setAttributes | FooterSection | |
setText | FooterSection | |
setTextAlignment | FooterSection |
Class Footnote
メソッド名 | タイプ | 簡単な説明 |
copy | Footnote | |
getAttributes | Object | |
getFootnoteContents | FootnoteSection | |
getNextSibling | Element | |
getParent | ContainerElement | |
getPreviousSibling | Element | |
getType | ElementType | |
isAtDocumentEnd | Boolean | |
removeFromParent | Footnote | |
setAttributes | Footnote |
Class FootnoteSection
メソッド名 | タイプ | 簡単な説明 |
appendParagraph | Paragraph | |
clear | Equation | |
copy | Equation | |
editAsText | Text | |
findElement | RangeElement | |
findText | RangeElement | |
getAttributes | Object | |
getChild | Element | |
getChildIndex | Integer | |
getNextSibling | Element | |
getNumChildren | Integer | |
getParagraphs | paragraph[] | |
getParent | ContainerElement | |
getPreviousSibling | Element | |
getText | String | |
getTextAlignment | TextAlignment | |
getType | ElementType | |
insertParagraph | Paragraph | |
removeChild | FootnoteSection | |
removeFromParent | FootnoteSection | |
replaceText | Element | |
setAttributes | FootnoteSection | |
setText | FootnoteSection | |
setTextAlignment | FootnoteSection |
Class HeaderSection
メソッド名 | タイプ | 簡単な説明 |
appendHorizontalRule | HorizontalRule | |
appendImage | InlineImage | |
appendListItem | ListItem | |
appendParagraph | Paragraph | |
appendTable | Table | |
clear | HeaderSection | |
copy | HeaderSection | |
editAsText | Text | |
findElement | RangeElement | |
findText | RangeElement | |
getAttributes | Object | |
getChild | Element | |
getChildIndex | Integer | |
getImages | InlineImage[] | |
getListItems | ListItem[] | |
getNumChildren | Integer | |
getParagraphs | paragraph[] | |
getParent | ContainerElement | |
getTables | Table[] | |
getText | String | |
getTextAlignment | TextAlignment | |
getType | ElementType | |
insertHorizontalRule | HorizontalRule | |
insertImage | InlineImage | |
insertListItem | ListItem | |
insertParagraph | Paragraph | |
insertTable | Table | |
removeChild | HeaderSection | |
removeFromParent | HeaderSection | |
replaceText | Element | |
setAttributes | HeaderSection | |
setText | HeaderSection | |
setTextAlignment | HeaderSection |