Google Sheets 파일에 액세스하고 수정합니다. 일반적인 작업은 새 시트 추가와 공동작업자 추가입니다.
방법
자세한 문서
addDeveloperMetadata(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
addDeveloperMetadata(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 | DeveloperMetadataVisibility | 새 개발자 메타데이터의 공개 상태입니다. |
리턴
Spreadsheet
— 연결용 스프레드시트입니다.
승인
이 방법을 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
addDeveloperMetadata(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
addDeveloperMetadata(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 | DeveloperMetadataVisibility | 새 개발자 메타데이터의 공개 상태입니다. |
리턴
Spreadsheet
— 연결용 스프레드시트입니다.
승인
이 방법을 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
addEditor(emailAddress)
지정된 사용자를 Spreadsheet
의 편집자 목록에 추가합니다. 사용자가 이미 뷰어 목록에 있다면 이 메서드는 사용자를 뷰어 목록 밖으로 승격시킵니다.
매개변수
이름 | 유형 | 설명 |
---|---|---|
emailAddress | String | 추가할 사용자의 이메일 주소입니다. |
리턴
Spreadsheet
- 연결을 위한 이 Spreadsheet
입니다.
승인
이 방법을 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
addEditor(user)
지정된 사용자를 Spreadsheet
의 편집자 목록에 추가합니다. 사용자가 이미 뷰어 목록에 있다면 이 메서드는 사용자를 뷰어 목록 밖으로 승격시킵니다.
매개변수
이름 | 유형 | 설명 |
---|---|---|
user | User | 추가할 사용자의 표현입니다. |
리턴
Spreadsheet
- 연결을 위한 이 Spreadsheet
입니다.
승인
이 방법을 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
addEditors(emailAddresses)
지정된 사용자 배열을 Spreadsheet
의 편집자 목록에 추가합니다. 뷰어 목록에 이미 있는 사용자가 있으면 이 방법을 통해 해당 사용자를 뷰어 목록 밖으로 승격시킵니다.
매개변수
이름 | 유형 | 설명 |
---|---|---|
emailAddresses | String[] | 추가할 사용자의 이메일 주소의 배열입니다. |
리턴
Spreadsheet
- 연결을 위한 이 Spreadsheet
입니다.
승인
이 방법을 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
addMenu(name, subMenus)
스프레드시트 UI에 새 메뉴를 만듭니다.
각 메뉴 항목은 사용자 정의 함수를 실행합니다. 일반적으로 스프레드시트가 로드될 때 메뉴가 자동으로 생성되도록 onOpen()
함수에서 호출하는 것이 좋습니다.
// The onOpen function is executed automatically every time a Spreadsheet is loaded function onOpen() { var ss = SpreadsheetApp.getActiveSpreadsheet(); var 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 | 생성될 메뉴의 이름입니다. |
subMenus | Object[] | name 및 functionName
매개변수가 있는 자바스크립트 지도의 배열입니다. 포함된 라이브러리(예:
Library.libFunction1 )의 함수를 사용할 수 있습니다. |
승인
이 방법을 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
addViewer(emailAddress)
지정된 사용자를 Spreadsheet
의 뷰어 목록에 추가합니다. 사용자가 이미 편집자 목록에 있다면 이 방법은 효과가 없습니다.
매개변수
이름 | 유형 | 설명 |
---|---|---|
emailAddress | String | 추가할 사용자의 이메일 주소입니다. |
리턴
Spreadsheet
- 연결을 위한 이 Spreadsheet
입니다.
승인
이 방법을 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
addViewer(user)
지정된 사용자를 Spreadsheet
의 뷰어 목록에 추가합니다. 사용자가 이미 편집자 목록에 있다면 이 방법은 효과가 없습니다.
매개변수
이름 | 유형 | 설명 |
---|---|---|
user | User | 추가할 사용자의 표현입니다. |
리턴
Spreadsheet
- 연결을 위한 이 Spreadsheet
입니다.
승인
이 방법을 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
addViewers(emailAddresses)
지정된 사용자 배열을 Spreadsheet
의 뷰어 목록에 추가합니다. 편집자 목록에 이미 있는 사용자가 있다면 이 방법은 아무런 영향을 미치지 않습니다.
매개변수
이름 | 유형 | 설명 |
---|---|---|
emailAddresses | String[] | 추가할 사용자의 이메일 주소의 배열입니다. |
리턴
Spreadsheet
- 연결을 위한 이 Spreadsheet
입니다.
승인
이 방법을 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
appendRow(rowContents)
시트에서 현재 데이터 리전의 하단에 행을 추가합니다. 셀의 내용이 =
로 시작하면 수식으로 해석됩니다.
var ss = SpreadsheetApp.getActiveSpreadsheet(); var 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"]);
매개변수
이름 | 유형 | 설명 |
---|---|---|
rowContents | Object[] | 시트의 마지막 행 뒤에 삽입할 값의 배열입니다. |
리턴
Sheet
- 시트로, 메서드 체이닝에 유용합니다.
승인
이 방법을 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
autoResizeColumn(columnPosition)
콘텐츠에 맞게 지정된 열의 너비를 설정합니다.
var ss = SpreadsheetApp.getActiveSpreadsheet(); var 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);
매개변수
이름 | 유형 | 설명 |
---|---|---|
columnPosition | 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 var 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
createDeveloperMetadataFinder()
이 스프레드시트의 범위 내에서 개발자 메타데이터를 찾는 DeveloperMetadataFinder
를 반환합니다. 기본적으로 스프레드시트, 시트, 행, 열과 관련된 모든 메타데이터를 고려합니다.
// 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());
리턴
DeveloperMetadataFinder
— 이 스프레드시트 범위에 있는 메타데이터를 검색할 수 있는 개발자 메타데이터 찾기입니다.
createTextFinder(findText)
스프레드시트 내에서 텍스트를 찾아 바꾸는 데 사용할 수 있는 스프레드시트용 텍스트 파인더를 만듭니다. 검색은 스프레드시트의 첫 번째 시트에서 시작됩니다.
var spreadsheet = SpreadsheetApp.getActiveSpreadsheet(); // Creates a text finder. var textFinder = spreadsheet.createTextFinder('dog'); // Returns the first occurrence of 'dog' in the spreadsheet. var firstOccurrence = textFinder.findNext(); // Replaces the last found occurrence of 'dog' with 'cat' and returns the number // of occurrences replaced. var numOccurrencesReplaced = findOccurrence.replaceWith('cat');
매개변수
이름 | 유형 | 설명 |
---|---|---|
findText | String | 검색할 텍스트입니다. |
리턴
TextFinder
: 스프레드시트의 TextFinder
입니다.
deleteActiveSheet()
현재 활성화된 시트를 삭제합니다.
// The code below deletes the currently active sheet and stores the new active sheet in a // variable var newSheet = SpreadsheetApp.getActiveSpreadsheet().deleteActiveSheet();
리턴
Sheet
- 새 활성 시트입니다.
승인
이 방법을 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
deleteColumn(columnPosition)
지정된 열 위치에서 열을 삭제합니다.
var ss = SpreadsheetApp.getActiveSpreadsheet(); var sheet = ss.getSheets()[0]; // Columns start at "1" - this deletes the first column sheet.deleteColumn(1);
매개변수
이름 | 유형 | 설명 |
---|---|---|
columnPosition | Integer | 열의 위치입니다. 첫 번째 열의 경우 1부터 시작합니다. |
리턴
Sheet
: 메서드 체이닝에 유용한 시트
승인
이 방법을 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
deleteColumns(columnPosition, howMany)
지정된 열 위치부터 시작하여 여러 열을 삭제합니다.
var ss = SpreadsheetApp.getActiveSpreadsheet(); var sheet = ss.getSheets()[0]; // Columns start at "1" - this deletes the first two columns sheet.deleteColumns(1, 2);
매개변수
이름 | 유형 | 설명 |
---|---|---|
columnPosition | Integer | 삭제할 첫 번째 열의 위치입니다. |
howMany | Integer | 삭제할 열의 수입니다. |
승인
이 방법을 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
deleteRow(rowPosition)
지정된 행 위치에서 행을 삭제합니다.
var ss = SpreadsheetApp.getActiveSpreadsheet(); var sheet = ss.getSheets()[0]; // Rows start at "1" - this deletes the first row sheet.deleteRow(1);
매개변수
이름 | 유형 | 설명 |
---|---|---|
rowPosition | Integer | 행의 위치입니다. 첫 번째 행의 경우 1부터 시작합니다. |
리턴
Sheet
: 메서드 체이닝에 유용한 시트
승인
이 방법을 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
deleteRows(rowPosition, howMany)
지정된 행 위치부터 시작하여 여러 행을 삭제합니다.
var ss = SpreadsheetApp.getActiveSpreadsheet(); var sheet = ss.getSheets()[0]; // Rows start at "1" - this deletes the first two rows sheet.deleteRows(1, 2);
매개변수
이름 | 유형 | 설명 |
---|---|---|
rowPosition | Integer | 삭제할 첫 번째 행의 위치입니다. |
howMany | Integer | 삭제할 행 수입니다. |
승인
이 방법을 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
deleteSheet(sheet)
지정된 시트를 삭제합니다.
// The code below deletes the specified sheet. var ss = SpreadsheetApp.getActive(); var sheet = ss.getSheetByName('My Sheet'); ss.deleteSheet(sheet);
매개변수
이름 | 유형 | 설명 |
---|---|---|
sheet | Sheet | 삭제할 시트입니다. |
승인
이 방법을 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
duplicateActiveSheet()
활성 시트를 복제하여 활성 시트로 만듭니다.
// 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
getActiveCell()
이 시트의 활성 셀을 반환합니다.
참고: 현재 강조표시된 셀을 반환하는 getCurrentCell()
를 사용하는 것이 좋습니다.
var ss = SpreadsheetApp.getActiveSpreadsheet(); var sheet = ss.getSheets()[0]; // Returns the active cell var cell = sheet.getActiveCell();
리턴
Range
— 현재 활성 셀
승인
이 방법을 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
getActiveRange()
활성 시트에서 선택된 범위를 반환하거나, 활성 범위가 없으면 null
을 반환합니다. 여러 범위를 선택한 경우 이 메서드는 마지막으로 선택한 범위만 반환합니다.
'활성 범위'라는 용어는 사용자가 활성 시트에서 선택한 범위를 나타내지만 맞춤 함수에서는 능동적으로 다시 계산 중인 셀을 나타냅니다.
var sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet(); var activeRange = sheet.getActiveRange();
리턴
Range
: 활성 범위
승인
이 방법을 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
참고 항목
getActiveRangeList()
활성 시트의 활성 범위 목록을 반환하거나 활성 범위가 없는 경우 null
을 반환합니다.
단일 범위를 선택한 경우 getActiveRange()
호출처럼 작동합니다.
var sheet = SpreadsheetApp.getActiveSheet(); // Returns the list of active ranges. var activeRangeList = sheet.getActiveRangeList();
리턴
RangeList
- 활성 범위 목록
승인
이 방법을 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
참고 항목
getActiveSheet()
스프레드시트의 활성 시트를 가져옵니다.
스프레드시트의 활성 시트는 스프레드시트 UI에 표시되는 시트입니다.
var sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
리턴
Sheet
— 스프레드시트의 활성 시트입니다.
getAs(contentType)
이 객체 내의 데이터를 지정된 콘텐츠 유형으로 변환된 blob으로 반환합니다. 이 메서드는 파일 이름에 적절한 확장자(예: 'myfile.pdf')를 추가합니다. 그러나 파일 이름에서 마지막 마침표 다음에 오는 부분 (있는 경우)이 대체되어야 하는 기존 확장자라고 가정합니다. 따라서 'ShoppingList.12.25.2014'는 'ShoppingList.12.25.pdf'가 됩니다.
변환의 일일 할당량을 보려면 Google 서비스 할당량을 참조하세요. 새로 생성된 Google Workspace 도메인에는 일시적으로 더 엄격한 할당량이 적용될 수 있습니다.
매개변수
이름 | 유형 | 설명 |
---|---|---|
contentType | String | 변환할 MIME 유형입니다. 대부분의 blob에서는 'application/pdf' 옵션만 유효합니다. BMP, GIF, JPEG 또는 PNG 형식의 이미지인 경우 'image/bmp' , 'image/gif' , 'image/jpeg' , 'image/png' 중 어느 것도 유효합니다. |
리턴
Blob
- blob의 데이터입니다.
getBandings()
이 스프레드시트의 모든 밴딩을 반환합니다.
// 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
getBlob()
getColumnWidth(columnPosition)
지정된 열의 너비를 픽셀 단위로 가져옵니다.
var ss = SpreadsheetApp.getActiveSpreadsheet(); var sheet = ss.getSheets()[0]; // Columns start at 1 Logger.log(sheet.getColumnWidth(1));
매개변수
이름 | 유형 | 설명 |
---|---|---|
columnPosition | Integer | 검사할 열의 위치입니다. |
리턴
Integer
— 픽셀 단위의 열 너비
승인
이 방법을 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
getCurrentCell()
활성 시트의 현재 셀을 반환하거나 현재 셀이 없는 경우 null
을 반환합니다. 현재 셀은 Google Sheets UI에서 포커스가 있는 셀이며 어두운 테두리로 강조 표시됩니다. 현재 셀은 2개 이상일 수 없습니다. 사용자가 하나 이상의 셀 범위를 선택하면 선택 항목의 셀 중 하나가 현재 셀이 됩니다.
var sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet(); // Returns the current highlighted cell in the one of the active ranges. var currentCell = sheet.getCurrentCell();
리턴
Range
: 현재 셀
승인
이 방법을 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
getDataRange()
데이터가 있는 측정기준에 해당하는 Range
를 반환합니다.
이는 A1 및 (Sheet.getLastColumn(), Sheet.getLastRow())로 제한된 범위를 만드는 것과 기능적으로 동일합니다.
var ss = SpreadsheetApp.getActiveSpreadsheet(); var sheet = ss.getSheets()[0]; // This represents ALL the data var range = sheet.getDataRange(); var values = range.getValues(); // This logs the spreadsheet in CSV format with a trailing comma for (var i = 0; i < values.length; i++) { var row = ""; for (var 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
getDataSourceFormulas()
모든 데이터 소스 수식을 가져옵니다.
// 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());
리턴
DataSourceFormula[]
- 데이터 소스 수식의 목록입니다.
승인
이 방법을 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
getDataSourcePivotTables()
모든 데이터 소스 피벗 테이블을 가져옵니다.
// 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());
리턴
DataSourcePivotTable[]
- 데이터 소스 피벗 테이블의 목록입니다.
승인
이 방법을 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
getDataSourceRefreshSchedules()
이 스프레드시트의 새로고침 일정을 가져옵니다.
// 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);
리턴
DataSourceRefreshSchedule[]
— 이 스프레드시트의 새로고침 일정입니다.
승인
이 방법을 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
getDataSourceSheets()
스프레드시트의 모든 데이터 소스 시트를 반환합니다.
// 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());
리턴
DataSourceSheet[]
- 모든 데이터 소스 시트의 배열입니다.
승인
이 방법을 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
getDataSourceTables()
모든 데이터 소스 테이블을 가져옵니다.
// 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());
리턴
DataSourceTable[]
- 데이터 소스 테이블의 목록입니다.
승인
이 방법을 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
getDataSources()
스프레드시트의 모든 데이터 소스를 반환합니다.
// 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());
리턴
DataSource[]
- 모든 데이터 소스의 배열입니다.
승인
이 방법을 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
getDeveloperMetadata()
최상위 스프레드시트와 연결된 개발자 메타데이터를 가져옵니다.
// 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());
리턴
DeveloperMetadata[]
- 이 범위와 연결된 개발자 메타데이터입니다.
승인
이 방법을 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
getEditors()
이 Spreadsheet
의 편집자 목록을 가져옵니다.
리턴
User[]
- 수정 권한이 있는 사용자의 배열입니다.
승인
이 방법을 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
getFormUrl()
이 스프레드시트에 응답을 보내는 양식의 URL 또는 이 스프레드시트에 연결된 양식이 없는 경우 null
를 반환합니다. 여러 양식에서 이 스프레드시트에 응답을 보내는 경우 반환되는 양식 URL은 확실하지 않습니다. 또는 Sheet.getFormUrl()
메서드를 통해 시트 양식별 URL 연결을 가져올 수 있습니다.
// 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
getFrozenColumns()
고정된 열의 수를 반환합니다.
var ss = SpreadsheetApp.getActiveSpreadsheet(); var 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
getFrozenRows()
고정된 행의 수를 반환합니다.
var ss = SpreadsheetApp.getActiveSpreadsheet(); var 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
getId()
이 스프레드시트의 고유 식별자를 가져옵니다. 스프레드시트 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 또는 키입니다.
getImages()
시트의 모든 그리드 위에 있는 이미지를 반환합니다.
// 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()); }
리턴
OverGridImage[]
- 그리드 위의 이미지 배열입니다.
승인
이 방법을 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
getIterativeCalculationConvergenceThreshold()
반복 계산 중에 사용되는 임계값을 반환합니다. 연속 계산 결과의 차이가 이 값보다 작으면 반복 계산이 중지됩니다.
// 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
getLastColumn()
콘텐츠가 있는 마지막 열의 위치를 반환합니다.
var ss = SpreadsheetApp.getActiveSpreadsheet(); var sheet = ss.getSheets()[0]; // This logs the value in the very last cell of this sheet var lastRow = sheet.getLastRow(); var lastColumn = sheet.getLastColumn(); var lastCell = sheet.getRange(lastRow, lastColumn); Logger.log(lastCell.getValue());
리턴
Integer
: 콘텐츠가 포함된 시트의 마지막 열
승인
이 방법을 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
getLastRow()
콘텐츠가 있는 마지막 행의 위치를 반환합니다.
var ss = SpreadsheetApp.getActiveSpreadsheet(); var sheet = ss.getSheets()[0]; // This logs the value in the very last cell of this sheet var lastRow = sheet.getLastRow(); var lastColumn = sheet.getLastColumn(); var lastCell = sheet.getRange(lastRow, lastColumn); Logger.log(lastCell.getValue());
리턴
Integer
: 콘텐츠가 포함된 시트의 마지막 행
승인
이 방법을 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
getMaxIterativeCalculationCycles()
반복 계산에 사용할 최대 반복 횟수를 반환합니다.
// 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
getName()
문서의 이름을 가져옵니다.
var ss = SpreadsheetApp.getActiveSpreadsheet(); Logger.log(ss.getName());
리턴
String
- 스프레드시트의 이름입니다.
승인
이 방법을 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
getNamedRanges()
이 스프레드시트에서 이름이 지정된 모든 범위를 가져옵니다.
// The code below logs the name of the first named range. var namedRanges = SpreadsheetApp.getActiveSpreadsheet().getNamedRanges(); for (var i = 0; i < namedRanges.length; i++) { Logger.log(namedRanges[i].getName()); }
리턴
NamedRange[]
- 스프레드시트에 있는 이름이 지정된 모든 범위의 배열입니다.
승인
이 방법을 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
getNumSheets()
이 스프레드시트의 시트 수를 반환합니다.
// The code below logs the number of sheets in the active spreadsheet. Logger.log(SpreadsheetApp.getActiveSpreadsheet().getNumSheets());
리턴
Integer
- 스프레드시트의 시트 수입니다.
getOwner()
문서 소유자를 반환하거나 공유 드라이브에 있는 문서의 경우 null
를 반환합니다.
var ss = SpreadsheetApp.getActiveSpreadsheet(); var owner = ss.getOwner(); Logger.log(owner.getEmail());
리턴
User
: 문서 소유자 또는 null
(문서가 공유 드라이브에 있는 경우)입니다.
승인
이 방법을 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
getPredefinedSpreadsheetThemes()
미리 정의된 테마 목록을 반환합니다.
// The code below returns the list of predefined themes. var predefinedThemesList = SpreadsheetApp.getActiveSpreadsheet() .getPredefinedSpreadsheetThemes();
리턴
SpreadsheetTheme[]
- 사전 정의된 테마 목록입니다.
승인
이 방법을 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
getProtections(type)
스프레드시트의 모든 보호된 범위나 시트를 나타내는 객체의 배열을 가져옵니다.
// Remove all range protections in the spreadsheet that the user has permission to edit. var ss = SpreadsheetApp.getActive(); var protections = ss.getProtections(SpreadsheetApp.ProtectionType.RANGE); for (var i = 0; i < protections.length; i++) { var protection = protections[i]; if (protection.canEdit()) { protection.remove(); } }
// Remove all sheet protections in the spreadsheet that the user has permission to edit. var ss = SpreadsheetApp.getActive(); var protections = ss.getProtections(SpreadsheetApp.ProtectionType.SHEET); for (var i = 0; i < protections.length; i++) { var protection = protections[i]; if (protection.canEdit()) { protection.remove(); } }
매개변수
이름 | 유형 | 설명 |
---|---|---|
type | ProtectionType | 보호 구역의 유형입니다(SpreadsheetApp.ProtectionType.RANGE 또는 SpreadsheetApp.ProtectionType.SHEET ). |
리턴
Protection[]
- 스프레드시트의 모든 보호된 범위 또는 시트를 나타내는 객체의 배열.
승인
이 방법을 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
getRange(a1Notation)
A1 표기법 또는 R1C1 표기법으로 지정된 범위를 반환합니다.
// Get a range A1:D4 on sheet titled "Invoices" var ss = SpreadsheetApp.getActiveSpreadsheet(); var range = ss.getRange("Invoices!A1:D4"); // Get cell A1 on the first sheet var sheet = ss.getSheets()[0]; var cell = sheet.getRange("A1");
매개변수
이름 | 유형 | 설명 |
---|---|---|
a1Notation | String | A1 표기법 또는 R1C1 표기법에 지정된 대로 반환할 범위입니다. |
리턴
Range
: 지정된 위치의 범위
승인
이 방법을 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
getRangeByName(name)
이름이 지정된 범위를 반환하거나 지정된 이름을 가진 범위를 찾을 수 없는 경우 null
를 반환합니다. 스프레드시트의 여러 시트에서 동일한 범위 이름을 사용하는 경우 따옴표를 추가하지 않고 시트 이름을 지정합니다(예: getRangeByName('TaxRates')
또는 getRangeByName('Sheet Name!TaxRates')
). getRangeByName('"Sheet
Name"!TaxRates')
는 지정하지 않습니다.
// Log the number of columns for the range named 'TaxRates' in the active spreadsheet. var range = SpreadsheetApp.getActiveSpreadsheet().getRangeByName('TaxRates'); if (range != null) { Logger.log(range.getNumColumns()); }
매개변수
이름 | 유형 | 설명 |
---|---|---|
name | String | 가져올 범위의 이름입니다. |
리턴
Range
- 지정된 이름의 셀 범위입니다.
getRangeList(a1Notations)
A1 표기법 또는 R1C1 표기법의 비어 있지 않은 목록으로 지정된 동일한 시트의 범위를 나타내는 RangeList
컬렉션을 반환합니다.
// Get a list of ranges A1:D4, F1:H4. var sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet(); var rangeList = sheet.getRangeList(['A1:D4', 'F1:H4']);
매개변수
이름 | 유형 | 설명 |
---|---|---|
a1Notations | String[] | A1 표기법 또는 R1C1 표기법에 지정된 대로 반환할 범위 목록입니다. |
리턴
RangeList
: 지정된 위치의 범위 목록
승인
이 방법을 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
getRecalculationInterval()
이 스프레드시트의 계산 간격을 반환합니다.
// 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());
리턴
RecalculationInterval
— 이 스프레드시트의 계산 간격입니다.
승인
이 방법을 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
getRowHeight(rowPosition)
지정된 행의 높이를 픽셀 단위로 가져옵니다.
var ss = SpreadsheetApp.getActiveSpreadsheet(); var sheet = ss.getSheets()[0]; // Rows start at 1 Logger.log(sheet.getRowHeight(1));
매개변수
이름 | 유형 | 설명 |
---|---|---|
rowPosition | Integer | 검사할 행의 위치입니다. |
리턴
Integer
— 행 높이(픽셀)
승인
이 방법을 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
getSelection()
스프레드시트의 현재 Selection
를 반환합니다.
var selection = SpreadsheetApp.getActiveSpreadsheet().getSelection(); var currentCell = selection.getCurrentCell();
리턴
Selection
: 현재 선택 항목
승인
이 방법을 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
getSheetByName(name)
지정된 이름의 시트를 반환합니다.
여러 시트의 이름이 동일한 경우 가장 왼쪽 시트가 반환됩니다. 지정된 이름의 시트가 없으면 null
를 반환합니다.
// The code below logs the index of a sheet named "Expenses" var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Expenses"); if (sheet != null) { Logger.log(sheet.getIndex()); }
매개변수
이름 | 유형 | 설명 |
---|---|---|
name | String | 가져올 시트의 이름입니다. |
리턴
Sheet
- 지정된 이름의 시트입니다.
getSheetId()
이 객체가 나타내는 시트의 ID를 반환합니다.
이는 스프레드시트에 고유한 시트의 ID입니다. ID는 시트 생성 시 할당되는 단조 증가 정수로, 시트 위치와는 무관합니다. Sheet
인스턴스가 아닌 gridId
매개변수를 사용하는 Range.copyFormatToRange(gridId, column, columnEnd, row, rowEnd)
와 같은 메서드와 함께 사용하면 유용합니다.
var ss = SpreadsheetApp.getActiveSpreadsheet(); var sheet = ss.getSheets()[0]; Logger.log(sheet.getSheetId());
리턴
Integer
: 스프레드시트에 고유한 시트 ID
승인
이 방법을 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
getSheetName()
시트 이름을 반환합니다.
var ss = SpreadsheetApp.getActiveSpreadsheet(); var sheet = ss.getSheets()[0]; Logger.log(sheet.getSheetName());
리턴
String
: 시트의 이름
승인
이 방법을 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
getSheetValues(startRow, startColumn, numRows, numColumns)
지정된 좌표에서 시작하여 이 범위에 대해 값의 직사각형 그리드를 반환합니다. 행 또는 열 위치로 지정된 -1 값은 시트에 데이터가 있는 마지막 행 또는 열을 가져오는 것과 같습니다.
var ss = SpreadsheetApp.getActiveSpreadsheet(); var sheet = ss.getSheets()[0]; // The two samples below produce the same output var values = sheet.getSheetValues(1, 1, 3, 3); Logger.log(values); var range = sheet.getRange(1, 1, 3, 3); values = range.getValues(); Logger.log(values);
매개변수
이름 | 유형 | 설명 |
---|---|---|
startRow | Integer | 시작 행의 위치입니다. |
startColumn | Integer | 시작 열의 위치입니다. |
numRows | Integer | 값을 반환할 행 수입니다. |
numColumns | Integer | 값을 반환할 열의 개수입니다. |
리턴
Object[][]
— 값의 2차원 배열
승인
이 방법을 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
getSheets()
이 스프레드시트의 모든 시트를 가져옵니다.
// The code below logs the name of the second sheet var sheets = SpreadsheetApp.getActiveSpreadsheet().getSheets(); if (sheets.length > 1) { Logger.log(sheets[1].getName()); }
리턴
Sheet[]
- 스프레드시트에 있는 모든 시트의 배열입니다.
getSpreadsheetLocale()
스프레드시트 언어를 가져옵니다.
// 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
getSpreadsheetTheme()
스프레드시트의 현재 테마를 반환하거나 테마가 적용되지 않은 경우 null
를 반환합니다.
// The code below returns the current theme of the spreadsheet. var currentTheme = SpreadsheetApp.getActiveSpreadsheet().getSpreadsheetTheme();
리턴
SpreadsheetTheme
- 현재 적용된 테마입니다.
승인
이 방법을 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
getSpreadsheetTimeZone()
스프레드시트의 시간대를 가져옵니다.
// 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
getUrl()
지정된 스프레드시트의 URL을 반환합니다.
var ss = SpreadsheetApp.getActiveSpreadsheet(); Logger.log(ss.getUrl());
리턴
String
- 지정된 스프레드시트의 URL입니다.
승인
이 방법을 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
getViewers()
이 Spreadsheet
의 뷰어 및 댓글 작성자 목록을 가져옵니다.
리턴
User[]
- 보기 또는 댓글 작성 권한이 있는 사용자의 배열.
승인
이 방법을 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
hideColumn(column)
지정된 범위에서 열을 숨깁니다.
let ss = SpreadsheetApp.getActiveSpreadsheet(); let sheet = ss.getSheets()[0]; // This hides the first column let range = sheet.getRange("A1"); sheet.hideColumn(range); // This hides the first 3 columns let range = sheet.getRange("A:C"); sheet.hideColumn(range);
매개변수
이름 | 유형 | 설명 |
---|---|---|
column | Range | 숨길 열 범위입니다. |
승인
이 방법을 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
hideRow(row)
지정된 범위에서 행을 숨깁니다.
var ss = SpreadsheetApp.getActiveSpreadsheet(); var sheet = ss.getSheets()[0]; // This hides the first row var range = sheet.getRange("A1"); sheet.hideRow(range);
매개변수
이름 | 유형 | 설명 |
---|---|---|
row | Range | 숨길 행 범위입니다. |
승인
이 방법을 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
insertColumnAfter(afterPosition)
지정된 열 위치 뒤에 열을 삽입합니다.
var ss = SpreadsheetApp.getActiveSpreadsheet(); var sheet = ss.getSheets()[0]; // This inserts a column after the first column position sheet.insertColumnAfter(1);
매개변수
이름 | 유형 | 설명 |
---|---|---|
afterPosition | Integer | 뒤에 새 열을 추가해야 하는 열입니다. |
리턴
Sheet
: 메서드 체이닝에 유용한 시트
승인
이 방법을 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
insertColumnBefore(beforePosition)
지정된 열 위치 앞에 열을 삽입합니다.
var ss = SpreadsheetApp.getActiveSpreadsheet(); var sheet = ss.getSheets()[0]; // This inserts a column in the first column position sheet.insertColumnBefore(1);
매개변수
이름 | 유형 | 설명 |
---|---|---|
beforePosition | Integer | 앞에 새 열을 추가해야 하는 열입니다. |
리턴
Sheet
: 메서드 체이닝에 유용한 시트
승인
이 방법을 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
insertColumnsAfter(afterPosition, howMany)
지정된 열 위치 뒤에 여러 열을 삽입합니다.
var ss = SpreadsheetApp.getActiveSpreadsheet(); var sheet = ss.getSheets()[0]; // This inserts a column in the second column position sheet.insertColumnsAfter(1);
매개변수
이름 | 유형 | 설명 |
---|---|---|
afterPosition | Integer | 뒤에 새 열을 추가해야 하는 열입니다. |
howMany | Integer | 삽입할 열의 수입니다. |
리턴
Sheet
: 메서드 체이닝에 유용한 시트
승인
이 방법을 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
insertColumnsBefore(beforePosition, howMany)
지정된 열 위치 앞에 여러 열을 삽입합니다.
var ss = SpreadsheetApp.getActiveSpreadsheet(); var sheet = ss.getSheets()[0]; // This inserts five columns before the first column sheet.insertColumnsBefore(1, 5);
매개변수
이름 | 유형 | 설명 |
---|---|---|
beforePosition | Integer | 앞에 새 열을 추가해야 하는 열입니다. |
howMany | Integer | 삽입할 열의 수입니다. |
리턴
Sheet
: 메서드 체이닝에 유용한 시트
승인
이 방법을 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
insertDataSourceSheet(spec)
스프레드시트에 새 DataSourceSheet
를 삽입하고 데이터 실행을 시작합니다. 이로 인해 새 시트가 활성 시트가 됩니다.
데이터 소스 유형이 사용 설정되지 않은 경우 예외가 발생합니다. SpreadsheetApp#enable...Execution()
메서드를 사용하여 특정 데이터 소스 유형에 대해 데이터 실행을 사용 설정합니다.
// 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 | DataSourceSpec | 삽입할 데이터 소스 사양입니다. |
리턴
DataSourceSheet
- 새 데이터 소스 시트입니다.
승인
이 방법을 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
insertImage(blobSource, column, row)
문서의 지정된 행과 열에 Spreadsheet
을 이미지로 삽입합니다. 이미지 크기는 blob 콘텐츠에서 가져옵니다. 지원되는 최대 blob 크기는 2MB입니다.
var ss = SpreadsheetApp.getActiveSpreadsheet(); var sheet = ss.getSheets()[0]; var blob = Utilities.newBlob(binaryData, 'image/png', 'MyImageName'); sheet.insertImage(blob, 1, 1);
매개변수
이름 | 유형 | 설명 |
---|---|---|
blobSource | BlobSource | 이미지 콘텐츠, MIME 유형, 이름 (선택사항)이 포함된 blob입니다. |
column | Integer | 열 위치입니다. |
row | Integer | 행 위치입니다. |
리턴
OverGridImage
- 삽입된 이미지입니다.
승인
이 방법을 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
insertImage(blobSource, column, row, offsetX, offsetY)
문서에서 지정된 행과 열에 픽셀 오프셋과 함께 Spreadsheet
를 이미지로 삽입합니다. 이미지 크기는 blob 콘텐츠에서 가져옵니다. 지원되는 최대 blob 크기는 2MB입니다.
var ss = SpreadsheetApp.getActiveSpreadsheet(); var sheet = ss.getSheets()[0]; var blob = Utilities.newBlob(binaryData, 'image/png', 'MyImageName'); sheet.insertImage(blob, 1, 1, 10, 10);
매개변수
이름 | 유형 | 설명 |
---|---|---|
blobSource | BlobSource | 이미지 콘텐츠, MIME 유형, 이름 (선택사항)이 포함된 blob입니다. |
column | Integer | 열 위치입니다. |
row | Integer | 행 위치입니다. |
offsetX | Integer | 셀 모서리로부터의 가로 오프셋(픽셀)입니다. |
offsetY | Integer | 셀 모서리로부터의 세로 오프셋(픽셀)입니다. |
리턴
OverGridImage
- 삽입된 이미지입니다.
승인
이 방법을 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
insertImage(url, column, row)
문서의 지정된 행과 열에 이미지를 삽입합니다.
제공된 URL은 공개적으로 액세스할 수 있어야 합니다.
var ss = SpreadsheetApp.getActiveSpreadsheet(); var sheet = ss.getSheets()[0]; sheet.insertImage("https://www.google.com/images/srpr/logo3w.png", 1, 1);
매개변수
이름 | 유형 | 설명 |
---|---|---|
url | String | 이미지의 URL입니다. |
column | Integer | 그리드 열 위치입니다. |
row | Integer | 그리드 행 위치입니다. |
리턴
OverGridImage
- 삽입된 이미지입니다.
승인
이 방법을 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
insertImage(url, column, row, offsetX, offsetY)
문서에서 지정된 행과 열에 픽셀 오프셋을 사용하여 이미지를 삽입합니다.
제공된 URL은 공개적으로 액세스할 수 있어야 합니다.
var ss = SpreadsheetApp.getActiveSpreadsheet(); var 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 | 셀 모서리로부터의 세로 오프셋(픽셀)입니다. |
리턴
OverGridImage
- 삽입된 이미지입니다.
승인
이 방법을 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
insertRowAfter(afterPosition)
지정된 행 위치 뒤에 행을 삽입합니다.
var ss = SpreadsheetApp.getActiveSpreadsheet(); var sheet = ss.getSheets()[0]; // This inserts a row after the first row position sheet.insertRowAfter(1);
매개변수
이름 | 유형 | 설명 |
---|---|---|
afterPosition | Integer | 새 행을 추가해야 하는 행입니다. |
리턴
Sheet
: 메서드 체이닝에 유용한 시트
승인
이 방법을 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
insertRowBefore(beforePosition)
지정된 행 위치 앞에 행을 삽입합니다.
var ss = SpreadsheetApp.getActiveSpreadsheet(); var sheet = ss.getSheets()[0]; // This inserts a row before the first row position sheet.insertRowBefore(1);
매개변수
이름 | 유형 | 설명 |
---|---|---|
beforePosition | Integer | 앞에 새 행을 추가해야 하는 행입니다. |
리턴
Sheet
: 메서드 체이닝에 유용한 시트
승인
이 방법을 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
insertRowsAfter(afterPosition, howMany)
지정된 행 위치 뒤에 여러 행을 삽입합니다.
var ss = SpreadsheetApp.getActiveSpreadsheet(); var sheet = ss.getSheets()[0]; // This inserts five rows after the first row sheet.insertRowsAfter(1, 5);
매개변수
이름 | 유형 | 설명 |
---|---|---|
afterPosition | Integer | 새 행을 추가해야 하는 행입니다. |
howMany | Integer | 삽입할 행 수입니다. |
리턴
Sheet
: 메서드 체이닝에 유용한 시트
승인
이 방법을 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
insertRowsBefore(beforePosition, howMany)
지정된 행 위치 앞에 여러 행을 삽입합니다.
var ss = SpreadsheetApp.getActiveSpreadsheet(); var sheet = ss.getSheets()[0]; // This inserts five rows before the first row sheet.insertRowsBefore(1, 5);
매개변수
이름 | 유형 | 설명 |
---|---|---|
beforePosition | Integer | 새 행을 추가해야 하는 행입니다. |
howMany | Integer | 삽입할 행 수입니다. |
리턴
Sheet
: 메서드 체이닝에 유용한 시트
승인
이 방법을 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
insertSheet()
insertSheet(sheetIndex)
스프레드시트에 지정된 색인의 새 시트를 삽입합니다. 그러면 새 시트가 활성 시트가 됩니다.
var ss = SpreadsheetApp.getActiveSpreadsheet(); ss.insertSheet(1);
매개변수
이름 | 유형 | 설명 |
---|---|---|
sheetIndex | Integer | 새로 만든 시트의 색인입니다. 스프레드시트의 첫 번째 시트로 시트를 삽입하려면 0으로 설정하세요. |
리턴
Sheet
- 새 시트입니다.
승인
이 방법을 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
insertSheet(sheetIndex, options)
지정된 색인의 스프레드시트에 새 시트를 삽입하고 선택적 고급 인수를 사용합니다. 그러면 새 시트가 활성 시트가 됩니다.
var ss = SpreadsheetApp.getActiveSpreadsheet(); var templateSheet = ss.getSheetByName('Sales'); ss.insertSheet(1, {template: templateSheet});
매개변수
이름 | 유형 | 설명 |
---|---|---|
sheetIndex | Integer | 새로 만든 시트의 색인입니다. 스프레드시트의 첫 번째 시트로 시트를 삽입하려면 0으로 설정하세요. |
options | Object | 선택적 자바스크립트 고급 인수입니다. |
고급 매개변수
이름 | 유형 | 설명 |
---|---|---|
template | Sheet | 템플릿 시트 객체의 모든 데이터가 새 시트에 복사됩니다. 시트 템플릿은 스프레드시트 객체의 시트 중 하나여야 합니다. |
리턴
Sheet
- 새 시트입니다.
승인
이 방법을 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
insertSheet(options)
기본 시트 이름과 선택적 고급 인수를 사용하여 스프레드시트에 새 시트를 삽입합니다. 그러면 새 시트가 활성 시트가 됩니다.
var ss = SpreadsheetApp.getActiveSpreadsheet(); var templateSheet = ss.getSheetByName('Sales'); ss.insertSheet({template: templateSheet});
매개변수
이름 | 유형 | 설명 |
---|---|---|
options | Object | 아래에 나열된 선택적 자바스크립트 고급 인수입니다. |
고급 매개변수
이름 | 유형 | 설명 |
---|---|---|
template | Sheet | 템플릿 시트 객체의 모든 데이터가 새 시트에 복사됩니다. 시트 템플릿은 이 스프레드시트 객체의 시트 중 하나여야 합니다. |
리턴
Sheet
- 새 시트입니다.
승인
이 방법을 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
insertSheet(sheetName)
스프레드시트에 지정된 이름의 새 시트를 삽입합니다. 그러면 새 시트가 활성 시트가 됩니다.
var ss = SpreadsheetApp.getActiveSpreadsheet(); ss.insertSheet('My New Sheet');
매개변수
이름 | 유형 | 설명 |
---|---|---|
sheetName | String | 새 시트의 이름입니다. |
리턴
Sheet
- 새 시트입니다.
승인
이 방법을 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
insertSheet(sheetName, sheetIndex)
지정된 색인에서 지정된 이름의 새 시트를 스프레드시트에 삽입합니다. 새 시트가 활성 시트가 됩니다.
var ss = SpreadsheetApp.getActiveSpreadsheet(); ss.insertSheet('My New Sheet', 1);
매개변수
이름 | 유형 | 설명 |
---|---|---|
sheetName | String | 새 시트의 이름입니다. |
sheetIndex | Integer | 새로 만든 시트의 색인입니다. 스프레드시트의 첫 번째 시트로 시트를 삽입하려면 0으로 설정하세요. |
리턴
Sheet
- 새 시트입니다.
승인
이 방법을 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
insertSheet(sheetName, sheetIndex, options)
지정된 색인에 지정된 이름을 가진 새 시트를 스프레드시트에 삽입하고 선택적 고급 인수를 사용합니다. 그러면 새 시트가 활성 시트가 됩니다.
var ss = SpreadsheetApp.getActiveSpreadsheet(); var templateSheet = ss.getSheetByName('Sales'); ss.insertSheet('My New Sheet', 1, {template: templateSheet});
매개변수
이름 | 유형 | 설명 |
---|---|---|
sheetName | String | 새 시트의 이름입니다. |
sheetIndex | Integer | 새로 삽입된 시트의 색인입니다. 스프레드시트의 첫 번째 시트로 시트를 삽입하려면 0으로 설정하세요. |
options | Object | 선택적 자바스크립트 고급 인수입니다. |
고급 매개변수
이름 | 유형 | 설명 |
---|---|---|
template | Sheet | 템플릿 시트 객체의 모든 데이터가 새 시트에 복사됩니다. 시트 템플릿은 스프레드시트 객체의 시트 중 하나여야 합니다. |
리턴
Sheet
- 새 시트입니다.
승인
이 방법을 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
insertSheet(sheetName, options)
지정된 이름의 새 시트를 스프레드시트에 삽입하고 선택적 고급 인수를 사용합니다. 그러면 새 시트가 활성 시트가 됩니다.
var ss = SpreadsheetApp.getActiveSpreadsheet(); var templateSheet = ss.getSheetByName('Sales'); ss.insertSheet('My New Sheet', {template: templateSheet});
매개변수
이름 | 유형 | 설명 |
---|---|---|
sheetName | String | 새 시트의 이름입니다. |
options | Object | 선택적 자바스크립트 고급 인수입니다. |
고급 매개변수
이름 | 유형 | 설명 |
---|---|---|
template | Sheet | 템플릿 시트 객체의 모든 데이터가 새 시트에 복사됩니다. 시트 템플릿은 스프레드시트 객체의 시트 중 하나여야 합니다. |
리턴
Sheet
- 새 시트입니다.
승인
이 방법을 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
insertSheetWithDataSourceTable(spec)
스프레드시트에 새 시트를 삽입하고 지정된 데이터 소스 사양이 있는 전체 시트에 걸쳐 DataSourceTable
를 만들고 데이터 실행을 시작합니다. 이로 인해 새 시트를 활성 시트로 만듭니다.
데이터 소스 유형이 사용 설정되지 않은 경우 예외가 발생합니다. SpreadsheetApp#enable...Execution()
메서드를 사용하여 특정 데이터 소스 유형에 대해 데이터 실행을 사용 설정합니다.
// 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 | DataSourceSpec | 삽입할 데이터 소스 사양입니다. |
리턴
Sheet
- 새 시트입니다.
승인
이 방법을 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
isColumnHiddenByUser(columnPosition)
지정된 열이 사용자에 의해 숨겨져 있는지 여부를 반환합니다.
var ss = SpreadsheetApp.getActiveSpreadsheet(); var sheet = ss.getSheets()[0]; // Columns start at 1 Logger.log(sheet.isColumnHiddenByUser(1));
매개변수
이름 | 유형 | 설명 |
---|---|---|
columnPosition | Integer | 검사할 열의 위치입니다. |
리턴
Boolean
: 열이 숨겨져 있으면 true
, 그렇지 않으면 false
입니다.
승인
이 방법을 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
isIterativeCalculationEnabled()
이 스프레드시트에서 반복 계산이 활성화되었는지 여부를 반환합니다.
// 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
isRowHiddenByFilter(rowPosition)
지정된 행이 필터 보기가 아닌 필터에 의해 숨겨졌는지 여부를 반환합니다.
var ss = SpreadsheetApp.getActiveSpreadsheet(); var sheet = ss.getSheets()[0]; // Rows start at 1 Logger.log(sheet.isRowHiddenByFilter(1));
매개변수
이름 | 유형 | 설명 |
---|---|---|
rowPosition | Integer | 검사할 행의 위치입니다. |
리턴
Boolean
: 행이 숨겨져 있으면 true
, 그렇지 않으면 false
입니다.
승인
이 방법을 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
isRowHiddenByUser(rowPosition)
지정된 행이 사용자에 의해 숨겨져 있는지 여부를 반환합니다.
var ss = SpreadsheetApp.getActiveSpreadsheet(); var sheet = ss.getSheets()[0]; // Rows start at 1 Logger.log(sheet.isRowHiddenByUser(1));
매개변수
이름 | 유형 | 설명 |
---|---|---|
rowPosition | Integer | 검사할 행의 위치입니다. |
리턴
Boolean
: 행이 숨겨져 있으면 true
, 그렇지 않으면 false
입니다.
승인
이 방법을 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
moveActiveSheet(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. var spreadsheet = SpreadsheetApp.getActiveSpreadsheet(); // Gets the "first" sheet and activates it. var 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
moveChartToObjectSheet(chart)
새 SheetType.OBJECT
시트를 만들고 제공된 차트를 이 시트로 이동합니다. 차트가 이미 자체 시트에 있는 경우 새 시트를 만들지 않고 해당 시트가 반환됩니다.
var sheet = SpreadsheetApp.getActiveSheet(); var chart = sheet.newChart().setPosition(1, 1, 0, 0).build(); sheet.insertChart(chart); var objectSheet = SpreadsheetApp.getActive().moveChartToObjectSheet(chart);
매개변수
이름 | 유형 | 설명 |
---|---|---|
chart | EmbeddedChart | 이동할 차트입니다. |
리턴
Sheet
- 차트가 있는 시트입니다.
승인
이 방법을 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
refreshAllDataSources()
지원되는 모든 데이터 소스 및 연결된 데이터 소스 객체를 새로고침하고 잘못된 데이터 소스 객체를 건너뜁니다.
SpreadsheetApp#enable...Execution()
메서드를 사용하여 특정 데이터 소스 유형에 대해 데이터 실행을 사용 설정합니다.
// 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
removeEditor(emailAddress)
Spreadsheet
의 편집자 목록에서 지정된 사용자를 삭제합니다. 이 메서드는 사용자가 일반 액세스 권한을 가진 사용자 클래스에 속하는 경우(예: Spreadsheet
가 사용자의 전체 도메인과 공유되거나 Spreadsheet
가 사용자가 액세스할 수 있는 공유 드라이브에 있는 경우) Spreadsheet
에 액세스하는 것을 차단하지 않습니다.
Drive 파일의 경우 뷰어 목록에서도 사용자가 삭제됩니다.
매개변수
이름 | 유형 | 설명 |
---|---|---|
emailAddress | String | 삭제할 사용자의 이메일 주소입니다. |
리턴
Spreadsheet
- 연결을 위한 이 Spreadsheet
입니다.
승인
이 방법을 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
removeEditor(user)
Spreadsheet
의 편집자 목록에서 지정된 사용자를 삭제합니다. 이 메서드는 사용자가 일반 액세스 권한을 가진 사용자 클래스에 속하는 경우(예: Spreadsheet
가 사용자의 전체 도메인과 공유되거나 Spreadsheet
가 사용자가 액세스할 수 있는 공유 드라이브에 있는 경우) Spreadsheet
에 액세스하는 것을 차단하지 않습니다.
Drive 파일의 경우 뷰어 목록에서도 사용자가 삭제됩니다.
매개변수
이름 | 유형 | 설명 |
---|---|---|
user | User | 삭제할 사용자의 표현입니다. |
리턴
Spreadsheet
- 연결을 위한 이 Spreadsheet
입니다.
승인
이 방법을 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
removeMenu(name)
addMenu(name, subMenus)
에서 추가한 메뉴를 삭제합니다. name
인수는 상응하는 addMenu(name, subMenus)
호출과 값이 같아야 합니다.
// The onOpen function is executed automatically every time a Spreadsheet is loaded function onOpen() { var ss = SpreadsheetApp.getActiveSpreadsheet(); ss.addMenu("badMenu", [{name: "remove bad menu", functionName: "removeBadMenu"}, {name: "foo", functionName: "foo"}]); } function removeBadMenu() { var 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
removeNamedRange(name)
지정된 이름을 가진 이름이 지정된 범위를 삭제합니다. 스프레드시트에 지정된 이름의 범위를 찾을 수 없으면 예외가 발생합니다.
// The code below creates a new named range "foo", and then remove it. var 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
removeViewer(emailAddress)
Spreadsheet
의 뷰어 및 댓글 작성자 목록에서 지정된 사용자를 삭제합니다. 사용자가 뷰어나 댓글 작성자가 아닌 편집자인 경우에는 이 방법이 아무런 영향을 미치지 않습니다. 또한 이 메서드는 사용자가 일반 액세스 권한을 가진 사용자 클래스에 속하는 경우(예: Spreadsheet
가 사용자의 전체 도메인과 공유되거나 Spreadsheet
가 사용자가 액세스할 수 있는 공유 드라이브에 있는 경우) Spreadsheet
에 액세스하는 것을 차단하지 않습니다.
Drive 파일의 경우 편집자 목록에서도 사용자가 삭제됩니다.
매개변수
이름 | 유형 | 설명 |
---|---|---|
emailAddress | String | 삭제할 사용자의 이메일 주소입니다. |
리턴
Spreadsheet
: 이 Spreadsheet
는 연계를 위한 것입니다.
승인
이 방법을 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
removeViewer(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)
문서 이름을 바꿉니다.
var ss = SpreadsheetApp.getActiveSpreadsheet(); ss.rename("This is the new name");
매개변수
이름 | 유형 | 설명 |
---|---|---|
newName | String | 문서의 새 이름입니다. |
승인
이 방법을 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
renameActiveSheet(newName)
현재 활성 시트의 이름을 지정된 새 이름으로 바꿉니다.
// The code below renames the active sheet to "Hello world" SpreadsheetApp.getActiveSpreadsheet().renameActiveSheet("Hello world");
매개변수
이름 | 유형 | 설명 |
---|---|---|
newName | String | 현재 활성 시트의 새 이름입니다. |
승인
이 방법을 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
resetSpreadsheetTheme()
적용된 테마를 삭제하고 스프레드시트에 기본 테마를 설정합니다.
// The code below applies default theme on the spreadsheet. SpreadsheetApp.getActiveSpreadsheet().resetSpreadsheetTheme();
리턴
SpreadsheetTheme
- 기본 테마입니다.
승인
이 방법을 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
setActiveRange(range)
지정된 범위를 활성 시트에서 active range
로 설정하고 범위의 왼쪽 상단 셀은 current cell
로 설정합니다.
var sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet(); var range = sheet.getRange('A1:D4'); sheet.setActiveRange(range); var selection = sheet.getSelection(); // Current cell: A1 var currentCell = selection.getCurrentCell(); // Active Range: A1:D4 var activeRange = selection.getActiveRange();
매개변수
이름 | 유형 | 설명 |
---|---|---|
range | Range | 활성 범위로 설정할 범위입니다. |
리턴
Range
- 새로 활성 범위
승인
이 방법을 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
setActiveRangeList(rangeList)
활성 시트에서 지정된 범위 목록을 active ranges
로 설정합니다. 목록의 마지막 범위가 active range
로 설정됩니다.
var sheet = SpreadsheetApp.getActiveSheet(); var rangeList = sheet.getRangeList(['D4', 'B2:C4']); sheet.setActiveRangeList(rangeList); var selection = sheet.getSelection(); // Current cell: B2 var currentCell = selection.getCurrentCell(); // Active range: B2:C4 var activeRange = selection.getActiveRange(); // Active range list: [D4, B2:C4] var activeRangeList = selection.getActiveRangeList();
매개변수
이름 | 유형 | 설명 |
---|---|---|
rangeList | RangeList | 선택할 범위 목록입니다. |
리턴
RangeList
- 새로 선택한 범위 목록
승인
이 방법을 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
setActiveSelection(range)
이 시트의 활성 선택 영역을 설정합니다.
var ss = SpreadsheetApp.getActiveSpreadsheet(); var sheet = ss.getSheets()[0]; var range = sheet.getRange("A1:D4"); sheet.setActiveSelection(range);
매개변수
이름 | 유형 | 설명 |
---|---|---|
range | Range | 활성 선택으로 설정할 범위입니다. |
리턴
Range
- 새로 활성 범위
승인
이 방법을 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
setActiveSelection(a1Notation)
A1 표기법 또는 R1C1 표기법에 지정된 대로 활성 선택을 설정합니다.
var ss = SpreadsheetApp.getActiveSpreadsheet(); var 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
setActiveSheet(sheet)
지정된 시트를 스프레드시트의 활성 시트로 설정합니다. 시트가 다른 스프레드시트에 속하지 않는 한 Google Sheets UI는 선택한 시트를 표시합니다.
// The code below makes the first sheet active in the active spreadsheet. var spreadsheet = SpreadsheetApp.getActiveSpreadsheet(); spreadsheet.setActiveSheet(spreadsheet.getSheets()[0]);
매개변수
이름 | 유형 | 설명 |
---|---|---|
sheet | Sheet | 활성 시트로 설정할 시트입니다. |
리턴
Sheet
- 활성 시트입니다.
승인
이 방법을 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
setActiveSheet(sheet, restoreSelection)
해당 시트 내에서 가장 최근에 선택한 항목을 복원하는 옵션과 함께 지정된 시트를 스프레드시트의 활성 시트로 설정합니다. 시트가 다른 스프레드시트에 속해 있지 않으면 Google Sheets UI에 선택된 시트가 표시됩니다.
var spreadsheet = SpreadsheetApp.getActiveSpreadsheet(); var firstSheet = spreadsheet.getSheets()[0]; var 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 var range = spreadsheet.getActiveSheet().getSelection().getActiveRange(); Logger.log(range.getA1Notation());
매개변수
이름 | 유형 | 설명 |
---|---|---|
sheet | Sheet | 새 활성 시트입니다. |
restoreSelection | Boolean | Tf true 인 경우 새 시트가 활성화되면 새 활성 시트의 가장 최근에 선택한 항목이 다시 선택됩니다. false 인 경우 현재 선택을 변경하지 않고 새 시트가 활성화됩니다. |
리턴
Sheet
- 새 활성 시트입니다.
승인
이 방법을 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
setColumnWidth(columnPosition, width)
지정된 열의 너비를 픽셀 단위로 설정합니다.
var ss = SpreadsheetApp.getActiveSpreadsheet(); var sheet = ss.getSheets()[0]; // Sets the first column to a width of 200 pixels sheet.setColumnWidth(1, 200);
매개변수
이름 | 유형 | 설명 |
---|---|---|
columnPosition | Integer | 설정할 지정된 열의 위치입니다. |
width | Integer | 설정할 너비(픽셀)입니다. |
리턴
Sheet
: 메서드 체이닝에 유용한 시트
승인
이 방법을 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
setCurrentCell(cell)
지정된 셀을 current cell
로 설정합니다.
지정된 셀이 이미 선택된 범위 내에 있으면 이 범위는 셀이 현재 셀인 활성 범위가 됩니다.
지정된 셀이 선택한 범위에 없으면, 기존 선택이 삭제되고 셀이 현재 셀 및 활성 범위가 됩니다.
참고: 지정된 Range
는 하나의 셀로 구성되어야 하며, 그렇지 않으면 예외가 발생합니다.
var sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet(); var cell = sheet.getRange('B5'); sheet.setCurrentCell(cell); var selection = sheet.getSelection(); // Current cell: B5 var currentCell = selection.getCurrentCell();
매개변수
이름 | 유형 | 설명 |
---|---|---|
cell | Range | 현재 셀로 설정할 셀입니다. |
리턴
Range
— 새로 설정된 현재 셀
승인
이 방법을 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
setFrozenColumns(columns)
지정된 수의 열을 고정합니다. 0인 경우 열이 고정되지 않습니다.
var ss = SpreadsheetApp.getActiveSpreadsheet(); var 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
setFrozenRows(rows)
지정된 수의 행을 고정합니다. 0인 경우 어떤 행도 고정되지 않습니다.
var ss = SpreadsheetApp.getActiveSpreadsheet(); var 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
setIterativeCalculationConvergenceThreshold(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());
매개변수
이름 | 유형 | 설명 |
---|---|---|
minThreshold | Number | 최소 수렴 임곗값입니다 (음수가 아니어야 함). |
리턴
Spreadsheet
— 연결용 스프레드시트입니다.
승인
이 방법을 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
setIterativeCalculationEnabled(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());
매개변수
이름 | 유형 | 설명 |
---|---|---|
isEnabled | Boolean | 반복 계산을 사용해야 하는 경우 true , 그렇지 않은 경우 false |
리턴
Spreadsheet
— 연결용 스프레드시트입니다.
승인
이 방법을 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
setMaxIterativeCalculationCycles(maxIterations)
반복 계산 중 수행해야 하는 최대 계산 반복 수를 설정합니다. 이 값은 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());
매개변수
이름 | 유형 | 설명 |
---|---|---|
maxIterations | Integer | 계산의 최대 반복 횟수 (1~10,000)입니다. |
리턴
Spreadsheet
— 연결용 스프레드시트입니다.
승인
이 방법을 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
setNamedRange(name, range)
범위의 이름을 지정합니다.
// The code below creates a new named range "TaxRates" in the active spreadsheet var 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
setRecalculationInterval(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);
매개변수
이름 | 유형 | 설명 |
---|---|---|
recalculationInterval | RecalculationInterval | 새 재계산 간격. |
리턴
Spreadsheet
— 연결용 스프레드시트입니다.
승인
이 방법을 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
setRowHeight(rowPosition, height)
지정된 행의 행 높이를 픽셀 단위로 설정합니다. 기본적으로 행은 셀 내용에 맞게 늘어납니다. 행을 지정된 높이로 강제 설정하려면 Sheet.setRowHeightsForced(startRow, numRows, height)
를 사용합니다.
var ss = SpreadsheetApp.getActiveSpreadsheet(); var sheet = ss.getSheets()[0]; // Sets the first row to a height of 200 pixels sheet.setRowHeight(1, 200);
매개변수
이름 | 유형 | 설명 |
---|---|---|
rowPosition | Integer | 변경할 행 위치입니다. |
height | Integer | 설정할 높이(픽셀)입니다. |
리턴
Sheet
- 시트로, 메서드 체이닝에 유용합니다.
승인
이 방법을 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
setSpreadsheetLocale(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
setSpreadsheetTheme(theme)
스프레드시트에 테마를 설정합니다.
var spreadsheet = SpreadsheetApp.getActiveSpreadsheet(); // The code below sets the second predefined theme as the current theme of the spreadsheet. var predefinedThemesList = spreadsheet.getPredefinedSpreadsheetThemes(); spreadsheet.setSpreadsheetTheme(predefinedThemesList[1]);
매개변수
이름 | 유형 | 설명 |
---|---|---|
theme | SpreadsheetTheme | 적용할 테마입니다. |
리턴
SpreadsheetTheme
- 새로운 현재 테마입니다.
승인
이 방법을 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
setSpreadsheetTimeZone(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 | 'long' 형식으로 지정된 시간대입니다 (예: Joda.org에서 나열한 'America/New_York'). |
승인
이 방법을 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
show(userInterface)
사용자 브라우저의 표시 영역을 중심으로 하는 대화상자에 맞춤 사용자 인터페이스 구성요소를 표시합니다. 서버 측 스크립트의 실행이 정지되지 않습니다. 서버 측과 통신하려면 사용자 인터페이스 구성요소가 서버 측 스크립트에 비동기 콜백을 실행해야 합니다.
서버 측 스크립트가 이전에 아직 닫지 않은 대화상자를 표시했다면 기존 대화상자가 새로 요청된 대화상자의 사용자 인터페이스로 대체됩니다.
다음 코드 스니펫은 지정된 제목, 높이, 너비가 있는 대화상자에 간단한 HtmlService
애플리케이션을 표시합니다.
var 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.
매개변수
이름 | 유형 | 설명 |
---|---|---|
userInterface | Object | HtmlOutput |
승인
이 방법을 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/script.container.ui
sort(columnPosition)
열을 기준으로 시트를 오름차순으로 정렬합니다.
var ss = SpreadsheetApp.getActiveSpreadsheet(); var sheet = ss.getSheets()[0]; // Sorts the sheet by the first column, ascending sheet.sort(1);
매개변수
이름 | 유형 | 설명 |
---|---|---|
columnPosition | Integer | 정렬할 열입니다. |
리턴
Sheet
: 메서드 체이닝에 유용한 시트
승인
이 방법을 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
sort(columnPosition, ascending)
열을 기준으로 시트를 정렬합니다. 매개변수를 사용하여 오름차순 또는 내림차순을 지정합니다.
var ss = SpreadsheetApp.getActiveSpreadsheet(); var sheet = ss.getSheets()[0]; // Sorts the sheet by the first column, descending sheet.sort(1, false);
매개변수
이름 | 유형 | 설명 |
---|---|---|
columnPosition | 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 | 토스트의 제목(선택사항)입니다. |
timeoutSeconds | Number | 제한 시간(초)입니다. null 인 경우 토스트 메시지는 기본적으로 5초로 설정됩니다. 음수인 경우 토스트 메시지는 닫을 때까지 유지됩니다. |
승인
이 방법을 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
unhideColumn(column)
지정된 범위에서 열을 숨기기 해제합니다.
var ss = SpreadsheetApp.getActiveSpreadsheet(); var sheet = ss.getSheets()[0]; // This unhides the first column if it was previously hidden var range = sheet.getRange("A1"); sheet.unhideColumn(range);
매개변수
이름 | 유형 | 설명 |
---|---|---|
column | Range | 숨기기 해제할 범위입니다(숨겨진 경우). |
승인
이 방법을 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
unhideRow(row)
지정된 범위에서 행 숨기기를 해제합니다.
var ss = SpreadsheetApp.getActiveSpreadsheet(); var sheet = ss.getSheets()[0]; // This unhides the first row if it was previously hidden var range = sheet.getRange("A1"); sheet.unhideRow(range);
매개변수
이름 | 유형 | 설명 |
---|---|---|
row | Range | 숨기기 해제할 범위입니다(숨겨진 경우). |
승인
이 방법을 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
updateMenu(name, subMenus)
addMenu(name, subMenus)
에서 추가한 메뉴를 업데이트합니다. addMenu(name, subMenus)
와 동일하게 작동합니다.
var ss = SpreadsheetApp.getActiveSpreadsheet(); var menuEntries = []; menuEntries.push({name: "Lone Menu Entry", functionName: "function1"}); ss.updateMenu("addMenuExample", menuEntries);
매개변수
이름 | 유형 | 설명 |
---|---|---|
name | String | 업데이트할 메뉴의 이름입니다. |
subMenus | Object[] | name 및 functionName
매개변수가 있는 자바스크립트 지도의 배열입니다. 포함된 라이브러리(예:
Library.libFunction1 )의 함수를 사용할 수 있습니다. |
승인
이 방법을 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
waitForAllDataExecutionsCompletion(timeoutInSeconds)
스프레드시트의 현재 실행이 모두 완료될 때까지 기다린 후 지정된 시간(초)이 지나면 타임아웃됩니다. 타임아웃 시 실행이 완료되지 않으면 예외를 발생시키지만 데이터 실행을 취소하지는 않습니다.
매개변수
이름 | 유형 | 설명 |
---|---|---|
timeoutInSeconds | Integer | 데이터 실행을 기다리는 시간(초)입니다. 최댓값은 300초입니다. |
승인
이 방법을 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets