Class Sheet

시트

스프레드시트 시트에 액세스하고 수정합니다. 일반적인 작업은 시트 이름을 바꾸고 시트에서 범위 객체에 액세스하는 것입니다.

방법

메서드반환 유형간략한 설명
activate()Sheet이 시트를 활성화합니다.
addDeveloperMetadata(key)Sheet지정된 키와 함께 개발자 메타데이터를 시트에 추가합니다.
addDeveloperMetadata(key, visibility)Sheet지정된 키와 함께 개발자 메타데이터를 시트에 추가합니다.
addDeveloperMetadata(key, value)Sheet지정된 키와 값이 있는 개발자 메타데이터를 시트에 추가합니다.
addDeveloperMetadata(key, value, visibility)Sheet지정된 키, 값, 가시성과 함께 개발자 메타데이터를 시트에 추가합니다.
appendRow(rowContents)Sheet시트에서 현재 데이터 리전의 하단에 행을 추가합니다.
asDataSourceSheet()DataSourceSheet시트가 SheetType.DATASOURCE 유형이면 시트를 DataSourceSheet로, 그렇지 않으면 null로 반환합니다.
autoResizeColumn(columnPosition)Sheet콘텐츠에 맞게 지정된 열의 너비를 설정합니다.
autoResizeColumns(startColumn, numColumns)Sheet지정된 열 위치에서 시작하는 모든 열의 너비를 콘텐츠에 맞도록 설정합니다.
autoResizeRows(startRow, numRows)Sheet지정된 행 위치에서 시작하는 모든 행의 높이를 콘텐츠에 맞게 설정합니다.
clear()Sheet콘텐츠 시트 및 서식 정보를 지웁니다.
clear(options)Sheet지정된 고급 옵션으로 지정된 대로 목차 및/또는 형식의 시트를 지웁니다.
clearConditionalFormatRules()void시트에서 모든 조건부 서식 규칙을 삭제합니다.
clearContents()Sheet서식 정보를 유지하면서 목차를 지웁니다.
clearFormats()Sheet콘텐츠는 유지하면서 서식 시트를 지웁니다.
clearNotes()Sheet모든 메모의 시트를 지웁니다.
collapseAllColumnGroups()Sheet시트의 모든 열 그룹을 접습니다.
collapseAllRowGroups()Sheet시트의 모든 행 그룹을 접습니다.
copyTo(spreadsheet)Sheet소스와 동일한 스프레드시트일 수 있는 특정 스프레드시트에 시트를 복사합니다.
createDeveloperMetadataFinder()DeveloperMetadataFinder이 시트의 범위 내에서 개발자 메타데이터를 찾는 DeveloperMetadataFinder를 반환합니다.
createTextFinder(findText)TextFinder시트 내에서 텍스트를 찾아 바꿀 수 있는 시트의 텍스트 찾기 도구를 만듭니다.
deleteColumn(columnPosition)Sheet지정된 열 위치에서 열을 삭제합니다.
deleteColumns(columnPosition, howMany)void지정된 열 위치에서 시작하는 열 수를 삭제합니다.
deleteRow(rowPosition)Sheet지정된 행 위치에서 행을 삭제합니다.
deleteRows(rowPosition, howMany)void지정된 행 위치에서 시작하여 여러 행을 삭제합니다.
expandAllColumnGroups()Sheet시트의 모든 열 그룹을 펼칩니다.
expandAllRowGroups()Sheet시트의 모든 행 그룹을 펼칩니다.
expandColumnGroupsUpToDepth(groupDepth)Sheet모든 열 그룹을 지정된 깊이까지 펼치고 다른 모든 열 그룹을 접습니다.
expandRowGroupsUpToDepth(groupDepth)Sheet모든 행 그룹을 지정된 깊이까지 펼치고 다른 모든 행 그룹을 접습니다.
getActiveCell()Range이 시트의 활성 셀을 반환합니다.
getActiveRange()Range활성 시트에서 선택된 범위를 반환하거나 활성 범위가 없는 경우 null을 반환합니다.
getActiveRangeList()RangeList활성 시트의 활성 범위 목록을 반환하거나 활성 범위가 없는 경우 null을 반환합니다.
getBandings()Banding[]이 시트의 모든 밴딩을 반환합니다.
getCharts()EmbeddedChart[]이 시트의 차트의 배열을 반환합니다.
getColumnGroup(columnIndex, groupDepth)Group지정된 색인 및 그룹 깊이의 열 그룹을 반환합니다.
getColumnGroupControlPosition()GroupControlTogglePosition시트의 모든 열 그룹에 대해 GroupControlTogglePosition를 반환합니다.
getColumnGroupDepth(columnIndex)Integer지정된 색인에 있는 열의 그룹 깊이를 반환합니다.
getColumnWidth(columnPosition)Integer지정된 열의 너비를 픽셀 단위로 가져옵니다.
getConditionalFormatRules()ConditionalFormatRule[]이 시트의 모든 조건부 서식 규칙을 가져옵니다.
getCurrentCell()Range활성 시트의 현재 셀을 반환하거나 현재 셀이 없는 경우 null을 반환합니다.
getDataRange()Range데이터가 있는 측정기준에 해당하는 Range를 반환합니다.
getDataSourceFormulas()DataSourceFormula[]모든 데이터 소스 수식을 가져옵니다.
getDataSourcePivotTables()DataSourcePivotTable[]모든 데이터 소스 피벗 테이블을 가져옵니다.
getDataSourceTables()DataSourceTable[]모든 데이터 소스 테이블을 가져옵니다.
getDeveloperMetadata()DeveloperMetadata[]이 시트와 연결된 모든 개발자 메타데이터를 가져옵니다.
getDrawings()Drawing[]시트에 있는 그림의 배열을 반환합니다.
getFilter()Filter이 시트의 필터를 반환하거나 필터가 없는 경우 null을 반환합니다.
getFormUrl()String이 시트에 응답을 보내는 양식의 URL을 반환하거나 이 시트에 연결된 양식이 없는 경우 null을 반환합니다.
getFrozenColumns()Integer고정된 열의 수를 반환합니다.
getFrozenRows()Integer고정된 행의 개수를 반환합니다.
getImages()OverGridImage[]시트의 모든 그리드 위에 있는 이미지를 반환합니다.
getIndex()Integer상위 스프레드시트에서 시트의 위치를 가져옵니다.
getLastColumn()Integer콘텐츠가 있는 마지막 열의 위치를 반환합니다.
getLastRow()Integer콘텐츠가 있는 마지막 행의 위치를 반환합니다.
getMaxColumns()Integer콘텐츠에 관계없이 시트의 현재 열 수를 반환합니다.
getMaxRows()Integer콘텐츠에 관계없이 시트의 현재 행 수를 반환합니다.
getName()String시트의 이름을 반환합니다.
getNamedRanges()NamedRange[]이 시트의 이름이 지정된 모든 범위를 가져옵니다.
getParent()Spreadsheet이 시트가 포함된 Spreadsheet를 반환합니다.
getPivotTables()PivotTable[]이 시트의 모든 피벗 테이블을 반환합니다.
getProtections(type)Protection[]시트의 모든 보호된 범위를 나타내는 객체의 배열 또는 시트 자체의 보호를 나타내는 단일 요소 배열을 가져옵니다.
getRange(row, column)Range지정된 좌표에서 왼쪽 상단 셀이 있는 범위를 반환합니다.
getRange(row, column, numRows)Range지정된 좌표에 왼쪽 상단 셀이 있고 지정된 행 수를 포함하는 범위를 반환합니다.
getRange(row, column, numRows, numColumns)Range지정된 좌표에 왼쪽 상단 셀이 있고 지정된 수의 행과 열이 있는 범위를 반환합니다.
getRange(a1Notation)RangeA1 표기법 또는 R1C1 표기법으로 지정된 범위를 반환합니다.
getRangeList(a1Notations)RangeList비어 있지 않은 A1 표기법 또는 R1C1 표기법 목록으로 지정된 동일한 시트의 범위를 나타내는 RangeList 컬렉션을 반환합니다.
getRowGroup(rowIndex, groupDepth)Group지정된 색인 및 그룹 깊이에서 행 그룹을 반환합니다.
getRowGroupControlPosition()GroupControlTogglePosition시트에 있는 모든 행 그룹의 GroupControlTogglePosition를 반환합니다.
getRowGroupDepth(rowIndex)Integer지정된 색인에 있는 행의 그룹 깊이를 반환합니다.
getRowHeight(rowPosition)Integer지정된 행의 높이를 픽셀 단위로 가져옵니다.
getSelection()Selection스프레드시트의 현재 Selection를 반환합니다.
getSheetId()Integer이 객체가 나타내는 시트의 ID를 반환합니다.
getSheetName()String시트 이름을 반환합니다.
getSheetValues(startRow, startColumn, numRows, numColumns)Object[][]지정된 좌표에서 시작하여 이 범위에 대한 값의 직사각형 그리드를 반환합니다.
getSlicers()Slicer[]시트의 슬라이서 배열을 반환합니다.
getTabColorObject()Color시트 탭 색상을 가져오거나 시트 탭에 색상이 없는 경우 null를 가져옵니다.
getType()SheetType시트의 유형을 반환합니다.
hasHiddenGridlines()Boolean시트의 격자선이 숨겨져 있으면 true를 반환하고 그렇지 않으면 false을 반환합니다.
hideColumn(column)void지정된 범위에서 열을 숨깁니다.
hideColumns(columnIndex)void지정된 색인에서 단일 열을 숨깁니다.
hideColumns(columnIndex, numColumns)void지정된 색인에서 시작하는 하나 이상의 연속 열을 숨깁니다.
hideRow(row)void지정된 범위의 행을 숨깁니다.
hideRows(rowIndex)void지정된 색인의 행을 숨깁니다.
hideRows(rowIndex, numRows)void지정된 색인에서 시작하여 하나 이상의 연속된 행을 숨깁니다.
hideSheet()Sheet이 시트를 숨깁니다.
insertChart(chart)void이 시트에 새 차트를 추가합니다.
insertColumnAfter(afterPosition)Sheet지정된 열 위치 뒤에 열을 삽입합니다.
insertColumnBefore(beforePosition)Sheet지정된 열 위치 앞에 열을 삽입합니다.
insertColumns(columnIndex)void시트의 지정된 위치에 빈 열을 삽입합니다.
insertColumns(columnIndex, numColumns)void지정된 위치에서 시작하는 시트에 하나 이상의 연속된 빈 열을 삽입합니다.
insertColumnsAfter(afterPosition, howMany)Sheet지정된 열 위치 뒤에 지정된 수의 열을 삽입합니다.
insertColumnsBefore(beforePosition, howMany)Sheet지정된 열 위치 앞에 열 수를 삽입합니다.
insertImage(blobSource, column, row)OverGridImageBlobSource를 문서의 지정된 행과 열에 이미지로 삽입합니다.
insertImage(blobSource, column, row, offsetX, offsetY)OverGridImage문서에서 픽셀 오프셋을 사용하여 지정된 행과 열에 BlobSource을 이미지로 삽입합니다.
insertImage(url, column, row)OverGridImage문서의 지정된 행과 열에 이미지를 삽입합니다.
insertImage(url, column, row, offsetX, offsetY)OverGridImage문서에서 지정된 행과 열에 픽셀 오프셋을 사용하여 이미지를 삽입합니다.
insertRowAfter(afterPosition)Sheet지정된 행 위치 뒤에 행을 삽입합니다.
insertRowBefore(beforePosition)Sheet지정된 행 위치 앞에 행을 삽입합니다.
insertRows(rowIndex)void시트의 지정된 위치에 빈 행을 삽입합니다.
insertRows(rowIndex, numRows)void지정된 위치에서 시작하는 시트에 하나 이상의 연속된 빈 행을 삽입합니다.
insertRowsAfter(afterPosition, howMany)Sheet지정된 행 위치 뒤에 여러 행을 삽입합니다.
insertRowsBefore(beforePosition, howMany)Sheet지정된 행 위치 앞에 여러 행을 삽입합니다.
insertSlicer(range, anchorRowPos, anchorColPos)Slicer이 시트에 새 슬라이서를 추가합니다.
insertSlicer(range, anchorRowPos, anchorColPos, offsetX, offsetY)Slicer이 시트에 새 슬라이서를 추가합니다.
isColumnHiddenByUser(columnPosition)Boolean지정된 열을 사용자가 숨겼는지 여부를 반환합니다.
isRightToLeft()Boolean이 시트 레이아웃이 오른쪽에서 왼쪽이면 true를 반환합니다.
isRowHiddenByFilter(rowPosition)Boolean지정된 행이 필터 보기가 아닌 필터에 의해 숨겨져 있는지 여부를 반환합니다.
isRowHiddenByUser(rowPosition)Boolean지정된 행을 사용자가 숨겼는지 여부를 반환합니다.
isSheetHidden()Boolean시트가 현재 숨겨져 있으면 true를 반환합니다.
moveColumns(columnSpec, destinationIndex)void지정된 범위로 선택된 열을 destinationIndex가 나타내는 위치로 이동합니다.
moveRows(rowSpec, destinationIndex)void지정된 범위로 선택된 행을 destinationIndex로 표시된 위치로 이동합니다.
newChart()EmbeddedChartBuilder이 시트의 새 차트를 만드는 빌더를 반환합니다.
protect()Protection권한이 있는 사용자를 제외하고 시트가 수정되지 않도록 보호할 수 있는 객체를 만듭니다.
removeChart(chart)void상위 시트에서 차트를 삭제합니다.
setActiveRange(range)Range지정된 범위를 활성 시트에서 active range로 설정하고 범위의 왼쪽 상단 셀은 current cell로 설정합니다.
setActiveRangeList(rangeList)RangeList지정된 범위 목록을 활성 시트에서 active ranges로 설정합니다.
setActiveSelection(range)Range이 시트의 활성 선택 영역을 설정합니다.
setActiveSelection(a1Notation)RangeA1 표기법 또는 R1C1 표기법에 지정된 대로 활성 선택을 설정합니다.
setColumnGroupControlPosition(position)Sheet시트에서 열 그룹 컨트롤 토글의 위치를 설정합니다.
setColumnWidth(columnPosition, width)Sheet지정된 열의 너비를 픽셀 단위로 설정합니다.
setColumnWidths(startColumn, numColumns, width)Sheet지정된 열의 너비를 픽셀 단위로 설정합니다.
setConditionalFormatRules(rules)void시트에 있는 현재 존재하는 모든 조건부 서식 규칙을 입력 규칙으로 대체합니다.
setCurrentCell(cell)Range지정된 셀을 current cell로 설정합니다.
setFrozenColumns(columns)void지정된 수의 열을 고정합니다.
setFrozenRows(rows)void지정된 수의 행을 고정합니다.
setHiddenGridlines(hideGridlines)Sheet시트 격자선을 숨기거나 표시합니다.
setName(name)Sheet시트 이름을 설정합니다.
setRightToLeft(rightToLeft)Sheet시트 레이아웃을 오른쪽에서 왼쪽으로 설정하거나 설정 해제합니다.
setRowGroupControlPosition(position)Sheet시트에서 행 그룹 컨트롤 토글의 위치를 설정합니다.
setRowHeight(rowPosition, height)Sheet지정된 행의 행 높이를 픽셀 단위로 설정합니다.
setRowHeights(startRow, numRows, height)Sheet지정된 행의 높이를 픽셀 단위로 설정합니다.
setRowHeightsForced(startRow, numRows, height)Sheet지정된 행의 높이를 픽셀 단위로 설정합니다.
setTabColor(color)Sheet시트 탭 색상을 설정합니다.
setTabColorObject(color)Sheet시트 탭 색상을 설정합니다.
showColumns(columnIndex)void지정된 색인에서 열을 숨기기 해제합니다.
showColumns(columnIndex, numColumns)void지정된 색인에서 시작하는 하나 이상의 연속 열을 숨기기 해제합니다.
showRows(rowIndex)void지정된 색인에서 행을 숨기기 해제합니다.
showRows(rowIndex, numRows)void지정된 색인에서 시작하는 하나 이상의 연속된 행을 숨기기 해제합니다.
showSheet()Sheet시트를 표시합니다.
sort(columnPosition)Sheet열을 기준으로 시트를 오름차순으로 정렬합니다.
sort(columnPosition, ascending)Sheet열을 기준으로 시트를 정렬합니다.
unhideColumn(column)void지정된 범위에서 열을 숨기기 해제합니다.
unhideRow(row)void지정된 범위에서 행 숨기기를 해제합니다.
updateChart(chart)void이 시트의 차트를 업데이트합니다.

자세한 문서

activate()

이 시트를 활성화합니다. 시트 자체는 변경하지 않으며 활성 시트의 상위 개념만 변경합니다.

// This example assumes there is a sheet named "first"
var ss = SpreadsheetApp.getActiveSpreadsheet();
var first = ss.getSheetByName("first");
first.activate();

리턴

Sheet - 새로 활성화된 시트입니다.


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

// Gets a sheet by its name.
const sheet = ss.getSheetByName('Sheet1');

// Adds the key 'NAME' to the developer metadata for the sheet.
sheet.addDeveloperMetadata('NAME');

// Gets the updated metadata info and logs it to the console.
console.log(sheet.getDeveloperMetadata()[0].getKey());

매개변수

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

리턴

Sheet - 이 시트는 체인을 위해 사용됩니다.

승인

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

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

// Gets a sheet by its name.
const sheet = ss.getSheetByName('Sheet1');

// Adds the key 'NAME' and sets the developer metadata visibility to PROJECT
// for the sheet.
sheet.addDeveloperMetadata('NAME', SpreadsheetApp.DeveloperMetadataVisibility.PROJECT);

// Gets the updated metadata info and logs it to the console.
const developerMetaData = sheet.getDeveloperMetadata()[0];
console.log(developerMetaData.getKey());
console.log(developerMetaData.getVisibility().toString());

매개변수

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

리턴

Sheet - 이 시트는 체인을 위해 사용됩니다.

승인

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

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

// Gets a sheet by its name.
const sheet = ss.getSheetByName('Sheet1');

// Adds the key 'COMPANY' with the value 'TECH' to the developer metadata for the sheet.
sheet.addDeveloperMetadata('COMPANY', 'TECH');

// Gets the updated metadata info and logs it to the console.
const developerMetaData = sheet.getDeveloperMetadata()[0];
console.log(developerMetaData.getKey());
console.log(developerMetaData.getValue());

매개변수

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

리턴

Sheet - 이 시트는 체인을 위해 사용됩니다.

승인

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

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

// Gets a sheet by its name.
const sheet = ss.getSheetByName('Sheet1');

// Adds the key 'COMPANY' with the value 'TECH' to the developer metadata and sets the
// visibility to DOCUMENT for the sheet.
sheet.addDeveloperMetadata(
  'COMPANY',
  'TECH',
  SpreadsheetApp.DeveloperMetadataVisibility.DOCUMENT);

// Gets the updated metadata info and logs it to the console.
const developerMetaData = sheet.getDeveloperMetadata()[0];
console.log(developerMetaData.getKey());
console.log(developerMetaData.getValue());
console.log(developerMetaData.getVisibility().toString());

매개변수

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

리턴

Sheet - 이 시트는 체인을 위해 사용됩니다.

승인

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

  • 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

asDataSourceSheet()

시트가 SheetType.DATASOURCE 유형이면 시트를 DataSourceSheet로, 그렇지 않으면 null로 반환합니다.

// Opens the spreadsheet file by its URL. If you created your script from within a
// Google Sheets file, you can useSpreadsheetApp.getActiveSpreadsheet() instead.
// TODO(developer): Replace the URL with your own.
const ss = SpreadsheetApp.openByUrl('https://docs.google.com/spreadsheets/d/abc123456/edit');

// Gets a sheet by its name.
const sheet = ss.getSheetByName('Sheet1');

// Gets the data source sheet value if the sheet is of type
// SpreadsheetApp.SheetType.DATASOURCE, otherwise this returns a null value.
const dataSourceSheet = sheet.asDataSourceSheet();

// Gets the data source sheet value and logs it to the console.
console.log(dataSourceSheet);
console.log(sheet.getType().toString());

리턴

DataSourceSheet - 데이터 소스 시트입니다.

승인

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

  • 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

autoResizeColumns(startColumn, numColumns)

지정된 열 위치에서 시작하는 모든 열의 너비를 콘텐츠에 맞도록 설정합니다.

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

// Sets the first 15 columns to a width that fits their text.
sheet.autoResizeColumns(1, 15);

매개변수

이름유형설명
startColumnInteger자동 크기 조절을 시작할 열입니다.
numColumnsInteger크기를 자동 조절할 열의 수입니다.

리턴

Sheet - 이 시트는 체인을 위해 사용됩니다.

승인

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

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

autoResizeRows(startRow, numRows)

지정된 행 위치에서 시작하는 모든 행의 높이를 콘텐츠에 맞게 설정합니다.

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

// Sets the first 15 rows to a height that fits their text.
sheet.autoResizeRows(1, 15);

매개변수

이름유형설명
startRowInteger자동 크기 조절을 시작할 행입니다.
numRowsInteger자동 크기 조절을 위한 행 수입니다.

리턴

Sheet - 이 시트는 체인을 위해 사용됩니다.

승인

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

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

clear()

콘텐츠 시트 및 서식 정보를 지웁니다.

// This example assumes there is a sheet named "first"
var ss = SpreadsheetApp.getActiveSpreadsheet();
var first = ss.getSheetByName("first");
first.clear();

리턴

Sheet - 삭제된 시트입니다.

승인

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

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

clear(options)

지정된 고급 옵션으로 지정된 대로 목차 및/또는 형식의 시트를 지웁니다.

var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheets()[0];
sheet.clear({ formatOnly: true, contentsOnly: true });

매개변수

이름유형설명
optionsObject아래에 나열된 고급 옵션이 포함된 JavaScript 지도.

고급 매개변수

이름유형설명
contentsOnlyBoolean콘텐츠 삭제 여부입니다.
formatOnlyBoolean형식을 삭제할지 여부입니다.

리턴

Sheet - 이 시트는 체인을 위해 사용됩니다.

승인

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

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

clearConditionalFormatRules()

시트에서 모든 조건부 서식 규칙을 삭제합니다. 빈 배열을 입력으로 사용하여 setConditionalFormatRules(rules)를 호출하는 것과 같습니다.

var sheet = SpreadsheetApp.getActiveSheet();
sheet.clearConditionalFormatRules();

승인

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

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

clearContents()

서식 정보를 유지하면서 목차를 지웁니다.

// This example assumes there is a sheet named "first"
var ss = SpreadsheetApp.getActiveSpreadsheet();
var first = ss.getSheetByName("first");
first.clearContents();

리턴

Sheet - 이 시트는 체인을 위해 사용됩니다.

승인

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

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

clearFormats()

콘텐츠는 유지하면서 서식 시트를 지웁니다.

형식 지정이란 셀의 너비나 높이가 아니라 '서식' 메뉴에서 선택할 수 있는 데이터 형식(예: 굵게, 기울임꼴, 조건부 서식)을 의미합니다.

// This example assumes there is a sheet named "first"
var ss = SpreadsheetApp.getActiveSpreadsheet();
var first = ss.getSheetByName("first");
first.clearFormats();

리턴

Sheet - 이 시트는 체인을 위해 사용됩니다.

승인

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

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

clearNotes()

모든 메모의 시트를 지웁니다.

// This example assumes there is a sheet named "first"
var ss = SpreadsheetApp.getActiveSpreadsheet();
var first = ss.getSheetByName("first");
first.clearNotes();

리턴

Sheet - 이 시트는 체인을 위해 사용됩니다.

승인

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

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

collapseAllColumnGroups()

시트의 모든 열 그룹을 접습니다.

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

// All column groups on the sheet are collapsed.
sheet.collapseAllColumnGroups();

리턴

Sheet - 이 시트는 체인을 위해 사용됩니다.

승인

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

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

collapseAllRowGroups()

시트의 모든 행 그룹을 접습니다.

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

// All row groups on the sheet are collapsed.
sheet.collapseAllRowGroups();

리턴

Sheet - 이 시트는 체인을 위해 사용됩니다.

승인

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

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

copyTo(spreadsheet)

소스와 동일한 스프레드시트일 수 있는 특정 스프레드시트에 시트를 복사합니다. 복사된 시트의 이름은 '[원본 이름]의 사본'으로 지정됩니다.

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

var destination = SpreadsheetApp.openById('ID_GOES HERE');
sheet.copyTo(destination);

매개변수

이름유형설명
spreadsheetSpreadsheet이 시트를 복사할 스프레드시트로, 소스와 동일한 스프레드시트일 수 있습니다.

리턴

Sheet - 체인을 위한 새 시트입니다.

승인

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

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

// Gets a sheet by its name.
const sheet = ss.getSheetByName('Sheet1');

// Adds developer metadata for testing.
sheet.addDeveloperMetadata('CITY', 'PARIS');

// Creates the developer metadata finder.
const metadatafinder = sheet.createDeveloperMetadataFinder();

// Finds the metadata with value 'PARIS' and displays its key in the console.
console.log(metadatafinder.withValue('PARIS').find()[0].getKey());

리턴

DeveloperMetadataFinder - 이 시트 범위에 있는 메타데이터를 검색할 수 있는 개발자 메타데이터 찾기입니다.


createTextFinder(findText)

시트 내에서 텍스트를 찾아 바꿀 수 있는 시트의 텍스트 찾기 도구를 만듭니다.

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

// Creates  a text finder.
var textFinder = sheet.createTextFinder('dog');

// Returns the first occurrence of 'dog' in the sheet.
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입니다.


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

expandAllColumnGroups()

시트의 모든 열 그룹을 펼칩니다. 이 방법에는 열 그룹이 하나 이상 필요합니다.

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

// All column groups on the sheet are expanded.
sheet.expandAllColumnGroups();

리턴

Sheet - 이 시트는 체인을 위해 사용됩니다.

승인

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

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

expandAllRowGroups()

시트의 모든 행 그룹을 펼칩니다. 이 메서드에는 하나 이상의 행 그룹이 필요합니다.

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

// All row groups on the sheet are expanded.
sheet.expandAllRowGroups();

리턴

Sheet - 이 시트는 체인을 위해 사용됩니다.

승인

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

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

expandColumnGroupsUpToDepth(groupDepth)

모든 열 그룹을 지정된 깊이까지 펼치고 다른 모든 열 그룹을 접습니다.

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

// All column groups of depth 2 and lower are expanded, and groups with depth
// 3 and higher are collapsed.
sheet.expandColumnGroupsUpToDepth(2);

매개변수

이름유형설명
groupDepthInteger열 그룹을 펼칠 최대 그룹 깊이입니다.

리턴

Sheet - 이 시트는 체인을 위해 사용됩니다.

승인

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

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

expandRowGroupsUpToDepth(groupDepth)

모든 행 그룹을 지정된 깊이까지 펼치고 다른 모든 행 그룹을 접습니다.

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

// All row groups of depth 2 and lower are expanded, and groups with depth
// 3 and higher are collapsed.
sheet.expandRowGroupsUpToDepth(2);

매개변수

이름유형설명
groupDepthInteger행 그룹을 펼칠 최대 그룹 깊이입니다.

리턴

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

참고 항목


getBandings()

이 시트의 모든 밴딩을 반환합니다.

// Opens the spreadsheet file by its URL. If you created your script from within a
// Google Sheets file, you can use SpreadsheetApp.getActiveSpreadsheet() instead.
// TODO(developer): Replace the URL with your own.
const ss = SpreadsheetApp.openByUrl('https://docs.google.com/spreadsheets/d/abc123456/edit');

// Gets a sheet by its name.
const sheet = ss.getSheetByName('Sheet1');

// Gets the banding info for the sheet.
const bandings = sheet.getBandings();

// Gets info on the bandings' second row color and logs it to the console.
for (const banding of bandings) {
  console.log(banding.getSecondRowColor());
}

리턴

Banding[] - 이 시트의 모든 밴딩입니다.

승인

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

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

getCharts()

이 시트의 차트의 배열을 반환합니다.

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

for (var i in charts) {
  var chart = charts[i];
  // Do something with the chart
}

리턴

EmbeddedChart[] - 차트의 배열입니다.

승인

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

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

getColumnGroup(columnIndex, groupDepth)

지정된 색인 및 그룹 깊이의 열 그룹을 반환합니다.

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

// Returns the group whose control index is at column 2 and has a depth of 1, or
// null if the group doesn’t exist.
var columnGroup = sheet.getColumnGroup(2, 1);

매개변수

이름유형설명
columnIndexInteger그룹 컨트롤 토글의 열 색인 또는 그룹 내 색인입니다.
groupDepthInteger그룹의 깊이입니다.

리턴

Group - 제어 색인 및 깊이의 열 그룹. 그룹이 없으면 예외가 발생합니다.

승인

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

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

getColumnGroupControlPosition()

시트의 모든 열 그룹에 대해 GroupControlTogglePosition를 반환합니다.

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

// GroupControlTogglePosition.AFTER if the column grouping control toggle is shown after the
// group.
var columnGroupControlPosition = sheet.getColumnGroupControlPosition();

리턴

GroupControlTogglePosition - 열 그룹화 컨트롤 전환이 이 시트의 그룹 뒤에 표시되면 true, 그렇지 않으면 false입니다.

승인

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

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

getColumnGroupDepth(columnIndex)

지정된 색인에 있는 열의 그룹 깊이를 반환합니다.

그룹 깊이는 열과 겹치는 그룹의 수를 나타냅니다. 범위는 0에서 8 사이입니다.

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

// 1 if there is a group over columns 1 through 3
var groupDepth = sheet.getColumnGroupDepth(1);

매개변수

이름유형설명
columnIndexInteger열의 색인입니다.

리턴

Integer - 지정된 색인에 있는 열의 그룹 깊이입니다.

승인

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

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

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

getConditionalFormatRules()

이 시트의 모든 조건부 서식 규칙을 가져옵니다.

// Logs the conditional format rules in a sheet.
var rules = SpreadsheetApp.getActiveSheet().getConditionalFormatRules();
for (var i = 0; i < rules.length; i++) {
  var rule = rules[i];
  Logger.log(rule);
}

리턴

ConditionalFormatRule[] - 시트에 있는 모든 규칙의 배열입니다.

승인

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

  • 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

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

getDeveloperMetadata()

이 시트와 연결된 모든 개발자 메타데이터를 가져옵니다.

// Opens the spreadsheet file by its URL. If you created your script from within a
// Google Sheets file, you can use SpreadsheetApp.getActiveSpreadsheet() instead.
// TODO(developer): Replace the URL with your own.
const ss = SpreadsheetApp.openByUrl('https://docs.google.com/spreadsheets/d/abc123456/edit');

// Gets a sheet by its name.
const sheet = ss.getSheetByName('Sheet1');

// Adds developer metadata for testing.
sheet.addDeveloperMetadata('CITY', 'PARIS');

// Gets all the developer metadata for the sheet.
const developerMetaDataList = sheet.getDeveloperMetadata();

// Logs the developer metadata to the console.
for (const developerMetaData of developerMetaDataList) {
  console.log(developerMetaData.getKey());
}

리턴

DeveloperMetadata[] - 이 시트와 연결된 개발자 메타데이터입니다.

승인

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

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

getDrawings()

시트에 있는 그림의 배열을 반환합니다.

// Opens the spreadsheet file by its URL. If you created your script from within a
// Google Sheets file, you can use SpreadsheetApp.getActiveSpreadsheet() instead.
// TODO(developer): Replace the URL with your own.
const ss = SpreadsheetApp.openByUrl('https://docs.google.com/spreadsheets/d/abc123456/edit');

// Gets a sheet by its name.
const sheet = ss.getSheetByName('Sheet1');

// Gets all the drawings from the sheet.
const allDrawings = sheet.getDrawings();

 // Logs the number of drawings present on the sheet.
console.log(allDrawings.length);

리턴

Drawing[] - 이 시트의 그림 목록입니다.

승인

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

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

getFilter()

이 시트의 필터를 반환하거나 필터가 없는 경우 null을 반환합니다.

// Gets the filter on the active sheet.
let ss = SpreadsheetApp.getActiveSheet();
let filter = ss.getFilter();

리턴

Filter - 필터입니다.

승인

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

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

getFormUrl()

이 시트에 응답을 보내는 양식의 URL을 반환하거나 이 시트에 연결된 양식이 없는 경우 null을 반환합니다.

var sheet = SpreadsheetApp.getActiveSheet();
var url = sheet.getFormUrl();

리턴

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

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

getIndex()

상위 스프레드시트에서 시트의 위치를 가져옵니다. 1부터 시작합니다.

var ss = SpreadsheetApp.getActiveSpreadsheet();
// Note that the JavaScript index is 0, but this logs 1
var sheet = ss.getSheets()[0];
// ... because spreadsheets are 1-indexed
Logger.log(sheet.getIndex());

리턴

Integer - 상위 스프레드시트에서 시트의 위치입니다.

승인

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

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

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

getMaxColumns()

콘텐츠에 관계없이 시트의 현재 열 수를 반환합니다.

// This example assumes there is a sheet named "first"
var ss = SpreadsheetApp.getActiveSpreadsheet();
var first = ss.getSheetByName("first");
Logger.log(first.getMaxColumns());

리턴

Integer - 시트의 최대 너비입니다.

승인

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

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

getMaxRows()

콘텐츠에 관계없이 시트의 현재 행 수를 반환합니다.

// This example assumes there is a sheet named "first"
var ss = SpreadsheetApp.getActiveSpreadsheet();
var first = ss.getSheetByName("first");
Logger.log(first.getMaxRows());

리턴

Integer - 시트의 최대 높이입니다.

승인

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

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

getName()

시트의 이름을 반환합니다.

