Google Sheets 파일에 액세스하고 수정합니다. 일반적인 작업은 새 시트 추가 및 공동작업자 추가입니다.
메서드
자세한 문서
add Developer Metadata(key)
지정된 키가 있는 개발자 메타데이터를 최상위 스프레드시트에 추가합니다.
// Opens the spreadsheet file by its URL. If you created your script from within // a Google Sheets file, you can use SpreadsheetApp.getActiveSpreadsheet() // instead. // TODO(developer): Replace the URL with your own. const ss = SpreadsheetApp.openByUrl( 'https://docs.google.com/spreadsheets/d/abc123456/edit', ); // Adds the key 'NAME' in the developer metadata for the spreadsheet. ss.addDeveloperMetadata('NAME'); // Gets the first developer metadata object and logs its key. const developerMetaData = ss.getDeveloperMetadata()[0]; console.log(developerMetaData.getKey());
매개변수
이름 | 유형 | 설명 |
---|---|---|
key | String | 새 개발자 메타데이터의 키입니다. |
리턴
Spreadsheet
- 이 스프레드시트(연결용)
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
add Developer Metadata(key, visibility)
지정된 키와 공개 상태를 사용하여 개발자 메타데이터를 스프레드시트에 추가합니다.
// Opens the spreadsheet file by its URL. If you created your script from within // a Google Sheets file, you can use SpreadsheetApp.getActiveSpreadsheet() // instead. // TODO(developer): Replace the URL with your own. const ss = SpreadsheetApp.openByUrl( 'https://docs.google.com/spreadsheets/d/abc123456/edit', ); // Adds the key 'NAME' in the developer metadata for the spreadsheet and sets // the visibility to the developer project that created the metadata. ss.addDeveloperMetadata( 'NAME', SpreadsheetApp.DeveloperMetadataVisibility.PROJECT, ); // Gets the first developer metadata object and logs its key and visibility // setting. const developerMetaData = ss.getDeveloperMetadata()[0]; console.log(developerMetaData.getKey()); console.log(`Key: ${developerMetaData.getKey()}, . Visibility: ${developerMetaData.getVisibility()}`);
매개변수
이름 | 유형 | 설명 |
---|---|---|
key | String | 새 개발자 메타데이터의 키입니다. |
visibility | Developer | 새 개발자 메타데이터의 공개 상태입니다. |
리턴
Spreadsheet
- 이 스프레드시트(연결용)
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
add Developer Metadata(key, value)
지정된 키와 값을 사용하여 개발자 메타데이터를 스프레드시트에 추가합니다.
// Opens the spreadsheet file by its URL. If you created your script from within // a Google Sheets file, you can use SpreadsheetApp.getActiveSpreadsheet() // instead. // TODO(developer): Replace the URL with your own. const ss = SpreadsheetApp.openByUrl( 'https://docs.google.com/spreadsheets/d/abc123456/edit', ); // Adds the key 'NAME' and sets the value to 'GOOGLE' in the developer metadata // for the spreadsheet. ss.addDeveloperMetadata('NAME', 'GOOGLE'); // Gets the first developer metadata object and logs its key and value. const developerMetaData = ss.getDeveloperMetadata()[0]; console.log(developerMetaData.getKey()); console.log( `Key: ${developerMetaData.getKey()}, Value: ${ developerMetaData.getValue()}`, );
매개변수
이름 | 유형 | 설명 |
---|---|---|
key | String | 새 개발자 메타데이터의 키입니다. |
value | String | 새 개발자 메타데이터의 값입니다. |
리턴
Spreadsheet
- 이 스프레드시트(연결용)
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
add Developer Metadata(key, value, visibility)
지정된 키, 값, 공개 상태를 사용하여 개발자 메타데이터를 스프레드시트에 추가합니다.
// Opens the spreadsheet file by its URL. If you created your script from within // a Google Sheets file, you can use SpreadsheetApp.getActiveSpreadsheet() // instead. // TODO(developer): Replace the URL with your own. const ss = SpreadsheetApp.openByUrl( 'https://docs.google.com/spreadsheets/d/abc123456/edit', ); // Adds the key 'NAME', sets the value to 'GOOGLE', and sets the visibility // to any developer project with document access. ss.addDeveloperMetadata( 'NAME', 'GOOGLE', SpreadsheetApp.DeveloperMetadataVisibility.DOCUMENT, ); // Gets the first developer metadata object and logs its key, value, and // visibility setting. const developerMetaData = ss.getDeveloperMetadata()[0]; console.log(`Key: ${developerMetaData.getKey()}, Value: ${developerMetaData.getValue()}, Visibility: ${developerMetaData.getVisibility()}`);
매개변수
이름 | 유형 | 설명 |
---|---|---|
key | String | 새 개발자 메타데이터의 키입니다. |
value | String | 새 개발자 메타데이터의 값입니다. |
visibility | Developer | 새 개발자 메타데이터의 공개 상태입니다. |
리턴
Spreadsheet
- 이 스프레드시트(연결용)
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
add Editor(emailAddress)
지정된 사용자를 Spreadsheet
의 편집자 목록에 추가합니다. 사용자가 이미 시청자 목록에 있는 경우 이 메서드는 사용자를 시청자 목록에서 승격합니다.
매개변수
이름 | 유형 | 설명 |
---|---|---|
email | String | 추가할 사용자의 이메일 주소입니다. |
리턴
Spreadsheet
- 체이닝을 위한 이 Spreadsheet
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
add Editor(user)
지정된 사용자를 Spreadsheet
의 편집자 목록에 추가합니다. 사용자가 이미 시청자 목록에 있는 경우 이 메서드는 사용자를 시청자 목록에서 승격합니다.
매개변수
이름 | 유형 | 설명 |
---|---|---|
user | User | 추가할 사용자를 나타냅니다. |
리턴
Spreadsheet
- 체이닝을 위한 이 Spreadsheet
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
add Editors(emailAddresses)
지정된 사용자 배열을 Spreadsheet
의 편집자 목록에 추가합니다. 사용자가 이미 시청자 목록에 있는 경우 이 메서드는 시청자 목록에서 사용자를 승격합니다.
매개변수
이름 | 유형 | 설명 |
---|---|---|
email | String[] | 추가할 사용자의 이메일 주소 배열입니다. |
리턴
Spreadsheet
- 체이닝을 위한 이 Spreadsheet
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
add Menu(name, subMenus)
스프레드시트 UI에 새 메뉴를 만듭니다.
각 메뉴 항목은 사용자 정의 함수를 실행합니다. 일반적으로 스프레드시트가 로드될 때 메뉴가 자동으로 생성되도록 on
함수에서 호출하는 것이 좋습니다.
// The onOpen function is executed automatically every time a Spreadsheet is // loaded function onOpen() { const ss = SpreadsheetApp.getActiveSpreadsheet(); const menuEntries = []; // When the user clicks on "addMenuExample" then "Menu Entry 1", the function // function1 is executed. menuEntries.push({name: 'Menu Entry 1', functionName: 'function1'}); menuEntries.push(null); // line separator menuEntries.push({name: 'Menu Entry 2', functionName: 'function2'}); ss.addMenu('addMenuExample', menuEntries); }
매개변수
이름 | 유형 | 설명 |
---|---|---|
name | String | 만들려는 메뉴의 이름입니다. |
sub | Object[] | name 및 function 매개변수가 있는 JavaScript 지도의 배열입니다. Library.libFunction1 와 같은 포함된 라이브러리의 함수를 사용할 수 있습니다. |
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
add Viewer(emailAddress)
지정된 사용자를 Spreadsheet
의 보기 권한 사용자 목록에 추가합니다. 사용자가 이미 편집자 목록에 있는 경우 이 메서드는 아무런 영향을 미치지 않습니다.
매개변수
이름 | 유형 | 설명 |
---|---|---|
email | String | 추가할 사용자의 이메일 주소입니다. |
리턴
Spreadsheet
- 체이닝을 위한 이 Spreadsheet
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
add Viewer(user)
지정된 사용자를 Spreadsheet
의 보기 권한 사용자 목록에 추가합니다. 사용자가 이미 편집자 목록에 있는 경우 이 메서드는 아무런 영향을 미치지 않습니다.
매개변수
이름 | 유형 | 설명 |
---|---|---|
user | User | 추가할 사용자를 나타냅니다. |
리턴
Spreadsheet
- 체이닝을 위한 이 Spreadsheet
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
add Viewers(emailAddresses)
지정된 사용자 배열을 Spreadsheet
의 보기 권한 사용자 목록에 추가합니다. 사용자가 이미 편집자 목록에 있는 경우 이 메서드는 영향을 미치지 않습니다.
매개변수
이름 | 유형 | 설명 |
---|---|---|
email | String[] | 추가할 사용자의 이메일 주소 배열입니다. |
리턴
Spreadsheet
- 체이닝을 위한 이 Spreadsheet
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
append Row(rowContents)
시트의 현재 데이터 리전 하단에 행을 추가합니다. 셀의 콘텐츠가 =
로 시작되면 수식으로 해석됩니다.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; // Appends a new row with 3 columns to the bottom of the current // data region in the sheet containing the values in the array. sheet.appendRow(['a man', 'a plan', 'panama']);
매개변수
이름 | 유형 | 설명 |
---|---|---|
row | Object[] | 시트의 마지막 행 뒤에 삽입할 값의 배열입니다. |
리턴
Sheet
- 메서드 연결에 유용한 시트입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
auto Resize Column(columnPosition)
주어진 열의 너비를 콘텐츠에 맞게 설정합니다.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; sheet.getRange('a1').setValue( 'Whenever it is a damp, drizzly November in my soul...'); // Sets the first column to a width which fits the text sheet.autoResizeColumn(1);
매개변수
이름 | 유형 | 설명 |
---|---|---|
column | Integer | 크기를 조정할 지정된 열의 위치입니다. |
리턴
Sheet
- 메서드 연결에 유용한 시트입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
copy(name)
스프레드시트를 복사하고 새 스프레드시트를 반환합니다.
// This code makes a copy of the current spreadsheet and names it appropriately const ss = SpreadsheetApp.getActiveSpreadsheet(); ss.copy(`Copy of ${ss.getName()}`);
매개변수
이름 | 유형 | 설명 |
---|---|---|
name | String | 사본의 이름입니다. |
리턴
Spreadsheet
- 이 스프레드시트(연결용)
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
create Developer Metadata Finder()
이 스프레드시트 범위 내에서 개발자 메타데이터를 찾는 Developer
를 반환합니다. 기본적으로 스프레드시트, 시트, 행, 열과 연결된 모든 메타데이터가 고려됩니다.
// Opens the spreadsheet file by its URL. If you created your script from within // a Google Sheets file, you can use SpreadsheetApp.getActiveSpreadsheet() // instead. // TODO(developer): Replace the URL with your own. const ss = SpreadsheetApp.openByUrl( 'https://docs.google.com/spreadsheets/d/abc123456/edit', ); // Adds developer metadata to the spreadsheet. ss.addDeveloperMetadata('NAME', 'CHARLIE'); ss.addDeveloperMetadata('COMPANY', 'EXAMPLE ORGANIZATION'); ss.addDeveloperMetadata('TECHNOLOGY', 'JAVASCRIPT'); // Creates a developer metadata finder. const developerMetadataFinder = ss.createDeveloperMetadataFinder(); // Finds the developer metadata objects with 'COMPANY' as the key. const googleMetadataFromSpreadsheet = developerMetadataFinder.withKey('COMPANY').find(); // Gets the first result of developer metadata that has the key 'COMPANY' and // logs its value. console.log(googleMetadataFromSpreadsheet[0].getValue());
리턴
Developer
- 이 스프레드시트 범위의 메타데이터를 검색하는 개발자 메타데이터 검색기입니다.
create Text Finder(findText)
스프레드시트의 텍스트 찾기를 만듭니다. 이 텍스트 찾기는 스프레드시트 내에서 텍스트를 찾고 바꾸는 데 사용할 수 있습니다. 검색은 스프레드시트의 첫 번째 시트에서 시작됩니다.
const spreadsheet = SpreadsheetApp.getActiveSpreadsheet(); // Creates a text finder. const textFinder = spreadsheet.createTextFinder('dog'); // Returns the first occurrence of 'dog' in the spreadsheet. const firstOccurrence = textFinder.findNext(); // Replaces the last found occurrence of 'dog' with 'cat' and returns the number // of occurrences replaced. const numOccurrencesReplaced = textFinder.replaceWith('cat');
매개변수
이름 | 유형 | 설명 |
---|---|---|
find | String | 검색할 텍스트입니다. |
리턴
Text
- 스프레드시트의 Text
입니다.
delete Active Sheet()
현재 활성 시트를 삭제합니다.
// The code below deletes the currently active sheet and stores the new active // sheet in a variable const newSheet = SpreadsheetApp.getActiveSpreadsheet().deleteActiveSheet();
리턴
Sheet
- 새로 활성화된 시트입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
delete Column(columnPosition)
지정된 열 위치의 열을 삭제합니다.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; // Columns start at "1" - this deletes the first column sheet.deleteColumn(1);
매개변수
이름 | 유형 | 설명 |
---|---|---|
column | Integer | 열의 위치입니다. 첫 번째 열은 1부터 시작합니다. |
리턴
Sheet
- 메서드 연결에 유용한 시트입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
delete Columns(columnPosition, howMany)
지정된 열 위치에서 시작하는 여러 열을 삭제합니다.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; // Columns start at "1" - this deletes the first two columns sheet.deleteColumns(1, 2);
매개변수
이름 | 유형 | 설명 |
---|---|---|
column | Integer | 삭제할 첫 번째 열의 위치입니다. |
how | Integer | 삭제할 열 수입니다. |
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
delete Row(rowPosition)
지정된 행 위치의 행을 삭제합니다.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; // Rows start at "1" - this deletes the first row sheet.deleteRow(1);
매개변수
이름 | 유형 | 설명 |
---|---|---|
row | Integer | 행의 위치입니다. 첫 번째 행은 1부터 시작합니다. |
리턴
Sheet
- 메서드 연결에 유용한 시트입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
delete Rows(rowPosition, howMany)
지정된 행 위치에서 시작하는 여러 행을 삭제합니다.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; // Rows start at "1" - this deletes the first two rows sheet.deleteRows(1, 2);
매개변수
이름 | 유형 | 설명 |
---|---|---|
row | Integer | 삭제할 첫 번째 행의 위치입니다. |
how | Integer | 삭제할 행 수입니다. |
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
delete Sheet(sheet)
지정된 시트를 삭제합니다.
// The code below deletes the specified sheet. const ss = SpreadsheetApp.getActive(); const sheet = ss.getSheetByName('My Sheet'); ss.deleteSheet(sheet);
매개변수
이름 | 유형 | 설명 |
---|---|---|
sheet | Sheet | 삭제할 시트입니다. |
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
duplicate Active Sheet()
활성 시트를 복제하여 활성 시트로 만듭니다.
// The code below makes a duplicate of the active sheet SpreadsheetApp.getActiveSpreadsheet().duplicateActiveSheet();
리턴
Sheet
- 새 시트입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
get Active Cell()
이 시트의 활성 셀을 반환합니다.
참고: 현재 강조 표시된 셀을 반환하는 get
을 사용하는 것이 좋습니다.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; // Returns the active cell const cell = sheet.getActiveCell();
리턴
Range
- 현재 활성 셀입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
get Active Range()
활성 시트에서 선택된 범위를 반환합니다. 활성 범위가 없으면 null
를 반환합니다. 범위가 여러 개 선택된 경우 이 메서드는 마지막으로 선택된 범위만 반환합니다.
'활성 범위'는 사용자가 활성 시트에서 선택한 범위를 의미하지만, 맞춤 함수에서는 활발하게 재계산되는 셀을 의미합니다.
const sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet(); const activeRange = sheet.getActiveRange();
리턴
Range
- 활성 범위입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
참고 항목
get Active Range List()
활성 시트의 활성 범위 목록을 반환하거나 활성 범위가 없는 경우 null
를 반환합니다.
선택된 범위가 하나인 경우 get
호출로 작동합니다.
const sheet = SpreadsheetApp.getActiveSheet(); // Returns the list of active ranges. const activeRangeList = sheet.getActiveRangeList();
리턴
Range
- 활성 범위 목록입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
참고 항목
get Active Sheet()
스프레드시트의 활성 시트를 가져옵니다.
스프레드시트의 활성 시트는 스프레드시트 UI에 표시되는 시트입니다.
const sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
리턴
Sheet
- 스프레드시트의 활성 시트입니다.
get As(contentType)
이 객체 내의 데이터를 지정된 콘텐츠 유형으로 변환된 blob으로 반환합니다. 이 메서드는 파일 이름에 적절한 확장자(예: 'myfile.pdf')를 추가합니다. 하지만 마지막 마침표 뒤에 오는 파일 이름 부분이 대체해야 하는 기존 확장 프로그램이라고 가정합니다. 따라서 'ShoppingList.12.25.2014'는 'ShoppingList.12.25.pdf'가 됩니다.
전환의 일일 할당량을 보려면 Google 서비스 할당량을 참고하세요. 새로 생성된 Google Workspace 도메인에는 일시적으로 더 엄격한 할당량이 적용될 수 있습니다.
매개변수
이름 | 유형 | 설명 |
---|---|---|
content | String | 변환할 MIME 유형입니다. 대부분의 블롭의 경우 'application/pdf' 만 사용할 수 있습니다. BMP, GIF, JPEG 또는 PNG 형식의 이미지의 경우 'image/bmp' , 'image/gif' , 'image/jpeg' 또는 'image/png' 도 유효합니다. Google Docs 문서의 경우 'text/markdown' 도 유효합니다. |
리턴
Blob
- 데이터를 blob으로 나타냅니다.
get Bandings()
이 스프레드시트의 모든 밴딩을 반환합니다.
// Opens the spreadsheet file by its URL. If you created your script from within // a Google Sheets spreadsheet, you can use // SpreadsheetApp.getActiveSpreadsheet() instead. // TODO(developer): Replace the URL with your own. const ss = SpreadsheetApp.openByUrl( 'https://docs.google.com/spreadsheets/d/abc123456/edit', ); // Gets an array of the bandings in the spreadsheet. const bandings = ss.getBandings(); // Logs the range of the first banding in the spreadsheet to the console. console.log(bandings[0].getRange().getA1Notation());
리턴
Banding[]
- 이 스프레드시트의 밴딩입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
get Blob()
get Column Width(columnPosition)
지정된 열의 너비(픽셀)를 가져옵니다.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; // Columns start at 1 Logger.log(sheet.getColumnWidth(1));
매개변수
이름 | 유형 | 설명 |
---|---|---|
column | Integer | 검사할 열의 위치입니다. |
리턴
Integer
- 열 너비(픽셀)입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
get Current Cell()
활성 시트의 현재 셀을 반환하거나 현재 셀이 없는 경우 null
을 반환합니다. 현재 셀은 Google Sheets UI에서 포커스가 있는 셀이며 어두운 테두리로 강조 표시됩니다. 현재 셀은 항상 하나만 있습니다. 사용자가 하나 이상의 셀 범위를 선택하면 선택한 셀 중 하나가 현재 셀입니다.
const sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet(); // Returns the current highlighted cell in the one of the active ranges. const currentCell = sheet.getCurrentCell();
리턴
Range
- 현재 셀
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
get Data Range()
데이터가 있는 측정기준에 해당하는 Range
를 반환합니다.
이는 A1과 (Sheet.getLastColumn(), Sheet.getLastRow())로 제한된 범위를 만드는 것과 기능적으로 동일합니다.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; // This represents ALL the data const range = sheet.getDataRange(); const values = range.getValues(); // This logs the spreadsheet in CSV format with a trailing comma for (let i = 0; i < values.length; i++) { let row = ''; for (let j = 0; j < values[i].length; j++) { if (values[i][j]) { row = row + values[i][j]; } row = `${row},`; } Logger.log(row); }
리턴
Range
- 스프레드시트의 모든 데이터로 구성된 범위입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
get Data Source Formulas()
모든 데이터 소스 수식을 가져옵니다.
// Opens the spreadsheet by its ID. If you created your script from within a // Google Sheets file, use SpreadsheetApp.getActiveSpreadsheet(). // TODO(developer): Replace the ID with your own. const ss = SpreadsheetApp.openById('abc123456'); // Gets Sheet1 by its name. const sheet = ss.getSheetByName('Sheet1'); // Gets an array of the data source formulas on Sheet1. // To get an array of data source formulas for the entire spreadsheet, // replace 'sheet' with 'ss'. const dataSourceFormulas = sheet.getDataSourceFormulas(); // Logs the first data source formula in the array. console.log(dataSourceFormulas[0].getFormula());
리턴
Data
- 데이터 소스 공식 목록입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
get Data Source Pivot Tables()
모든 데이터 소스 피벗 테이블을 가져옵니다.
// Opens the spreadsheet file by its ID. If you created your script from a // Google Sheets file, use SpreadsheetApp.getActiveSpreadsheet(). // TODO(developer): Replace the ID with your own. const ss = SpreadsheetApp.openById('abc123456'); // Gets Sheet1 by its name. const sheet = ss.getSheetByName('Sheet1'); // Gets an array of the data source pivot tables on Sheet1. // To get an array of data source pivot tables for the entire // spreadsheet, replace 'sheet' with 'ss'. const dataSourcePivotTables = sheet.getDataSourcePivotTables(); // Logs the last time that the first pivot table in the array was refreshed. console.log(dataSourcePivotTables[0].getStatus().getLastRefreshedTime());
리턴
Data
- 데이터 소스 피벗 테이블 목록입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
get Data Source Refresh Schedules()
이 스프레드시트의 새로고침 일정을 가져옵니다.
// Opens the spreadsheet file by its URL. If you created your script from within // a Google Sheets file, you can use SpreadsheetApp.getActiveSpreadsheet() // instead. // TODO(developer): Replace the URL with your own. const ss = SpreadsheetApp.openByUrl( 'https://docs.google.com/spreadsheets/d/abc123456/edit', ); // Activates BigQuery operations for the connected spreadsheet. SpreadsheetApp.enableBigQueryExecution(); // Gets the frequency type of the first referesh schedule in the array. const frequencyType = ss.getDataSourceRefreshSchedules()[0] .getFrequency() .getFrequencyType() .toString(); // Logs the frequency type to the console. console.log(frequencyType);
리턴
Data
- 이 스프레드시트의 새로고침 일정입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
get Data Source Sheets()
스프레드시트의 모든 데이터 소스 시트를 반환합니다.
// Turns data execution on for BigQuery data sources. SpreadsheetApp.enableBigQueryExecution(); // Opens the spreadsheet file by its URL. If you created your script from within // a Google Sheets spreadsheet, you can use // SpreadsheetApp.getActiveSpreadsheet() instead. // TODO(developer): Replace the URL with your own. const ss = SpreadsheetApp.openByUrl( 'https://docs.google.com/spreadsheets/d/abc123456/edit', ); // Gets the first data source sheet in the spreadsheet. const dataSource = ss.getDataSourceSheets()[0]; // Gets the name of the data source sheet. console.log(dataSource.asSheet().getName());
리턴
Data
- 모든 데이터 소스 시트의 배열입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
get Data Source Tables()
모든 데이터 소스 테이블을 가져옵니다.
// Opens the spreadsheet file by its ID. If you created your script from a // Google Sheets file, use SpreadsheetApp.getActiveSpreadsheet(). // TODO(developer): Replace the ID with your own. const ss = SpreadsheetApp.openById('abc123456'); // Gets Sheet1 by its name. const sheet = ss.getSheetByName('Sheet1'); // Gets an array of data source tables on Sheet1. // To get an array of data source tables for the entire spreadsheet, // replace 'sheet' with 'ss'. const dataSourceTables = sheet.getDataSourceTables(); // Logs the last completed data execution time on the first data source table. console.log(dataSourceTables[0].getStatus().getLastExecutionTime());
리턴
Data
- 데이터 소스 테이블 목록입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
get Data Sources()
스프레드시트의 모든 데이터 소스를 반환합니다.
// Turns data execution on for BigQuery data sources. SpreadsheetApp.enableBigQueryExecution(); // Opens the spreadsheet file by its URL. If you created your script from within // a Google Sheets spreadsheet, you can use // SpreadsheetApp.getActiveSpreadsheet() instead. // TODO(developer): Replace the URL with your own. const ss = SpreadsheetApp.openByUrl( 'https://docs.google.com/spreadsheets/d/abc123456/edit', ); // Gets the data sources on the spreadsheet. const dataSources = ss.getDataSources(); // Logs the name of the first column on the first data source. console.log(dataSources[0].getColumns()[0].getName());
리턴
Data
- 모든 데이터 소스의 배열입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
get Developer Metadata()
최상위 스프레드시트와 연결된 개발자 메타데이터를 가져옵니다.
// Opens the spreadsheet file by its URL. If you created your script from within // a Google Sheets spreadsheet, you can use // SpreadsheetApp.getActiveSpreadsheet() instead. // TODO(developer): Replace the URL with your own. const ss = SpreadsheetApp.openByUrl( 'https://docs.google.com/spreadsheets/d/abc123456/edit', ); // Adds 'Google' as a key to the spreadsheet metadata. ss.addDeveloperMetadata('Google'); // Gets the spreadsheet's metadata. const ssMetadata = ss.getDeveloperMetadata(); // Gets the first set of the spreadsheet's metadata and logs the key to the // console. console.log(ssMetadata[0].getKey());
리턴
Developer
- 이 범위와 연결된 개발자 메타데이터입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
get Editors()
이 Spreadsheet
의 편집자 목록을 가져옵니다.
리턴
User[]
- 수정 권한이 있는 사용자의 배열입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
get Form Url()
이 스프레드시트로 응답을 전송하는 양식의 URL을 반환합니다. 이 스프레드시트에 연결된 양식이 없는 경우 null
을 반환합니다. 여러 양식에서 이 스프레드시트로 응답을 보내는 경우 반환되는 양식 URL은 정해져 있지 않습니다. 또는 시트별 양식 URL 연결을 Sheet.getFormUrl()
메서드를 통해 검색할 수 있습니다. 사용자에게 스프레드시트를 수정할 권한이 없는 경우 예외를 발생시킵니다.
// Opens the spreadsheet file by its URL. If you created your script from within // a Google Sheets spreadsheet, you can use // SpreadsheetApp.getActiveSpreadsheet() instead. // TODO(developer): Replace the URL with your own. const ss = SpreadsheetApp.openByUrl( 'https://docs.google.com/spreadsheets/d/abc123456/edit', ); // Gets the form URL from the spreadsheet. const formUrl = ss.getFormUrl(); // Logs the form URL to the console. console.log(formUrl);
리턴
String
- 이 스프레드시트에 응답을 배치하는 양식의 URL입니다. 이 스프레드시트에 연결된 양식이 없는 경우 null
입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
get Frozen Columns()
고정된 열의 수를 반환합니다.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; Logger.log('Number of frozen columns: %s', sheet.getFrozenColumns());
리턴
Integer
: 고정된 열의 수입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
get Frozen Rows()
고정된 행 수를 반환합니다.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; Logger.log('Number of frozen rows: %s', sheet.getFrozenRows());
리턴
Integer
- 고정된 행 수입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
get Id()
이 스프레드시트의 고유 식별자를 가져옵니다. 스프레드시트 ID는 URL에서 추출할 수 있습니다. 예를 들어 URL https://docs.google.com/spreadsheets/d/abc1234567/edit#gid=0의 스프레드시트 ID는 'abc1234567'입니다.
// The code below logs the ID for the active spreadsheet. Logger.log(SpreadsheetApp.getActiveSpreadsheet().getId());
리턴
String
- 스프레드시트의 고유 ID (또는 키)입니다.
get Images()
시트의 모든 그리드 외부 이미지를 반환합니다.
// Opens the spreadsheet file by its URL. If you created your script from within // a Google Sheets spreadsheet, you can use // SpreadsheetApp.getActiveSpreadsheet() instead. // TODO(developer): Replace the URL with your own. const ss = SpreadsheetApp.openByUrl( 'https://docs.google.com/spreadsheets/d/abc123456/edit', ); // Gets Sheet1 by its name. const sheet = ss.getSheetByName('Sheet1'); // Gets the over-the-grid images from Sheet1. // To get the over-the-grid images from the entire spreadsheet, use // ss.getImages() instead. const images = sheet.getImages(); // For each image, logs the anchor cell in A1 notation. for (const image of images) { console.log(image.getAnchorCell().getA1Notation()); }
리턴
Over
- 그리드 위 이미지의 배열입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
get Iterative Calculation Convergence Threshold()
반복 계산 중에 사용된 기준값을 반환합니다. 연속 계산 결과의 차이가 이 값보다 작으면 반복 계산이 중지됩니다.
// Opens the spreadsheet file by its URL. If you created your script from within // a Google Sheets spreadsheet, you can use // SpreadsheetApp.getActiveSpreadsheet() instead. // TODO(developer): Replace the URL with your own. const ss = SpreadsheetApp.openByUrl( 'https://docs.google.com/spreadsheets/d/abc123456/edit', ); // Sets the iterative calculation convergence threshold for the spreadsheet. ss.setIterativeCalculationConvergenceThreshold(2); // Logs the threshold to the console. console.log(ss.getIterativeCalculationConvergenceThreshold());
리턴
Number
- 수렴 기준입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
get Last Column()
콘텐츠가 있는 마지막 열의 위치를 반환합니다.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; // This logs the value in the very last cell of this sheet const lastRow = sheet.getLastRow(); const lastColumn = sheet.getLastColumn(); const lastCell = sheet.getRange(lastRow, lastColumn); Logger.log(lastCell.getValue());
리턴
Integer
- 콘텐츠가 포함된 시트의 마지막 열입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
get Last Row()
콘텐츠가 있는 마지막 행의 위치를 반환합니다.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; // This logs the value in the very last cell of this sheet const lastRow = sheet.getLastRow(); const lastColumn = sheet.getLastColumn(); const lastCell = sheet.getRange(lastRow, lastColumn); Logger.log(lastCell.getValue());
리턴
Integer
- 콘텐츠가 포함된 시트의 마지막 행입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
get Max Iterative Calculation Cycles()
반복 계산 중에 사용할 최대 반복 횟수를 반환합니다.
// Opens the spreadsheet file by its URL. If you created your script from within // a Google Sheets spreadsheet, you can use // SpreadsheetApp.getActiveSpreadsheet() instead. // TODO(developer): Replace the URL with your own. const ss = SpreadsheetApp.openByUrl( 'https://docs.google.com/spreadsheets/d/abc123456/edit', ); // Sets the max iterative calculation cycles for the spreadsheet. ss.setMaxIterativeCalculationCycles(10); // Logs the max iterative calculation cycles to the console. console.log(ss.getMaxIterativeCalculationCycles());
리턴
Integer
- 계산 반복의 최대 수입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
get Name()
문서의 이름을 가져옵니다.
const ss = SpreadsheetApp.getActiveSpreadsheet(); Logger.log(ss.getName());
리턴
String
- 스프레드시트의 이름입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
get Named Ranges()
이 스프레드시트의 모든 이름이 지정된 범위를 가져옵니다.
// The code below logs the name of the first named range. const namedRanges = SpreadsheetApp.getActiveSpreadsheet().getNamedRanges(); for (let i = 0; i < namedRanges.length; i++) { Logger.log(namedRanges[i].getName()); }
리턴
Named
- 스프레드시트의 모든 이름이 지정된 범위의 배열입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
get Num Sheets()
이 스프레드시트의 시트 수를 반환합니다.
// The code below logs the number of sheets in the active spreadsheet. Logger.log(SpreadsheetApp.getActiveSpreadsheet().getNumSheets());
리턴
Integer
- 스프레드시트의 시트 수입니다.
get Owner()
문서의 소유자를 반환합니다. 공유 드라이브에 있는 문서의 경우 null
를 반환합니다.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const owner = ss.getOwner(); Logger.log(owner.getEmail());
리턴
User
- 문서의 소유자 또는 문서가 공유 드라이브에 있는 경우 null
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
get Predefined Spreadsheet Themes()
사전 정의된 테마 목록을 반환합니다.
// The code below returns the list of predefined themes. const predefinedThemesList = SpreadsheetApp.getActiveSpreadsheet().getPredefinedSpreadsheetThemes();
리턴
Spreadsheet
- 사전 정의된 테마 목록입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
get Protections(type)
스프레드시트의 모든 보호 범위 또는 시트를 나타내는 객체의 배열을 가져옵니다.
// Remove all range protections in the spreadsheet that the user has permission // to edit. const ss = SpreadsheetApp.getActive(); const protections = ss.getProtections(SpreadsheetApp.ProtectionType.RANGE); for (let i = 0; i < protections.length; i++) { const protection = protections[i]; if (protection.canEdit()) { protection.remove(); } }
// Remove all sheet protections in the spreadsheet that the user has permission // to edit. const ss = SpreadsheetApp.getActive(); const protections = ss.getProtections(SpreadsheetApp.ProtectionType.SHEET); for (let i = 0; i < protections.length; i++) { const protection = protections[i]; if (protection.canEdit()) { protection.remove(); } }
매개변수
이름 | 유형 | 설명 |
---|---|---|
type | Protection | 보호된 영역의 유형입니다(Spreadsheet 또는 Spreadsheet ). |
리턴
Protection[]
- 스프레드시트의 모든 보호 범위 또는 시트를 나타내는 객체의 배열입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
get Range(a1Notation)
범위를 A1 표기법 또는 R1C1 표기법으로 지정하여 반환합니다.
// Get a range A1:D4 on sheet titled "Invoices" const ss = SpreadsheetApp.getActiveSpreadsheet(); const range = ss.getRange('Invoices!A1:D4'); // Get cell A1 on the first sheet const sheet = ss.getSheets()[0]; const cell = sheet.getRange('A1');
매개변수
이름 | 유형 | 설명 |
---|---|---|
a1Notation | String | 반환할 범위입니다(A1 표기법 또는 R1C1 표기법으로 지정됨). |
리턴
Range
- 지정된 위치의 범위입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
get Range By Name(name)
이름이 지정된 범위를 반환하거나 지정된 이름의 범위가 없는 경우 null
을 반환합니다. 스프레드시트의 여러 시트에서 동일한 범위 이름을 사용하는 경우 추가 따옴표 없이 시트 이름을 지정합니다(예: get
또는 get
, get
아님).
// Log the number of columns for the range named 'TaxRates' in the active // spreadsheet. const range = SpreadsheetApp.getActiveSpreadsheet().getRangeByName('TaxRates'); if (range != null) { Logger.log(range.getNumColumns()); }
매개변수
이름 | 유형 | 설명 |
---|---|---|
name | String | 가져올 범위의 이름입니다. |
리턴
Range
- 지정된 이름이 있는 셀 범위입니다.
get Range List(a1Notations)
비어 있지 않은 A1 표기법 또는 R1C1 표기법 목록으로 지정된 동일한 시트의 범위를 나타내는 Range
컬렉션을 반환합니다.
// Get a list of ranges A1:D4, F1:H4. const sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet(); const rangeList = sheet.getRangeList(['A1:D4', 'F1:H4']);
매개변수
이름 | 유형 | 설명 |
---|---|---|
a1Notations | String[] | 반환할 범위 목록입니다(A1 표기법 또는 R1C1 표기법으로 지정됨). |
리턴
Range
- 지정된 위치의 범위 목록입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
get Recalculation Interval()
이 스프레드시트의 계산 간격을 반환합니다.
// Opens the spreadsheet file by its URL. If you created your script from within // a Google Sheets spreadsheet, you can use // SpreadsheetApp.getActiveSpreadsheet() instead. // TODO(developer): Replace the URL with your own. const ss = SpreadsheetApp.openByUrl( 'https://docs.google.com/spreadsheets/d/abc123456/edit', ); // Logs the calculation interval for the spreadsheet to the console. console.log(ss.getRecalculationInterval().toString());
리턴
Recalculation
- 이 스프레드시트의 계산 간격입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
get Row Height(rowPosition)
지정된 행의 높이(픽셀)를 가져옵니다.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; // Rows start at 1 Logger.log(sheet.getRowHeight(1));
매개변수
이름 | 유형 | 설명 |
---|---|---|
row | Integer | 검사할 행의 위치입니다. |
리턴
Integer
- 행 높이(픽셀)입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
get Selection()
스프레드시트의 현재 Selection
을 반환합니다.
const selection = SpreadsheetApp.getActiveSpreadsheet().getSelection(); const currentCell = selection.getCurrentCell();
리턴
Selection
: 현재 선택 항목입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
get Sheet By Id(id)
지정된 ID의 시트를 가져옵니다. Sheet.getSheetId()
을 사용합니다.
const sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetById(12345);
매개변수
이름 | 유형 | 설명 |
---|---|---|
id | Integer | 가져올 시트의 ID입니다. |
리턴
Sheet
- 지정된 ID의 시트 또는 시트를 찾을 수 없는 경우 null
get Sheet By Name(name)
지정된 이름의 시트를 반환합니다.
이름이 같은 시트가 여러 개 있으면 가장 왼쪽에 있는 시트가 반환됩니다. 지정된 이름의 시트가 없으면 null
를 반환합니다.
// The code below logs the index of a sheet named "Expenses" const sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Expenses'); if (sheet != null) { Logger.log(sheet.getIndex()); }
매개변수
이름 | 유형 | 설명 |
---|---|---|
name | String | 가져올 시트의 이름입니다. |
리턴
Sheet
- 지정된 이름의 시트입니다.
get Sheet Id()
이 객체로 표현되는 시트의 ID를 반환합니다.
스프레드시트에서 고유한 시트의 ID입니다. ID는 시트 생성 시간에 할당되며 시트 위치와는 독립적인 단조 증가 정수입니다. 이는 Sheet
인스턴스 대신 grid
매개변수를 사용하는 Range.copyFormatToRange(gridId, column, columnEnd, row, rowEnd)
와 같은 메서드와 함께 유용합니다.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; Logger.log(sheet.getSheetId());
리턴
Integer
- 스프레드시트에 고유한 시트의 ID입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
get Sheet Name()
시트 이름을 반환합니다.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; Logger.log(sheet.getSheetName());
리턴
String
- 시트의 이름입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
get Sheet Values(startRow, startColumn, numRows, numColumns)
지정된 좌표에서 시작하는 이 범위의 값으로 된 직사각형 그리드를 반환합니다. 행 또는 열 위치로 지정된 -1 값은 시트에서 데이터가 있는 마지막 행 또는 열을 가져오는 것과 같습니다.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; // The two samples below produce the same output let values = sheet.getSheetValues(1, 1, 3, 3); Logger.log(values); const range = sheet.getRange(1, 1, 3, 3); values = range.getValues(); Logger.log(values);
매개변수
이름 | 유형 | 설명 |
---|---|---|
start | Integer | 시작 행의 위치입니다. |
start | Integer | 시작 열의 위치입니다. |
num | Integer | 값을 반환할 행의 수입니다. |
num | Integer | 값을 반환할 열의 수입니다. |
리턴
Object[][]
- 값의 2차원 배열입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
get Sheets()
이 스프레드시트의 모든 시트를 가져옵니다.
// The code below logs the name of the second sheet const sheets = SpreadsheetApp.getActiveSpreadsheet().getSheets(); // Iterates through the sheets and logs the name and ID of each sheet. for (const sheet of sheets) { Logger.log(`name: ${sheet.getName()}, ID: ${sheet.getSheetId()}`); }
리턴
Sheet[]
- 스프레드시트의 모든 시트 배열입니다.
get Spreadsheet Locale()
스프레드시트 언어를 가져옵니다.
// Opens the spreadsheet file by its URL. If you created your script from within // a Google Sheets spreadsheet, you can use // SpreadsheetApp.getActiveSpreadsheet() instead. // TODO(developer): Replace the URL with your own. const ss = SpreadsheetApp.openByUrl( 'https://docs.google.com/spreadsheets/d/abc123456/edit', ); // Gets the spreadsheet locale. const ssLocale = ss.getSpreadsheetLocale(); // Logs the locale to the console. console.log(ssLocale);
리턴
String
- 스프레드시트 언어입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
get Spreadsheet Theme()
스프레드시트의 현재 테마를 반환하거나 테마가 적용되지 않은 경우 null
을 반환합니다.
// The code below returns the current theme of the spreadsheet. const currentTheme = SpreadsheetApp.getActiveSpreadsheet().getSpreadsheetTheme();
리턴
Spreadsheet
- 현재 적용된 테마입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
get Spreadsheet Time Zone()
스프레드시트의 시간대를 가져옵니다.
// Opens the spreadsheet file by its URL. If you created your script from within // a Google Sheets spreadsheet, you can use // SpreadsheetApp.getActiveSpreadsheet() instead. // TODO(developer): Replace the URL with your own. const ss = SpreadsheetApp.openByUrl( 'https://docs.google.com/spreadsheets/d/abc123456/edit', ); // Sets the time zone of the spreadsheet. ss.setSpreadsheetTimeZone('America/New_York'); // Gets the time zone of the spreadsheet. const ssTimeZone = ss.getSpreadsheetTimeZone(); // Logs the time zone to the console. console.log(ssTimeZone);
리턴
String
- 시간대입니다. 'long' 형식으로 지정됩니다 (예: Joda.org에 나열된 'America/New_York').
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
get Url()
지정된 스프레드시트의 URL을 반환합니다.
const ss = SpreadsheetApp.getActiveSpreadsheet(); Logger.log(ss.getUrl());
리턴
String
- 지정된 스프레드시트의 URL입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
get Viewers()
이 Spreadsheet
의 뷰어 및 댓글 작성자 목록을 가져옵니다.
리턴
User[]
- 보기 또는 댓글 권한이 있는 사용자의 배열입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
hide Column(column)
지정된 범위의 열을 숨깁니다.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; // This hides the first column let range = sheet.getRange('A1'); sheet.hideColumn(range); // This hides the first 3 columns range = sheet.getRange('A:C'); sheet.hideColumn(range);
매개변수
이름 | 유형 | 설명 |
---|---|---|
column | Range | 숨길 열 범위입니다. |
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
hide Row(row)
지정된 범위의 행을 숨깁니다.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; // This hides the first row const range = sheet.getRange('A1'); sheet.hideRow(range);
매개변수
이름 | 유형 | 설명 |
---|---|---|
row | Range | 숨길 행 범위입니다. |
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
insert Column After(afterPosition)
지정된 열 위치 뒤에 열을 삽입합니다.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; // This inserts a column after the first column position sheet.insertColumnAfter(1);
매개변수
이름 | 유형 | 설명 |
---|---|---|
after | Integer | 새 열을 추가해야 하는 열입니다. |
리턴
Sheet
- 메서드 연결에 유용한 시트입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
insert Column Before(beforePosition)
지정된 열 위치 앞에 열을 삽입합니다.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; // This inserts a column in the first column position sheet.insertColumnBefore(1);
매개변수
이름 | 유형 | 설명 |
---|---|---|
before | Integer | 새 열을 추가해야 하는 열입니다. |
리턴
Sheet
- 메서드 연결에 유용한 시트입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
insert Columns After(afterPosition, howMany)
지정된 열 위치 뒤에 지정된 수의 열을 삽입합니다.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; // Inserts two columns after the first column on the first sheet of the // spreadsheet. sheet.insertColumnsAfter(1, 2);
매개변수
이름 | 유형 | 설명 |
---|---|---|
after | Integer | 새 열을 추가해야 하는 열입니다. |
how | Integer | 삽입할 열의 수입니다. |
리턴
Sheet
- 메서드 연결에 유용한 시트입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
insert Columns Before(beforePosition, howMany)
지정된 열 위치 앞에 여러 열을 삽입합니다.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; // This inserts five columns before the first column sheet.insertColumnsBefore(1, 5);
매개변수
이름 | 유형 | 설명 |
---|---|---|
before | Integer | 새 열을 추가해야 하는 열입니다. |
how | Integer | 삽입할 열의 수입니다. |
리턴
Sheet
- 메서드 연결에 유용한 시트입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
insert Data Source Sheet(spec)
스프레드시트에 새 Data
를 삽입하고 데이터 실행을 시작합니다. 이로 인해 새 시트가 활성 시트가 됩니다.
데이터 소스 유형이 사용 설정되지 않은 경우 예외를 발생시킵니다. Spreadsheet
메서드를 사용하여 특정 데이터 소스 유형의 데이터 실행을 사용 설정합니다.
// Activates BigQuery operations. SpreadsheetApp.enableBigQueryExecution(); // Opens the spreadsheet file by its URL. If you created your script from within // a Google Sheets file, you can use SpreadsheetApp.getActiveSpreadsheet() // instead. // TODO(developer): Replace the URL with your own. const ss = SpreadsheetApp.openByUrl( 'https://docs.google.com/spreadsheets/d/abc123456/edit', ); // Builds a data source specification. // TODO (developer): Update the project ID to your own Google Cloud project ID. const dataSourceSpec = SpreadsheetApp.newDataSourceSpec() .asBigQuery() .setProjectId('project-id-1') .setTableProjectId('bigquery-public-data') .setDatasetId('ncaa_basketball') .setTableId('mbb_historical_teams_games') .build(); // Adds the data source and its data to the spreadsheet. ss.insertDataSourceSheet(dataSourceSpec);
매개변수
이름 | 유형 | 설명 |
---|---|---|
spec | Data | 삽입할 데이터 소스 사양입니다. |
리턴
Data
: 새 데이터 소스 시트입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
insert Image(blobSource, column, row)
지정된 행과 열에 Spreadsheet
을 문서의 이미지로 삽입합니다. 이미지 크기는 블롭 콘텐츠에서 가져옵니다. 지원되는 최대 Blob 크기는 2MB입니다.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; const binaryData = []; // TODO(developer): Replace with your binary data. const blob = Utilities.newBlob(binaryData, 'image/png', 'MyImageName'); sheet.insertImage(blob, 1, 1);
매개변수
이름 | 유형 | 설명 |
---|---|---|
blob | Blob | 이미지 콘텐츠, MIME 유형, (선택사항) 이름을 포함하는 blob입니다. |
column | Integer | 열 위치입니다. |
row | Integer | 행 위치입니다. |
리턴
Over
- 삽입된 이미지입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
insert Image(blobSource, column, row, offsetX, offsetY)
지정된 행과 열에 Spreadsheet
를 이미지로 삽입합니다(픽셀 오프셋 사용). 이미지 크기는 blob 콘텐츠에서 가져옵니다. 지원되는 최대 blob 크기는 2MB입니다.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; const binaryData = []; // TODO(developer): Replace with your binary data. const blob = Utilities.newBlob(binaryData, 'image/png', 'MyImageName'); sheet.insertImage(blob, 1, 1, 10, 10);
매개변수
이름 | 유형 | 설명 |
---|---|---|
blob | Blob | 이미지 콘텐츠, MIME 유형, (선택사항) 이름을 포함하는 blob입니다. |
column | Integer | 열 위치입니다. |
row | Integer | 행 위치입니다. |
offsetX | Integer | 셀 모서리에서 가로 오프셋(픽셀)입니다. |
offsetY | Integer | 셀 모서리에서 세로 오프셋(픽셀)입니다. |
리턴
Over
- 삽입된 이미지입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
insert Image(url, column, row)
지정된 행과 열에 문서를 삽입합니다.
제공된 URL은 공개적으로 액세스할 수 있어야 합니다.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; sheet.insertImage('https://www.google.com/images/srpr/logo3w.png', 1, 1);
매개변수
이름 | 유형 | 설명 |
---|---|---|
url | String | 이미지의 URL입니다. |
column | Integer | 그리드 열 위치입니다. |
row | Integer | 그리드 행 위치입니다. |
리턴
Over
- 삽입된 이미지입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
insert Image(url, column, row, offsetX, offsetY)
픽셀 오프셋을 사용하여 지정된 행과 열에 이미지를 삽입합니다.
제공된 URL은 공개적으로 액세스할 수 있어야 합니다.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; sheet.insertImage( 'https://www.google.com/images/srpr/logo3w.png', 1, 1, 10, 10, );
매개변수
이름 | 유형 | 설명 |
---|---|---|
url | String | 이미지의 URL입니다. |
column | Integer | 열 위치입니다. |
row | Integer | 행 위치입니다. |
offsetX | Integer | 셀 모서리에서 가로 오프셋(픽셀)입니다. |
offsetY | Integer | 셀 모서리에서 세로 오프셋(픽셀)입니다. |
리턴
Over
- 삽입된 이미지입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
insert Row After(afterPosition)
지정된 행 위치 뒤에 행을 삽입합니다.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; // This inserts a row after the first row position sheet.insertRowAfter(1);
매개변수
이름 | 유형 | 설명 |
---|---|---|
after | Integer | 새 행을 추가해야 하는 행입니다. |
리턴
Sheet
- 메서드 연결에 유용한 시트입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
insert Row Before(beforePosition)
지정된 행 위치 앞에 행을 삽입합니다.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; // This inserts a row before the first row position sheet.insertRowBefore(1);
매개변수
이름 | 유형 | 설명 |
---|---|---|
before | Integer | 새 행을 추가해야 하는 행입니다. |
리턴
Sheet
- 메서드 연결에 유용한 시트입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
insert Rows After(afterPosition, howMany)
지정된 행 위치 뒤에 여러 행을 삽입합니다.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; // This inserts five rows after the first row sheet.insertRowsAfter(1, 5);
매개변수
이름 | 유형 | 설명 |
---|---|---|
after | Integer | 새 행을 추가해야 하는 행입니다. |
how | Integer | 삽입할 행 수입니다. |
리턴
Sheet
- 메서드 연결에 유용한 시트입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
insert Rows Before(beforePosition, howMany)
지정된 행 위치 앞에 여러 행을 삽입합니다.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; // This inserts five rows before the first row sheet.insertRowsBefore(1, 5);
매개변수
이름 | 유형 | 설명 |
---|---|---|
before | Integer | 새 행을 추가해야 하는 행입니다. |
how | Integer | 삽입할 행 수입니다. |
리턴
Sheet
- 메서드 연결에 유용한 시트입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
insert Sheet()
insert Sheet(sheetIndex)
지정된 색인에 스프레드시트에 새 시트를 삽입합니다. 새 시트가 활성 시트가 됩니다.
const ss = SpreadsheetApp.getActiveSpreadsheet(); ss.insertSheet(1);
매개변수
이름 | 유형 | 설명 |
---|---|---|
sheet | Integer | 새로 생성된 시트의 색인입니다. 시트를 스프레드시트의 첫 번째 시트로 삽입하려면 0으로 설정합니다. |
리턴
Sheet
- 새 시트입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
insert Sheet(sheetIndex, options)
지정된 색인에 스프레드시트의 새 시트를 삽입하고 선택적 고급 인수를 사용합니다. 새 시트가 활성 시트가 됩니다.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const templateSheet = ss.getSheetByName('Sales'); ss.insertSheet(1, {template: templateSheet});
매개변수
이름 | 유형 | 설명 |
---|---|---|
sheet | Integer | 새로 생성된 시트의 색인입니다. 시트를 스프레드시트의 첫 번째 시트로 삽입하려면 0으로 설정합니다. |
options | Object | 선택적 JavaScript 고급 인수입니다. |
고급 매개변수
이름 | 유형 | 설명 |
---|---|---|
template | Sheet | 템플릿 시트 객체의 모든 데이터가 새 시트에 복사됩니다. 시트 템플릿은 Spreadsheet 객체의 시트 중 하나여야 합니다. |
리턴
Sheet
- 새 시트입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
insert Sheet(options)
기본 시트 이름과 선택적 고급 인수를 사용하여 스프레드시트에 새 시트를 삽입합니다. 새 시트가 활성 시트가 됩니다.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const templateSheet = ss.getSheetByName('Sales'); ss.insertSheet({template: templateSheet});
매개변수
이름 | 유형 | 설명 |
---|---|---|
options | Object | 선택적 JavaScript 고급 인수(아래에 나열됨) |
고급 매개변수
이름 | 유형 | 설명 |
---|---|---|
template | Sheet | 템플릿 시트 객체의 모든 데이터가 새 시트에 복사됩니다. 시트 템플릿은 이 Spreadsheet 객체의 시트 중 하나여야 합니다. |
리턴
Sheet
- 새 시트입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
insert Sheet(sheetName)
지정된 이름으로 새 시트를 스프레드시트에 삽입합니다. 새 시트가 활성 시트가 됩니다.
const ss = SpreadsheetApp.getActiveSpreadsheet(); ss.insertSheet('My New Sheet');
매개변수
이름 | 유형 | 설명 |
---|---|---|
sheet | String | 새 시트의 이름입니다. |
리턴
Sheet
- 새 시트입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
insert Sheet(sheetName, sheetIndex)
지정된 이름의 새 시트를 지정된 색인에 스프레드시트에 삽입합니다. 새 시트가 활성 시트가 됩니다.
const ss = SpreadsheetApp.getActiveSpreadsheet(); ss.insertSheet('My New Sheet', 1);
매개변수
이름 | 유형 | 설명 |
---|---|---|
sheet | String | 새 시트의 이름입니다. |
sheet | Integer | 새로 생성된 시트의 색인입니다. 시트를 스프레드시트의 첫 번째 시트로 삽입하려면 0으로 설정합니다. |
리턴
Sheet
- 새 시트입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
insert Sheet(sheetName, sheetIndex, options)
지정된 이름의 새 시트를 지정된 색인에 스프레드시트에 삽입하고 선택적 고급 인수를 사용합니다. 새 시트가 활성 시트가 됩니다.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const templateSheet = ss.getSheetByName('Sales'); ss.insertSheet('My New Sheet', 1, {template: templateSheet});
매개변수
이름 | 유형 | 설명 |
---|---|---|
sheet | String | 새 시트의 이름입니다. |
sheet | Integer | 새로 삽입된 시트의 색인입니다. 시트를 스프레드시트의 첫 번째 시트로 삽입하려면 0으로 설정합니다. |
options | Object | 선택적 JavaScript 고급 인수입니다. |
고급 매개변수
이름 | 유형 | 설명 |
---|---|---|
template | Sheet | 템플릿 시트 객체의 모든 데이터가 새 시트에 복사됩니다. 시트 템플릿은 Spreadsheet 객체의 시트 중 하나여야 합니다. |
리턴
Sheet
- 새 시트입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
insert Sheet(sheetName, options)
지정된 이름으로 스프레드시트에 새 시트를 삽입하고 선택적 고급 인수를 사용합니다. 새 시트가 활성 시트가 됩니다.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const templateSheet = ss.getSheetByName('Sales'); ss.insertSheet('My New Sheet', {template: templateSheet});
매개변수
이름 | 유형 | 설명 |
---|---|---|
sheet | String | 새 시트의 이름입니다. |
options | Object | 선택적 JavaScript 고급 인수입니다. |
고급 매개변수
이름 | 유형 | 설명 |
---|---|---|
template | Sheet | 템플릿 시트 객체의 모든 데이터가 새 시트에 복사됩니다. 시트 템플릿은 Spreadsheet 객체의 시트 중 하나여야 합니다. |
리턴
Sheet
- 새 시트입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
insert Sheet With Data Source Table(spec)
스프레드시트에 새 시트를 삽입하고, 지정된 데이터 소스 사양으로 전체 시트에 걸쳐 있는 Data
를 만들고, 데이터 실행을 시작합니다. 부작용으로 새 시트가 활성 시트가 됩니다.
데이터 소스 유형이 사용 설정되지 않은 경우 예외를 발생시킵니다. Spreadsheet
메서드를 사용하여 특정 데이터 소스 유형의 데이터 실행을 사용 설정합니다.
// Activates BigQuery operations. SpreadsheetApp.enableBigQueryExecution(); // Opens the spreadsheet file by its URL. If you created your script from within // a Google Sheets file, you can use SpreadsheetApp.getActiveSpreadsheet() // instead. // TODO(developer): Replace the URL with your own. const ss = SpreadsheetApp.openByUrl( 'https://docs.google.com/spreadsheets/d/abc123456/edit', ); // Adds a sheet and sets cell A1 as the parameter cell. const parameterCell = ss.insertSheet('parameterSheet').getRange('A1'); // Sets the value of the parameter cell to 'Duke'. parameterCell.setValue('Duke'); const query = 'select * from `bigquery-public-data`.`ncaa_basketball`.' + '`mbb_historical_tournament_games` WHERE win_school_ncaa = @SCHOOL'; // Adds a data source with a query parameter. // TODO(developer): Update the project ID to your own Google Cloud project ID. const dataSourceSpec = SpreadsheetApp.newDataSourceSpec() .asBigQuery() .setProjectId('project-id-1') .setRawQuery(query) .setParameterFromCell('SCHOOL', 'parameterSheet!A1') .build(); // Adds sheets for the data source and data source table to the spreadsheet. ss.insertSheetWithDataSourceTable(dataSourceSpec);
매개변수
이름 | 유형 | 설명 |
---|---|---|
spec | Data | 삽입할 데이터 소스 사양입니다. |
리턴
Sheet
- 새 시트입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
is Column Hidden By User(columnPosition)
사용자가 지정된 열을 숨겼는지 여부를 반환합니다.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; // Columns start at 1 Logger.log(sheet.isColumnHiddenByUser(1));
매개변수
이름 | 유형 | 설명 |
---|---|---|
column | Integer | 검사할 열의 위치입니다. |
리턴
Boolean
- 열이 숨겨진 경우 true
, 그렇지 않은 경우 false
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
is Iterative Calculation Enabled()
이 스프레드시트에서 반복 계산이 활성화되었는지 여부를 반환합니다.
// Opens the spreadsheet file by its URL. If you created your script from within // a Google Sheets spreadsheet, you can use // SpreadsheetApp.getActiveSpreadsheet() instead. // TODO(developer): Replace the URL with your own. const ss = SpreadsheetApp.openByUrl( 'https://docs.google.com/spreadsheets/d/abc123456/edit', ); // Activates iterative calculation on the spreadsheet. ss.setIterativeCalculationEnabled(true); // Logs whether iterative calculation is activated for the spreadsheet. console.log(ss.isIterativeCalculationEnabled());
리턴
Boolean
- 반복 계산이 활성화된 경우 true
, 그렇지 않은 경우 false
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
is Row Hidden By Filter(rowPosition)
지정된 행이 필터 (필터 보기가 아님)에 의해 숨겨져 있는지 여부를 반환합니다.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; // Rows start at 1 Logger.log(sheet.isRowHiddenByFilter(1));
매개변수
이름 | 유형 | 설명 |
---|---|---|
row | Integer | 검사할 행의 위치입니다. |
리턴
Boolean
- 행이 숨겨져 있으면 true
, 그렇지 않으면 false
입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
is Row Hidden By User(rowPosition)
주어진 행이 사용자에 의해 숨겨져 있는지 여부를 반환합니다.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; // Rows start at 1 Logger.log(sheet.isRowHiddenByUser(1));
매개변수
이름 | 유형 | 설명 |
---|---|---|
row | Integer | 검사할 행의 위치입니다. |
리턴
Boolean
- 행이 숨겨져 있으면 true
, 그렇지 않으면 false
입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
move Active Sheet(pos)
활성 시트를 시트 목록의 지정된 위치로 이동합니다. 위치가 음수이거나 시트 수보다 큰 경우 예외를 발생시킵니다.
// This example assumes that there are 2 sheets in the current // active spreadsheet: one named "first" in position 1 and another named // "second" in position 2. const spreadsheet = SpreadsheetApp.getActiveSpreadsheet(); // Gets the "first" sheet and activates it. const sheet = spreadsheet.getSheetByName('first').activate(); // Logs 'Current index of sheet: 1' console.log('Current index of sheet: %s', sheet.getIndex()); spreadsheet.moveActiveSheet(2); // Logs 'New index of sheet: 2' console.log('New index of sheet: %s', sheet.getIndex());
매개변수
이름 | 유형 | 설명 |
---|---|---|
pos | Integer | 활성 시트를 시트 목록에서 이동할 1 기반 색인 위치입니다. |
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
move Chart To Object Sheet(chart)
새 Sheet
시트를 만들고 제공된 차트를 새 시트로 이동합니다. 차트가 이미 자체 시트에 있는 경우 새 시트를 만들지 않고 해당 시트가 반환됩니다.
const sheet = SpreadsheetApp.getActiveSheet(); const chart = sheet.newChart().setPosition(1, 1, 0, 0).build(); sheet.insertChart(chart); const objectSheet = SpreadsheetApp.getActive().moveChartToObjectSheet(chart);
매개변수
이름 | 유형 | 설명 |
---|---|---|
chart | Embedded | 이동할 차트입니다. |
리턴
Sheet
- 차트가 있는 시트입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
refresh All Data Sources()
지원되는 모든 데이터 소스와 연결된 데이터 소스 객체를 새로고침하고 유효하지 않은 데이터 소스 객체는 건너뜁니다.
Spreadsheet
메서드를 사용하여 특정 데이터 소스 유형의 데이터 실행을 사용 설정합니다.
// Activates BigQuery operations. SpreadsheetApp.enableBigQueryExecution(); // Opens the spreadsheet file by its URL. If you created your script from within // a Google Sheets file, you can use SpreadsheetApp.getActiveSpreadsheet() // instead. // TODO(developer): Replace the URL with your own. const ss = SpreadsheetApp.openByUrl( 'https://docs.google.com/spreadsheets/d/abc123456/edit', ); // Gets the first data source sheet on the spreadsheet. const dataSheet = ss.getDataSourceSheets()[0]; // Refreshes all data sources on the spreadsheet. ss.refreshAllDataSources(); // Logs the last refreshed time of the first data source sheet. console.log( `Last refresh time: ${dataSheet.getStatus().getLastRefreshedTime()}`, );
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
remove Editor(emailAddress)
Spreadsheet
의 편집자 목록에서 지정된 사용자를 삭제합니다. 이 메서드는 일반 액세스 권한이 있는 사용자 클래스에 속한 경우 사용자가 Spreadsheet
에 액세스하는 것을 차단하지 않습니다. 예를 들어 Spreadsheet
이 사용자의 전체 도메인과 공유되거나 Spreadsheet
이 사용자가 액세스할 수 있는 공유 드라이브에 있는 경우입니다.
Drive 파일의 경우 이 작업으로 사용자가 보기 권한 사용자 목록에서도 삭제됩니다.
매개변수
이름 | 유형 | 설명 |
---|---|---|
email | String | 삭제할 사용자의 이메일 주소입니다. |
리턴
Spreadsheet
- 체이닝을 위한 이 Spreadsheet
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
remove Editor(user)
Spreadsheet
의 편집자 목록에서 지정된 사용자를 삭제합니다. 이 메서드는 일반 액세스 권한이 있는 사용자 클래스에 속한 경우 사용자가 Spreadsheet
에 액세스하는 것을 차단하지 않습니다. 예를 들어 Spreadsheet
이 사용자의 전체 도메인과 공유되거나 Spreadsheet
이 사용자가 액세스할 수 있는 공유 드라이브에 있는 경우입니다.
Drive 파일의 경우 이 작업으로 사용자가 보기 권한 사용자 목록에서도 삭제됩니다.
매개변수
이름 | 유형 | 설명 |
---|---|---|
user | User | 삭제할 사용자를 나타냅니다. |
리턴
Spreadsheet
- 체이닝을 위한 이 Spreadsheet
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
remove Menu(name)
add
에 의해 추가된 메뉴를 삭제합니다. name
인수는 add
에 대한 해당 호출과 동일한 값을 가져야 합니다.
// The onOpen function is executed automatically every time a Spreadsheet is // loaded function onOpen() { const ss = SpreadsheetApp.getActiveSpreadsheet(); ss.addMenu('badMenu', [ {name: 'remove bad menu', functionName: 'removeBadMenu'}, {name: 'foo', functionName: 'foo'}, ]); } function removeBadMenu() { const ss = SpreadsheetApp.getActiveSpreadsheet(); ss.removeMenu( 'badMenu'); // name must match the name used when added the menu } function foo() { // Do nothing }
매개변수
이름 | 유형 | 설명 |
---|---|---|
name | String | 삭제할 메뉴의 이름입니다. |
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
remove Named Range(name)
지정된 이름의 이름이 지정된 범위를 삭제합니다. 스프레드시트에서 지정된 이름의 범위가 없으면 예외를 발생시킵니다.
// The code below creates a new named range "foo", and then remove it. const ss = SpreadsheetApp.getActiveSpreadsheet(); ss.setNamedRange('foo', ss.getActiveRange()); ss.removeNamedRange('foo');
매개변수
이름 | 유형 | 설명 |
---|---|---|
name | String | 범위 이름입니다. |
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
remove Viewer(emailAddress)
Spreadsheet
의 조회자 및 댓글 작성자 목록에서 지정된 사용자를 삭제합니다. 사용자가 보기 권한 사용자나 댓글 작성자가 아닌 편집자인 경우 이 메서드는 아무런 영향을 미치지 않습니다. 또한 이 메서드는 일반 액세스 권한이 있는 사용자 클래스에 속한 경우 사용자가 Spreadsheet
에 액세스하는 것을 차단하지 않습니다. 예를 들어 Spreadsheet
이 사용자의 전체 도메인과 공유되거나 Spreadsheet
이 사용자가 액세스할 수 있는 공유 드라이브에 있는 경우입니다.
Drive 파일의 경우 편집자 목록에서도 사용자가 삭제됩니다.
매개변수
이름 | 유형 | 설명 |
---|---|---|
email | String | 삭제할 사용자의 이메일 주소입니다. |
리턴
Spreadsheet
- 체이닝을 위한 Spreadsheet
입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
remove Viewer(user)
Spreadsheet
의 조회자 및 댓글 작성자 목록에서 지정된 사용자를 삭제합니다. 사용자가 뷰어가 아닌 편집자인 경우 이 메서드는 영향을 미치지 않습니다. 또한 이 방법은 일반 액세스 권한이 있는 사용자 클래스에 속한 사용자가 Spreadsheet
에 액세스하는 것을 차단하지 않습니다. 예를 들어 Spreadsheet
이 사용자의 전체 도메인과 공유되거나 Spreadsheet
이 사용자가 액세스할 수 있는 공유 드라이브에 있는 경우입니다.
Drive 파일의 경우 편집자 목록에서도 사용자가 삭제됩니다.
매개변수
이름 | 유형 | 설명 |
---|---|---|
user | User | 삭제할 사용자를 나타냅니다. |
리턴
Spreadsheet
- 체이닝을 위한 Spreadsheet
입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
rename(newName)
문서 이름을 바꿉니다.
const ss = SpreadsheetApp.getActiveSpreadsheet(); ss.rename('This is the new name');
매개변수
이름 | 유형 | 설명 |
---|---|---|
new | String | 문서의 새 이름입니다. |
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
rename Active Sheet(newName)
현재 활성 시트의 이름을 지정된 새 이름으로 바꿉니다.
// The code below renames the active sheet to "Hello world" SpreadsheetApp.getActiveSpreadsheet().renameActiveSheet('Hello world');
매개변수
이름 | 유형 | 설명 |
---|---|---|
new | String | 현재 활성 시트의 새 이름입니다. |
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
reset Spreadsheet Theme()
적용된 테마를 삭제하고 스프레드시트에 기본 테마를 설정합니다.
// The code below applies default theme on the spreadsheet. SpreadsheetApp.getActiveSpreadsheet().resetSpreadsheetTheme();
리턴
Spreadsheet
- 기본 테마입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
set Active Range(range)
지정된 범위를 활성 시트의 active range
로 설정합니다. 범위의 왼쪽 상단 셀이 current cell
이 됩니다.
const sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet(); const range = sheet.getRange('A1:D4'); sheet.setActiveRange(range); const selection = sheet.getSelection(); // Current cell: A1 const currentCell = selection.getCurrentCell(); // Active Range: A1:D4 const activeRange = selection.getActiveRange();
매개변수
이름 | 유형 | 설명 |
---|---|---|
range | Range | 활성 범위로 설정할 범위입니다. |
리턴
Range
- 새로 활성화된 범위입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
set Active Range List(rangeList)
지정된 범위 목록을 활성 시트의 active ranges
로 설정합니다. 목록의 마지막 범위가 active range
로 설정됩니다.
const sheet = SpreadsheetApp.getActiveSheet(); const rangeList = sheet.getRangeList(['D4', 'B2:C4']); sheet.setActiveRangeList(rangeList); const selection = sheet.getSelection(); // Current cell: B2 const currentCell = selection.getCurrentCell(); // Active range: B2:C4 const activeRange = selection.getActiveRange(); // Active range list: [D4, B2:C4] const activeRangeList = selection.getActiveRangeList();
매개변수
이름 | 유형 | 설명 |
---|---|---|
range | Range | 선택할 범위 목록입니다. |
리턴
Range
- 새로 선택된 범위 목록입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
set Active Selection(range)
이 시트의 활성 선택 영역을 설정합니다.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; const range = sheet.getRange('A1:D4'); sheet.setActiveSelection(range);
매개변수
이름 | 유형 | 설명 |
---|---|---|
range | Range | 활성 선택으로 설정할 범위입니다. |
리턴
Range
- 새로 활성화된 범위입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
set Active Selection(a1Notation)
A1 표기법 또는 R1C1 표기법에 지정된 대로 활성 선택을 설정합니다.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; sheet.setActiveSelection('A1:D4');
매개변수
이름 | 유형 | 설명 |
---|---|---|
a1Notation | String | 활성으로 설정할 범위입니다(A1 표기법 또는 R1C1 표기법으로 지정됨). |
리턴
Range
- 새로 활성화된 범위입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
set Active Sheet(sheet)
주어진 시트를 스프레드시트의 활성 시트로 설정합니다. 시트가 다른 스프레드시트에 속하지 않는 한 Google Sheets UI에 선택한 시트가 표시됩니다.
// The code below makes the first sheet active in the active spreadsheet. const spreadsheet = SpreadsheetApp.getActiveSpreadsheet(); spreadsheet.setActiveSheet(spreadsheet.getSheets()[0]);
매개변수
이름 | 유형 | 설명 |
---|---|---|
sheet | Sheet | 활성 시트로 설정할 시트입니다. |
리턴
Sheet
- 활성 시트입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
set Active Sheet(sheet, restoreSelection)
지정된 시트를 스프레드시트의 활성 시트로 설정합니다. 시트 내에서 가장 최근에 선택한 항목을 복원하는 옵션이 있습니다. 시트가 다른 스프레드시트에 속하지 않는 한 Google Sheets UI에 선택한 시트가 표시됩니다.
const spreadsheet = SpreadsheetApp.getActiveSpreadsheet(); const firstSheet = spreadsheet.getSheets()[0]; const secondSheet = spreadsheet.getSheets()[1]; // Set the first sheet as the active sheet and select the range D4:F4. spreadsheet.setActiveSheet(firstSheet).getRange('D4:F4').activate(); // Switch to the second sheet to do some work. spreadsheet.setActiveSheet(secondSheet); // Switch back to first sheet, and restore its selection. spreadsheet.setActiveSheet(firstSheet, true); // The selection of first sheet is restored, and it logs D4:F4 const range = spreadsheet.getActiveSheet().getSelection().getActiveRange(); Logger.log(range.getA1Notation());
매개변수
이름 | 유형 | 설명 |
---|---|---|
sheet | Sheet | 새 활성 시트입니다. |
restore | Boolean | true 인 경우 새 활성 시트의 가장 최근 선택 항목이 새 시트가 활성화될 때 다시 선택됩니다. false 인 경우 현재 선택 항목을 변경하지 않고 새 시트가 활성화됩니다. |
리턴
Sheet
- 새로 활성화된 시트입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
set Column Width(columnPosition, width)
지정된 열의 너비를 픽셀 단위로 설정합니다.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; // Sets the first column to a width of 200 pixels sheet.setColumnWidth(1, 200);
매개변수
이름 | 유형 | 설명 |
---|---|---|
column | Integer | 설정할 열의 위치입니다. |
width | Integer | 설정할 너비(픽셀)입니다. |
리턴
Sheet
- 메서드 연결에 유용한 시트입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
set Current Cell(cell)
지정된 셀을 current cell
로 설정합니다.
지정된 셀이 이미 선택된 범위에 있으면 해당 범위가 셀을 현재 셀로 하여 활성 범위가 됩니다.
지정된 셀이 선택된 범위에 없으면 기존 선택이 삭제되고 셀이 현재 셀 및 활성 범위가 됩니다.
참고: 지정된 Range
는 셀 하나로 구성되어야 합니다. 그렇지 않으면 예외가 발생합니다.
const sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet(); const cell = sheet.getRange('B5'); sheet.setCurrentCell(cell); const selection = sheet.getSelection(); // Current cell: B5 const currentCell = selection.getCurrentCell();
매개변수
이름 | 유형 | 설명 |
---|---|---|
cell | Range | 현재 셀로 설정할 셀입니다. |
리턴
Range
- 새로 설정된 현재 셀입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
set Frozen Columns(columns)
지정된 수의 열을 고정합니다. 0이면 고정된 열이 없습니다.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; // Freezes the first column sheet.setFrozenColumns(1);
매개변수
이름 | 유형 | 설명 |
---|---|---|
columns | Integer | 고정할 열 수입니다. |
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
set Frozen Rows(rows)
지정된 수의 행을 고정합니다. 0이면 고정된 행이 없습니다.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; // Freezes the first row sheet.setFrozenRows(1);
매개변수
이름 | 유형 | 설명 |
---|---|---|
rows | Integer | 고정할 행 수입니다. |
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
set Iterative Calculation Convergence Threshold(minThreshold)
반복 계산의 최소 기준 값을 설정합니다. 연속 계산 결과의 차이가 이 값보다 작으면 반복 계산이 중지됩니다. 이 값은 음수가 아니어야 하며 기본값은 0.05입니다.
// Opens the spreadsheet file by its URL. If you created your script from within // a Google Sheets spreadsheet, you can use // SpreadsheetApp.getActiveSpreadsheet() instead. // TODO(developer): Replace the URL with your own. const ss = SpreadsheetApp.openByUrl( 'https://docs.google.com/spreadsheets/d/abc123456/edit', ); // Sets the iterative calculation convergence threshold for the spreadsheet. ss.setIterativeCalculationConvergenceThreshold(2); // Logs the threshold to the console. console.log(ss.getIterativeCalculationConvergenceThreshold());
매개변수
이름 | 유형 | 설명 |
---|---|---|
min | Number | 최소 수렴 임계값 (음수가 아니어야 함)입니다. |
리턴
Spreadsheet
- 이 스프레드시트(연결용)
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
set Iterative Calculation Enabled(isEnabled)
이 스프레드시트에서 반복 계산이 활성화되었는지 여부를 설정합니다. 계산이 활성화되었을 때 최대 계산 주기 수와 수렴 기준이 이전에 설정되지 않은 경우 각각 50과 0.05로 기본 설정됩니다. 이전에 설정된 경우 이전 값이 유지됩니다.
// Opens the spreadsheet file by its URL. If you created your script from within // a Google Sheets spreadsheet, you can use // SpreadsheetApp.getActiveSpreadsheet() instead. // TODO(developer): Replace the URL with your own. const ss = SpreadsheetApp.openByUrl( 'https://docs.google.com/spreadsheets/d/abc123456/edit', ); // Activates iterative calculation on the spreadsheet. ss.setIterativeCalculationEnabled(true); // Logs whether iterative calculation is activated for the spreadsheet. console.log(ss.isIterativeCalculationEnabled());
매개변수
이름 | 유형 | 설명 |
---|---|---|
is | Boolean | 반복 계산을 사용 설정해야 하는 경우 true , 그렇지 않은 경우 false 입니다. |
리턴
Spreadsheet
- 이 스프레드시트(연결용)
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
set Max Iterative Calculation Cycles(maxIterations)
반복 계산 중에 실행해야 하는 최대 계산 반복 횟수를 설정합니다. 이 값은 1~10,000 사이여야 하며 (1과 10,000 포함) 기본값은 50입니다.
// Opens the spreadsheet file by its URL. If you created your script from within // a Google Sheets spreadsheet, you can use // SpreadsheetApp.getActiveSpreadsheet() instead. // TODO(developer): Replace the URL with your own. const ss = SpreadsheetApp.openByUrl( 'https://docs.google.com/spreadsheets/d/abc123456/edit', ); // Sets the max iterative calculation cycles for the spreadsheet. ss.setMaxIterativeCalculationCycles(10); // Logs the max iterative calculation cycles to the console. console.log(ss.getMaxIterativeCalculationCycles());
매개변수
이름 | 유형 | 설명 |
---|---|---|
max | Integer | 계산 반복의 최대 횟수 (1~10,000)입니다. |
리턴
Spreadsheet
- 이 스프레드시트(연결용)
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
set Named Range(name, range)
범위에 이름을 지정합니다.
// The code below creates a new named range "TaxRates" in the active spreadsheet const ss = SpreadsheetApp.getActiveSpreadsheet(); ss.setNamedRange('TaxRates', SpreadsheetApp.getActiveRange());
매개변수
이름 | 유형 | 설명 |
---|---|---|
name | String | 범위에 지정할 이름입니다. |
range | Range | 범위 사양입니다. |
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
set Recalculation Interval(recalculationInterval)
이 스프레드시트가 다시 계산되는 빈도를 설정합니다.
// Opens the spreadsheet file by its URL. If you created your script from within // a Google Sheets file, you can use SpreadsheetApp.getActiveSpreadsheet() // instead. // TODO(developer): Replace the URL with your own. const ss = SpreadsheetApp.openByUrl( 'https://docs.google.com/spreadsheets/d/abc123456/edit', ); // Sets the calculation interval for the spreadsheet to 'ON_CHANGE'. const interval = ss.setRecalculationInterval( SpreadsheetApp.RecalculationInterval.ON_CHANGE, ); // Logs the calculation interval to the console. console.log(interval);
매개변수
이름 | 유형 | 설명 |
---|---|---|
recalculation | Recalculation | 새로운 재계산 간격입니다. |
리턴
Spreadsheet
- 이 스프레드시트(연결용)
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
set Row Height(rowPosition, height)
지정된 행의 행 높이를 픽셀 단위로 설정합니다. 기본적으로 행은 셀 콘텐츠에 맞게 확장됩니다. 행을 지정된 높이로 강제하려면 Sheet.setRowHeightsForced(startRow, numRows, height)
을 사용합니다.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; // Sets the first row to a height of 200 pixels sheet.setRowHeight(1, 200);
매개변수
이름 | 유형 | 설명 |
---|---|---|
row | Integer | 변경할 행 위치입니다. |
height | Integer | 설정할 높이(픽셀)입니다. |
리턴
Sheet
- 메서드 연결에 유용한 시트입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
set Spreadsheet Locale(locale)
스프레드시트 언어를 설정합니다.
// Opens the spreadsheet file by its URL. If you created your script from within // a Google Sheets spreadsheet, you can use // SpreadsheetApp.getActiveSpreadsheet() instead. // TODO(developer): Replace the URL with your own. const ss = SpreadsheetApp.openByUrl( 'https://docs.google.com/spreadsheets/d/abc123456/edit', ); // Sets the spreadsheet locale. ss.setSpreadsheetLocale('fr'); // Gets the spreadsheet locale. const ssLocale = ss.getSpreadsheetLocale(); // Logs the locale to the console. console.log(ssLocale);
매개변수
이름 | 유형 | 설명 |
---|---|---|
locale | String | 사용할 언어 코드입니다 (예: 'en', 'fr', 'en_US'). |
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
set Spreadsheet Theme(theme)
스프레드시트의 테마를 설정합니다.
const spreadsheet = SpreadsheetApp.getActiveSpreadsheet(); // The code below sets the second predefined theme as the current theme of the // spreadsheet. const predefinedThemesList = spreadsheet.getPredefinedSpreadsheetThemes(); spreadsheet.setSpreadsheetTheme(predefinedThemesList[1]);
매개변수
이름 | 유형 | 설명 |
---|---|---|
theme | Spreadsheet | 적용할 테마입니다. |
리턴
Spreadsheet
- 새로운 현재 테마입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
set Spreadsheet Time Zone(timezone)
스프레드시트의 시간대를 설정합니다.
// Opens the spreadsheet file by its URL. If you created your script from within // a Google Sheets spreadsheet, you can use // SpreadsheetApp.getActiveSpreadsheet() instead. // TODO(developer): Replace the URL with your own. const ss = SpreadsheetApp.openByUrl( 'https://docs.google.com/spreadsheets/d/abc123456/edit', ); // Sets the time zone of the spreadsheet. ss.setSpreadsheetTimeZone('America/New_York'); // Gets the time zone of the spreadsheet. const ssTimeZone = ss.getSpreadsheetTimeZone(); // Logs the time zone to the console. console.log(ssTimeZone);
매개변수
이름 | 유형 | 설명 |
---|---|---|
timezone | String | 시간대입니다. '긴' 형식으로 지정됩니다 (예: Joda.org에 나열된 'America/New_York'). |
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
show(userInterface)
사용자 브라우저의 뷰포트 중앙에 있는 대화상자에 맞춤 사용자 인터페이스 구성요소를 표시합니다. 서버 측 스크립트의 실행이 일시중지되지 않습니다. 서버 측과 통신하려면 사용자 인터페이스 구성요소가 서버 측 스크립트에 비동기 콜백을 만들어야 합니다.
서버 측 스크립트에서 아직 닫히지 않은 대화상자를 이전에 표시한 경우 기존 대화상자가 새로 요청된 대화상자의 사용자 인터페이스로 대체됩니다.
다음 코드 스니펫은 지정된 제목, 높이, 너비가 있는 대화상자에 간단한 Html
애플리케이션을 표시합니다.
const htmlApp = HtmlService .createHtmlOutput( '<p>A change of speed, a change of style...</p>', ) .setTitle('My HtmlService Application') .setWidth(250) .setHeight(300); SpreadsheetApp.getActiveSpreadsheet().show(htmlApp); // The script resumes execution immediately after showing the dialog.
매개변수
이름 | 유형 | 설명 |
---|---|---|
user | Object | Html 입니다. |
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/script.container.ui
sort(columnPosition)
열을 기준으로 시트를 오름차순으로 정렬합니다.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; // Sorts the sheet by the first column, ascending sheet.sort(1);
매개변수
이름 | 유형 | 설명 |
---|---|---|
column | Integer | 정렬 기준으로 사용할 열입니다. |
리턴
Sheet
- 메서드 연결에 유용한 시트입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
sort(columnPosition, ascending)
열을 기준으로 시트를 정렬합니다. 오름차순 또는 내림차순을 지정하는 매개변수를 사용합니다.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; // Sorts the sheet by the first column, descending sheet.sort(1, false);
매개변수
이름 | 유형 | 설명 |
---|---|---|
column | Integer | 정렬 기준으로 사용할 열입니다. |
ascending | Boolean | 오름차순 정렬의 경우 true , 내림차순의 경우 false 입니다. |
리턴
Sheet
- 메서드 연결에 유용한 시트입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
toast(msg)
주어진 메시지와 함께 스프레드시트의 오른쪽 하단에 팝업 창을 표시합니다.
// Show a popup with the message "Task started". SpreadsheetApp.getActiveSpreadsheet().toast('Task started');
매개변수
이름 | 유형 | 설명 |
---|---|---|
msg | String | 토스트에 표시할 메시지입니다. |
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
toast(msg, title)
주어진 메시지와 제목으로 스프레드시트의 오른쪽 하단에 팝업 창을 표시합니다.
// Show a popup with the title "Status" and the message "Task started". SpreadsheetApp.getActiveSpreadsheet().toast('Task started', 'Status');
매개변수
이름 | 유형 | 설명 |
---|---|---|
msg | String | 토스트에 표시할 메시지입니다. |
title | String | 토스트의 제목(선택사항)입니다. |
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
toast(msg, title, timeoutSeconds)
지정된 제목과 메시지가 포함된 팝업 창을 스프레드시트의 오른쪽 하단에 표시합니다. 팝업 창은 일정 시간 동안 표시됩니다.
// Show a 3-second popup with the title "Status" and the message "Task started". SpreadsheetApp.getActiveSpreadsheet().toast('Task started', 'Status', 3);
매개변수
이름 | 유형 | 설명 |
---|---|---|
msg | String | 토스트에 표시할 메시지입니다. |
title | String | 토스트의 제목(선택사항)입니다. |
timeout | Number | 초 단위의 제한 시간입니다. null 인 경우 토스트는 기본적으로 5초 동안 표시됩니다. 음수인 경우 토스트는 닫힐 때까지 표시됩니다. |
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
unhide Column(column)
지정된 범위의 열을 숨김 해제합니다.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; // This unhides the first column if it was previously hidden const range = sheet.getRange('A1'); sheet.unhideColumn(range);
매개변수
이름 | 유형 | 설명 |
---|---|---|
column | Range | 숨겨진 경우 숨김 해제할 범위입니다. |
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
unhide Row(row)
지정된 범위의 행을 숨김 해제합니다.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; // This unhides the first row if it was previously hidden const range = sheet.getRange('A1'); sheet.unhideRow(range);
매개변수
이름 | 유형 | 설명 |
---|---|---|
row | Range | 숨겨진 경우 숨김 해제할 범위입니다. |
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
update Menu(name, subMenus)
add
에 의해 추가된 메뉴를 업데이트합니다. add
과 정확히 동일하게 작동합니다.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const menuEntries = []; menuEntries.push({name: 'Lone Menu Entry', functionName: 'function1'}); ss.updateMenu('addMenuExample', menuEntries);
매개변수
이름 | 유형 | 설명 |
---|---|---|
name | String | 업데이트할 메뉴의 이름입니다. |
sub | Object[] | name 및 function 매개변수가 있는 JavaScript 지도의 배열입니다. Library.libFunction1 와 같은 포함된 라이브러리의 함수를 사용할 수 있습니다. |
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
wait For All Data Executions Completion(timeoutInSeconds)
스프레드시트의 현재 실행이 모두 완료될 때까지 대기하며, 제공된 시간(초)이 지나면 시간 초과됩니다. 시간이 초과될 때 실행이 완료되지 않으면 예외를 발생시키지만 데이터 실행을 취소하지는 않습니다.
매개변수
이름 | 유형 | 설명 |
---|---|---|
timeout | Integer | 데이터 실행을 기다리는 시간(초)입니다. 최댓값은 300초입니다. |
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets