Class Spreadsheet

스프레드시트

Google Sheets 파일에 액세스하고 수정합니다. 일반적인 작업은 새 시트 추가와 공동작업자 추가입니다.

방법

메서드반환 유형간략한 설명
addDeveloperMetadata(key)Spreadsheet지정된 키가 있는 개발자 메타데이터를 최상위 스프레드시트에 추가합니다.
addDeveloperMetadata(key, visibility)Spreadsheet지정된 키와 함께 개발자 메타데이터를 스프레드시트에 추가합니다.
addDeveloperMetadata(key, value)Spreadsheet지정된 키와 값이 포함된 개발자 메타데이터를 스프레드시트에 추가합니다.
addDeveloperMetadata(key, value, visibility)Spreadsheet지정된 키, 값, 가시성과 함께 개발자 메타데이터를 스프레드시트에 추가합니다.
addEditor(emailAddress)Spreadsheet지정된 사용자를 Spreadsheet의 편집자 목록에 추가합니다.
addEditor(user)Spreadsheet지정된 사용자를 Spreadsheet의 편집자 목록에 추가합니다.
addEditors(emailAddresses)Spreadsheet지정된 사용자 배열을 Spreadsheet의 편집자 목록에 추가합니다.
addMenu(name, subMenus)void스프레드시트 UI에서 새 메뉴를 만듭니다.
addViewer(emailAddress)Spreadsheet지정된 사용자를 Spreadsheet의 뷰어 목록에 추가합니다.
addViewer(user)Spreadsheet지정된 사용자를 Spreadsheet의 뷰어 목록에 추가합니다.
addViewers(emailAddresses)Spreadsheet지정된 사용자 배열을 Spreadsheet의 뷰어 목록에 추가합니다.
appendRow(rowContents)Sheet시트에서 현재 데이터 리전의 하단에 행을 추가합니다.
autoResizeColumn(columnPosition)Sheet콘텐츠에 맞게 지정된 열의 너비를 설정합니다.
copy(name)Spreadsheet스프레드시트를 복사하고 새 스프레드시트를 반환합니다.
createDeveloperMetadataFinder()DeveloperMetadataFinder이 스프레드시트의 범위 내에서 개발자 메타데이터를 찾는 DeveloperMetadataFinder를 반환합니다.
createTextFinder(findText)TextFinder스프레드시트용 텍스트 찾기 도구를 만듭니다. 이 도구는 스프레드시트 내에서 텍스트를 찾아 바꾸는 데 사용할 수 있습니다.
deleteActiveSheet()Sheet현재 활성화된 시트를 삭제합니다.
deleteColumn(columnPosition)Sheet지정된 열 위치에서 열을 삭제합니다.
deleteColumns(columnPosition, howMany)void지정된 열 위치에서 시작하는 열 수를 삭제합니다.
deleteRow(rowPosition)Sheet지정된 행 위치에서 행을 삭제합니다.
deleteRows(rowPosition, howMany)void지정된 행 위치에서 시작하여 여러 행을 삭제합니다.
deleteSheet(sheet)void지정된 시트를 삭제합니다.
duplicateActiveSheet()Sheet활성 시트를 복제하여 활성 시트로 만듭니다.
getActiveCell()Range이 시트의 활성 셀을 반환합니다.
getActiveRange()Range활성 시트에서 선택된 범위를 반환하거나 활성 범위가 없는 경우 null을 반환합니다.
getActiveRangeList()RangeList활성 시트의 활성 범위 목록을 반환하거나 활성 범위가 없는 경우 null을 반환합니다.
getActiveSheet()Sheet스프레드시트의 활성 시트를 가져옵니다.
getAs(contentType)Blob이 객체 내의 데이터를 지정된 콘텐츠 유형으로 변환된 blob으로 반환합니다.
getBandings()Banding[]이 스프레드시트의 모든 밴딩을 반환합니다.
getBlob()Blob이 객체 내의 데이터를 blob으로 반환합니다.
getColumnWidth(columnPosition)Integer지정된 열의 너비를 픽셀 단위로 가져옵니다.
getCurrentCell()Range활성 시트의 현재 셀을 반환하거나 현재 셀이 없는 경우 null을 반환합니다.
getDataRange()Range데이터가 있는 측정기준에 해당하는 Range를 반환합니다.
getDataSourceFormulas()DataSourceFormula[]모든 데이터 소스 수식을 가져옵니다.
getDataSourcePivotTables()DataSourcePivotTable[]모든 데이터 소스 피벗 테이블을 가져옵니다.
getDataSourceRefreshSchedules()DataSourceRefreshSchedule[]이 스프레드시트의 새로고침 일정을 가져옵니다.
getDataSourceSheets()DataSourceSheet[]스프레드시트의 모든 데이터 소스 시트를 반환합니다.
getDataSourceTables()DataSourceTable[]모든 데이터 소스 테이블을 가져옵니다.
getDataSources()DataSource[]스프레드시트의 모든 데이터 소스를 반환합니다.
getDeveloperMetadata()DeveloperMetadata[]최상위 스프레드시트와 연결된 개발자 메타데이터를 가져옵니다.
getEditors()User[]Spreadsheet의 편집자 목록을 가져옵니다.
getFormUrl()String이 스프레드시트에 응답을 보내는 양식의 URL을 반환하거나 이 스프레드시트에 연결된 양식이 없는 경우 null를 반환합니다.
getFrozenColumns()Integer고정된 열의 수를 반환합니다.
getFrozenRows()Integer고정된 행의 개수를 반환합니다.
getId()String이 스프레드시트의 고유 식별자를 가져옵니다.
getImages()OverGridImage[]시트의 모든 그리드 위에 있는 이미지를 반환합니다.
getIterativeCalculationConvergenceThreshold()Number반복 계산 중에 사용된 임계값을 반환합니다.
getLastColumn()Integer콘텐츠가 있는 마지막 열의 위치를 반환합니다.
getLastRow()Integer콘텐츠가 있는 마지막 행의 위치를 반환합니다.
getMaxIterativeCalculationCycles()Integer반복 계산 중에 사용할 최대 반복 횟수를 반환합니다.
getName()String문서의 이름을 가져옵니다.
getNamedRanges()NamedRange[]이 스프레드시트에서 이름이 지정된 모든 범위를 가져옵니다.
getNumSheets()Integer이 스프레드시트의 시트 수를 반환합니다.
getOwner()User문서의 소유자를 반환하거나 공유 드라이브에 있는 문서의 경우 null를 반환합니다.
getPredefinedSpreadsheetThemes()SpreadsheetTheme[]미리 정의된 테마 목록을 반환합니다.
getProtections(type)Protection[]스프레드시트의 모든 보호된 범위 또는 시트를 나타내는 객체의 배열을 가져옵니다.
getRange(a1Notation)RangeA1 표기법 또는 R1C1 표기법으로 지정된 범위를 반환합니다.
getRangeByName(name)Range이름이 지정된 범위를 반환하거나 지정된 이름의 범위를 찾을 수 없으면 null를 반환합니다.
getRangeList(a1Notations)RangeList비어 있지 않은 A1 표기법 또는 R1C1 표기법 목록으로 지정된 동일한 시트의 범위를 나타내는 RangeList 컬렉션을 반환합니다.
getRecalculationInterval()RecalculationInterval이 스프레드시트의 계산 간격을 반환합니다.
getRowHeight(rowPosition)Integer지정된 행의 높이를 픽셀 단위로 가져옵니다.
getSelection()Selection스프레드시트의 현재 Selection를 반환합니다.
getSheetByName(name)Sheet지정된 이름의 시트를 반환합니다.
getSheetId()Integer이 객체가 나타내는 시트의 ID를 반환합니다.
getSheetName()String시트 이름을 반환합니다.
getSheetValues(startRow, startColumn, numRows, numColumns)Object[][]지정된 좌표에서 시작하여 이 범위에 대한 값의 직사각형 그리드를 반환합니다.
getSheets()Sheet[]이 스프레드시트의 모든 시트를 가져옵니다.
getSpreadsheetLocale()String스프레드시트 언어를 가져옵니다.
getSpreadsheetTheme()SpreadsheetTheme스프레드시트의 현재 테마를 반환하거나 테마가 적용되지 않은 경우 null를 반환합니다.
getSpreadsheetTimeZone()String스프레드시트의 시간대를 가져옵니다.
getUrl()String지정된 스프레드시트의 URL을 반환합니다.
getViewers()User[]Spreadsheet의 뷰어 및 댓글 작성자 목록을 가져옵니다.
hideColumn(column)void지정된 범위에서 열을 숨깁니다.
hideRow(row)void지정된 범위의 행을 숨깁니다.
insertColumnAfter(afterPosition)Sheet지정된 열 위치 뒤에 열을 삽입합니다.
insertColumnBefore(beforePosition)Sheet지정된 열 위치 앞에 열을 삽입합니다.
insertColumnsAfter(afterPosition, howMany)Sheet지정된 열 위치 뒤에 지정된 수의 열을 삽입합니다.
insertColumnsBefore(beforePosition, howMany)Sheet지정된 열 위치 앞에 열 수를 삽입합니다.
insertDataSourceSheet(spec)DataSourceSheet스프레드시트에 새 DataSourceSheet를 삽입하고 데이터 실행을 시작합니다.
insertImage(blobSource, column, row)OverGridImageSpreadsheet를 문서의 지정된 행과 열에 이미지로 삽입합니다.
insertImage(blobSource, column, row, offsetX, offsetY)OverGridImage문서에서 픽셀 오프셋을 사용하여 지정된 행과 열에 Spreadsheet을 이미지로 삽입합니다.
insertImage(url, column, row)OverGridImage문서의 지정된 행과 열에 이미지를 삽입합니다.
insertImage(url, column, row, offsetX, offsetY)OverGridImage문서에서 지정된 행과 열에 픽셀 오프셋을 사용하여 이미지를 삽입합니다.
insertRowAfter(afterPosition)Sheet지정된 행 위치 뒤에 행을 삽입합니다.
insertRowBefore(beforePosition)Sheet지정된 행 위치 앞에 행을 삽입합니다.
insertRowsAfter(afterPosition, howMany)Sheet지정된 행 위치 뒤에 여러 행을 삽입합니다.
insertRowsBefore(beforePosition, howMany)Sheet지정된 행 위치 앞에 여러 행을 삽입합니다.
insertSheet()Sheet기본 시트 이름을 사용하여 스프레드시트에 새 시트를 삽입합니다.
insertSheet(sheetIndex)Sheet스프레드시트의 지정된 색인에 새 시트를 삽입합니다.
insertSheet(sheetIndex, options)Sheet지정된 색인의 스프레드시트에 새 시트를 삽입하고 선택적 고급 인수를 사용합니다.
insertSheet(options)Sheet기본 시트 이름과 선택적 고급 인수를 사용하여 새 시트를 스프레드시트에 삽입합니다.
insertSheet(sheetName)Sheet지정된 이름의 새 시트를 스프레드시트에 삽입합니다.
insertSheet(sheetName, sheetIndex)Sheet지정된 색인에 지정된 이름을 가진 새 시트를 스프레드시트에 삽입합니다.
insertSheet(sheetName, sheetIndex, options)Sheet지정된 색인에 지정된 이름을 가진 새 시트를 스프레드시트에 삽입하고 선택적 고급 인수를 사용합니다.
insertSheet(sheetName, options)Sheet지정된 이름으로 새 시트를 스프레드시트에 삽입하고 선택적 고급 인수를 사용합니다.
insertSheetWithDataSourceTable(spec)Sheet스프레드시트에 새 시트를 삽입하고 지정된 데이터 소스 사양이 있는 전체 시트에 걸쳐 DataSourceTable를 만들고 데이터 실행을 시작합니다.
isColumnHiddenByUser(columnPosition)Boolean지정된 열을 사용자가 숨겼는지 여부를 반환합니다.
isIterativeCalculationEnabled()Boolean이 스프레드시트에서 반복 계산이 활성화되었는지 여부를 반환합니다.
isRowHiddenByFilter(rowPosition)Boolean지정된 행이 필터 보기가 아닌 필터에 의해 숨겨져 있는지 여부를 반환합니다.
isRowHiddenByUser(rowPosition)Boolean지정된 행을 사용자가 숨겼는지 여부를 반환합니다.
moveActiveSheet(pos)void활성 시트를 시트 목록의 지정된 위치로 이동합니다.
moveChartToObjectSheet(chart)SheetSheetType.OBJECT 시트를 만들고 제공된 차트를 이 시트로 이동합니다.
refreshAllDataSources()void지원되는 모든 데이터 소스 및 연결된 데이터 소스 객체를 새로고침하고 잘못된 데이터 소스 객체는 건너뜁니다.
removeEditor(emailAddress)Spreadsheet지정된 사용자를 Spreadsheet의 편집자 목록에서 삭제합니다.
removeEditor(user)Spreadsheet지정된 사용자를 Spreadsheet의 편집자 목록에서 삭제합니다.
removeMenu(name)voidaddMenu(name, subMenus)에 의해 추가된 메뉴를 삭제합니다.
removeNamedRange(name)void지정된 이름의 이름이 지정된 범위를 삭제합니다.
removeViewer(emailAddress)SpreadsheetSpreadsheet의 뷰어 및 댓글 작성자 목록에서 지정된 사용자를 삭제합니다.
removeViewer(user)SpreadsheetSpreadsheet의 뷰어 및 댓글 작성자 목록에서 지정된 사용자를 삭제합니다.
rename(newName)void문서 이름을 변경합니다.
renameActiveSheet(newName)void현재 활성 시트의 이름을 지정된 새 이름으로 바꿉니다.
resetSpreadsheetTheme()SpreadsheetTheme적용된 테마를 삭제하고 스프레드시트에 기본 테마를 설정합니다.
setActiveRange(range)Range지정된 범위를 활성 시트에서 active range로 설정하고 범위의 왼쪽 상단 셀은 current cell로 설정합니다.
setActiveRangeList(rangeList)RangeList지정된 범위 목록을 활성 시트에서 active ranges로 설정합니다.
setActiveSelection(range)Range이 시트의 활성 선택 영역을 설정합니다.
setActiveSelection(a1Notation)RangeA1 표기법 또는 R1C1 표기법에 지정된 대로 활성 선택을 설정합니다.
setActiveSheet(sheet)Sheet지정된 시트를 스프레드시트의 활성 시트로 설정합니다.
setActiveSheet(sheet, restoreSelection)Sheet지정된 시트를 스프레드시트의 활성 시트로 설정하고 해당 시트 내에서 가장 최근에 선택한 항목을 복원하는 옵션을 제공합니다.
setColumnWidth(columnPosition, width)Sheet지정된 열의 너비를 픽셀 단위로 설정합니다.
setCurrentCell(cell)Range지정된 셀을 current cell로 설정합니다.
setFrozenColumns(columns)void지정된 수의 열을 고정합니다.
setFrozenRows(rows)void지정된 수의 행을 고정합니다.
setIterativeCalculationConvergenceThreshold(minThreshold)Spreadsheet반복 계산의 최소 임계값을 설정합니다.
setIterativeCalculationEnabled(isEnabled)Spreadsheet이 스프레드시트에서 반복 계산을 활성화할지 여부를 설정합니다.
setMaxIterativeCalculationCycles(maxIterations)Spreadsheet반복 계산 중에 실행해야 하는 최대 계산 반복 횟수를 설정합니다.
setNamedRange(name, range)void범위의 이름을 지정합니다.
setRecalculationInterval(recalculationInterval)Spreadsheet스프레드시트를 다시 계산할 빈도를 설정합니다.
setRowHeight(rowPosition, height)Sheet지정된 행의 행 높이를 픽셀 단위로 설정합니다.
setSpreadsheetLocale(locale)void스프레드시트의 언어를 설정합니다.
setSpreadsheetTheme(theme)SpreadsheetTheme스프레드시트에 테마를 설정합니다.
setSpreadsheetTimeZone(timezone)void스프레드시트의 시간대를 설정합니다.
show(userInterface)void사용자의 브라우저의 표시 영역을 중심으로 하는 대화상자에 맞춤 사용자 인터페이스 구성요소를 표시합니다.
sort(columnPosition)Sheet열을 기준으로 시트를 오름차순으로 정렬합니다.
sort(columnPosition, ascending)Sheet열을 기준으로 시트를 정렬합니다.
toast(msg)void스프레드시트의 오른쪽 하단에 특정 메시지가 포함된 팝업 창을 표시합니다.
toast(msg, title)void스프레드시트의 오른쪽 하단에 지정된 메시지와 제목이 있는 팝업 창을 표시합니다.
toast(msg, title, timeoutSeconds)void스프레드시트의 오른쪽 하단에 지정된 제목과 메시지가 포함된 팝업 창을 표시합니다. 이 팝업은 일정 시간 동안 계속 표시됩니다.
unhideColumn(column)void지정된 범위에서 열을 숨기기 해제합니다.
unhideRow(row)void지정된 범위에서 행 숨기기를 해제합니다.
updateMenu(name, subMenus)voidaddMenu(name, subMenus)에서 추가한 메뉴를 업데이트합니다.
waitForAllDataExecutionsCompletion(timeoutInSeconds)void스프레드시트의 현재 실행이 모두 완료될 때까지 대기하고 제공된 시간(초)이 지나면 타임아웃됩니다.

자세한 문서

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())

매개변수

이름유형설명
keyString새 개발자 메타데이터의 키입니다.

리턴

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()}`);

매개변수

이름유형설명
keyString새 개발자 메타데이터의 키입니다.
visibilityDeveloperMetadataVisibility새 개발자 메타데이터의 공개 상태입니다.

리턴

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()}`);

매개변수

이름유형설명
keyString새 개발자 메타데이터의 키입니다.
valueString새 개발자 메타데이터 값입니다.

리턴

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()}`);

매개변수

이름유형설명
keyString새 개발자 메타데이터의 키입니다.
valueString새 개발자 메타데이터 값입니다.
visibilityDeveloperMetadataVisibility새 개발자 메타데이터의 공개 상태입니다.

리턴

Spreadsheet - 연결용 스프레드시트입니다.

승인

이 방법을 사용하는 스크립트는 다음 범위 중 하나 이상을 승인해야 합니다.

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

addEditor(emailAddress)

지정된 사용자를 Spreadsheet의 편집자 목록에 추가합니다. 사용자가 이미 뷰어 목록에 있는 경우 이 메서드는 사용자를 뷰어 목록에서 제거할 수 있습니다.

매개변수

이름유형설명
emailAddressString추가할 사용자의 이메일 주소입니다.

리턴

Spreadsheet: 체이닝을 위한 Spreadsheet입니다.

승인

이 방법을 사용하는 스크립트는 다음 범위 중 하나 이상을 승인해야 합니다.

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

addEditor(user)

지정된 사용자를 Spreadsheet의 편집자 목록에 추가합니다. 사용자가 이미 뷰어 목록에 있는 경우 이 메서드는 사용자를 뷰어 목록에서 제거할 수 있습니다.

매개변수

이름유형설명
userUser추가할 사용자의 표현입니다.

리턴

Spreadsheet: 체이닝을 위한 Spreadsheet입니다.

승인

이 방법을 사용하는 스크립트는 다음 범위 중 하나 이상을 승인해야 합니다.

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

addEditors(emailAddresses)

지정된 사용자 배열을 Spreadsheet의 편집자 목록에 추가합니다. 사용자가 이미 뷰어 목록에 있다면 이 메서드는 해당 사용자를 뷰어 목록 밖으로 승격시킵니다.

매개변수

이름유형설명
emailAddressesString[]추가할 사용자의 이메일 주소 배열입니다.

리턴

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);
}

매개변수

이름유형설명
nameString생성할 메뉴의 이름입니다.
subMenusObject[]namefunctionName 매개변수가 있는 자바스크립트 지도의 배열입니다. 포함된 라이브러리(예: Library.libFunction1)의 함수를 사용할 수 있습니다.

승인

이 방법을 사용하는 스크립트는 다음 범위 중 하나 이상을 승인해야 합니다.

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

addViewer(emailAddress)

지정된 사용자를 Spreadsheet의 뷰어 목록에 추가합니다. 사용자가 이미 편집자 목록에 있었다면 이 메서드는 아무런 영향을 미치지 않습니다.

매개변수

이름유형설명
emailAddressString추가할 사용자의 이메일 주소입니다.

리턴

Spreadsheet: 체이닝을 위한 Spreadsheet입니다.

승인

이 방법을 사용하는 스크립트는 다음 범위 중 하나 이상을 승인해야 합니다.

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

addViewer(user)

지정된 사용자를 Spreadsheet의 뷰어 목록에 추가합니다. 사용자가 이미 편집자 목록에 있었다면 이 메서드는 아무런 영향을 미치지 않습니다.

매개변수

이름유형설명
userUser추가할 사용자의 표현입니다.

리턴

Spreadsheet: 체이닝을 위한 Spreadsheet입니다.

승인

이 방법을 사용하는 스크립트는 다음 범위 중 하나 이상을 승인해야 합니다.

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

addViewers(emailAddresses)

지정된 사용자 배열을 Spreadsheet의 뷰어 목록에 추가합니다. 사용자가 이미 편집자 목록에 있다면 이 메서드는 영향을 미치지 않습니다.

매개변수

이름유형설명
emailAddressesString[]추가할 사용자의 이메일 주소 배열입니다.

리턴

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"]);

매개변수

이름유형설명
rowContentsObject[]시트의 마지막 행 뒤에 삽입할 값의 배열입니다.

리턴

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);

매개변수

이름유형설명
columnPositionInteger크기를 조절할 지정된 열의 위치입니다.

리턴

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());

매개변수

이름유형설명
nameString사본의 이름입니다.

리턴

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');

매개변수

이름유형설명
findTextString검색할 텍스트입니다.

리턴

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);

매개변수

이름유형설명
columnPositionInteger열의 위치로, 첫 번째 열의 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);

매개변수

이름유형설명
columnPositionInteger삭제할 첫 번째 열의 위치입니다.
howManyInteger삭제할 열의 개수입니다.

승인

이 방법을 사용하는 스크립트는 다음 범위 중 하나 이상을 승인해야 합니다.

  • 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);

매개변수

이름유형설명
rowPositionInteger행의 위치로, 첫 번째 행의 경우 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);

매개변수

이름유형설명
rowPositionInteger삭제할 첫 번째 행의 위치입니다.
howManyInteger삭제할 행 수입니다.

승인

이 방법을 사용하는 스크립트는 다음 범위 중 하나 이상을 승인해야 합니다.

  • 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);

매개변수

이름유형설명
sheetSheet삭제할 시트입니다.

승인

이 방법을 사용하는 스크립트는 다음 범위 중 하나 이상을 승인해야 합니다.

  • 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 도메인에는 일시적으로 더 엄격한 할당량이 적용될 수 있습니다.

매개변수

이름유형설명
contentTypeString변환할 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()

이 객체 내의 데이터를 blob으로 반환합니다.

리턴

Blob - blob 형식의 데이터입니다.


getColumnWidth(columnPosition)

지정된 열의 너비를 픽셀 단위로 가져옵니다.

var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheets()[0];

// Columns start at 1
Logger.log(sheet.getColumnWidth(1));

매개변수

이름유형설명
columnPositionInteger검사할 열의 위치입니다.

리턴

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();
  }
}

매개변수

이름유형설명
typeProtectionType보호 구역의 유형으로, 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");

매개변수

이름유형설명
a1NotationStringA1 표기법 또는 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());
}

매개변수

이름유형설명
nameString가져올 범위의 이름입니다.

리턴

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']);

매개변수

이름유형설명
a1NotationsString[]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));

매개변수

이름유형설명
rowPositionInteger검토할 행의 위치입니다.

리턴

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());
}

매개변수

이름유형설명
nameString가져올 시트의 이름입니다.

리턴

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);

매개변수

이름유형설명
startRowInteger시작 행의 위치입니다.
startColumnInteger시작 열의 위치입니다.
numRowsInteger값을 반환할 행 수입니다.
numColumnsInteger값을 반환할 열의 개수입니다.

리턴

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);

매개변수

이름유형설명
columnRange숨길 열 범위입니다.

승인

이 방법을 사용하는 스크립트는 다음 범위 중 하나 이상을 승인해야 합니다.

  • 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);

매개변수

이름유형설명
rowRange숨길 행 범위입니다.

승인

이 방법을 사용하는 스크립트는 다음 범위 중 하나 이상을 승인해야 합니다.

  • 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);

매개변수

이름유형설명
afterPositionInteger새 열을 추가해야 하는 열입니다.

리턴

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);

매개변수

이름유형설명
beforePositionInteger앞에 새 열을 추가해야 하는 열입니다.

리턴

Sheet: 메서드 체이닝에 유용한 시트

승인

이 방법을 사용하는 스크립트는 다음 범위 중 하나 이상을 승인해야 합니다.

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

insertColumnsAfter(afterPosition, howMany)

지정된 열 위치 뒤에 지정된 수의 열을 삽입합니다.

let ss = SpreadsheetApp.getActiveSpreadsheet();
let sheet = ss.getSheets()[0];

// Inserts two columns after the first column on the first sheet of the spreadsheet.
sheet.insertColumnsAfter(1,2);

매개변수

이름유형설명
afterPositionInteger새 열을 추가해야 하는 열입니다.
howManyInteger삽입할 열의 수입니다.

리턴

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);

매개변수

이름유형설명
beforePositionInteger앞에 새 열을 추가해야 하는 열입니다.
howManyInteger삽입할 열의 수입니다.

리턴

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);

매개변수

이름유형설명
specDataSourceSpec삽입할 데이터 소스 사양입니다.

리턴

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);

매개변수

이름유형설명
blobSourceBlobSource이미지 콘텐츠, MIME 유형 및 이름 (선택사항)을 포함하는 blob입니다.
columnInteger열 위치입니다.
rowInteger행 위치입니다.

리턴

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);

매개변수

이름유형설명
blobSourceBlobSource이미지 콘텐츠, MIME 유형 및 이름 (선택사항)을 포함하는 blob입니다.
columnInteger열 위치입니다.
rowInteger행 위치입니다.
offsetXInteger셀 모서리로부터의 가로 오프셋(픽셀)입니다.
offsetYInteger셀 모서리로부터의 세로 오프셋(픽셀)입니다.

리턴

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);

매개변수

이름유형설명
urlString이미지의 URL입니다.
columnInteger그리드 열 위치입니다.
rowInteger그리드 행 위치입니다.

리턴

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);

매개변수

이름유형설명
urlString이미지의 URL입니다.
columnInteger열 위치입니다.
rowInteger행 위치입니다.
offsetXInteger셀 모서리로부터의 가로 오프셋(픽셀)입니다.
offsetYInteger셀 모서리로부터의 세로 오프셋(픽셀)입니다.

리턴

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);

매개변수

이름유형설명
afterPositionInteger새 행을 추가해야 하는 행입니다.

리턴

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);

매개변수

이름유형설명
beforePositionInteger앞에 새 행을 추가해야 하는 행입니다.

리턴

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);

매개변수

이름유형설명
afterPositionInteger새 행을 추가해야 하는 행입니다.
howManyInteger삽입할 행 수입니다.

리턴

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);

매개변수

이름유형설명
beforePositionInteger앞에 새 행을 추가해야 하는 행입니다.
howManyInteger삽입할 행 수입니다.

리턴

Sheet: 메서드 체이닝에 유용한 시트

승인

이 방법을 사용하는 스크립트는 다음 범위 중 하나 이상을 승인해야 합니다.

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

insertSheet()

기본 시트 이름을 사용하여 스프레드시트에 새 시트를 삽입합니다. 새 시트가 활성 시트가 됩니다.

var ss = SpreadsheetApp.getActiveSpreadsheet();
ss.insertSheet();

리턴

Sheet - 새 시트입니다.

승인

이 방법을 사용하는 스크립트는 다음 범위 중 하나 이상을 승인해야 합니다.

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

insertSheet(sheetIndex)

스프레드시트의 지정된 색인에 새 시트를 삽입합니다. 새 시트가 활성 시트가 됩니다.

var ss = SpreadsheetApp.getActiveSpreadsheet();
ss.insertSheet(1);

매개변수

이름유형설명
sheetIndexInteger새로 만든 시트의 색인입니다. 스프레드시트의 첫 번째 시트로 시트를 삽입하려면 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});

매개변수

이름유형설명
sheetIndexInteger새로 만든 시트의 색인입니다. 스프레드시트의 첫 번째 시트로 시트를 삽입하려면 0으로 설정하세요.
optionsObject선택적 자바스크립트 고급 인수입니다.

고급 매개변수

이름유형설명
templateSheet템플릿 시트 객체의 모든 데이터가 새 시트에 복사됩니다. 시트 템플릿은 스프레드시트 객체의 시트 중 하나여야 합니다.

리턴

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});

매개변수

이름유형설명
optionsObject아래에 나열된 선택적 JavaScript 고급 인수입니다.

고급 매개변수

이름유형설명
templateSheet템플릿 시트 객체의 모든 데이터가 새 시트에 복사됩니다. 시트 템플릿은 이 스프레드시트 객체의 시트 중 하나여야 합니다.

리턴

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');

매개변수

이름유형설명
sheetNameString새 시트의 이름입니다.

리턴

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);

매개변수

이름유형설명
sheetNameString새 시트의 이름입니다.
sheetIndexInteger새로 만든 시트의 색인입니다. 스프레드시트의 첫 번째 시트로 시트를 삽입하려면 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});

매개변수

이름유형설명
sheetNameString새 시트의 이름입니다.
sheetIndexInteger새로 삽입된 시트의 색인입니다. 스프레드시트의 첫 번째 시트로 시트를 삽입하려면 0으로 설정하세요.
optionsObject선택적 자바스크립트 고급 인수입니다.

고급 매개변수

이름유형설명
templateSheet템플릿 시트 객체의 모든 데이터가 새 시트에 복사됩니다. 시트 템플릿은 스프레드시트 객체의 시트 중 하나여야 합니다.

리턴

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});

매개변수

이름유형설명
sheetNameString새 시트의 이름입니다.
optionsObject선택적 자바스크립트 고급 인수입니다.

고급 매개변수

이름유형설명
templateSheet템플릿 시트 객체의 모든 데이터가 새 시트에 복사됩니다. 시트 템플릿은 스프레드시트 객체의 시트 중 하나여야 합니다.

리턴

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);

매개변수

이름유형설명
specDataSourceSpec삽입할 데이터 소스 사양입니다.

리턴

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));

매개변수

이름유형설명
columnPositionInteger검사할 열의 위치입니다.

리턴

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));

매개변수

이름유형설명
rowPositionInteger검토할 행의 위치입니다.

리턴

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));

매개변수

이름유형설명
rowPositionInteger검토할 행의 위치입니다.

리턴

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());

매개변수

이름유형설명
posInteger시트 목록에서 활성 시트를 이동할 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);

매개변수

이름유형설명
chartEmbeddedChart이동할 차트입니다.

리턴

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 파일의 경우 뷰어 목록에서도 사용자가 삭제됩니다.

매개변수

이름유형설명
emailAddressString삭제할 사용자의 이메일 주소입니다.

리턴

Spreadsheet: 체이닝을 위한 Spreadsheet입니다.

승인

이 방법을 사용하는 스크립트는 다음 범위 중 하나 이상을 승인해야 합니다.

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

removeEditor(user)

지정된 사용자를 Spreadsheet의 편집자 목록에서 삭제합니다. 일반 액세스 권한이 있는 사용자 클래스에 속한 경우(예: Spreadsheet가 사용자의 전체 도메인과 공유되거나 Spreadsheet가 사용자가 액세스할 수 있는 공유 드라이브에 있는 경우) 이 메서드는 사용자가 Spreadsheet에 액세스하는 것을 차단하지 않습니다.

Drive 파일의 경우 뷰어 목록에서도 사용자가 삭제됩니다.

매개변수

이름유형설명
userUser삭제할 사용자의 표현입니다.

리턴

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
}

매개변수

이름유형설명
nameString삭제할 메뉴의 이름입니다.

승인

이 방법을 사용하는 스크립트는 다음 범위 중 하나 이상을 승인해야 합니다.

  • 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");

매개변수

이름유형설명
nameString범위 이름입니다.

승인

이 방법을 사용하는 스크립트는 다음 범위 중 하나 이상을 승인해야 합니다.

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

removeViewer(emailAddress)

Spreadsheet의 뷰어 및 댓글 작성자 목록에서 지정된 사용자를 삭제합니다. 사용자가 뷰어나 댓글 작성자가 아닌 편집자인 경우에는 이 메서드가 영향을 미치지 않습니다. 또한 이 메서드는 일반 액세스 권한이 있는 사용자 클래스에 속한 경우(예: Spreadsheet가 사용자의 전체 도메인과 공유되거나 Spreadsheet가 사용자가 액세스할 수 있는 공유 드라이브에 있는 경우) Spreadsheet에 액세스하는 것을 차단하지 않습니다.

Drive 파일의 경우 편집자 목록에서도 사용자가 삭제됩니다.

매개변수

이름유형설명
emailAddressString삭제할 사용자의 이메일 주소입니다.

리턴

Spreadsheet: 체이닝을 위한 Spreadsheet입니다.

승인

이 방법을 사용하는 스크립트는 다음 범위 중 하나 이상을 승인해야 합니다.

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

removeViewer(user)

Spreadsheet의 뷰어 및 댓글 작성자 목록에서 지정된 사용자를 삭제합니다. 사용자가 뷰어가 아닌 편집자인 경우에는 이 메서드가 영향을 미치지 않습니다. 또한 이 메서드는 일반 액세스 권한이 있는 사용자 클래스에 속한 경우(예: Spreadsheet가 사용자의 전체 도메인과 공유되거나 Spreadsheet가 사용자가 액세스할 수 있는 공유 드라이브에 있는 경우) Spreadsheet에 액세스하는 것을 차단하지 않습니다.

Drive 파일의 경우 편집자 목록에서도 사용자가 삭제됩니다.

매개변수

이름유형설명
userUser삭제할 사용자의 표현입니다.

리턴

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");

매개변수

이름유형설명
newNameString문서의 새 이름입니다.

승인

이 방법을 사용하는 스크립트는 다음 범위 중 하나 이상을 승인해야 합니다.

  • 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");

매개변수

이름유형설명
newNameString현재 활성 시트의 새 이름입니다.

승인

이 방법을 사용하는 스크립트는 다음 범위 중 하나 이상을 승인해야 합니다.

  • 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();

매개변수

이름유형설명
rangeRange활성 범위로 설정할 범위입니다.

리턴

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();

매개변수

이름유형설명
rangeListRangeList선택할 범위 목록입니다.

리턴

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);

매개변수

이름유형설명
rangeRange활성 선택으로 설정할 범위입니다.

리턴

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");

매개변수

이름유형설명
a1NotationStringA1 표기법 또는 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]);

매개변수

이름유형설명
sheetSheet활성 시트로 설정할 시트입니다.

리턴

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());

매개변수

이름유형설명
sheetSheet새 활성 시트입니다.
restoreSelectionBooleanTf 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);

매개변수

이름유형설명
columnPositionInteger설정할 지정된 열의 위치입니다.
widthInteger설정할 너비(픽셀)입니다.

리턴

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();

매개변수

이름유형설명
cellRange현재 셀로 설정할 셀입니다.

리턴

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);

매개변수

이름유형설명
columnsInteger고정할 열의 수입니다.

승인

이 방법을 사용하는 스크립트는 다음 범위 중 하나 이상을 승인해야 합니다.

  • 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);

매개변수

이름유형설명
rowsInteger고정할 행 수입니다.

승인

이 방법을 사용하는 스크립트는 다음 범위 중 하나 이상을 승인해야 합니다.

  • 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());

매개변수

이름유형설명
minThresholdNumber최소 수렴 기준입니다 (음수가 아니어야 함).

리턴

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());

매개변수

이름유형설명
isEnabledBoolean반복 계산을 사용해야 하는 경우 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());

매개변수

이름유형설명
maxIterationsInteger최대 계산 반복 횟수 (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());

매개변수

이름유형설명
nameString범위에 지정할 이름입니다.
rangeRange범위 사양입니다.

승인

이 방법을 사용하는 스크립트는 다음 범위 중 하나 이상을 승인해야 합니다.

  • 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);

매개변수

이름유형설명
recalculationIntervalRecalculationInterval새 재계산 간격입니다.

리턴

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);

매개변수

이름유형설명
rowPositionInteger변경할 행 위치입니다.
heightInteger설정할 높이(픽셀)입니다.

리턴

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);

매개변수

이름유형설명
localeString사용할 언어 코드입니다 (예: '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]);

매개변수

이름유형설명
themeSpreadsheetTheme적용할 테마입니다.

리턴

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);

매개변수

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

매개변수

이름유형설명
userInterfaceObjectHtmlOutput입니다.

승인

이 방법을 사용하는 스크립트는 다음 범위 중 하나 이상을 승인해야 합니다.

  • 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);

매개변수

이름유형설명
columnPositionInteger정렬할 열입니다.

리턴

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);

매개변수

이름유형설명
columnPositionInteger정렬할 열입니다.
ascendingBoolean오름차순 정렬의 경우 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');

매개변수

이름유형설명
msgString토스트 메시지에 표시할 메시지입니다.

승인

이 방법을 사용하는 스크립트는 다음 범위 중 하나 이상을 승인해야 합니다.

  • 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');

매개변수

이름유형설명
msgString토스트 메시지에 표시할 메시지입니다.
titleString토스트의 제목(선택사항)입니다.

승인

이 방법을 사용하는 스크립트는 다음 범위 중 하나 이상을 승인해야 합니다.

  • 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);

매개변수

이름유형설명
msgString토스트 메시지에 표시할 메시지입니다.
titleString토스트의 제목(선택사항)입니다.
timeoutSecondsNumber제한 시간(초)입니다. 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);

매개변수

이름유형설명
columnRange숨겨진 경우 숨기기 해제할 범위입니다.

승인

이 방법을 사용하는 스크립트는 다음 범위 중 하나 이상을 승인해야 합니다.

  • 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);

매개변수

이름유형설명
rowRange숨겨진 경우 숨기기 해제할 범위입니다.

승인

이 방법을 사용하는 스크립트는 다음 범위 중 하나 이상을 승인해야 합니다.

  • 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);

매개변수

이름유형설명
nameString업데이트할 메뉴의 이름입니다.
subMenusObject[]namefunctionName 매개변수가 있는 자바스크립트 지도의 배열입니다. 포함된 라이브러리(예: Library.libFunction1)의 함수를 사용할 수 있습니다.

승인

이 방법을 사용하는 스크립트는 다음 범위 중 하나 이상을 승인해야 합니다.

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

waitForAllDataExecutionsCompletion(timeoutInSeconds)

스프레드시트의 현재 실행이 모두 완료될 때까지 대기하고 제공된 시간(초)이 지나면 타임아웃됩니다. 시간 초과 시 실행이 완료되지 않지만 데이터 실행을 취소하지는 않으면 예외가 발생합니다.

매개변수

이름유형설명
timeoutInSecondsInteger데이터 실행을 기다리는 시간(초)입니다. 최댓값은 300초입니다.

승인

이 방법을 사용하는 스크립트는 다음 범위 중 하나 이상을 승인해야 합니다.

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

지원 중단된 메서드