var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheets()[0];
Logger.log(sheet.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.getActiveSheet().getNamedRanges();
if (namedRanges.length > 1) {
  Logger.log(namedRanges[0].getName());
}

리턴

NamedRange[] - 시트에 있는 모든 이름이 지정된 범위의 배열입니다.

승인

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

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

getParent()

이 시트가 포함된 Spreadsheet를 반환합니다.

var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheets()[0];
// parent is identical to ss
var parent = sheet.getParent();

리턴

Spreadsheet - 상위 스프레드시트입니다.

승인

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

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

getPivotTables()

이 시트의 모든 피벗 테이블을 반환합니다.

// Opens the spreadsheet file by its URL. If you created your script from within a
// Google Sheets file, you can use SpreadsheetApp.getActiveSpreadsheet() instead.
// TODO(developer): Replace the URL with your own.
const ss = SpreadsheetApp.openByUrl('https://docs.google.com/spreadsheets/d/abc123456/edit');

// Gets a sheet by its name.
const sheet = ss.getSheetByName('Sheet1');

// Gets all the pivot table info for the sheet.
const pivotTables = sheet.getPivotTables();

// Logs the pivot tables to the console.
for (const pivotTable of pivotTables) {
  console.log(pivotTable.getSourceDataRange().getValues());
}

리턴

PivotTable[] - 이 시트의 피벗 테이블입니다.

승인

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

  • 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 sheet = SpreadsheetApp.getActiveSheet();
var protections = sheet.getProtections(SpreadsheetApp.ProtectionType.RANGE);
for (var i = 0; i < protections.length; i++) {
  var protection = protections[i];
  if (protection.canEdit()) {
    protection.remove();
  }
}
// Remove sheet protection from the active sheet, if the user has permission to edit it.
var sheet = SpreadsheetApp.getActiveSheet();
var protection = sheet.getProtections(SpreadsheetApp.ProtectionType.SHEET)[0];
if (protection && 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(row, column)

지정된 좌표에서 왼쪽 상단 셀이 있는 범위를 반환합니다.

var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheets()[0];
// Passing only two arguments returns a "range" with a single cell.
var range = sheet.getRange(1, 1);
var values = range.getValues();
Logger.log(values[0][0]);

매개변수

이름유형설명
rowInteger반환할 셀의 행 색인입니다. 행 색인 생성은 1로 시작합니다.
columnInteger반환할 셀의 열 색인입니다. 열 색인은 1로 시작합니다.

리턴

Range - 이 셀만 포함하는 범위입니다.

승인

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

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

getRange(row, column, numRows)

지정된 좌표에 왼쪽 상단 셀이 있고 지정된 행 수를 포함하는 범위를 반환합니다.

var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheets()[0];
// When the "numRows" argument is used, only a single column of data is returned.
var range = sheet.getRange(1, 1, 3);
var values = range.getValues();

// Prints 3 values from the first column, starting from row 1.
for (var row in values) {
  for (var col in values[row]) {
    Logger.log(values[row][col]);
  }
}

매개변수

이름유형설명
rowInteger범위의 시작 행 색인입니다. 행 색인 생성은 1부터 시작합니다.
columnInteger범위의 열 색인입니다. 열 색인 생성은 1로 시작합니다.
numRowsInteger반환할 행 수입니다.

리턴

Range - 지정된 행 수의 데이터 열 하나를 포함하는 범위입니다.

승인

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

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

getRange(row, column, numRows, numColumns)

지정된 좌표에 왼쪽 상단 셀이 있고 지정된 수의 행과 열이 있는 범위를 반환합니다.

var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheets()[0];
var range = sheet.getRange(1, 1, 3, 3);
var values = range.getValues();

// Print values from a 3x3 box.
for (var row in values) {
  for (var col in values[row]) {
    Logger.log(values[row][col]);
  }
}

매개변수

이름유형설명
rowInteger범위의 시작 행 색인입니다. 행 색인 생성은 1부터 시작합니다.
columnInteger범위의 시작 열 색인입니다. 열 색인 생성은 1로 시작합니다.
numRowsInteger반환할 행 수입니다.
numColumnsInteger반환할 열의 개수입니다.

리턴

Range - 지정된 영역에 해당하는 범위입니다.

승인

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

  • 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

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

getRowGroup(rowIndex, groupDepth)

지정된 색인 및 그룹 깊이에서 행 그룹을 반환합니다.

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

// Returns the group whose control index is at row 2 and has a depth of 1, or
// null if the group doesn’t exist.
var rowGroup = sheet.getRowGroup(2, 1);

매개변수

이름유형설명
rowIndexInteger그룹 컨트롤 전환 스위치의 행 색인 또는 그룹 내 색인입니다.
groupDepthInteger그룹의 깊이입니다.

리턴

Group - 제어 색인 및 깊이에 있는 행 그룹. 그룹이 존재하지 않으면 예외가 발생합니다.

승인

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

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

getRowGroupControlPosition()

시트에 있는 모든 행 그룹의 GroupControlTogglePosition를 반환합니다.

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

// GroupControlTogglePosition.AFTER if the row grouping control toggle is shown after the
// group.
var rowGroupControlPosition = sheet.getRowGroupControlPosition();

리턴

GroupControlTogglePosition - 행 그룹화 컨트롤 전환이 이 시트의 그룹 뒤에 표시되면 true, 그렇지 않으면 false입니다.

승인

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

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

getRowGroupDepth(rowIndex)

지정된 색인에 있는 행의 그룹 깊이를 반환합니다.

그룹 깊이는 행과 겹치는 그룹 수를 나타냅니다. 범위는 0에서 8 사이일 수 있습니다.

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

// 1 if there is a group over rows 1 through 3
var groupDepth = sheet.getRowGroupDepth(1);

매개변수

이름유형설명
rowIndexInteger행의 색인입니다.

리턴

Integer - 지정된 색인에 있는 행의 그룹 깊이입니다.

승인

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

  • 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

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

getSlicers()

시트의 슬라이서 배열을 반환합니다.

// Opens the spreadsheet file by its URL. If you created your script from within a
// Google Sheets file, you can use SpreadsheetApp.getActiveSpreadsheet() instead.
// TODO(developer): Replace the URL with your own.
const ss = SpreadsheetApp.openByUrl('https://docs.google.com/spreadsheets/d/abc123456/edit');

// Gets a sheet by its name.
const sheet = ss.getSheetByName('Sheet1');

// Gets all slicers in the spreadsheet.
const slicers = sheet.getSlicers();

// Logs the slicer titles to the console.
for (const slicer of slicers) {
  console.log(slicer.getTitle());
}

리턴

Slicer[] - 이 시트의 슬라이서 목록입니다.

승인

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

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

getTabColorObject()

시트 탭 색상을 가져오거나 시트 탭에 색상이 없는 경우 null를 가져옵니다.

// This example assumes there is a sheet named "Sheet1"
var ss = SpreadsheetApp.getActiveSpreadsheet();
var first = ss.getSheetByName("Sheet1");
var color = first.getTabColorObject();

리턴

Color - 시트 탭 색상 또는 null(시트 탭에 색상이 없는 경우)

승인

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

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

getType()

시트의 유형을 반환합니다.

시트의 기본 유형은 SheetType.GRID입니다. EmbeddedChart와 같이 삽입된 단일 객체가 포함된 시트는 SheetType.OBJECT 시트입니다.

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

리턴

SheetType - 시트의 유형입니다.

승인

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

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

hasHiddenGridlines()

시트의 격자선이 숨겨져 있으면 true를 반환하고 그렇지 않으면 false을 반환합니다. 격자선은 기본적으로 표시됩니다.

// Opens the spreadsheet file by its URL. If you created your script from within a
// Google Sheets file, you can use SpreadsheetApp.getActiveSpreadsheet() instead.
// TODO(developer): Replace the URL with your own.
const ss = SpreadsheetApp.openByUrl('https://docs.google.com/spreadsheets/d/abc123456/edit');

// Gets a sheet by its name.
const sheet = ss.getSheetByName('Sheet1');

// Checks if the spreadsheet has hidden gridelines and logs the result to the console.
console.log(sheet.hasHiddenGridlines());

리턴

Boolean: 격자선이 숨겨져 있으면 true, 그렇지 않으면 false입니다.

승인

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

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

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

hideColumns(columnIndex)

지정된 색인에서 단일 열을 숨깁니다. 이 메서드에는 1-색인을 사용합니다.

색인을 사용하여 열을 두 개 이상 숨기려면 hideColumns(columnIndex, numColumns)를 사용합니다.

범위를 사용하여 둘 이상의 열을 숨기려면 hideColumn()를 사용합니다.

let ss = SpreadsheetApp.getActiveSpreadsheet();
let sheet = ss.getSheets()[0];
// Hides the first column
sheet.hideColumns(1);

매개변수

이름유형설명
columnIndexInteger숨길 열의 색인입니다.

승인

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

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

hideColumns(columnIndex, numColumns)

지정된 색인에서 시작하는 하나 이상의 연속 열을 숨깁니다. 이 메서드에는 1-색인을 사용합니다.

var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheets()[0];
// Hides the first three columns
sheet.hideColumns(1, 3);

매개변수

이름유형설명
columnIndexInteger숨길 열의 시작 색인입니다.
numColumnsInteger숨길 열의 수입니다.

승인

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

  • 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

hideRows(rowIndex)

지정된 색인의 행을 숨깁니다.

var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheets()[0];
// Hides the first row
sheet.hideRows(1);

매개변수

이름유형설명
rowIndexInteger숨길 행의 색인입니다.

승인

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

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

hideRows(rowIndex, numRows)

지정된 색인에서 시작하여 하나 이상의 연속된 행을 숨깁니다.

var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheets()[0];
// Hides the first three rows
sheet.hideRows(1, 3);

매개변수

이름유형설명
rowIndexInteger숨길 행의 시작 색인입니다.
numRowsInteger숨길 행 수입니다.

승인

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

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

hideSheet()

이 시트를 숨깁니다. 시트가 이미 숨겨져 있으면 아무런 효과가 없습니다. 표시되는 시트에서만 이 메서드를 호출하면 예외가 발생합니다.

var sheet = SpreadsheetApp.getActiveSheet();
sheet.hideSheet();

리턴

Sheet - 현재 시트입니다.

승인

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

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

insertChart(chart)

이 시트에 새 차트를 추가합니다.

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

// This creates a simple bar chart from the first three rows
// of the first two columns of the spreadsheet
var chart = sheet.newChart()
    .setChartType(Charts.ChartType.BAR)
    .addRange(sheet.getRange("A1:B4"))
    .setPosition(5, 5, 0, 0)
    .setOption("title", "Dynamic Chart")
    .build();
sheet.insertChart(chart);

매개변수

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

승인

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

  • 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

insertColumns(columnIndex)

시트의 지정된 위치에 빈 열을 삽입합니다.

var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheets()[0];
// Shifts all columns by one
sheet.insertColumns(1);

매개변수

이름유형설명
columnIndexInteger열을 삽입할 위치를 나타내는 색인입니다.

승인

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

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

insertColumns(columnIndex, numColumns)

지정된 위치에서 시작하는 시트에 하나 이상의 연속된 빈 열을 삽입합니다.

var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheets()[0];
// Shifts all columns by three
sheet.insertColumns(1, 3);

매개변수

이름유형설명
columnIndexInteger열을 삽입할 위치를 나타내는 색인입니다.
numColumnsInteger삽입할 열의 수입니다.

승인

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

  • 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

insertImage(blobSource, column, row)

BlobSource를 문서의 지정된 행과 열에 이미지로 삽입합니다. 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)

문서에서 픽셀 오프셋을 사용하여 지정된 행과 열에 BlobSource을 이미지로 삽입합니다. 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

insertRows(rowIndex)

시트의 지정된 위치에 빈 행을 삽입합니다.

var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheets()[0];
// Shifts all rows down by one
sheet.insertRows(1);

매개변수

이름유형설명
rowIndexInteger행을 삽입할 위치를 나타내는 색인입니다.

승인

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

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

insertRows(rowIndex, numRows)

지정된 위치에서 시작하는 시트에 하나 이상의 연속된 빈 행을 삽입합니다.

var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheets()[0];
// Shifts all rows down by three
sheet.insertRows(1, 3);

매개변수

이름유형설명
rowIndexInteger행을 삽입할 위치를 나타내는 색인입니다.
numRowsInteger삽입할 행 수입니다.

승인

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

  • 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

insertSlicer(range, anchorRowPos, anchorColPos)

이 시트에 새 슬라이서를 추가합니다.

// Opens the spreadsheet file by its URL. If you created your script from within a
// Google Sheets file, you can use SpreadsheetApp.getActiveSpreadsheet() instead.
// TODO(developer): Replace the URL with your own.
const ss = SpreadsheetApp.openByUrl('https://docs.google.com/spreadsheets/d/abc123456/edit');

// Gets a sheet by its name.
const sheet = ss.getSheetByName('Sheet1');

// Gets the range of the sheet.
const range = sheet.getRange('A1:D10');

// Inserts the slicer with a random range into the sheet.
const insertSlicers = sheet.insertSlicer(range.randomize(), 1, 10);

// Logs the insert slicer result to the console.
console.log(insertSlicers);

매개변수

이름유형설명
rangeRange슬라이서 슬라이서가 생성되는 범위입니다.
anchorRowPosInteger슬라이서의 상단이 이 행에 고정됩니다.
anchorColPosInteger슬라이서의 상단은 이 열에 고정됩니다.

리턴

Slicer - 새로 삽입된 슬라이서입니다.

승인

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

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

insertSlicer(range, anchorRowPos, anchorColPos, offsetX, offsetY)

이 시트에 새 슬라이서를 추가합니다.

// Opens the spreadsheet file by its URL. If you created your script from within a
// Google Sheets file, you can use SpreadsheetApp.getActiveSpreadsheet() instead.
// TODO(developer): Replace the URL with your own.
const ss = SpreadsheetApp.openByUrl('https://docs.google.com/spreadsheets/d/abc123456/edit');

// Gets a sheet by its name.
const sheet = ss.getSheetByName('Sheet1');

// Gets the range.
const range = sheet.getRange('A1:D10');

// Inserts a slicer using the random range function.
const insertSlicers = sheet.insertSlicer(range.randomize(), 1, 10, 0, 0);

// Logs the insert slicer result to the console.
console.log(insertSlicers);

매개변수

이름유형설명
rangeRange슬라이서 슬라이서가 생성되는 범위입니다.
anchorRowPosInteger슬라이서의 상단이 이 행에 고정됩니다.
anchorColPosInteger슬라이서의 상단은 이 열에 고정됩니다.
offsetXInteger셀 모서리로부터의 가로 오프셋(픽셀)입니다.
offsetYInteger셀 모서리로부터의 세로 오프셋(픽셀)입니다.

리턴

Slicer - 새로 삽입된 슬라이서입니다.

승인

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

  • 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

isRightToLeft()

이 시트 레이아웃이 오른쪽에서 왼쪽이면 true를 반환합니다. 시트에서 기본 왼쪽에서 오른쪽 레이아웃을 사용하면 false를 반환합니다.

// Opens the spreadsheet file by its URL. If you created your script from within a
// Google Sheets file, you can use SpreadsheetApp.getActiveSpreadsheet() instead.
// TODO(developer): Replace the URL with your own.
const ss = SpreadsheetApp.openByUrl('https://docs.google.com/spreadsheets/d/abc123456/edit');

// Gets a sheet by its name.
const sheet = ss.getSheetByName('Sheet1');

// Checks if a spreadsheet is ordered from right to left and logs the result to the console.
console.log(sheet.isRightToLeft());

리턴

Boolean - 오른쪽에서 왼쪽이면 true이고 그렇지 않으면 false입니다.

승인

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

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

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

isSheetHidden()

시트가 현재 숨겨져 있으면 true를 반환합니다.

var sheet = SpreadsheetApp.getActiveSheet();
if (sheet.isSheetHidden()) {
  // do something...
}

리턴

Boolean: 시트가 숨겨져 있으면 true, 숨겨져 있으면 false입니다.

승인

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

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

moveColumns(columnSpec, destinationIndex)

지정된 범위로 선택된 열을 destinationIndex가 나타내는 위치로 이동합니다. columnSpec 자체는 이동할 전체 열 또는 열 그룹을 정확하게 나타내지 않아도 됩니다. 범위에 걸쳐 있는 모든 열을 선택합니다.

// The code below moves rows A-B to destination index 5.
// This results in those columns becoming columns C-D.
var sheet = SpreadsheetApp.getActiveSheet();
// Selects column A and column B to be moved.
var columnSpec = sheet.getRange("A1:B1");
sheet.moveColumns(columnSpec, 5);

매개변수

이름유형설명
columnSpecRange이동해야 하는 열 범위의 범위입니다.
destinationIndexInteger열을 이동할 색인입니다. 이 색인은 열이 이동되기 전의 좌표를 기반으로 합니다. 소스 열은 그리드에서 삭제되는 동안 이동된 열을 위한 공간을 확보하기 위해 기존 데이터가 오른쪽으로 이동합니다. 따라서 데이터가 원래 지정된 것과 다른 색인에 배치될 수 있습니다.

승인

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

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

moveRows(rowSpec, destinationIndex)

지정된 범위로 선택된 행을 destinationIndex로 표시된 위치로 이동합니다. rowSpec 자체는 이동할 전체 행 또는 행 그룹을 정확하게 나타내지 않아도 됩니다. 범위에 걸쳐 있는 모든 행을 선택합니다.

// The code below moves rows 1-2 to destination index 5.
// This results in those rows becoming rows 3-4.
var sheet = SpreadsheetApp.getActiveSheet();
// Selects row 1 and row 2 to be moved.
var rowSpec = sheet.getRange("A1:A2");
sheet.moveRows(rowSpec, 5);

매개변수

이름유형설명
rowSpecRange이동해야 하는 행에 걸쳐 있는 범위입니다.
destinationIndexInteger행을 이동해야 하는 색인입니다. 이 색인은 행이 이동되기 전의 좌표를 기반으로 합니다. 소스 행은 그리드에서 삭제되는 동안 기존 데이터가 아래로 이동하여 이동된 행을 위한 공간을 확보합니다. 따라서 데이터가 원래 지정된 것과 다른 색인에 배치될 수 있습니다.

승인

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

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

newChart()

이 시트의 새 차트를 만드는 빌더를 반환합니다.

이 예에서는 새 차트를 만드는 방법을 보여줍니다.

var sheet = SpreadsheetApp.getActiveSheet();
var range = sheet.getRange("A1:B8");
var chartBuilder = sheet.newChart();
chartBuilder.addRange(range)
    .setChartType(Charts.ChartType.LINE)
    .setPosition(2, 2, 0, 0)
    .setOption('title', 'My Line Chart!');
sheet.insertChart(chartBuilder.build());

리턴

EmbeddedChartBuilder - 새 차트를 만드는 빌더입니다.


protect()

권한이 있는 사용자를 제외하고 시트가 수정되지 않도록 보호할 수 있는 객체를 만듭니다. 스크립트가 실제로 시트의 편집자 목록을 변경할 때까지 (Protection.removeEditor(emailAddress), Protection.removeEditor(user), Protection.removeEditors(emailAddresses), Protection.addEditor(emailAddress), Protection.addEditor(user), Protection.addEditors(emailAddresses)를 호출하거나 Protection.setDomainEdit(editable)의 새 값을 설정하여) 권한은 스프레드시트 자체의 권한을 미러링합니다. 즉, 사실상 시트가 보호되지 않은 상태로 유지됩니다. 시트가 이미 보호되어 있는 경우 이 메서드는 기존 보호 설정을 나타내는 객체를 반환합니다. 보호된 시트에는 보호되지 않은 영역이 포함될 수 있습니다.

// Protect the active sheet, then remove all other users from the list of editors.
var sheet = SpreadsheetApp.getActiveSheet();
var protection = sheet.protect().setDescription('Sample protected sheet');

// Ensure the current user is an editor before removing others. Otherwise, if the user's edit
// permission comes from a group, the script throws an exception upon removing the group.
var me = Session.getEffectiveUser();
protection.addEditor(me);
protection.removeEditors(protection.getEditors());
if (protection.canDomainEdit()) {
  protection.setDomainEdit(false);
}

리턴

Protection - 보호 설정을 나타내는 객체입니다.

승인

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

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

removeChart(chart)

상위 시트에서 차트를 삭제합니다.

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

// This removes all the embedded charts from the spreadsheet
var charts = sheet.getCharts();
for (var i in charts) {
  sheet.removeChart(charts[i]);
}

매개변수

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

승인

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

  • 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

setColumnGroupControlPosition(position)

시트에서 열 그룹 컨트롤 토글의 위치를 설정합니다.

var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheets()[0];
sheet.setColumnGroupControlPosition(SpreadsheetApp.GroupControlTogglePosition.AFTER);

매개변수

이름유형설명
positionGroupControlTogglePosition열 그룹 컨트롤 전환 버튼의 위치입니다.

리턴

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

setColumnWidths(startColumn, numColumns, width)

지정된 열의 너비를 픽셀 단위로 설정합니다.

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

// Sets the first three columns to a width of 200 pixels
sheet.setColumnWidths(1, 3, 200);

매개변수

이름유형설명
startColumnInteger변경할 시작 열 위치입니다.
numColumnsInteger변경할 열의 수입니다.
widthInteger설정할 너비(픽셀)입니다.

리턴

Sheet - 이 시트는 체인을 위해 사용됩니다.

승인

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

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

setConditionalFormatRules(rules)

시트에 있는 현재 존재하는 모든 조건부 서식 규칙을 입력 규칙으로 대체합니다. 규칙은 입력 순서대로 평가됩니다.

// Remove one of the existing conditional format rules.
var sheet = SpreadsheetApp.getActiveSheet();
var rules = sheet.getConditionalFormatRules();
rules.splice(1, 1); // Deletes the 2nd format rule.
sheet.setConditionalFormatRules(rules);

매개변수

이름유형설명
rulesConditionalFormatRule[]새 조건부 서식 규칙

승인

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

  • 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

setHiddenGridlines(hideGridlines)

시트 격자선을 숨기거나 표시합니다.

// Opens the spreadsheet file by its URL. If you created your script from within a
// Google Sheets file, you can us eSpreadsheetApp.getActiveSpreadsheet() instead.
// TODO(developer): Replace the URL with your own.
const ss = SpreadsheetApp.openByUrl('https://docs.google.com/spreadsheets/d/abc123456/edit');

// Gets a sheet by its name.
const sheet = ss.getSheetByName('Sheet1');

// Hides the gridlines in the sheet.
sheet.setHiddenGridlines(true);

매개변수

이름유형설명
hideGridlinesBooleantrue인 경우 이 시트에서 격자선을 숨기고, 그렇지 않으면 격자선을 표시합니다.

리턴

Sheet - 이 시트는 체인을 위해 사용됩니다.

승인

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

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

setName(name)

시트 이름을 설정합니다.

// This example assumes there is a sheet named "first"
var ss = SpreadsheetApp.getActiveSpreadsheet();
var first = ss.getSheetByName("first");
first.setName("not first anymore");

매개변수

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

리턴

Sheet - 이 시트는 체인을 위해 사용됩니다.

승인

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

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

setRightToLeft(rightToLeft)

시트 레이아웃을 오른쪽에서 왼쪽으로 설정하거나 설정 해제합니다.

// Opens the spreadsheet file by its URL. If you created your script from within a
// Google Sheets file, you can use SpreadsheetApp.getActiveSpreadsheet() instead.
// TODO(developer): Replace the URL with your own.
const ss = SpreadsheetApp.openByUrl('https://docs.google.com/spreadsheets/d/abc123456/edit');

// Gets a sheet by its name.
const sheet = ss.getSheetByName('Sheet1');

// Sets the sheet layout, so that the sheet is ordered from right to left.
sheet.setRightToLeft(true);

매개변수

이름유형설명
rightToLeftBooleantrue인 경우 시트 레이아웃은 오른쪽에서 왼쪽으로 설정되고 셀 A1은 오른쪽 상단에 있습니다. false인 경우 시트 레이아웃은 기본적으로 왼쪽에서 오른쪽으로 설정되고 셀 A1이 왼쪽 상단에 배치됩니다.

리턴

Sheet - 이 시트는 체인을 위해 사용됩니다.

승인

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

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

setRowGroupControlPosition(position)

시트에서 행 그룹 컨트롤 토글의 위치를 설정합니다.

var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheets()[0];
sheet.setRowGroupControlPosition(SpreadsheetApp.GroupControlTogglePosition.AFTER);

매개변수

이름유형설명
positionGroupControlTogglePosition행 그룹 컨트롤 전환의 위치입니다.

리턴

Sheet - 이 시트는 체인을 위해 사용됩니다.

승인

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

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

setRowHeight(rowPosition, height)

지정된 행의 행 높이를 픽셀 단위로 설정합니다. 기본적으로 행은 셀 내용에 맞게 늘어납니다. 행을 지정된 높이로 강제 설정하려면 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

setRowHeights(startRow, numRows, height)

지정된 행의 높이를 픽셀 단위로 설정합니다. 기본적으로 행은 셀 내용에 맞게 늘어납니다. 행을 지정된 높이로 강제 설정하려면 setRowHeightsForced(startRow, numRows, height)를 사용하세요.

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

// Sets the first three rows to a height of 20 pixels
sheet.setRowHeights(1, 3, 20);

매개변수

이름유형설명
startRowInteger변경할 시작 행 위치입니다.
numRowsInteger변경할 행 수입니다.
heightInteger설정할 높이(픽셀)입니다.

리턴

Sheet - 이 시트는 체인을 위해 사용됩니다.

승인

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

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

setRowHeightsForced(startRow, numRows, height)

지정된 행의 높이를 픽셀 단위로 설정합니다. 기본적으로 행은 셀 내용에 맞게 늘어납니다. setRowHeightsForced를 사용하면 셀 콘텐츠가 행 높이보다 크더라도 행이 지정된 높이로 강제 설정됩니다.

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

// Sets the first three rows to a height of 5 pixels.
sheet.setRowHeightsForced(1, 3, 5);

매개변수

이름유형설명
startRowInteger변경할 시작 행 위치입니다.
numRowsInteger변경할 행 수입니다.
heightInteger설정할 높이(픽셀)입니다.

리턴

Sheet - 이 시트는 체인을 위해 사용됩니다.

승인

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

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

setTabColor(color)

시트 탭 색상을 설정합니다.

// This example assumes there is a sheet named "first"
var ss = SpreadsheetApp.getActiveSpreadsheet();
var first = ss.getSheetByName("first");
first.setTabColor("ff0000"); // Set the color to red.
first.setTabColor(null); // Unset the color.

매개변수

이름유형설명
colorString탭 색상을 재설정하는 CSS 표기법 (예: '#ffffff' 또는 'white')의 색상 코드 또는 null입니다.

리턴

Sheet - 이 시트는 체인을 위해 사용됩니다.

승인

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

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

setTabColorObject(color)

시트 탭 색상을 설정합니다.

// This example assumes there is a sheet named "Sheet1"
var ss = SpreadsheetApp.getActiveSpreadsheet();
var first = ss.getSheetByName("Sheet1");
var color = SpreadsheetApp.newColor()
    .setThemeColor(SpreadsheetApp.ThemeColorType.ACCENT1)
    .build();
first.setTabColorObject(color); // Set the color to theme accent 1.
first.setTabColorObject(null); // Unset the color.

매개변수

이름유형설명
colorColor설정할 시트 탭 색상입니다.

리턴

Sheet - 이 시트는 체인을 위해 사용됩니다.

승인

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

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

showColumns(columnIndex)

지정된 색인에서 열을 숨기기 해제합니다.

var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheets()[0];
// Unhides the first column
sheet.showColumns(1);

매개변수

이름유형설명
columnIndexInteger숨기기 해제할 열의 색인입니다.

승인

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

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

showColumns(columnIndex, numColumns)

지정된 색인에서 시작하는 하나 이상의 연속 열을 숨기기 해제합니다.

var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheets()[0];
// Unhides the first three columns
sheet.showColumns(1, 3);

매개변수

이름유형설명
columnIndexInteger숨기기 해제할 열의 시작 색인입니다.
numColumnsInteger숨기기 해제할 열의 수입니다.

승인

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

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

showRows(rowIndex)

지정된 색인에서 행을 숨기기 해제합니다.

var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheets()[0];
// Unhides the first row
sheet.showRows(1);

매개변수

이름유형설명
rowIndexInteger숨기기 해제할 행의 색인입니다.

승인

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

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

showRows(rowIndex, numRows)

지정된 색인에서 시작하는 하나 이상의 연속된 행을 숨기기 해제합니다.

var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheets()[0];
// Unhides the first three rows
sheet.showRows(1, 3);

매개변수

이름유형설명
rowIndexInteger숨기기 해제할 행의 시작 색인입니다.
numRowsInteger숨기기 해제할 행 수입니다.

승인

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

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

showSheet()

시트를 표시합니다. 시트가 이미 표시되어 있으면 아무 효과가 없습니다.

var sheet = SpreadsheetApp.getActiveSheet();
sheet.showSheet();

리턴

Sheet - 현재 시트입니다.

승인

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

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

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

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

updateChart(chart)

이 시트의 차트를 업데이트합니다.

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

// This code is going to loop through all the charts and change them to
// column charts
var charts = sheet.getCharts();
for (var i in charts) {
  var chart = charts[i];
  var newChart = chart
      .modify()
      .setChartType(Charts.ChartType.COLUMN)
      .build();
  sheet.updateChart(newChart);
}

매개변수

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

승인

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

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

지원 중단된 메서드