Class HeaderSection

HeaderSection

헤더 섹션을 나타내는 요소입니다. Document에는 일반적으로 최대 1개의 HeaderSection가 포함됩니다. HeaderSection에는 ListItem, Paragraph, Table 요소. 문서 구조에 대한 자세한 내용은 Google Docs 확장 가이드를 참조하세요.

메서드

메서드반환 유형간략한 설명
appendHorizontalRule()HorizontalRuleHorizontalRule를 만들고 추가합니다.
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()TableTable를 만들고 추가합니다.
appendTable(cells)Table지정된 각 문자열 값의 TableCell가 포함된 새 Table를 추가합니다.
appendTable(table)Table지정된 Table를 추가합니다.
clear()HeaderSection요소의 콘텐츠를 지웁니다.
copy()HeaderSection현재 요소의 분리된 전체 사본을 반환합니다.
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[]섹션에 포함된 모든 Paragraphs를 검색합니다 (ListItems 포함).
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)HeaderSection지정된 하위 요소를 삭제합니다.
removeFromParent()HeaderSection상위 항목에서 요소를 삭제합니다.
replaceText(searchPattern, replacement)Element정규식을 사용하여 지정된 텍스트 패턴과 일치하는 모든 항목을 지정된 대체 문자열로 바꿉니다. 식을 사용할 수 있습니다.
setAttributes(attributes)HeaderSection요소의 속성을 설정합니다.
setText(text)HeaderSection콘텐츠를 일반 텍스트로 설정합니다.
setTextAlignment(textAlignment)HeaderSection텍스트 정렬을 설정합니다.

자세한 문서

appendHorizontalRule()

HorizontalRule를 만들고 추가합니다.

HorizontalRule가 새 Paragraph에 포함됩니다.

리턴

HorizontalRule - 새 가로 규칙입니다.

승인

이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상으로 승인이 필요합니다.

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

appendImage(image)

지정된 이미지 blob에서 새 InlineImage를 만들고 추가합니다.

이미지가 새 Paragraph에 포함됩니다.

매개변수

이름유형설명
imageBlobSource이미지 데이터입니다.

리턴

InlineImage - 추가된 이미지입니다.

승인

이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상으로 승인이 필요합니다.

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

appendImage(image)

지정된 InlineImage를 추가합니다.

InlineImage가 새 Paragraph에 포함됩니다.

기존 InlineImage의 사본을 추가할 때 이 버전의 appendImage를 사용합니다.

매개변수

이름유형설명
imageInlineImage이미지 데이터입니다.

리턴

InlineImage - 추가된 이미지입니다.

승인

이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상으로 승인이 필요합니다.

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

appendListItem(listItem)

지정된 ListItem를 추가합니다.

기존 ListItem의 사본을 추가할 때 이 버전의 appendListItem를 사용합니다.

매개변수

이름유형설명
listItemListItem추가할 목록 항목입니다.

리턴

ListItem - 추가된 목록 항목입니다.

승인

이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상으로 승인이 필요합니다.

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

appendListItem(text)

지정된 텍스트 콘텐츠를 포함하는 새 ListItem를 만들고 추가합니다.

연속된 목록 항목은 동일한 목록의 일부로 추가됩니다.

매개변수

이름유형설명
textString목록 항목의 텍스트 콘텐츠

리턴

ListItem - 새 목록 항목입니다.

승인

이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상으로 승인이 필요합니다.

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

appendParagraph(paragraph)

지정된 Paragraph를 추가합니다.

기존 Paragraph의 사본을 추가할 때 이 버전의 appendParagraph를 사용합니다.

매개변수

이름유형설명
paragraphParagraph추가할 단락입니다.

리턴

Paragraph - 추가된 단락입니다.

승인

이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상으로 승인이 필요합니다.

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

appendParagraph(text)

지정된 텍스트 콘텐츠를 포함하는 새 Paragraph를 만들고 추가합니다.

매개변수

이름유형설명
textString단락의 텍스트 내용입니다.

리턴

Paragraph - 새 단락입니다.

승인

이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상으로 승인이 필요합니다.

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

appendTable()

Table를 만들고 추가합니다.

이 방법은 또한 표 다음에 빈 단락을 추가합니다. 왜냐하면 Google Docs도구의 문서도 테이블로 끝날 수 없습니다.

리턴

Table - 새 테이블입니다.

승인

이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상으로 승인이 필요합니다.

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

appendTable(cells)

지정된 각 문자열 값의 TableCell가 포함된 새 Table를 추가합니다.

이 방법은 또한 표 다음에 빈 단락을 추가합니다. Google Docs도구의 문서도 테이블로 끝날 수 없습니다.

매개변수

이름유형설명
cellsString[][]새 표에 추가할 표 셀의 텍스트 콘텐츠입니다.

리턴

Table - 추가된 테이블입니다.

승인

이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상으로 승인이 필요합니다.

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

appendTable(table)

지정된 Table를 추가합니다.

기존 Table의 사본을 추가할 때 이 버전의 appendTable를 사용합니다. 이 방법은 또한 표 다음에 빈 단락을 추가합니다. 왜냐하면 Google Docs도구의 문서도 테이블로 끝날 수 없습니다.

매개변수

이름유형설명
tableTable추가할 표입니다.

리턴

Table - 추가된 테이블입니다.

승인

이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상으로 승인이 필요합니다.

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

clear()

요소의 콘텐츠를 지웁니다.

리턴

HeaderSection - 현재 요소입니다.


copy()

현재 요소의 분리된 전체 사본을 반환합니다.

요소에 있는 모든 하위 요소도 복사됩니다. 새 요소에는 있습니다.

리턴

HeaderSection - 새 사본입니다.

승인

이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상으로 승인이 필요합니다.

  • 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 - 검색 요소의 위치를 나타내는 검색 결과입니다.

승인

이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상으로 승인이 필요합니다.

  • 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 - 검색 요소의 다음 위치를 나타내는 검색 결과입니다.

승인

이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상으로 승인이 필요합니다.

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

findText(searchPattern)

정규 표현식을 사용하여 요소의 콘텐츠에서 지정된 텍스트 패턴을 검색합니다.

JavaScript 정규 표현식 기능의 하위 집합은 완전히 지원되지 않습니다. 예를 들면 다음과 같습니다. 그룹 및 모드 수정자를 캡처합니다.

제공된 정규 표현식 패턴이 각 텍스트 블록과 독립적으로 일치됩니다. .

매개변수

이름유형설명
searchPatternString검색할 패턴

리턴

RangeElement — 검색 텍스트의 위치를 나타내는 검색 결과, 또는 없는 경우 null 일치

승인

이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상으로 승인이 필요합니다.

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

findText(searchPattern, from)

요소의 콘텐츠에서 지정된 텍스트 패턴(지정된 텍스트부터 시작)을 검색합니다. 표시됩니다.

JavaScript 정규 표현식 기능의 하위 집합은 완전히 지원되지 않습니다. 예를 들면 다음과 같습니다. 그룹 및 모드 수정자를 캡처합니다.

제공된 정규 표현식 패턴이 각 텍스트 블록과 독립적으로 일치됩니다. .

매개변수

이름유형설명
searchPatternString검색할 패턴
fromRangeElement검색할 검색결과

리턴

RangeElement: 검색 텍스트의 다음 위치를 나타내는 검색 결과, 또는 없는 경우 null입니다. 일치

승인

이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상으로 승인이 필요합니다.

  • 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 - 요소의 속성입니다.

승인

이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상으로 승인이 필요합니다.

  • 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 - 지정된 색인의 하위 요소입니다.

승인

이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상으로 승인이 필요합니다.

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

getChildIndex(child)

지정된 하위 요소의 하위 색인을 검색합니다.

매개변수

이름유형설명
childElement색인을 검색할 하위 요소입니다.

리턴

Integer - 하위 색인입니다.

승인

이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상으로 승인이 필요합니다.

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

getImages()

섹션에 포함된 모든 InlineImages를 검색합니다.

리턴

InlineImage[] - 섹션 이미지입니다.

승인

이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상으로 승인이 필요합니다.

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

getListItems()

섹션에 포함된 모든 ListItems를 검색합니다.

리턴

ListItem[] - 섹션 목록 항목입니다.

승인

이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상으로 승인이 필요합니다.

  • 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 - 하위 요소 수입니다.

승인

이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상으로 승인이 필요합니다.

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

getParagraphs()

섹션에 포함된 모든 Paragraphs를 검색합니다 (ListItems 포함).

리턴

Paragraph[] - 섹션 단락입니다.

승인

이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상으로 승인이 필요합니다.

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

getParent()

요소의 상위 요소를 검색합니다.

상위 요소에 현재 요소가 포함되어 있습니다.

리턴

ContainerElement - 상위 요소입니다.

승인

이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상으로 승인이 필요합니다.

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

getTables()

섹션에 포함된 모든 Tables를 검색합니다.

리턴

Table[] - 섹션 표입니다.

승인

이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상으로 승인이 필요합니다.

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

getText()

요소의 콘텐츠를 텍스트 문자열로 검색합니다.

리턴

String: 텍스트 문자열로 표시된 요소의 콘텐츠

승인

이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상으로 승인이 필요합니다.

  • 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(텍스트에 여러 유형의 텍스트가 포함된 경우) 텍스트 정렬이 설정되지 않은 경우

승인

이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상으로 승인이 필요합니다.

  • 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 - 요소 유형입니다.

승인

이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상으로 승인이 필요합니다.

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

insertHorizontalRule(childIndex)

지정된 색인에 새 HorizontalRule를 만들고 삽입합니다.

HorizontalRule가 새 Paragraph에 포함됩니다.

매개변수

이름유형설명
childIndexInteger요소를 삽입할 색인입니다.

리턴

HorizontalRule - 새 가로 규칙입니다.

승인

이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상으로 승인이 필요합니다.

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

insertImage(childIndex, image)

지정된 이미지 blob에서 지정된 위치에 InlineImage를 만들고 삽입합니다. 색인

매개변수

이름유형설명
childIndexInteger요소를 삽입할 색인입니다.
imageBlobSource이미지 데이터입니다.

리턴

InlineImage - 삽입된 인라인 이미지입니다.

승인

이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상으로 승인이 필요합니다.

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

insertImage(childIndex, image)

지정된 색인에 지정된 InlineImage를 삽입합니다.

이미지가 새 Paragraph에 포함됩니다.

매개변수

이름유형설명
childIndexInteger요소를 삽입할 색인입니다.
imageInlineImage삽입할 이미지입니다.

리턴

InlineImage - 삽입된 인라인 이미지입니다.

승인

이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상으로 승인이 필요합니다.

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

insertListItem(childIndex, listItem)

지정된 색인에 지정된 ListItem를 삽입합니다.

매개변수

이름유형설명
childIndexInteger삽입할 색인입니다.
listItemListItem삽입할 목록 항목입니다.

리턴

ListItem - 삽입된 목록 항목입니다.

승인

이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상으로 승인이 필요합니다.

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

insertListItem(childIndex, text)

지정된 색인에 지정된ListItem 있습니다.

매개변수

이름유형설명
childIndexInteger삽입할 색인입니다.
textString목록 항목의 텍스트 콘텐츠

리턴

ListItem - 새 목록 항목입니다.

승인

이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상으로 승인이 필요합니다.

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

insertParagraph(childIndex, paragraph)

지정된 색인에 지정된 Paragraph를 삽입합니다.

매개변수

이름유형설명
childIndexInteger삽입할 색인입니다.
paragraphParagraph삽입할 단락입니다.

리턴

Paragraph - 삽입된 단락입니다.

승인

이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상으로 승인이 필요합니다.

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

insertParagraph(childIndex, text)

지정된 색인에 지정된Paragraph 있습니다.

매개변수

이름유형설명
childIndexInteger삽입할 색인입니다.
textString단락의 텍스트 내용입니다.

리턴

Paragraph - 새 단락입니다.

승인

이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상으로 승인이 필요합니다.

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

insertTable(childIndex)

지정된 색인에 새 Table를 만들고 삽입합니다.

매개변수

이름유형설명
childIndexInteger삽입할 색인입니다.

리턴

Table - 새 테이블입니다.

승인

이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상으로 승인이 필요합니다.

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

insertTable(childIndex, cells)

지정된 색인에 지정된 셀을 포함하는 새 Table를 만들고 삽입합니다.

매개변수

이름유형설명
childIndexInteger삽입할 색인입니다.
cellsString[][]새 표에 추가할 표 셀의 텍스트 콘텐츠입니다.

리턴

Table - 새 테이블입니다.

승인

이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상으로 승인이 필요합니다.

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

insertTable(childIndex, table)

지정된 색인에 지정된 Table를 삽입합니다.

매개변수

이름유형설명
childIndexInteger삽입할 색인입니다.
tableTable삽입할 표입니다.

리턴

Table - 삽입된 표입니다.

승인

이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상으로 승인이 필요합니다.

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

removeChild(child)

지정된 하위 요소를 삭제합니다.

매개변수

이름유형설명
childElement삭제할 하위 요소입니다.

리턴

HeaderSection - 현재 요소입니다.

승인

이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상으로 승인이 필요합니다.

  • 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();
}

리턴

HeaderSection - 삭제된 요소입니다.

승인

이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상으로 승인이 필요합니다.

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

replaceText(searchPattern, replacement)

정규식을 사용하여 지정된 텍스트 패턴과 일치하는 모든 항목을 지정된 대체 문자열로 바꿉니다. 식을 사용할 수 있습니다.

검색 패턴은 JavaScript 정규 표현식 객체가 아닌 문자열로 전달됩니다. 따라서 패턴에서 백슬래시를 이스케이프 처리해야 합니다.

이 방법은 Google의 RE2 일반 표현식 라이브러리를 사용할 수 있습니다. 이 API는 지원되는 구문을 제한합니다.

제공된 정규 표현식 패턴이 각 텍스트 블록과 독립적으로 일치됩니다. .

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: 현재 요소

승인

이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상으로 승인이 필요합니다.

  • 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요소의 속성입니다.

리턴

HeaderSection - 현재 요소입니다.

승인

이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상으로 승인이 필요합니다.

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

setText(text)

콘텐츠를 일반 텍스트로 설정합니다.

참고: 기존 콘텐츠는 삭제됩니다.

매개변수

이름유형설명
textString새 텍스트 콘텐츠입니다.

리턴

HeaderSection - 현재 요소입니다.

승인

이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상으로 승인이 필요합니다.

  • 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 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적용할 텍스트 정렬 유형

리턴

HeaderSection: 현재 요소

승인

이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상으로 승인이 필요합니다.

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

지원 중단된 메서드