하나 이상의 Tab 객체를 포함하는 문서입니다. 각 객체에는 서식 있는 텍스트와 표, 목록과 같은 요소가 포함됩니다.
Document를 사용하여 문서를 열거나 만들 수 있습니다.
// Open a document by ID. let doc = DocumentApp.openById('<my-id>'); // Create and open a document. doc = DocumentApp.create('Document Title');
텍스트 콘텐츠에 직접 액세스하고 수정하는 Document 클래스의 메서드는 활성 탭 (특정 문서에 바인딩된 스크립트의 경우) 또는 첫 번째 탭 (활성 탭이 없는 경우)에서 작동합니다. 이러한 메서드 (예: get)를 사용하는 스크립트는 get 및 Tab.asDocumentTab()를 사용하여 탭을 지원하도록 이전할 수 있습니다.
메서드
| 메서드 | 반환 유형 | 간략한 설명 |
|---|---|---|
add | Bookmark | 지정된 Position에 첫 번째 탭 또는 문서에 바인드된 스크립트의 경우 활성 탭에 Bookmark를 추가합니다. |
add | Document | 지정된 사용자를 Document의 편집자 목록에 추가합니다. |
add | Document | 지정된 사용자를 Document의 편집자 목록에 추가합니다. |
add | Document | Document의 편집자 목록에 지정된 사용자 배열을 추가합니다. |
add | Footer | 첫 번째 탭 또는 문서에 바인드된 스크립트의 경우 활성 탭에 바닥글 섹션을 추가합니다(없는 경우). |
add | Header | 헤더 섹션이 없는 경우 첫 번째 탭 또는 문서에 바인드된 스크립트의 경우 활성 탭에 헤더 섹션을 추가합니다. |
add | Named | 이름과 ID가 있어 나중에 검색하는 데 사용할 수 있는 Range인 Named을 첫 번째 탭에 추가합니다. 문서에 바인딩된 스크립트의 경우 활성 탭에 추가합니다. |
add | Document | 지정된 사용자를 Document의 보기 권한 사용자 목록에 추가합니다. |
add | Document | 지정된 사용자를 Document의 보기 권한 사용자 목록에 추가합니다. |
add | Document | 지정된 사용자 배열을 Document의 보기 권한 사용자 목록에 추가합니다. |
get | Tab | 문서에서 현재 활성 상태인 사용자의 Tab를 가져옵니다. |
get | Blob | 현재 Document 콘텐츠를 지정된 유형의 blob으로 가져옵니다. |
get | Blob | 현재 Document 콘텐츠를 blob으로 가져옵니다. |
get | Body | 첫 번째 탭의 Body를 가져오거나 문서에 바인드된 스크립트의 경우 활성 탭의 Document를 가져옵니다. |
get | Bookmark|null | 첫 번째 탭 또는 문서에 바인드된 스크립트의 경우 활성 탭에서 지정된 ID의 Bookmark를 가져옵니다. |
get | Bookmark[] | 첫 번째 탭의 모든 Bookmark 객체를 가져오거나 문서에 바인딩된 스크립트의 경우 활성 탭의 모든 Bookmark 객체를 가져옵니다. |
get | Position|null | 활성 탭에서 사용자의 커서를 가져옵니다. |
get | User[] | 이 Document의 편집자 목록을 가져옵니다. |
get | Footer | 첫 번째 탭의 바닥글 섹션을 가져오거나 문서에 바인드된 스크립트의 경우 활성 탭의 바닥글 섹션을 가져옵니다. |
get | Footnote[]|null | 첫 번째 탭의 본문에 있는 모든 Footnote 요소를 가져오거나 문서에 바인드된 스크립트의 경우 활성 탭의 본문에 있는 모든 Footnote 요소를 가져옵니다. |
get | Header | 첫 번째 탭의 헤더 섹션을 가져오거나 문서에 바인딩된 스크립트의 경우 활성 탭의 헤더 섹션을 가져옵니다. |
get | String | 문서의 고유 식별자를 가져옵니다. |
get | String | 문서의 언어 코드를 가져옵니다. |
get | String | 문서의 제목을 가져옵니다. |
get | Named | 첫 번째 탭 또는 문서에 바인드된 스크립트의 경우 활성 탭에서 지정된 ID의 Named를 가져옵니다. |
get | Named | 첫 번째 탭의 모든 Named 객체를 가져오거나 문서에 바인딩된 스크립트의 경우 활성 탭의 모든 Named 객체를 가져옵니다. |
get | Named | 첫 번째 탭에 있는 지정된 이름의 모든 Named 객체를 가져옵니다. 문서에 바인드된 스크립트의 경우 활성 탭에 있는 지정된 이름의 모든 Named 객체를 가져옵니다. |
get | Range|null | 활성 탭에서 사용자의 선택을 가져옵니다. |
get | String[] | Google Docs 파일에서 지원되는 모든 언어 코드를 가져옵니다. |
get | Tab | 지정된 ID의 Tab를 가져옵니다. |
get | Tab[] | 문서에 포함된 모든 중첩되지 않은 Tab를 가져옵니다. |
get | String | 현재 문서에 액세스할 수 있는 URL을 가져옵니다. |
get | User[] | 이 Document의 뷰어 및 댓글 작성자 목록을 가져옵니다. |
new | Position | 첫 번째 탭의 특정 요소 또는 문서에 바인드된 스크립트의 경우 활성 탭을 기준으로 탭의 위치를 참조하는 새 Position를 만듭니다. |
new | Range | 첫 번째 탭의 탭 요소 또는 문서에 바인드된 스크립트의 경우 활성 탭에서 Range 객체를 생성하는 데 사용되는 빌더를 만듭니다. |
remove | Document | Document의 편집자 목록에서 지정된 사용자를 삭제합니다. |
remove | Document | Document의 편집자 목록에서 지정된 사용자를 삭제합니다. |
remove | Document | Document의 조회자 및 댓글 작성자 목록에서 지정된 사용자를 삭제합니다. |
remove | Document | Document의 조회자 및 댓글 작성자 목록에서 지정된 사용자를 삭제합니다. |
save | void | 현재 Document을 저장합니다. |
set | void | 현재 문서에서 사용자가 선택한 Tab을 지정된 ID의 탭으로 설정합니다. |
set | Document | Position가 지정된 경우 사용자의 커서를 설정합니다. |
set | Document | 문서의 언어 코드를 설정합니다. |
set | Document | 문서 제목을 설정합니다. |
set | Document | Range가 주어지면 활성 탭에서 사용자의 선택을 설정합니다. |
자세한 문서
add Bookmark(position)
지정된 Position에 첫 번째 탭 또는 문서에 바인드된 스크립트의 경우 활성 탭에 Bookmark를 추가합니다. 탭에 북마크를 추가하려면 Document 메서드를 사용합니다.
// Opens the Docs file by its ID. If you created your script from within // a Google Docs file, you can use DocumentApp.getActiveDocument() instead. // TODO(developer): Replace the ID with your own. const doc = DocumentApp.openById('123abc'); // Gets the active or first tab's body and adds a paragraph. const paragraph = doc.getBody().appendParagraph('My new paragraph.'); // Creates a position at the first character of the paragraph text. const position = doc.newPosition(paragraph.getChild(0), 0); // Adds a bookmark at the first character of the paragraph text. const bookmark = doc.addBookmark(position); // Logs the bookmark ID to the console. console.log(bookmark.getId());
매개변수
| 이름 | 유형 | 설명 |
|---|---|---|
position | Position | 새 북마크의 위치입니다. |
리턴
Bookmark - 새 북마크입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
add Editor(emailAddress)
add Editor(user)
add Editors(emailAddresses)
add Header()
헤더 섹션이 없는 경우 첫 번째 탭 또는 문서에 바인드된 스크립트의 경우 활성 탭에 헤더 섹션을 추가합니다. 탭에 헤더 섹션을 추가하려면 Document 메서드를 사용합니다.
// Opens the Docs file by its ID. If you created your script from within // a Google Docs file, you can use DocumentApp.getActiveDocument() instead. // TODO(developer): Replace the ID with your own. const doc = DocumentApp.openById('123abc'); // Adds a header to the document's active or first tab. const header = doc.addHeader(); // Sets the header text to 'This is a header.' header.setText('This is a header');
리턴
Header - 탭 헤더입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
add Named Range(name, range)
이름과 ID가 있어 나중에 검색하는 데 사용할 수 있는 Range인 Named을 첫 번째 탭에 추가합니다. 문서에 바인딩된 스크립트의 경우 활성 탭에 추가합니다. 탭에 Named를 추가하려면 Document 메서드를 사용합니다. 이름은 반드시 고유하지는 않습니다. 동일한 문서의 여러 범위가 HTML의 클래스와 마찬가지로 동일한 이름을 공유할 수 있습니다. 반면 ID는 HTML의 ID와 같이 문서 내에서 고유합니다.
문서에 Named을 추가한 후에는 수정할 수 없으며 삭제만 가능합니다.
문서에 액세스하는 스크립트는 Named에 액세스할 수 있습니다. 스크립트 간의 의도치 않은 충돌을 방지하려면 범위 이름에 고유한 문자열을 접두사로 추가하는 것이 좋습니다.
// Creates a named range that includes every table in the active tab. const doc = DocumentApp.getActiveDocument(); const rangeBuilder = doc.newRange(); const tables = doc.getBody().getTables(); for (let i = 0; i < tables.length; i++) { rangeBuilder.addElement(tables[i]); } // Adds the named range to the document's active tab. doc.addNamedRange('Document tables', rangeBuilder.build());
매개변수
| 이름 | 유형 | 설명 |
|---|---|---|
name | String | 범위의 이름입니다. 고유하지 않아도 됩니다. 범위 이름은 1~256자여야 합니다. |
range | Range | 이름과 연결할 요소의 범위입니다. 범위는 활성 선택, 검색 결과 또는 new로 수동으로 구성할 수 있습니다. |
리턴
Named - Named
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
add Viewer(emailAddress)
add Viewer(user)
add Viewers(emailAddresses)
get Active Tab()
문서에서 현재 활성 상태인 사용자의 Tab를 가져옵니다. 스크립트는 스크립트를 실행하는 사용자의 활성 탭에만 액세스할 수 있으며, 스크립트가 문서에 바인딩된 경우에만 액세스할 수 있습니다.
// Display a dialog box that shows the title of the tab that the // user is currently viewing. const tab = DocumentApp.getActiveDocument().getActiveTab(); DocumentApp.getUi().alert(`ID of selected tab: ${tab.getTitle()}`);
리턴
Tab - 사용자의 현재 활성 Tab입니다. 스크립트가 문서에 바인딩되지 않은 경우 null입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
get As(contentType)
현재 Document 콘텐츠를 지정된 유형의 blob으로 가져옵니다.
// Opens the Docs file by its ID. If you created your script from within // a Google Docs file, you can use DocumentApp.getActiveDocument() instead. // TODO(developer): Replace the ID with your own. const doc = DocumentApp.openById('123abc'); // Gets the document as a PDF. const pdf = doc.getAs('application/pdf'); // Logs the name of the PDF to the console. console.log(pdf.getName());
매개변수
| 이름 | 유형 | 설명 |
|---|---|---|
content | String | 변환할 MIME 유형입니다. 'application/pdf' 및 'text/markdown'이 지원됩니다. |
리턴
Blob - 현재 문서를 blob으로 나타냅니다.
get Blob()
현재 Document 콘텐츠를 blob으로 가져옵니다.
// Opens the Docs file by its ID. If you created your script from within // a Google Docs file, you can use DocumentApp.getActiveDocument() instead. // TODO(developer): Replace the ID with your own. const doc = DocumentApp.openById('123abc'); // Retrieves the current document's contents as a blob and logs it to the // console. console.log(doc.getBlob().getContentType());
리턴
Blob - 현재 문서를 blob으로 나타냅니다.
get Body()
첫 번째 탭의 Body를 가져오거나 문서에 바인드된 스크립트의 경우 활성 탭의 Document를 가져옵니다. 탭의 Document을 가져오려면 Document 메서드를 사용합니다.
탭에는 다양한 유형의 섹션 (예: Header, Footer)이 포함될 수 있습니다. 탭의 활성 섹션은 Body입니다.
Document의 요소 메서드는 활성 Body에 위임됩니다.
// Opens the Docs file by its ID. If you created your script from within // a Google Docs file, you can use DocumentApp.getActiveDocument() instead. // TODO(developer): Replace the ID with your own. const doc = DocumentApp.openById('123abc'); // Gets the active or first tab's body. const body = doc.getBody(); // Gets the body text and logs it to the console. console.log(body.getText());
리턴
Body - 탭 본문 섹션입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
get Bookmark(id)
첫 번째 탭 또는 문서에 바인드된 스크립트의 경우 활성 탭에서 지정된 ID의 Bookmark를 가져옵니다. 탭에서 북마크를 가져오려면 Document 메서드를 사용합니다. 이 메서드는 탭 내에 이러한 Bookmark이 없으면 null를 반환합니다.
// Opens the Docs file by its ID. If you created your script from within // a Google Docs file, you can use DocumentApp.getActiveDocument() instead. // TODO(developer): Replace the ID with your own. const doc = DocumentApp.openById('123abc'); // Gets the bookmark by its ID in the document's active or first tab. const bookmark = doc.getBookmark('id.xyz654321'); // If the bookmark exists, logs the character offset of its position to the // console. otherwise, logs 'No bookmark exists with the given ID.' to the // console. if (bookmark) { console.log(bookmark.getPosition().getOffset()); } else { console.log('No bookmark exists with the given ID.'); }
매개변수
| 이름 | 유형 | 설명 |
|---|---|---|
id | String | Bookmark의 ID입니다. |
리턴
Bookmark|null - 지정된 ID가 있는 Bookmark 또는 탭 내에 이러한 Bookmark이 없는 경우 null입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
get Bookmarks()
첫 번째 탭의 모든 Bookmark 객체를 가져오거나 문서에 바인딩된 스크립트의 경우 활성 탭의 모든 Bookmark 객체를 가져옵니다. 탭의 모든 북마크를 가져오려면 Document 메서드를 사용합니다.
// Opens the Docs file by its ID. If you created your script from within // a Google Docs file, you can use DocumentApp.getActiveDocument() instead. const doc = DocumentApp.openById('123abc'); // Gets all of the bookmarks in the document's active or first tab. const bookmarks = doc.getBookmarks(); // Logs the number of bookmarks in the tab to the console. console.log(bookmarks.length);
리턴
Bookmark[] - 탭에 있는 Bookmark 객체의 배열입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
get Cursor()
활성 탭에서 사용자의 커서를 가져옵니다. 스크립트는 스크립트를 실행하는 사용자의 커서에만 액세스할 수 있으며, 스크립트가 문서에 바인딩된 경우에만 가능합니다.
// Insert some text at the cursor position and make it bold. const cursor = DocumentApp.getActiveDocument().getCursor(); if (cursor) { // Attempt to insert text at the cursor position. If the insertion returns // null, the cursor's containing element doesn't allow insertions, so show the // user an error message. const element = cursor.insertText('ಠ‿ಠ'); if (element) { element.setBold(true); } else { DocumentApp.getUi().alert('Cannot insert text here.'); } } else { DocumentApp.getUi().alert('Cannot find a cursor.'); }
리턴
Position|null - 사용자의 커서를 나타냅니다. 사용자가 탭에 커서를 배치하지 않았거나 스크립트가 문서에 바인딩되지 않은 경우 null입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
get Editors()
get Footnotes()
첫 번째 탭의 본문에 있는 모든 Footnote 요소를 가져오거나 문서에 바인드된 스크립트의 경우 활성 탭의 본문에 있는 모든 Footnote 요소를 가져옵니다. 탭의 모든 각주를 가져오려면 Document 메서드를 사용합니다.
get 호출은 탭의 요소에 대한 반복을 유발합니다. 큰 탭의 경우 이 메서드를 불필요하게 호출하지 마세요.
// Opens the Docs file by its ID. If you created your script from within // a Google Docs file, you can use DocumentApp.getActiveDocument() instead. // TODO(developer): Replace the ID with your own. const doc = DocumentApp.openById('123abc'); // Gets the first footnote in the active or first tab's body. const footnote = doc.getFootnotes()[0]; // Logs footnote contents to the console. console.log(footnote.getFootnoteContents().getText());
리턴
Footnote[]|null - 탭의 각주입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
get Header()
첫 번째 탭의 헤더 섹션을 가져오거나 문서에 바인딩된 스크립트의 경우 활성 탭의 헤더 섹션을 가져옵니다. 탭의 헤더 섹션을 가져오려면 Document 메서드를 사용합니다.
// Opens the Docs file by its ID. If you created your script from within // a Google Docs file, you can use DocumentApp.getActiveDocument() instead. // TODO(developer): Replace the ID with your own. const doc = DocumentApp.openById('123abc'); // Gets the text of the active or first tab's header and logs it to the console. console.log(doc.getHeader().getText());
리턴
Header - 탭의 헤더입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
get Id()
문서의 고유 식별자를 가져옵니다. 문서 ID는 Document와 함께 사용하여 특정 문서 인스턴스를 엽니다.
리턴
String: 문서의 ID입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
get Language()
문서의 언어 코드를 가져옵니다. 문서 편집기의 파일 > 언어에 표시되는 언어입니다. 문서에 실제로 포함된 언어와 다를 수 있습니다.
리턴
String: 문서 언어입니다. 정의되지 않은 경우 null입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
get Name()
문서의 제목을 가져옵니다.
리턴
String: 문서 제목입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
get Named Range By Id(id)
첫 번째 탭 또는 문서에 바인드된 스크립트의 경우 활성 탭에서 지정된 ID의 Named를 가져옵니다. 탭에서 지정된 ID가 있는 Named를 가져오려면 Document 메서드를 사용합니다. 이 메서드는 탭에 이러한 Named이 없으면 null를 반환합니다. 이름은 탭 간에도 반드시 고유하지는 않습니다. 동일한 탭의 여러 범위가 HTML의 클래스와 마찬가지로 동일한 이름을 공유할 수 있습니다. 반면 ID는 HTML의 ID와 같이 탭 내에서 고유합니다.
매개변수
| 이름 | 유형 | 설명 |
|---|---|---|
id | String | 탭 내에서 고유한 범위의 ID입니다. |
리턴
Named - 지정된 ID가 있는 Named입니다. 탭에 이러한 범위가 없으면 null입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
get Named Ranges()
첫 번째 탭의 모든 Named 객체를 가져오거나 문서에 바인딩된 스크립트의 경우 활성 탭의 모든 Named 객체를 가져옵니다. 탭의 모든 Named 객체를 가져오려면 Document 메서드를 사용합니다.
Named는 탭에 액세스하는 모든 스크립트에서 액세스할 수 있습니다. 스크립트 간의 의도치 않은 충돌을 방지하려면 범위 이름에 고유한 문자열을 접두사로 추가하는 것이 좋습니다.
리턴
Named - 탭에 있는 Named 객체의 배열로, 이름이 같은 범위가 여러 개 포함될 수 있습니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
get Named Ranges(name)
첫 번째 탭에 있는 지정된 이름의 모든 Named 객체를 가져옵니다. 문서에 바인드된 스크립트의 경우 활성 탭에 있는 지정된 이름의 모든 Named 객체를 가져옵니다. 탭의 모든 Named 객체를 가져오려면 Document 메서드를 사용합니다. 이름은 탭 간에도 고유하지 않을 수 있습니다. 동일한 탭의 여러 범위가 HTML의 클래스와 마찬가지로 동일한 이름을 공유할 수 있습니다. 반면 ID는 HTML의 ID와 같이 탭 내에서 고유합니다.
Named는 문서에 액세스하는 모든 스크립트에서 액세스할 수 있습니다. 스크립트 간의 의도치 않은 충돌을 방지하려면 범위 이름에 고유한 문자열을 접두사로 추가하는 것이 좋습니다.
매개변수
| 이름 | 유형 | 설명 |
|---|---|---|
name | String | 범위의 이름입니다. 고유하지 않아도 됩니다. |
리턴
Named - 지정된 이름의 탭에 있는 Named 객체의 배열입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
get Selection()
활성 탭에서 사용자의 선택을 가져옵니다. 스크립트는 스크립트를 실행하는 사용자의 선택 항목에만 액세스할 수 있으며, 스크립트가 문서에 바인딩된 경우에만 액세스할 수 있습니다.
// Display a dialog box that tells the user how many elements are included in // the selection. const selection = DocumentApp.getActiveDocument().getSelection(); if (selection) { const elements = selection.getRangeElements(); DocumentApp.getUi().alert(`Number of selected elements: ${elements.length}`); } else { DocumentApp.getUi().alert('Nothing is selected.'); }
리턴
Range|null - 사용자의 선택을 나타냅니다. 사용자가 탭에서 선택한 항목이 없거나, 단락의 끝만 선택되었거나, 단락의 끝과 새 줄만 선택되었거나, 스크립트가 문서에 바인딩되지 않은 경우 null입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
get Supported Language Codes()
Google Docs 파일에서 지원되는 모든 언어 코드를 가져옵니다.
리턴
String[] - 언어 코드 배열입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
get Tab(tabId)
지정된 ID의 Tab를 가져옵니다. 이 메서드는 이러한 Tab가 없으면 null를 반환합니다. 모든 중첩 수준에서 탭에 액세스할 수 있습니다.
매개변수
| 이름 | 유형 | 설명 |
|---|---|---|
tab | String | 가져올 탭의 ID입니다. |
리턴
Tab - 지정된 ID가 있는 Tab 또는 이러한 Tab이 없는 경우 null
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
get Tabs()
문서에 포함된 모든 중첩되지 않은 Tab를 가져옵니다.
탭에는 하위 탭(다른 탭 내에 중첩된 탭)이 포함될 수 있습니다. Tab.getChildTabs()를 사용하여 하위 탭에 액세스할 수 있습니다.
리턴
Tab[] - 문서에 포함된 모든 Tab의 목록입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
get Url()
현재 문서에 액세스할 수 있는 URL을 가져옵니다.
const doc = DocumentApp.getActiveDocument(); // Send out the link to open the document. MailApp.sendEmail('<email-address>', doc.getName(), doc.getUrl());
리턴
String - 현재 문서에 액세스하는 URL입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
get Viewers()
new Position(element, offset)
첫 번째 탭의 특정 요소 또는 문서에 바인드된 스크립트의 경우 활성 탭을 기준으로 탭의 위치를 참조하는 새 Position를 만듭니다. 탭의 위치를 기준으로 Position를 만들려면 Document 메서드를 사용합니다. 사용자의 커서는 다른 용도와 함께 Position로 표시됩니다.
// Append a paragraph to the active tab, then place the user's cursor after the // first word of the new paragraph. const doc = DocumentApp.getActiveDocument(); const paragraph = doc.getBody().appendParagraph('My new paragraph.'); const position = doc.newPosition(paragraph.getChild(0), 2); doc.setCursor(position);
매개변수
| 이름 | 유형 | 설명 |
|---|---|---|
element | Element | 새 Position를 포함해야 하는 요소입니다. Text 요소 또는 Paragraph과 같은 컨테이너 요소여야 합니다. |
offset | Integer | Text 요소의 경우 Position 앞의 문자 수입니다. 다른 요소의 경우 동일한 컨테이너 요소 내에서 Position 앞의 하위 요소 수입니다. |
리턴
Position - 새 Position입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
new Range()
첫 번째 탭의 탭 요소 또는 문서에 바인드된 스크립트의 경우 활성 탭에서 Range 객체를 생성하는 데 사용되는 빌더를 만듭니다. 탭의 탭 요소에서 Document 객체를 생성하는 데 사용되는 빌더를 만들려면 Document 메서드를 사용하세요.
// Change the user's selection to a range that includes every table in the // active tab. const doc = DocumentApp.getActiveDocument(); const rangeBuilder = doc.newRange(); const tables = doc.getBody().getTables(); for (let i = 0; i < tables.length; i++) { rangeBuilder.addElement(tables[i]); } doc.setSelection(rangeBuilder.build());
리턴
Range - 새로운 빌더입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
remove Editor(emailAddress)
Document의 편집자 목록에서 지정된 사용자를 삭제합니다. 이 메서드는 일반 액세스 권한이 있는 사용자 클래스에 속한 경우 사용자가 Document에 액세스하는 것을 차단하지 않습니다. 예를 들어 Document이 사용자의 전체 도메인과 공유되거나 Document이 사용자가 액세스할 수 있는 공유 드라이브에 있는 경우입니다.
Drive 파일의 경우 보기 권한 사용자 목록에서도 사용자가 삭제됩니다.
매개변수
| 이름 | 유형 | 설명 |
|---|---|---|
email | String | 삭제할 사용자의 이메일 주소입니다. |
리턴
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
remove Editor(user)
Document의 편집자 목록에서 지정된 사용자를 삭제합니다. 이 메서드는 일반 액세스 권한이 있는 사용자 클래스에 속한 경우 사용자가 Document에 액세스하는 것을 차단하지 않습니다. 예를 들어 Document이 사용자의 전체 도메인과 공유되거나 Document이 사용자가 액세스할 수 있는 공유 드라이브에 있는 경우입니다.
Drive 파일의 경우 보기 권한 사용자 목록에서도 사용자가 삭제됩니다.
매개변수
| 이름 | 유형 | 설명 |
|---|---|---|
user | User | 삭제할 사용자를 나타냅니다. |
리턴
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
remove Viewer(emailAddress)
Document의 조회자 및 댓글 작성자 목록에서 지정된 사용자를 삭제합니다. 사용자가 뷰어나 댓글 작성자가 아닌 편집자인 경우 이 메서드는 아무런 영향을 미치지 않습니다. 또한 이 메서드는 일반 액세스 권한이 있는 사용자 클래스에 속한 경우 사용자가 Document에 액세스하는 것을 차단하지 않습니다. 예를 들어 Document이 사용자의 전체 도메인과 공유되거나 Document이 사용자가 액세스할 수 있는 공유 드라이브에 있는 경우입니다.
Drive 파일의 경우 편집자 목록에서도 사용자가 삭제됩니다.
매개변수
| 이름 | 유형 | 설명 |
|---|---|---|
email | String | 삭제할 사용자의 이메일 주소입니다. |
리턴
Document - 체이닝을 위한 Document입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
remove Viewer(user)
Document의 조회자 및 댓글 작성자 목록에서 지정된 사용자를 삭제합니다. 사용자가 뷰어가 아닌 편집자인 경우 이 메서드는 영향을 미치지 않습니다. 또한 이 방법은 일반 액세스 권한이 있는 사용자 클래스에 속한 사용자가 Document에 액세스하는 것을 차단하지 않습니다. 예를 들어 Document이 사용자의 전체 도메인과 공유되거나 Document이 사용자가 액세스할 수 있는 공유 드라이브에 있는 경우입니다.
Drive 파일의 경우 편집자 목록에서도 사용자가 삭제됩니다.
매개변수
| 이름 | 유형 | 설명 |
|---|---|---|
user | User | 삭제할 사용자를 나타냅니다. |
리턴
Document - 체이닝을 위한 Document입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
save And Close()
현재 Document을 저장합니다. 대기 중인 업데이트가 플러시되고 적용되도록 합니다.
save 메서드는 열려 있는 수정 가능한 각 Document의 스크립트 실행이 끝날 때 자동으로 호출됩니다.
종료된 Document은(는) 수정할 수 없습니다. Document를 사용하여 수정할 문서를 다시 엽니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
set Active Tab(tabId)
현재 문서에서 사용자가 선택한 Tab을 지정된 ID의 탭으로 설정합니다.
const doc = DocumentApp.getActiveDocument(); // Sets the user's selected tab by its ID. // TODO(developer): Replace the ID with your own. const tab = doc.setActiveTab('123abc');
매개변수
| 이름 | 유형 | 설명 |
|---|---|---|
tab | String | 활성으로 설정할 탭의 ID입니다. |
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
set Cursor(position)
Position가 지정된 경우 사용자의 커서를 설정합니다. 스크립트는 스크립트를 실행하는 사용자의 커서에만 액세스할 수 있으며, 스크립트가 문서에 바인드된 경우에만 가능합니다.
비활성 Tab에서 Position를 제공하면 사용자의 활성 탭이 전환됩니다.
const doc = DocumentApp.getActiveDocument(); const documentTab = doc.getActiveTab().asDocumentTab(); // Append a paragraph, then place the user's cursor after the first word of the // new paragraph. const paragraph = documentTab.getBody().appendParagraph('My new paragraph.'); const position = documentTab.newPosition(paragraph.getChild(0), 2); doc.setCursor(position);
매개변수
| 이름 | 유형 | 설명 |
|---|---|---|
position | Position | 새 커서 위치입니다. |
리턴
Document - 체이닝을 위한 이 Document
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
set Language(languageCode)
문서의 언어 코드를 설정합니다. 문서 편집기의 파일 > 언어에 표시되는 언어입니다. 문서에 실제로 포함된 언어와 다를 수 있습니다. get를 사용하여 유효한 언어 코드를 모두 가져옵니다.
매개변수
| 이름 | 유형 | 설명 |
|---|---|---|
language | String | 언어 코드입니다. |
리턴
Document - 체이닝을 위한 이 Document
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
set Name(name)
set Selection(range)
Range가 주어지면 활성 탭에서 사용자의 선택을 설정합니다. 스크립트는 스크립트를 실행하는 사용자의 선택 항목에만 액세스할 수 있으며, 스크립트가 문서에 바인딩된 경우에만 액세스할 수 있습니다.
const doc = DocumentApp.getActiveDocument(); const documentTab = doc.getActiveTab().asDocumentTab(); // Change the user's selection to a range that includes every table in the // document. const rangeBuilder = documentTab.newRange(); const tables = documentTab.getBody().getTables(); for (let i = 0; i < tables.length; i++) { rangeBuilder.addElement(tables[i]); } doc.setSelection(rangeBuilder.build());
매개변수
| 이름 | 유형 | 설명 |
|---|---|---|
range | Range | 선택할 요소의 새 범위입니다. |
리턴
Document - 체이닝을 위한 이 Document
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents