스프레드시트 시트에 액세스하고 수정합니다. 일반적인 작업은 시트 이름을 바꾸고 시트에서 범위 객체에 액세스하는 것입니다.
메서드
자세한 문서
activate()
이 시트를 활성화합니다. 시트 자체는 변경하지 않고 활성 시트에 대한 상위의 개념만 변경합니다.
// This example assumes there is a sheet named "first" const ss = SpreadsheetApp.getActiveSpreadsheet(); const first = ss.getSheetByName('first'); first.activate();
리턴
Sheet
- 새로 활성화된 시트입니다.
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', ); // Gets a sheet by its name. const sheet = ss.getSheetByName('Sheet1'); // Adds the key 'NAME' to the developer metadata for the sheet. sheet.addDeveloperMetadata('NAME'); // Gets the updated metadata info and logs it to the console. console.log(sheet.getDeveloperMetadata()[0].getKey());
매개변수
이름 | 유형 | 설명 |
---|---|---|
key | String | 새 개발자 메타데이터의 키입니다. |
리턴
Sheet
- 이 시트(연결용)
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
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', ); // Gets a sheet by its name. const sheet = ss.getSheetByName('Sheet1'); // Adds the key 'NAME' and sets the developer metadata visibility to PROJECT // for the sheet. sheet.addDeveloperMetadata( 'NAME', SpreadsheetApp.DeveloperMetadataVisibility.PROJECT, ); // Gets the updated metadata info and logs it to the console. const developerMetaData = sheet.getDeveloperMetadata()[0]; console.log(developerMetaData.getKey()); console.log(developerMetaData.getVisibility().toString());
매개변수
이름 | 유형 | 설명 |
---|---|---|
key | String | 새 개발자 메타데이터의 키입니다. |
visibility | Developer | 새 개발자 메타데이터의 공개 상태입니다. |
리턴
Sheet
- 이 시트(연결용)
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
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', ); // Gets a sheet by its name. const sheet = ss.getSheetByName('Sheet1'); // Adds the key 'COMPANY' with the value 'TECH' to the developer metadata for // the sheet. sheet.addDeveloperMetadata('COMPANY', 'TECH'); // Gets the updated metadata info and logs it to the console. const developerMetaData = sheet.getDeveloperMetadata()[0]; console.log(developerMetaData.getKey()); console.log(developerMetaData.getValue());
매개변수
이름 | 유형 | 설명 |
---|---|---|
key | String | 새 개발자 메타데이터의 키입니다. |
value | String | 새 개발자 메타데이터의 값입니다. |
리턴
Sheet
- 이 시트(연결용)
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
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', ); // Gets a sheet by its name. const sheet = ss.getSheetByName('Sheet1'); // Adds the key 'COMPANY' with the value 'TECH' to the developer metadata and // sets the visibility to DOCUMENT for the sheet. sheet.addDeveloperMetadata( 'COMPANY', 'TECH', SpreadsheetApp.DeveloperMetadataVisibility.DOCUMENT, ); // Gets the updated metadata info and logs it to the console. const developerMetaData = sheet.getDeveloperMetadata()[0]; console.log(developerMetaData.getKey()); console.log(developerMetaData.getValue()); console.log(developerMetaData.getVisibility().toString());
매개변수
이름 | 유형 | 설명 |
---|---|---|
key | String | 새 개발자 메타데이터의 키입니다. |
value | String | 새 개발자 메타데이터의 값입니다. |
visibility | Developer | 새 개발자 메타데이터의 공개 상태입니다. |
리턴
Sheet
- 이 시트(연결용)
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
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
as Data Source Sheet()
시트가 Sheet
유형이면 시트를 Data
로 반환하고, 그렇지 않으면 null
로 반환합니다.
// Opens the spreadsheet file by its URL. If you created your script from within // a Google Sheets file, you can useSpreadsheetApp.getActiveSpreadsheet() // instead. // TODO(developer): Replace the URL with your own. const ss = SpreadsheetApp.openByUrl( 'https://docs.google.com/spreadsheets/d/abc123456/edit', ); // Gets a sheet by its name. const sheet = ss.getSheetByName('Sheet1'); // Gets the data source sheet value if the sheet is of type // SpreadsheetApp.SheetType.DATASOURCE, otherwise this returns a null value. const dataSourceSheet = sheet.asDataSourceSheet(); // Gets the data source sheet value and logs it to the console. console.log(dataSourceSheet); console.log(sheet.getType().toString());
리턴
Data
: 데이터 소스 시트입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
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
auto Resize Columns(startColumn, numColumns)
지정된 열 위치에서 시작하는 모든 열의 너비를 콘텐츠에 맞게 설정합니다.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; // Sets the first 15 columns to a width that fits their text. sheet.autoResizeColumns(1, 15);
매개변수
이름 | 유형 | 설명 |
---|---|---|
start | Integer | 자동으로 크기를 조절할 시작 열입니다. |
num | Integer | 자동으로 크기를 조절할 열의 수입니다. |
리턴
Sheet
- 이 시트(연결용)
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
auto Resize Rows(startRow, numRows)
지정된 행 위치에서 시작하는 모든 행의 높이를 콘텐츠에 맞게 설정합니다.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; // Sets the first 15 rows to a height that fits their text. sheet.autoResizeRows(1, 15);
매개변수
이름 | 유형 | 설명 |
---|---|---|
start | Integer | 자동 크기 조절을 시작할 행입니다. |
num | Integer | 자동으로 크기를 조절할 행 수입니다. |
리턴
Sheet
- 이 시트(연결용)
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
clear()
시트의 콘텐츠 및 서식 정보를 지웁니다.
// This example assumes there is a sheet named "first" const ss = SpreadsheetApp.getActiveSpreadsheet(); const first = ss.getSheetByName('first'); first.clear();
리턴
Sheet
- 삭제된 시트입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
clear(options)
지정된 고급 옵션에 따라 콘텐츠 또는 형식을 지웁니다.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; sheet.clear({formatOnly: true, contentsOnly: true});
매개변수
이름 | 유형 | 설명 |
---|---|---|
options | Object | 아래에 나열된 고급 옵션이 포함된 JavaScript 지도입니다. |
고급 매개변수
이름 | 유형 | 설명 |
---|---|---|
contents | Boolean | 콘텐츠를 삭제할지 여부입니다. |
format | Boolean | 서식을 지울지 여부입니다. |
리턴
Sheet
- 이 시트(연결용)
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
clear Conditional Format Rules()
시트에서 모든 조건부 서식 규칙을 삭제합니다. 빈 배열을 입력으로 사용하여 set
를 호출하는 것과 같습니다.
const sheet = SpreadsheetApp.getActiveSheet(); sheet.clearConditionalFormatRules();
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
clear Contents()
서식 정보를 유지하면서 목차를 지웁니다.
// This example assumes there is a sheet named "first" const ss = SpreadsheetApp.getActiveSpreadsheet(); const first = ss.getSheetByName('first'); first.clearContents();
리턴
Sheet
- 이 시트(연결용)
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
clear Formats()
서식을 지우고 콘텐츠는 유지합니다.
서식은 '서식' 메뉴의 선택사항에 따라 허용되는 데이터 서식(예: 굵게, 기울임꼴, 조건부 서식)을 의미하며 셀의 너비나 높이를 의미하지 않습니다.
// This example assumes there is a sheet named "first" const ss = SpreadsheetApp.getActiveSpreadsheet(); const first = ss.getSheetByName('first'); first.clearFormats();
리턴
Sheet
- 이 시트(연결용)
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
clear Notes()
시트에서 모든 메모를 지웁니다.
// This example assumes there is a sheet named "first" const ss = SpreadsheetApp.getActiveSpreadsheet(); const first = ss.getSheetByName('first'); first.clearNotes();
리턴
Sheet
- 이 시트(연결용)
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
collapse All Column Groups()
시트의 모든 열 그룹을 접습니다.
const sheet = SpreadsheetApp.getActiveSpreadsheet().getSheets()[0]; // All column groups on the sheet are collapsed. sheet.collapseAllColumnGroups();
리턴
Sheet
- 이 시트(연결용)
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
collapse All Row Groups()
시트의 모든 행 그룹을 접습니다.
const sheet = SpreadsheetApp.getActiveSpreadsheet().getSheets()[0]; // All row groups on the sheet are collapsed. sheet.collapseAllRowGroups();
리턴
Sheet
- 이 시트(연결용)
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
copy To(spreadsheet)
시트를 지정된 스프레드시트에 복사합니다. 소스와 동일한 스프레드시트일 수 있습니다. 복사된 시트의 이름은 '[원본 이름]의 사본'입니다.
const source = SpreadsheetApp.getActiveSpreadsheet(); const sheet = source.getSheets()[0]; const destination = SpreadsheetApp.openById('ID_GOES HERE'); sheet.copyTo(destination);
매개변수
이름 | 유형 | 설명 |
---|---|---|
spreadsheet | Spreadsheet | 이 시트를 복사할 스프레드시트입니다. 소스와 동일한 스프레드시트일 수 있습니다. |
리턴
Sheet
- 연결을 위한 새 시트입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
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', ); // Gets a sheet by its name. const sheet = ss.getSheetByName('Sheet1'); // Adds developer metadata for testing. sheet.addDeveloperMetadata('CITY', 'PARIS'); // Creates the developer metadata finder. const metadatafinder = sheet.createDeveloperMetadataFinder(); // Finds the metadata with value 'PARIS' and displays its key in the console. console.log(metadatafinder.withValue('PARIS').find()[0].getKey());
리턴
Developer
- 이 시트 범위의 메타데이터를 검색하는 개발자 메타데이터 찾기 도구입니다.
create Text Finder(findText)
시트의 텍스트 찾기를 만듭니다. 이 텍스트 찾기는 시트 내에서 텍스트를 찾고 바꿀 수 있습니다.
const sheet = SpreadsheetApp.getActiveSpreadsheet().getSheets()[0]; // Creates a text finder. const textFinder = sheet.createTextFinder('dog'); // Returns the first occurrence of 'dog' in the sheet. const firstOccurrence = textFinder.findNext(); // Replaces the last found occurrence of 'dog' with 'cat' and returns the number // of occurrences replaced. const numOccurrencesReplaced = firstOccurrence.replaceWith('cat');
매개변수
이름 | 유형 | 설명 |
---|---|---|
find | String | 검색할 텍스트입니다. |
리턴
Text
- 시트의 Text
입니다.
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
expand All Column Groups()
시트의 모든 열 그룹을 펼칩니다. 이 메서드에는 열 그룹이 하나 이상 필요합니다.
const sheet = SpreadsheetApp.getActiveSpreadsheet().getSheets()[0]; // All column groups on the sheet are expanded. sheet.expandAllColumnGroups();
리턴
Sheet
- 이 시트(연결용)
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
expand All Row Groups()
시트의 모든 행 그룹을 펼칩니다. 이 메서드에는 행 그룹이 하나 이상 필요합니다.
const sheet = SpreadsheetApp.getActiveSpreadsheet().getSheets()[0]; // All row groups on the sheet are expanded. sheet.expandAllRowGroups();
리턴
Sheet
- 이 시트(연결용)
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
expand Column Groups Up To Depth(groupDepth)
지정된 깊이까지 모든 열 그룹을 펼치고 나머지는 모두 접습니다.
const sheet = SpreadsheetApp.getActiveSpreadsheet().getSheets()[0]; // All column groups of depth 2 and lower are expanded, and groups with depth // 3 and higher are collapsed. sheet.expandColumnGroupsUpToDepth(2);
매개변수
이름 | 유형 | 설명 |
---|---|---|
group | Integer | 열 그룹을 펼칠 그룹 깊이입니다. |
리턴
Sheet
- 이 시트(연결용)
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
expand Row Groups Up To Depth(groupDepth)
지정된 깊이까지 모든 행 그룹을 펼치고 다른 모든 행 그룹은 접습니다.
const sheet = SpreadsheetApp.getActiveSpreadsheet().getSheets()[0]; // All row groups of depth 2 and lower are expanded, and groups with depth // 3 and higher are collapsed. sheet.expandRowGroupsUpToDepth(2);
매개변수
이름 | 유형 | 설명 |
---|---|---|
group | Integer | 행 그룹을 펼칠 그룹 깊이입니다. |
리턴
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 Bandings()
이 시트의 모든 밴딩을 반환합니다.
// 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 a sheet by its name. const sheet = ss.getSheetByName('Sheet1'); // Gets the banding info for the sheet. const bandings = sheet.getBandings(); // Gets info on the bandings' second row color and logs it to the console. for (const banding of bandings) { console.log(banding.getSecondRowColor()); }
리턴
Banding[]
- 이 시트의 모든 밴딩입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
get Charts()
이 시트의 차트 배열을 반환합니다.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; const charts = sheet.getCharts(); for (const i in charts) { const chart = charts[i]; // Do something with the chart }
리턴
Embedded
- 차트의 배열입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
get Column Group(columnIndex, groupDepth)
지정된 색인과 그룹 깊이에 있는 열 그룹을 반환합니다.
const sheet = SpreadsheetApp.getActiveSpreadsheet().getSheets()[0]; // Returns the group whose control index is at column 2 and has a depth of 1, or // null if the group doesn’t exist. const columnGroup = sheet.getColumnGroup(2, 1);
매개변수
이름 | 유형 | 설명 |
---|---|---|
column | Integer | 그룹 컨트롤 전환 버튼의 열 색인 또는 그룹 내 색인입니다. |
group | Integer | 그룹의 깊이입니다. |
리턴
Group
- 제어 색인과 깊이에 있는 열 그룹입니다. 그룹이 없으면 예외가 발생합니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
get Column Group Control Position()
시트의 모든 열 그룹에 대한 Group
을 반환합니다.
const sheet = SpreadsheetApp.getActiveSpreadsheet().getSheets()[0]; // GroupControlTogglePosition.AFTER if the column grouping control toggle is // shown after the group. const columnGroupControlPosition = sheet.getColumnGroupControlPosition();
리턴
Group
- 열 그룹화 컨트롤 전환 버튼이 이 시트의 그룹 뒤에 표시되는 경우 true
, 그렇지 않은 경우 false
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
get Column Group Depth(columnIndex)
지정된 색인의 열 그룹 깊이를 반환합니다.
그룹 깊이는 열과 겹치는 그룹 수를 나타냅니다. 이 값은 0~8 사이입니다.
const sheet = SpreadsheetApp.getActiveSpreadsheet().getSheets()[0]; // 1 if there is a group over columns 1 through 3 const groupDepth = sheet.getColumnGroupDepth(1);
매개변수
이름 | 유형 | 설명 |
---|---|---|
column | Integer | 열의 색인입니다. |
리턴
Integer
- 지정된 색인에 있는 열의 그룹 깊이입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
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 Conditional Format Rules()
이 시트의 모든 조건부 서식 규칙을 가져옵니다.
// Logs the conditional format rules in a sheet. const rules = SpreadsheetApp.getActiveSheet().getConditionalFormatRules(); for (let i = 0; i < rules.length; i++) { const rule = rules[i]; Logger.log(rule); }
리턴
Conditional
- 시트의 모든 규칙 배열입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
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 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 Developer Metadata()
이 시트와 연결된 모든 개발자 메타데이터를 가져옵니다.
// 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 a sheet by its name. const sheet = ss.getSheetByName('Sheet1'); // Adds developer metadata for testing. sheet.addDeveloperMetadata('CITY', 'PARIS'); // Gets all the developer metadata for the sheet. const developerMetaDataList = sheet.getDeveloperMetadata(); // Logs the developer metadata to the console. for (const developerMetaData of developerMetaDataList) { console.log(developerMetaData.getKey()); }
리턴
Developer
- 이 시트와 연결된 개발자 메타데이터입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
get Drawings()
시트의 그림 배열을 반환합니다.
// 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 a sheet by its name. const sheet = ss.getSheetByName('Sheet1'); // Gets all the drawings from the sheet. const allDrawings = sheet.getDrawings(); // Logs the number of drawings present on the sheet. console.log(allDrawings.length);
리턴
Drawing[]
- 이 시트의 그림 목록입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
get Filter()
이 시트의 필터를 반환하거나 필터가 없는 경우 null
을 반환합니다.
// Gets the filter on the active sheet. const ss = SpreadsheetApp.getActiveSheet(); const filter = ss.getFilter();
리턴
Filter
- 필터
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
get Form Url()
이 시트에 응답을 전송하는 양식의 URL을 반환합니다. 이 시트에 연결된 양식이 없는 경우 null
을 반환합니다. 사용자에게 스프레드시트를 수정할 권한이 없는 경우 예외를 발생시킵니다.
const sheet = SpreadsheetApp.getActiveSheet(); const url = sheet.getFormUrl();
리턴
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 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 Index()
상위 스프레드시트에서 시트의 위치를 가져옵니다. 1부터 시작합니다.
const ss = SpreadsheetApp.getActiveSpreadsheet(); // Note that the JavaScript index is 0, but this logs 1 const sheet = ss.getSheets()[0]; // ... because spreadsheets are 1-indexed Logger.log(sheet.getIndex());
리턴
Integer
- 상위 스프레드시트에서 시트의 위치입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
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 Columns()
콘텐츠와 관계없이 시트의 현재 열 수를 반환합니다.
// This example assumes there is a sheet named "first" const ss = SpreadsheetApp.getActiveSpreadsheet(); const first = ss.getSheetByName('first'); Logger.log(first.getMaxColumns());
리턴
Integer
- 시트의 최대 너비입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
get Max Rows()
콘텐츠와 관계없이 시트의 현재 행 수를 반환합니다.
// This example assumes there is a sheet named "first" const ss = SpreadsheetApp.getActiveSpreadsheet(); const first = ss.getSheetByName('first'); Logger.log(first.getMaxRows());
리턴
Integer
- 시트의 최대 높이입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
get Name()
시트의 이름을 반환합니다.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; Logger.log(sheet.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.getActiveSheet().getNamedRanges(); if (namedRanges.length > 1) { Logger.log(namedRanges[0].getName()); }
리턴
Named
- 시트에 있는 모든 이름이 지정된 범위의 배열입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
get Parent()
이 시트가 포함된 Spreadsheet
를 반환합니다.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; // parent is identical to ss const parent = sheet.getParent();
리턴
Spreadsheet
: 상위 스프레드시트입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
get Pivot Tables()
이 시트의 모든 피벗 테이블을 반환합니다.
// 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 a sheet by its name. const sheet = ss.getSheetByName('Sheet1'); // Gets all the pivot table info for the sheet. const pivotTables = sheet.getPivotTables(); // Logs the pivot tables to the console. for (const pivotTable of pivotTables) { console.log(pivotTable.getSourceDataRange().getValues()); }
리턴
Pivot
- 이 시트의 피벗 테이블입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
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 sheet = SpreadsheetApp.getActiveSheet(); const protections = sheet.getProtections(SpreadsheetApp.ProtectionType.RANGE); for (let i = 0; i < protections.length; i++) { const protection = protections[i]; if (protection.canEdit()) { protection.remove(); } }
// Remove sheet protection from the active sheet, if the user has permission to // edit it. const sheet = SpreadsheetApp.getActiveSheet(); const protection = sheet.getProtections(SpreadsheetApp.ProtectionType.SHEET)[0]; 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(row, column)
왼쪽 상단 셀이 지정된 좌표에 있는 범위를 반환합니다.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; // Passing only two arguments returns a "range" with a single cell. const range = sheet.getRange(1, 1); const values = range.getValues(); Logger.log(values[0][0]);
매개변수
이름 | 유형 | 설명 |
---|---|---|
row | Integer | 반환할 셀의 행 색인입니다. 행 색인은 1부터 시작합니다. |
column | Integer | 반환할 셀의 열 색인입니다. 열 색인은 1부터 시작합니다. |
리턴
Range
- 이 셀만 포함하는 범위입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
get Range(row, column, numRows)
왼쪽 상단 셀이 지정된 좌표에 있고 행 수가 지정된 수인 범위를 반환합니다.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; // When the "numRows" argument is used, only a single column of data is // returned. const range = sheet.getRange(1, 1, 3); const values = range.getValues(); // Prints 3 values from the first column, starting from row 1. for (const row in values) { for (const col in values[row]) { Logger.log(values[row][col]); } }
매개변수
이름 | 유형 | 설명 |
---|---|---|
row | Integer | 범위의 시작 행 색인입니다. 행 색인은 1부터 시작합니다. |
column | Integer | 범위의 열 색인입니다. 열 색인은 1부터 시작합니다. |
num | Integer | 반환할 행 수입니다. |
리턴
Range
- 지정된 행 수가 있는 단일 데이터 열을 포함하는 범위입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
get Range(row, column, numRows, numColumns)
지정된 좌표에 왼쪽 상단 셀이 있고 지정된 행과 열이 있는 범위를 반환합니다.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; const range = sheet.getRange(1, 1, 3, 3); const values = range.getValues(); // Print values from a 3x3 box. for (const row in values) { for (const col in values[row]) { Logger.log(values[row][col]); } }
매개변수
이름 | 유형 | 설명 |
---|---|---|
row | Integer | 범위의 시작 행 색인입니다. 행 색인은 1부터 시작합니다. |
column | Integer | 범위의 시작 열 색인입니다. 열 색인은 1부터 시작합니다. |
num | Integer | 반환할 행 수입니다. |
num | Integer | 반환할 열의 개수입니다. |
리턴
Range
- 지정된 영역에 해당하는 범위입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
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 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 Row Group(rowIndex, groupDepth)
지정된 색인과 그룹 깊이에 있는 행 그룹을 반환합니다.
const sheet = SpreadsheetApp.getActiveSpreadsheet().getSheets()[0]; // Returns the group whose control index is at row 2 and has a depth of 1, or // null if the group doesn’t exist. const rowGroup = sheet.getRowGroup(2, 1);
매개변수
이름 | 유형 | 설명 |
---|---|---|
row | Integer | 그룹 컨트롤 전환의 행 색인 또는 그룹 내 색인입니다. |
group | Integer | 그룹의 깊이입니다. |
리턴
Group
- 제어 색인과 깊이에 있는 행 그룹입니다. 그룹이 없으면 예외가 발생합니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
get Row Group Control Position()
시트의 모든 행 그룹에 대해 Group
을 반환합니다.
const sheet = SpreadsheetApp.getActiveSpreadsheet().getSheets()[0]; // GroupControlTogglePosition.AFTER if the row grouping control toggle is shown // after the group. const rowGroupControlPosition = sheet.getRowGroupControlPosition();
리턴
Group
- 이 시트의 그룹 뒤에 행 그룹화 컨트롤 전환 버튼이 표시되면 true
, 그렇지 않으면 false
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
get Row Group Depth(rowIndex)
지정된 색인에 있는 행의 그룹 깊이를 반환합니다.
그룹 깊이는 행과 겹치는 그룹 수를 나타냅니다. 0~8 사이의 값일 수 있습니다.
const sheet = SpreadsheetApp.getActiveSpreadsheet().getSheets()[0]; // 1 if there is a group over rows 1 through 3 const groupDepth = sheet.getRowGroupDepth(1);
매개변수
이름 | 유형 | 설명 |
---|---|---|
row | Integer | 행의 색인입니다. |
리턴
Integer
- 지정된 색인의 행 그룹 깊이입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
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 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 Slicers()
시트의 슬라이서 배열을 반환합니다.
// 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 a sheet by its name. const sheet = ss.getSheetByName('Sheet1'); // Gets all slicers in the spreadsheet. const slicers = sheet.getSlicers(); // Logs the slicer titles to the console. for (const slicer of slicers) { console.log(slicer.getTitle()); }
리턴
Slicer[]
- 이 시트의 슬라이서 목록입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
get Tab Color Object()
시트 탭 색상을 가져옵니다. 시트 탭에 색상이 없으면 null
을 가져옵니다.
// This example assumes there is a sheet named "Sheet1" const ss = SpreadsheetApp.getActiveSpreadsheet(); const first = ss.getSheetByName('Sheet1'); const color = first.getTabColorObject();
리턴
Color
- 시트 탭 색상입니다. 시트 탭에 색상이 없으면 null
입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
get Type()
시트의 유형을 반환합니다.
시트의 기본 유형은 Sheet
입니다. Embedded
와 같은 단일 삽입 객체가 포함된 시트는 Sheet
시트입니다.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; Logger.log(sheet.getType());
리턴
Sheet
: 시트 유형입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
has Hidden Gridlines()
시트의 그리드 선이 숨겨져 있으면 true
를 반환하고 그렇지 않으면 false
를 반환합니다.
눈금선은 기본적으로 표시됩니다.
// 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 a sheet by its name. const sheet = ss.getSheetByName('Sheet1'); // Checks if the spreadsheet has hidden gridelines and logs the result to the // console. console.log(sheet.hasHiddenGridlines());
리턴
Boolean
: 그리드 선이 숨겨져 있으면 true
, 그렇지 않으면 false
입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
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 Columns(columnIndex)
지정된 색인의 단일 열을 숨깁니다. 이 메서드에는 1-index를 사용하세요.
색인을 사용하여 두 개 이상의 열을 숨기려면 hide
를 사용합니다.
범위를 사용하여 두 개 이상의 열을 숨기려면 hide
를 사용합니다.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; // Hides the first column sheet.hideColumns(1);
매개변수
이름 | 유형 | 설명 |
---|---|---|
column | Integer | 숨길 열의 색인입니다. |
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
hide Columns(columnIndex, numColumns)
지정된 인덱스에서 시작하는 하나 이상의 연속된 열을 숨깁니다. 이 메서드에는 1-index를 사용하세요.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; // Hides the first three columns sheet.hideColumns(1, 3);
매개변수
이름 | 유형 | 설명 |
---|---|---|
column | Integer | 숨길 열의 시작 색인입니다. |
num | Integer | 숨길 열의 수입니다. |
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
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
hide Rows(rowIndex)
지정된 색인의 행을 숨깁니다.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; // Hides the first row sheet.hideRows(1);
매개변수
이름 | 유형 | 설명 |
---|---|---|
row | Integer | 숨길 행의 색인입니다. |
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
hide Rows(rowIndex, numRows)
지정된 인덱스에서 시작하는 하나 이상의 연속된 행을 숨깁니다.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; // Hides the first three rows sheet.hideRows(1, 3);
매개변수
이름 | 유형 | 설명 |
---|---|---|
row | Integer | 숨길 행의 시작 색인입니다. |
num | Integer | 숨길 행 수입니다. |
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
hide Sheet()
이 시트를 숨깁니다. 시트가 이미 숨겨져 있는 경우에는 아무런 효과가 없습니다. 이 메서드가 표시되는 유일한 시트에서 호출되면 예외가 발생합니다.
const sheet = SpreadsheetApp.getActiveSheet(); sheet.hideSheet();
리턴
Sheet
- 현재 시트입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
insert Chart(chart)
이 시트에 새 차트를 추가합니다.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; // This creates a simple bar chart from the first three rows // of the first two columns of the spreadsheet const chart = sheet.newChart() .setChartType(Charts.ChartType.BAR) .addRange(sheet.getRange('A1:B4')) .setPosition(5, 5, 0, 0) .setOption('title', 'Dynamic Chart') .build(); sheet.insertChart(chart);
매개변수
이름 | 유형 | 설명 |
---|---|---|
chart | Embedded | 삽입할 차트입니다. |
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
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(columnIndex)
지정된 위치에 시트의 빈 열을 삽입합니다.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; // Shifts all columns by one sheet.insertColumns(1);
매개변수
이름 | 유형 | 설명 |
---|---|---|
column | Integer | 열을 삽입할 위치를 나타내는 색인입니다. |
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
insert Columns(columnIndex, numColumns)
지정된 위치에서 시작하는 하나 이상의 연속된 빈 열을 시트에 삽입합니다.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; // Shifts all columns by three sheet.insertColumns(1, 3);
매개변수
이름 | 유형 | 설명 |
---|---|---|
column | Integer | 열을 삽입할 위치를 나타내는 색인입니다. |
num | Integer | 삽입할 열의 수입니다. |
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
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 Image(blobSource, column, row)
지정된 행과 열에 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);
매개변수
이름 | 유형 | 설명 |
---|---|---|
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)
지정된 행과 열에 Blob
를 이미지로 삽입합니다(픽셀 오프셋 사용). 이미지 크기는 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(rowIndex)
지정된 위치에 시트의 빈 행을 삽입합니다.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; // Shifts all rows down by one sheet.insertRows(1);
매개변수
이름 | 유형 | 설명 |
---|---|---|
row | Integer | 행을 삽입할 위치를 나타내는 색인입니다. |
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
insert Rows(rowIndex, numRows)
지정된 위치에서 시작하는 하나 이상의 연속된 빈 행을 시트에 삽입합니다.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; // Shifts all rows down by three sheet.insertRows(1, 3);
매개변수
이름 | 유형 | 설명 |
---|---|---|
row | Integer | 행을 삽입할 위치를 나타내는 색인입니다. |
num | Integer | 삽입할 행 수입니다. |
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
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 Slicer(range, anchorRowPos, anchorColPos)
이 시트에 새 슬라이서를 추가합니다.
// 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 a sheet by its name. const sheet = ss.getSheetByName('Sheet1'); // Gets the range of the sheet. const range = sheet.getRange('A1:D10'); // Inserts the slicer with a random range into the sheet. const insertSlicers = sheet.insertSlicer(range.randomize(), 1, 10); // Logs the insert slicer result to the console. console.log(insertSlicers);
매개변수
이름 | 유형 | 설명 |
---|---|---|
range | Range | 슬라이서가 생성되는 범위입니다. |
anchor | Integer | 슬라이서의 상단이 이 행에 고정됩니다. |
anchor | Integer | 슬라이서의 상단이 이 열에 고정됩니다. |
리턴
Slicer
- 새로 삽입된 슬라이서입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
insert Slicer(range, anchorRowPos, anchorColPos, offsetX, offsetY)
이 시트에 새 슬라이서를 추가합니다.
// 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 a sheet by its name. const sheet = ss.getSheetByName('Sheet1'); // Gets the range. const range = sheet.getRange('A1:D10'); // Inserts a slicer using the random range function. const insertSlicers = sheet.insertSlicer(range.randomize(), 1, 10, 0, 0); // Logs the insert slicer result to the console. console.log(insertSlicers);
매개변수
이름 | 유형 | 설명 |
---|---|---|
range | Range | 슬라이서가 생성되는 범위입니다. |
anchor | Integer | 슬라이서의 상단이 이 행에 고정됩니다. |
anchor | Integer | 슬라이서의 상단이 이 열에 고정됩니다. |
offsetX | Integer | 셀 모서리에서 가로 오프셋(픽셀)입니다. |
offsetY | Integer | 셀 모서리에서 세로 오프셋(픽셀)입니다. |
리턴
Slicer
- 새로 삽입된 슬라이서입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
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 Right To Left()
이 시트 레이아웃이 오른쪽에서 왼쪽으로 되어 있으면 true
을 반환합니다. 시트에서 기본 왼쪽에서 오른쪽 레이아웃을 사용하는 경우 false
을 반환합니다.
// 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 a sheet by its name. const sheet = ss.getSheetByName('Sheet1'); // Checks if a spreadsheet is ordered from right to left and logs the result to // the console. console.log(sheet.isRightToLeft());
리턴
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
is Sheet Hidden()
시트가 현재 숨겨져 있으면 true
를 반환합니다.
const sheet = SpreadsheetApp.getActiveSheet(); if (sheet.isSheetHidden()) { // do something... }
리턴
Boolean
- 시트가 숨겨져 있으면 true
, 그렇지 않으면 false
입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
move Columns(columnSpec, destinationIndex)
지정된 범위로 선택된 열을 destination
로 표시된 위치로 이동합니다. column
자체가 이동할 전체 열 또는 열 그룹을 정확하게 나타낼 필요는 없습니다. 범위가 포함하는 모든 열을 선택합니다.
// The code below moves rows A-B to destination index 5. // This results in those columns becoming columns C-D. const sheet = SpreadsheetApp.getActiveSheet(); // Selects column A and column B to be moved. const columnSpec = sheet.getRange('A1:B1'); sheet.moveColumns(columnSpec, 5);
매개변수
이름 | 유형 | 설명 |
---|---|---|
column | Range | 이동해야 하는 열에 걸쳐 있는 범위입니다. |
destination | Integer | 열을 이동할 색인입니다. 이 색인은 열이 이동되기 전의 좌표를 기반으로 합니다. 기존 데이터는 이동된 열을 위한 공간을 확보하기 위해 오른쪽으로 이동되고 소스 열은 그리드에서 삭제됩니다. 따라서 데이터가 원래 지정된 인덱스와 다른 인덱스에 저장될 수 있습니다. |
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
move Rows(rowSpec, destinationIndex)
지정된 범위로 선택된 행을 destination
로 표시된 위치로 이동합니다. row
자체가 이동할 전체 행 또는 행 그룹을 정확하게 나타낼 필요는 없습니다. 범위가 포함된 모든 행을 선택합니다.
// The code below moves rows 1-2 to destination index 5. // This results in those rows becoming rows 3-4. const sheet = SpreadsheetApp.getActiveSheet(); // Selects row 1 and row 2 to be moved. const rowSpec = sheet.getRange('A1:A2'); sheet.moveRows(rowSpec, 5);
매개변수
이름 | 유형 | 설명 |
---|---|---|
row | Range | 이동해야 하는 행에 걸쳐 있는 범위입니다. |
destination | Integer | 행을 이동해야 하는 색인입니다. 이 색인은 행이 이동되기 전의 좌표를 기반으로 합니다. 기존 데이터는 이동된 행을 위한 공간을 확보하기 위해 아래로 이동되고 소스 행은 그리드에서 삭제됩니다. 따라서 데이터가 원래 지정된 인덱스와 다른 인덱스에 저장될 수 있습니다. |
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
new Chart()
이 시트의 새 차트를 만드는 빌더를 반환합니다.
다음은 새 차트를 만드는 방법을 보여주는 예입니다.
const sheet = SpreadsheetApp.getActiveSheet(); const range = sheet.getRange('A1:B8'); const chartBuilder = sheet.newChart(); chartBuilder.addRange(range) .setChartType(Charts.ChartType.LINE) .setPosition(2, 2, 0, 0) .setOption('title', 'My Line Chart!'); sheet.insertChart(chartBuilder.build());
리턴
Embedded
- 새 차트를 만드는 빌더입니다.
protect()
권한이 있는 사용자를 제외한 사용자가 시트를 수정하지 못하도록 보호할 수 있는 객체를 만듭니다. 스크립트가 Protection.removeEditor(emailAddress)
, Protection.removeEditor(user)
, Protection.removeEditors(emailAddresses)
, Protection.addEditor(emailAddress)
, Protection.addEditor(user)
, Protection.addEditors(emailAddresses)
를 호출하거나 Protection.setDomainEdit(editable)
의 새 값을 설정하여 시트의 편집자 목록을 실제로 변경할 때까지는 권한이 스프레드시트 자체의 권한을 반영하므로 시트가 보호되지 않은 상태로 유지됩니다. 시트가 이미 보호된 경우 이 메서드는 기존 보호 설정을 나타내는 객체를 반환합니다.
보호된 시트에는 보호되지 않은 영역이 포함될 수 있습니다.
// Protect the active sheet, then remove all other users from the list of // editors. const sheet = SpreadsheetApp.getActiveSheet(); const protection = sheet.protect().setDescription('Sample protected sheet'); // Ensure the current user is an editor before removing others. Otherwise, if // the user's edit permission comes from a group, the script throws an exception // upon removing the group. const me = Session.getEffectiveUser(); protection.addEditor(me); protection.removeEditors(protection.getEditors()); if (protection.canDomainEdit()) { protection.setDomainEdit(false); }
리턴
Protection
- 보호 설정을 나타내는 객체입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
remove Chart(chart)
상위 시트에서 차트를 삭제합니다.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; // This removes all the embedded charts from the spreadsheet const charts = sheet.getCharts(); for (const i in charts) { sheet.removeChart(charts[i]); }
매개변수
이름 | 유형 | 설명 |
---|---|---|
chart | Embedded | 삭제할 차트입니다. |
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
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 Column Group Control Position(position)
시트에서 열 그룹 컨트롤 전환 버튼의 위치를 설정합니다.
const sheet = SpreadsheetApp.getActiveSpreadsheet().getSheets()[0]; sheet.setColumnGroupControlPosition( SpreadsheetApp.GroupControlTogglePosition.AFTER, );
매개변수
이름 | 유형 | 설명 |
---|---|---|
position | Group | 열 그룹 컨트롤 전환 버튼의 위치입니다. |
리턴
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 Column Widths(startColumn, numColumns, width)
지정된 열의 너비를 픽셀 단위로 설정합니다.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; // Sets the first three columns to a width of 200 pixels sheet.setColumnWidths(1, 3, 200);
매개변수
이름 | 유형 | 설명 |
---|---|---|
start | Integer | 변경할 시작 열 위치입니다. |
num | Integer | 변경할 열의 수입니다. |
width | Integer | 설정할 너비(픽셀)입니다. |
리턴
Sheet
- 이 시트(연결용)
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
set Conditional Format Rules(rules)
시트의 현재 모든 조건부 서식 규칙을 입력 규칙으로 대체합니다. 규칙은 입력 순서대로 평가됩니다.
// Remove one of the existing conditional format rules. const sheet = SpreadsheetApp.getActiveSheet(); const rules = sheet.getConditionalFormatRules(); rules.splice(1, 1); // Deletes the 2nd format rule. sheet.setConditionalFormatRules(rules);
매개변수
이름 | 유형 | 설명 |
---|---|---|
rules | Conditional | 새 조건부 서식 규칙입니다. |
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
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 Hidden Gridlines(hideGridlines)
시트 격자선을 숨기거나 표시합니다.
// Opens the spreadsheet file by its URL. If you created your script from within // a Google Sheets file, you can us eSpreadsheetApp.getActiveSpreadsheet() // instead. // TODO(developer): Replace the URL with your own. const ss = SpreadsheetApp.openByUrl( 'https://docs.google.com/spreadsheets/d/abc123456/edit', ); // Gets a sheet by its name. const sheet = ss.getSheetByName('Sheet1'); // Hides the gridlines in the sheet. sheet.setHiddenGridlines(true);
매개변수
이름 | 유형 | 설명 |
---|---|---|
hide | Boolean | true 인 경우 이 시트에서 격자선을 숨깁니다. 그렇지 않으면 격자선을 표시합니다. |
리턴
Sheet
- 이 시트(연결용)
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
set Name(name)
시트 이름을 설정합니다.
// This example assumes there is a sheet named "first" const ss = SpreadsheetApp.getActiveSpreadsheet(); const first = ss.getSheetByName('first'); first.setName('not first anymore');
매개변수
이름 | 유형 | 설명 |
---|---|---|
name | String | 시트의 새 이름입니다. |
리턴
Sheet
- 이 시트(연결용)
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
set Right To Left(rightToLeft)
시트 레이아웃을 오른쪽에서 왼쪽으로 설정하거나 설정 해제합니다.
// 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 a sheet by its name. const sheet = ss.getSheetByName('Sheet1'); // Sets the sheet layout, so that the sheet is ordered from right to left. sheet.setRightToLeft(true);
매개변수
이름 | 유형 | 설명 |
---|---|---|
right | Boolean | true 인 경우 시트 레이아웃이 오른쪽에서 왼쪽으로 설정되고 셀 A1이 오른쪽 상단에 있습니다. false 인 경우 시트 레이아웃이 기본 왼쪽에서 오른쪽으로 설정되고 셀 A1이 왼쪽 상단에 있습니다. |
리턴
Sheet
- 이 시트(연결용)
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
set Row Group Control Position(position)
시트에서 행 그룹 컨트롤 전환 버튼의 위치를 설정합니다.
const sheet = SpreadsheetApp.getActiveSpreadsheet().getSheets()[0]; sheet.setRowGroupControlPosition( SpreadsheetApp.GroupControlTogglePosition.AFTER, );
매개변수
이름 | 유형 | 설명 |
---|---|---|
position | Group | 행 그룹 컨트롤 전환 버튼의 위치입니다. |
리턴
Sheet
- 이 시트(연결용)
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
set Row Height(rowPosition, height)
지정된 행의 행 높이를 픽셀 단위로 설정합니다. 기본적으로 행은 셀 콘텐츠에 맞게 확장됩니다. 행을 지정된 높이로 강제하려면 set
을 사용합니다.
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 Row Heights(startRow, numRows, height)
지정된 행의 높이를 픽셀 단위로 설정합니다. 기본적으로 행은 셀 콘텐츠에 맞게 확장됩니다. 행을 지정된 높이로 강제하려면 set
를 사용합니다.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; // Sets the first three rows to a height of 20 pixels sheet.setRowHeights(1, 3, 20);
매개변수
이름 | 유형 | 설명 |
---|---|---|
start | Integer | 변경할 시작 행 위치입니다. |
num | Integer | 변경할 행 수입니다. |
height | Integer | 설정할 높이(픽셀)입니다. |
리턴
Sheet
- 이 시트(연결용)
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
set Row Heights Forced(startRow, numRows, height)
지정된 행의 높이를 픽셀 단위로 설정합니다. 기본적으로 행은 셀 콘텐츠에 맞게 확장됩니다. set
를 사용하면 셀 콘텐츠가 행 높이보다 높더라도 행이 지정된 높이로 강제됩니다.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; // Sets the first three rows to a height of 5 pixels. sheet.setRowHeightsForced(1, 3, 5);
매개변수
이름 | 유형 | 설명 |
---|---|---|
start | Integer | 변경할 시작 행 위치입니다. |
num | Integer | 변경할 행 수입니다. |
height | Integer | 설정할 높이(픽셀)입니다. |
리턴
Sheet
- 이 시트(연결용)
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
set Tab Color(color)
시트 탭 색상을 설정합니다.
// This example assumes there is a sheet named "first" const ss = SpreadsheetApp.getActiveSpreadsheet(); const first = ss.getSheetByName('first'); first.setTabColor('ff0000'); // Set the color to red. first.setTabColor(null); // Unset the color.
매개변수
이름 | 유형 | 설명 |
---|---|---|
color | String | CSS 표기법의 색상 코드 (예: '#ffffff' 또는 'white' ) 또는 null 를 사용하여 탭 색상을 재설정합니다. |
리턴
Sheet
- 이 시트(연결용)
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
set Tab Color Object(color)
시트 탭 색상을 설정합니다.
// This example assumes there is a sheet named "Sheet1" const ss = SpreadsheetApp.getActiveSpreadsheet(); const first = ss.getSheetByName('Sheet1'); const color = SpreadsheetApp.newColor() .setThemeColor(SpreadsheetApp.ThemeColorType.ACCENT1) .build(); first.setTabColorObject(color); // Set the color to theme accent 1. first.setTabColorObject(null); // Unset the color.
매개변수
이름 | 유형 | 설명 |
---|---|---|
color | Color | 설정할 시트 탭 색상입니다. |
리턴
Sheet
- 이 시트(연결용)
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
show Columns(columnIndex)
지정된 색인의 열을 숨김 해제합니다.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; // Unhides the first column sheet.showColumns(1);
매개변수
이름 | 유형 | 설명 |
---|---|---|
column | Integer | 숨기기를 해제할 열의 색인입니다. |
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
show Columns(columnIndex, numColumns)
지정된 인덱스에서 시작하는 하나 이상의 연속된 열을 숨김 해제합니다.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; // Unhides the first three columns sheet.showColumns(1, 3);
매개변수
이름 | 유형 | 설명 |
---|---|---|
column | Integer | 숨김 해제할 열의 시작 색인입니다. |
num | Integer | 숨김 해제할 열의 수입니다. |
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
show Rows(rowIndex)
지정된 색인의 행을 숨김 해제합니다.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; // Unhides the first row sheet.showRows(1);
매개변수
이름 | 유형 | 설명 |
---|---|---|
row | Integer | 숨김 해제할 행의 색인입니다. |
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
show Rows(rowIndex, numRows)
지정된 인덱스에서 시작하는 하나 이상의 연속된 행을 숨김 해제합니다.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; // Unhides the first three rows sheet.showRows(1, 3);
매개변수
이름 | 유형 | 설명 |
---|---|---|
row | Integer | 숨김 해제할 행의 시작 색인입니다. |
num | Integer | 숨김 해제할 행 수입니다. |
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
show Sheet()
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
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 Chart(chart)
이 시트의 차트를 업데이트합니다.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; // This code is going to loop through all the charts and change them to // column charts const charts = sheet.getCharts(); for (const i in charts) { const chart = charts[i]; const newChart = chart.modify().setChartType(Charts.ChartType.COLUMN).build(); sheet.updateChart(newChart); }
매개변수
이름 | 유형 | 설명 |
---|---|---|
chart | Embedded | 업데이트할 차트입니다. |
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets