Class TableCell

TableCell

표 셀을 나타내는 요소입니다. TableCell는 항상 TableRow 내에 포함되며 ListItem, Paragraph 또는 Table 요소를 포함할 수 있습니다. 문서 구조에 대한 자세한 내용은 Google Docs 확장 가이드를 참고하세요.

메서드

메서드반환 유형간략한 설명
appendHorizontalRule()HorizontalRuleHorizontalRule를 만들어 추가합니다.
appendImage(image)InlineImage지정된 이미지 blob에서 새 InlineImage를 만들어 추가합니다.
appendImage(image)InlineImage지정된 InlineImage를 추가합니다.
appendListItem(listItem)ListItem지정된 ListItem를 추가합니다.
appendListItem(text)ListItemListItem를 만들어 추가합니다.
appendParagraph(paragraph)Paragraph지정된 Paragraph를 추가합니다.
appendParagraph(text)ParagraphParagraph를 만들어 추가합니다.
appendTable()TableTable를 만들어 추가합니다.
appendTable(cells)Table지정된 셀이 포함된 새 Table을 추가합니다.
appendTable(table)Table지정된 Table를 추가합니다.
clear()TableCell요소의 콘텐츠를 지웁니다.
copy()TableCell현재 요소의 분리된 전체 사본을 반환합니다.
editAsText()Text수정을 위해 현재 요소의 Text 버전을 가져옵니다.
findElement(elementType)RangeElement|null요소의 콘텐츠에서 지정된 유형의 하위 요소를 검색합니다.
findElement(elementType, from)RangeElement|null지정된 RangeElement에서 시작하여 지정된 유형의 하위 요소를 요소의 콘텐츠에서 검색합니다.
findText(searchPattern)RangeElement|null정규 표현식을 사용하여 요소의 콘텐츠에서 지정된 텍스트 패턴을 검색합니다.
findText(searchPattern, from)RangeElement|null지정된 검색 결과부터 시작하여 요소의 콘텐츠에서 지정된 텍스트 패턴을 검색합니다.
getAttributes()Object요소의 속성을 가져옵니다.
getBackgroundColor()String|null배경색을 가져옵니다.
getChild(childIndex)Element지정된 하위 색인에 있는 하위 요소를 가져옵니다.
getChildIndex(child)Integer지정된 하위 요소의 하위 색인을 가져옵니다.
getColSpan()Integer이 셀이 걸쳐 있는 표 셀의 열 수인 열 범위를 가져옵니다.
getLinkUrl()String|null링크 URL을 가져옵니다.
getNextSibling()Element|null요소의 다음 동위 요소를 가져옵니다.
getNumChildren()Integer자녀 수를 가져옵니다.
getPaddingBottom()Number|null하단 패딩을 포인트 단위로 가져옵니다.
getPaddingLeft()Number|null왼쪽 패딩을 포인트 단위로 가져옵니다.
getPaddingRight()Number|null오른쪽 패딩을 포인트 단위로 가져옵니다.
getPaddingTop()Number|null상단 패딩을 포인트 단위로 가져옵니다.
getParent()ContainerElement|null요소의 상위 요소를 가져옵니다.
getParentRow()TableRow|null현재 TableCell이 포함된 TableRow를 가져옵니다.
getParentTable()Table|null현재 TableCell이 포함된 Table를 가져옵니다.
getPreviousSibling()Element|null요소의 이전 동급 요소를 가져옵니다.
getRowSpan()Integer이 셀이 걸쳐 있는 표 셀의 행 수인 행 범위를 가져옵니다.
getText()String요소의 콘텐츠를 텍스트 문자열로 가져옵니다.
getTextAlignment()TextAlignment|null텍스트 정렬을 가져옵니다.
getType()ElementType요소의 ElementType를 가져옵니다.
getVerticalAlignment()VerticalAlignment|nullVerticalAlignment를 가져옵니다.
getWidth()Number|null셀이 포함된 열의 너비를 포인트 단위로 가져옵니다.
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를 삽입합니다.
isAtDocumentEnd()Boolean요소가 Document의 끝에 있는지 여부를 확인합니다.
merge()TableCell|null요소를 동일한 유형의 이전 형제와 병합합니다.
removeChild(child)TableCell지정된 하위 요소를 삭제합니다.
removeFromParent()TableCell|null요소를 상위 요소에서 삭제합니다.
replaceText(searchPattern, replacement)Element정규 표현식을 사용하여 지정된 텍스트 패턴의 모든 항목을 지정된 대체 문자열로 바꿉니다.
setAttributes(attributes)TableCell요소의 속성을 설정합니다.
setBackgroundColor(color)TableCell배경 색상을 설정합니다.
setLinkUrl(url)TableCell링크 URL을 설정합니다.
setPaddingBottom(paddingBottom)TableCell하단 패딩을 포인트 단위로 설정합니다.
setPaddingLeft(paddingLeft)TableCell포인트 단위로 왼쪽 패딩을 설정합니다.
setPaddingRight(paddingRight)TableCell오른쪽 패딩을 포인트 단위로 설정합니다.
setPaddingTop(paddingTop)TableCell상단 패딩을 포인트 단위로 설정합니다.
setText(text)TableCell콘텐츠를 일반 텍스트로 설정합니다.
setTextAlignment(textAlignment)TableCell텍스트 정렬을 설정합니다.
setVerticalAlignment(alignment)TableCell세로 정렬을 설정합니다.
setWidth(width)TableCell현재 셀이 포함된 열의 너비를 포인트 단위로 설정합니다.

자세한 문서

appendHorizontalRule()

HorizontalRule를 만들어 추가합니다.

HorizontalRule는 새 Paragraph에 포함됩니다.

리턴

HorizontalRule - 새 가로줄

승인

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

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

appendImage(image)

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

InlineImage는 새 Paragraph에 포함됩니다.

매개변수

이름유형설명
imageBlobSource이미지 데이터

리턴

InlineImage: 새 이미지

승인

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

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

appendImage(image)

지정된 InlineImage를 추가합니다.

InlineImage는 새 Paragraph에 포함됩니다.

매개변수

이름유형설명
imageInlineImage이미지 데이터

리턴

InlineImage - 추가된 이미지

승인

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

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

appendListItem(listItem)

지정된 ListItem를 추가합니다.

매개변수

이름유형설명
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를 추가합니다.

매개변수

이름유형설명
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를 만들어 추가합니다.

리턴

Table - 새 테이블

승인

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

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

appendTable(cells)

지정된 셀이 포함된 새 Table을 추가합니다.

매개변수

이름유형설명
cellsString[][]새 테이블에 추가할 표 셀의 텍스트 콘텐츠

리턴

Table - 추가된 테이블

승인

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

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

appendTable(table)

지정된 Table를 추가합니다.

매개변수

이름유형설명
tableTable추가할 테이블

리턴

Table - 추가된 테이블

승인

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

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

clear()

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

리턴

TableCell - 현재 요소


copy()

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

요소에 있는 하위 요소도 복사됩니다. 새 요소에 상위 요소가 없습니다.

리턴

TableCell - 새로운 문구입니다.

승인

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

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

editAsText()

수정을 위해 현재 요소의 Text 버전을 가져옵니다.

요소 콘텐츠를 서식 있는 텍스트로 조작하려면 editAsText를 사용하세요. editAsText 모드는 텍스트가 아닌 요소 (예: InlineImageHorizontalRule)를 무시합니다.

삭제된 텍스트 범위 내에 완전히 포함된 하위 요소는 요소에서 삭제됩니다.

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

승인

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

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

findElement(elementType, from)

지정된 RangeElement에서 시작하여 지정된 유형의 하위 요소를 요소의 콘텐츠에서 검색합니다.

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

// Define the search parameters.

let searchResult = null;

// Search until the paragraph is found.
while (
    (searchResult = body.findElement(
         DocumentApp.ElementType.PARAGRAPH,
         searchResult,
         ))) {
  const par = searchResult.getElement().asParagraph();
  if (par.getHeading() === DocumentApp.ParagraphHeading.HEADING1) {
    // Found one, update and stop.
    par.setText('This is the first header.');
    break;
  }
}

매개변수

이름유형설명
elementTypeElementType검색할 요소의 유형입니다.
fromRangeElement검색할 검색 결과입니다.

리턴

RangeElement|null - 검색 요소의 다음 위치를 나타내는 검색 결과입니다.

승인

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

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

findText(searchPattern)

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

캡처 그룹, 모드 수정자 등 JavaScript 정규 표현식 기능의 일부는 완전히 지원되지 않습니다.

제공된 정규 표현식 패턴은 현재 요소에 포함된 각 텍스트 블록에 대해 독립적으로 일치합니다.

매개변수

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

리턴

RangeElement|null - 검색 텍스트의 위치를 나타내는 검색 결과 또는 일치하는 항목이 없는 경우 null

승인

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

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

findText(searchPattern, from)

지정된 검색 결과부터 시작하여 요소의 콘텐츠에서 지정된 텍스트 패턴을 검색합니다.

캡처 그룹, 모드 수정자 등 JavaScript 정규 표현식 기능의 일부는 완전히 지원되지 않습니다.

제공된 정규 표현식 패턴은 현재 요소에 포함된 각 텍스트 블록에 대해 독립적으로 일치합니다.

매개변수

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

리턴

RangeElement|null - 검색 텍스트의 다음 위치를 나타내는 검색 결과입니다. 일치하는 항목이 없으면 null입니다.

승인

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

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

getAttributes()

요소의 속성을 가져옵니다.

결과는 각 속성 이름이 DocumentApp.Attribute 열거형의 항목에 해당하는 유효한 요소 속성의 속성을 포함하는 객체입니다.

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

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

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

// Log the paragraph attributes.
for (const att in atts) {
  Logger.log(`${att}:${atts[att]}`);
}

리턴

Object - 요소의 속성입니다.

승인

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

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

getBackgroundColor()

배경색을 가져옵니다.

리턴

String|null - CSS 표기법 (예: '#ffffff')으로 형식이 지정된 배경색

승인

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

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

getChild(childIndex)

지정된 하위 색인에 있는 하위 요소를 가져옵니다.

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

// Obtain the first element in the tab.
const 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

getColSpan()

이 셀이 걸쳐 있는 표 셀의 열 수인 열 범위를 가져옵니다. 병합되지 않은 셀의 col span은 1입니다.

리턴

Integer - 열 범위 또는 다른 셀에 의해 병합된 셀의 경우 0

승인

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

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

getLinkUrl()

링크 URL을 가져옵니다.

리턴

String|null - 링크 URL입니다. 요소에 이 속성의 값이 여러 개 포함된 경우 null입니다.

승인

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

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

getNextSibling()

요소의 다음 동위 요소를 가져옵니다.

다음 동위 요소는 상위 요소가 동일하며 현재 요소를 따릅니다.

리턴

Element|null - 다음 동급 요소입니다.

승인

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

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

getNumChildren()

자녀 수를 가져옵니다.

const 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

getPaddingBottom()

하단 패딩을 포인트 단위로 가져옵니다.

리턴

Number|null - 하단 패딩(단위: 포인트)

승인

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

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

getPaddingLeft()

왼쪽 패딩을 포인트 단위로 가져옵니다.

리턴

Number|null - 왼쪽 패딩(단위: 포인트)

승인

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

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

getPaddingRight()

오른쪽 패딩을 포인트 단위로 가져옵니다.

리턴

Number|null - 오른쪽 패딩(포인트)

승인

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

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

getPaddingTop()

상단 패딩을 포인트 단위로 가져옵니다.

리턴

Number|null - 상단 패딩(단위: 포인트)

승인

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

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

getParent()

요소의 상위 요소를 가져옵니다.

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

리턴

ContainerElement|null - 상위 요소입니다.

승인

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

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

getParentRow()

현재 TableCell이 포함된 TableRow를 가져옵니다.

리턴

TableRow|null - 현재 셀이 포함된 표 행

승인

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

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

getParentTable()

현재 TableCell이 포함된 Table를 가져옵니다.

리턴

Table|null - 현재 셀이 포함된 표

승인

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

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

getPreviousSibling()

요소의 이전 동급 요소를 가져옵니다.

이전 동급 요소의 상위 요소가 동일하고 현재 요소보다 앞에 있습니다.

리턴

Element|null - 이전 동급 요소입니다.

승인

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

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

getRowSpan()

이 셀이 걸쳐 있는 표 셀의 행 수인 행 범위를 가져옵니다. 병합되지 않은 셀의 행 범위는 1입니다.

리턴

Integer - 다른 셀에 의해 병합된 셀의 행 범위 또는 0

승인

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

  • 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 - 텍스트 정렬 유형 또는 텍스트에 여러 유형의 텍스트 정렬이 포함되어 있거나 텍스트 정렬이 설정된 적이 없는 경우 null

승인

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

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

getType()

요소의 ElementType를 가져옵니다.

getType()을 사용하여 지정된 요소의 정확한 유형을 확인합니다.

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

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

const 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

getVerticalAlignment()

VerticalAlignment를 가져옵니다.

리턴

VerticalAlignment|null - 세로 정렬

승인

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

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

getWidth()

셀이 포함된 열의 너비를 포인트 단위로 가져옵니다.

리턴

Number|null - 열 너비(포인트)

승인

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

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

insertHorizontalRule(childIndex)

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

수평선은 새 Paragraph에 포함됩니다.

매개변수

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

리턴

HorizontalRule - 새 가로줄

승인

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

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

insertImage(childIndex, image)

지정된 이미지 blob에서 지정된 색인에 InlineImage을 만들어 삽입합니다.

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

매개변수

이름유형설명
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

isAtDocumentEnd()

요소가 Document의 끝에 있는지 여부를 확인합니다.

리턴

Boolean - 요소가 탭 끝에 있는지 여부입니다.

승인

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

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

merge()

요소를 동일한 유형의 이전 형제와 병합합니다.

동일한 ElementType의 요소만 병합할 수 있습니다. 현재 요소에 포함된 하위 요소는 이전 형제 요소로 이동됩니다.

현재 요소가 문서에서 삭제됩니다.

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

// Example 1: Merge paragraphs
// Append two paragraphs to the document's active tab.
const par1 = body.appendParagraph('Paragraph 1.');
const 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.
const cells = [
  ['Row 1, Cell 1', 'Row 1, Cell 2'],
  ['Row 2, Cell 1', 'Row 2, Cell 2'],
];
// Build a table from the array.
const table = body.appendTable(cells);
// Get the first row in the table.
const row = table.getRow(0);
// Get the two cells in this row.
const cell1 = row.getCell(0);
const cell2 = row.getCell(1);
// Merge the current cell into its preceding sibling element.
const merged = cell2.merge();

리턴

TableCell|null - 병합된 요소입니다.

승인

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

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

removeChild(child)

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

매개변수

이름유형설명
childElement삭제할 하위 요소

리턴

TableCell - 현재 요소

승인

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

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

removeFromParent()

요소를 상위 요소에서 삭제합니다.

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

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

리턴

TableCell|null - 삭제된 요소입니다.

승인

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

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

replaceText(searchPattern, replacement)

정규 표현식을 사용하여 지정된 텍스트 패턴의 모든 항목을 지정된 대체 문자열로 바꿉니다.

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

이 메서드는 Google의 RE2 정규 표현식 라이브러리를 사용하므로 지원되는 문법이 제한됩니다.

제공된 정규 표현식 패턴은 현재 요소에 포함된 각 텍스트 블록에 대해 독립적으로 일치합니다.

const 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 열거형의 항목이고 각 속성 값이 적용할 새 값인 객체여야 합니다.

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

// Define a custom paragraph style.
const 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.
const par = body.appendParagraph('A paragraph with custom style.');

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

매개변수

이름유형설명
attributesObject요소의 속성입니다.

리턴

TableCell - 현재 요소

승인

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

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

setBackgroundColor(color)

배경 색상을 설정합니다.

매개변수

이름유형설명
colorString배경색 (CSS 표기법으로 서식 지정됨, 예: '#ffffff')

리턴

TableCell - 현재 요소

승인

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

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

setLinkUrl(url)

링크 URL을 설정합니다.

매개변수

이름유형설명
urlString링크 URL

리턴

TableCell - 현재 요소

승인

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

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

setPaddingBottom(paddingBottom)

하단 패딩을 포인트 단위로 설정합니다.

매개변수

이름유형설명
paddingBottomNumber포인트 단위의 하단 패딩

리턴

TableCell - 현재 요소

승인

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

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

setPaddingLeft(paddingLeft)

포인트 단위로 왼쪽 패딩을 설정합니다.

매개변수

이름유형설명
paddingLeftNumber왼쪽 패딩(단위: 포인트)

리턴

TableCell - 현재 요소

승인

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

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

setPaddingRight(paddingRight)

오른쪽 패딩을 포인트 단위로 설정합니다.

매개변수

이름유형설명
paddingRightNumber오른쪽 패딩(단위: 포인트)입니다.

리턴

TableCell - 현재 요소

승인

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

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

setPaddingTop(paddingTop)

상단 패딩을 포인트 단위로 설정합니다.

매개변수

이름유형설명
paddingTopNumber상단 패딩(단위: 포인트)

리턴

TableCell - 현재 요소

승인

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

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

setText(text)

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

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

매개변수

이름유형설명
textString새 텍스트 콘텐츠

리턴

TableCell - 현재 요소

승인

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

  • 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.
const documentTab =
    DocumentApp.getActiveDocument().getActiveTab().asDocumentTab();
const text = documentTab.getBody().getParagraphs()[0].editAsText();
text.setTextAlignment(DocumentApp.TextAlignment.SUPERSCRIPT);

매개변수

이름유형설명
textAlignmentTextAlignment적용할 텍스트 정렬 유형

리턴

TableCell - 현재 요소

승인

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

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

setVerticalAlignment(alignment)

세로 정렬을 설정합니다.

매개변수

이름유형설명
alignmentVerticalAlignment세로 정렬

리턴

TableCell - 현재 요소

승인

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

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

setWidth(width)

현재 셀이 포함된 열의 너비를 포인트 단위로 설정합니다.

매개변수

이름유형설명
widthNumber열 너비(포인트)

리턴

TableCell - 현재 요소

승인

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

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