Class SpreadsheetApp

스프레드시트 앱

Google Sheets 파일에 액세스하고 만들 수 있습니다. 이 클래스는 스프레드시트 서비스의 상위 클래스입니다.

속성

속성유형설명
AutoFillSeriesAutoFillSeries자동 입력 값을 계산하는 데 사용되는 계열 유형의 열거형입니다.
BandingThemeBandingTheme가능한 밴딩 테마의 열거형입니다.
BooleanCriteriaBooleanCriteria조건부 서식 부울 기준의 열거형입니다.
BorderStyleBorderStyleRange에 테두리를 설정하는 유효한 스타일의 열거형입니다.
ColorTypeColorType가능한 색상 유형의 열거형입니다.
CopyPasteTypeCopyPasteType가능한 붙여넣기 유형의 열거형입니다.
DataExecutionErrorCodeDataExecutionErrorCode가능한 데이터 실행 오류 코드의 열거형입니다.
DataExecutionStateDataExecutionState가능한 데이터 실행 상태의 열거형입니다.
DataSourceParameterTypeDataSourceParameterType가능한 데이터 소스 매개변수 유형의 열거형입니다.
DataSourceRefreshScopeDataSourceRefreshScope가능한 데이터 소스 새로고침 범위의 열거형입니다.
DataSourceTypeDataSourceType가능한 데이터 소스 유형의 열거형입니다.
DataValidationCriteriaDataValidationCriteria범위에서 설정할 수 있는 데이터 유효성 검사 기준을 나타내는 열거형입니다.
DateTimeGroupingRuleTypeDateTimeGroupingRuleType날짜 시간 그룹화 규칙의 열거형
DeveloperMetadataLocationTypeDeveloperMetadataLocationType가능한 개발자 메타데이터 위치 유형의 열거형입니다.
DeveloperMetadataVisibilityDeveloperMetadataVisibility가능한 개발자 메타데이터의 열거형입니다.
DimensionDimension스프레드시트에서 사용할 수 있는 측정기준의 열거형입니다.
DirectionDirection화살표 키를 사용하여 스프레드시트 내에서 이동할 수 있는 가능한 경로의 열거형입니다.
FrequencyTypeFrequencyType가능한 주파수 유형의 열거형입니다.
GroupControlTogglePositionGroupControlTogglePosition그룹 컨트롤 전환이 있을 수 있는 위치의 열거형입니다.
InterpolationTypeInterpolationType조건부 서식 그라데이션 보간 유형 열거형입니다.
PivotTableSummarizeFunctionPivotTableSummarizeFunction피벗 테이블의 값을 요약하는 데 사용할 수 있는 함수의 열거형입니다.
PivotValueDisplayTypePivotValueDisplayType피봇 값이 표시되는 방식의 열거형입니다.
ProtectionTypeProtectionType수정으로부터 보호할 수 있는 스프레드시트에서 부분을 나타내는 열거형입니다.
RecalculationIntervalRecalculationInterval스프레드시트 다시 계산에 사용할 수 있는 간격의 열거형입니다.
RelativeDateRelativeDate날짜 기반 BooleanCriteria에 사용할 값을 계산하는 상대 날짜 옵션의 열거형입니다.
SheetTypeSheetType스프레드시트에 존재할 수 있는 여러 유형의 시트가 열거되어 있습니다.
SortOrderSortOrder정렬 순서의 열거형입니다.
TextDirectionTextDirection유효한 텍스트 방향의 열거형입니다.
TextToColumnsDelimiterTextToColumnsDelimiter텍스트를 열로 분할하기 위한 미리 설정된 구분 기호의 열거형입니다.
ThemeColorTypeThemeColorType가능한 테마 색상 유형의 열거형입니다.
ValueTypeValueType스프레드시트 서비스의 Range 클래스에서 Range.getValue()Range.getValues()가 반환하는 값 유형의 열거형입니다. 아래에 나열된 열거형 값은 Number, Boolean, Date, String에 추가됩니다.
WrapStrategyWrapStrategy셀을 래핑하는 데 사용되는 전략의 열거형입니다.

메서드

메서드반환 유형간략한 설명
create(name)Spreadsheet지정된 이름으로 새 스프레드시트를 만듭니다.
create(name, rows, columns)Spreadsheet지정된 이름 및 지정된 수의 행과 열로 새 스프레드시트를 만듭니다.
enableAllDataSourcesExecution()void모든 유형의 데이터 소스에 대한 데이터 실행을 사용 설정합니다.
enableBigQueryExecution()voidBigQuery 데이터 소스에 대한 데이터 실행을 사용 설정합니다.
flush()void대기 중인 모든 스프레드시트 변경사항을 적용합니다.
getActive()Spreadsheet현재 사용 중인 스프레드시트를 반환하거나 없는 경우 null를 반환합니다.
getActiveRange()Range활성 시트에서 선택한 범위를 반환하거나 활성 범위가 없는 경우 null을 반환합니다.
getActiveRangeList()RangeList활성 시트의 활성 범위 목록을 반환하거나 선택된 범위가 없는 경우 null을 반환합니다.
getActiveSheet()Sheet스프레드시트에서 활성 시트를 가져옵니다.
getActiveSpreadsheet()Spreadsheet현재 사용 중인 스프레드시트를 반환하거나 없는 경우 null를 반환합니다.
getCurrentCell()Range활성 시트의 활성 범위 중 하나에서 선택된 현재 (강조표시된) 셀 또는 현재 셀이 없는 경우 null를 반환합니다.
getSelection()Selection스프레드시트에서 현재 Selection을 반환합니다.
getUi()Ui스크립트가 메뉴, 대화상자, 사이드바 등의 기능을 추가할 수 있도록 하는 스프레드시트의 사용자 인터페이스 환경 인스턴스를 반환합니다.
newCellImage()CellImageBuilderCellImage의 빌더를 만듭니다.
newColor()ColorBuilderColor의 빌더를 만듭니다.
newConditionalFormatRule()ConditionalFormatRuleBuilder조건부 서식 규칙의 빌더를 만듭니다.
newDataSourceSpec()DataSourceSpecBuilderDataSourceSpec의 빌더를 만듭니다.
newDataValidation()DataValidationBuilder데이터 검증 규칙을 위한 빌더를 만듭니다.
newFilterCriteria()FilterCriteriaBuilderFilterCriteria의 빌더를 만듭니다.
newRichTextValue()RichTextValueBuilder서식 있는 텍스트 값의 빌더를 만듭니다.
newTextStyle()TextStyleBuilder텍스트 스타일의 빌더를 만듭니다.
open(file)Spreadsheet지정된 파일 객체에 해당하는 스프레드시트를 엽니다.
openById(id)Spreadsheet해당 ID로 스프레드시트를 엽니다.
openByUrl(url)Spreadsheet주어진 URL의 스프레드시트를 엽니다.
setActiveRange(range)Range지정된 범위를 active range로 설정하고 범위의 왼쪽 상단 셀을 current cell로 설정합니다.
setActiveRangeList(rangeList)RangeList지정된 범위 목록을 active ranges로 설정합니다.
setActiveSheet(sheet)Sheet스프레드시트에서 활성 시트를 설정합니다.
setActiveSheet(sheet, restoreSelection)Sheet스프레드시트에서 활성 시트를 설정하고 해당 시트 내에서 가장 최근 선택을 복원할 수 있는 옵션을 설정합니다.
setActiveSpreadsheet(newActiveSpreadsheet)void활성 스프레드시트를 설정합니다.
setCurrentCell(cell)Range지정된 셀을 current cell으로 설정합니다.

자세한 문서

create(name)

지정된 이름으로 새 스프레드시트를 만듭니다.

// The code below creates a new spreadsheet "Finances" and logs the URL for it
var ssNew = SpreadsheetApp.create("Finances");
Logger.log(ssNew.getUrl());

매개변수

이름유형설명
nameString스프레드시트의 이름입니다.

Return

Spreadsheet: 새 스프레드시트

승인

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

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

create(name, rows, columns)

지정된 이름 및 지정된 수의 행과 열로 새 스프레드시트를 만듭니다.

// The code below creates a new spreadsheet "Finances" with 50 rows and 5 columns and logs the
// URL for it
var ssNew = SpreadsheetApp.create("Finances", 50, 5);
Logger.log(ssNew.getUrl());

매개변수

이름유형설명
nameString스프레드시트의 이름입니다.
rowsInteger스프레드시트의 행 수입니다.
columnsInteger스프레드시트의 열 수입니다.

Return

Spreadsheet: 새 스프레드시트

승인

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

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

enableAllDataSourcesExecution()

모든 유형의 데이터 소스에 대한 데이터 실행을 사용 설정합니다.

데이터 소스 유형이 사용 설정되어 있지 않으면 데이터 실행에 예외가 발생합니다. 모든 데이터 소스 유형에 대해 데이터 실행을 사용 설정하려면 이 메서드를 사용합니다.

승인

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

  • https://www.googleapis.com/auth/bigquery.readonly

enableBigQueryExecution()

BigQuery 데이터 소스에 대한 데이터 실행을 사용 설정합니다.

사용 설정하지 않으면 BigQuery 데이터 소스의 데이터 실행에서 예외가 발생합니다.

승인

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

  • https://www.googleapis.com/auth/bigquery.readonly

flush()

대기 중인 모든 스프레드시트 변경사항을 적용합니다.

성능 향상을 위해 Range.getValue()를 여러 번 호출하는 경우 등 스프레드시트 작업이 함께 번들로 제공되는 경우가 있습니다. 그러나 스크립트가 실행 중일 때 사용자에게 데이터를 표시하는 등 대기 중인 모든 변경사항이 즉시 이루어지도록 하는 것이 좋습니다.

// The code below changes the background color of cells A1 and B1 twenty times. You should be
// able to see the updates live in the spreadsheet. If flush() is not called, the updates may
// be applied live or may all be applied at once when the script completes.
function colors() {
  var sheet = SpreadsheetApp.getActiveSheet();
  for (var i = 0; i < 20; i++) {
    if ((i % 2) == 0) {
      sheet.getRange('A1').setBackground('green');
      sheet.getRange('B1').setBackground('red');
    } else {
      sheet.getRange('A1').setBackground('red');
      sheet.getRange('B1').setBackground('green');
    }
    SpreadsheetApp.flush();
  }
}

getActive()

현재 사용 중인 스프레드시트를 반환하거나 없는 경우 null를 반환합니다.

스프레드시트의 컨텍스트에서 실행되는 함수는 이 함수를 호출하여 해당 스프레드시트 객체에 대한 참조를 가져올 수 있습니다.

// The code below logs the URL for the active spreadsheet.
Logger.log(SpreadsheetApp.getActive().getUrl());

Return

Spreadsheet — 활성 스프레드시트 객체

승인

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

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

getActiveRange()

활성 시트에서 선택한 범위를 반환하거나 활성 범위가 없는 경우 null을 반환합니다. 여러 범위를 선택하면 이 메서드는 마지막으로 선택한 범위만 반환합니다.

이는 일반적으로 사용자가 활성 시트에서 선택한 범위를 나타내지만 맞춤 함수에서는 적극적으로 다시 계산되는 셀을 나타냅니다.

// The code below logs the background color for the active range.
var colorObject = SpreadsheetApp.getActiveRange().getBackgroundObject();
// Assume the color has ColorType.RGB.
Logger.log(colorObject.asRgbColor().asHexString());

Return

Range: 활성 범위

승인

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

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

getActiveRangeList()

활성 시트의 활성 범위 목록을 반환하거나 선택된 범위가 없는 경우 null을 반환합니다. 현재 강조표시된 셀을 포함하는 활성 범위는 목록의 마지막에 배치됩니다.

단일 범위를 선택하면 getActiveRange() 호출처럼 작동합니다.

// Returns the list of active ranges.
var rangeList = SpreadsheetApp.getActiveRangeList();

Return

RangeList: 활성 범위 목록

승인

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

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

getActiveSheet()

스프레드시트에서 활성 시트를 가져옵니다.

스프레드시트의 활성 시트는 스프레드시트 UI에 표시되고 있는 시트입니다.

// The code below logs the name of the active sheet.
Logger.log(SpreadsheetApp.getActiveSheet().getName());

Return

Sheet — 활성 시트 객체

승인

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

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

getActiveSpreadsheet()

현재 사용 중인 스프레드시트를 반환하거나 없는 경우 null를 반환합니다.

스프레드시트의 컨텍스트에서 실행되는 함수는 이 함수를 호출하여 해당 Spreadsheet 객체에 대한 참조를 가져올 수 있습니다.

// The code below logs the URL for the active spreadsheet.
Logger.log(SpreadsheetApp.getActiveSpreadsheet().getUrl());

Return

Spreadsheet — 활성 스프레드시트 객체

승인

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

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

getCurrentCell()

활성 시트의 활성 범위 중 하나에서 선택된 현재 (강조표시된) 셀 또는 현재 셀이 없는 경우 null를 반환합니다.

// Returns the current highlighted cell in the one of the active ranges.
var currentCell = SpreadsheetApp.getCurrentCell();

Return

Range: 현재 셀

승인

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

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

getSelection()

스프레드시트에서 현재 Selection을 반환합니다.

var selection = SpreadsheetApp.getSelection();
var currentCell = selection.getCurrentCell();

Return

Selection: 현재 선택

승인

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

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

getUi()

스크립트가 메뉴, 대화상자, 사이드바 등의 기능을 추가할 수 있도록 하는 스프레드시트의 사용자 인터페이스 환경 인스턴스를 반환합니다. 스크립트는 열려 있는 스프레드시트의 현재 인스턴스에 대한 UI와 상호작용할 수 있으며, 스크립트가 스프레드시트에 바인딩된 경우에만 가능합니다. 자세한 내용은 메뉴, 대화상자 및 사이드바 가이드를 참고하세요.

// Add a custom menu to the active spreadsheet, including a separator and a sub-menu.
function onOpen(e) {
  SpreadsheetApp.getUi()
      .createMenu('My Menu')
      .addItem('My menu item', 'myFunction')
      .addSeparator()
      .addSubMenu(SpreadsheetApp.getUi().createMenu('My sub-menu')
          .addItem('One sub-menu item', 'mySecondFunction')
          .addItem('Another sub-menu item', 'myThirdFunction'))
      .addToUi();
}

Return

Ui: 이 스프레드시트의 사용자 인터페이스 환경 인스턴스입니다.


newCellImage()

CellImage의 빌더를 만듭니다.

Return

CellImageBuilder — 새 빌더입니다.


newColor()

Color의 빌더를 만듭니다.

var rgbColor = SpreadsheetApp.newColor().setRgbColor("#FF0000").build();

Return

ColorBuilder — 새 빌더입니다.


newConditionalFormatRule()

조건부 서식 규칙의 빌더를 만듭니다.

// Adds a conditional format rule to a sheet that causes all cells in range A1:B3 to turn red
// if they contain a number between 1 and 10.
var sheet = SpreadsheetApp.getActive().getActiveSheet();
var range = sheet.getRange('A1:B3');
var rule = SpreadsheetApp.newConditionalFormatRule()
    .whenNumberBetween(1, 10)
    .setBackground("#FF0000")
    .setRanges([range])
    .build()
var rules = sheet.getConditionalFormatRules();
rules.push(rule);
sheet.setConditionalFormatRules(rules);

Return

ConditionalFormatRuleBuilder — 새 빌더입니다.


newDataSourceSpec()

DataSourceSpec의 빌더를 만듭니다.

Return

DataSourceSpecBuilder — 새 빌더입니다.


newDataValidation()

데이터 검증 규칙을 위한 빌더를 만듭니다.

var cell = SpreadsheetApp.getActive().getRange('A1');
var rule = SpreadsheetApp.newDataValidation()
    .requireNumberBetween(1, 100)
    .setAllowInvalid(false)
    .setHelpText('Number must be between 1 and 100.')
    .build();
cell.setDataValidation(rule);

Return

DataValidationBuilder — 새 빌더입니다.


newFilterCriteria()

FilterCriteria의 빌더를 만듭니다.

Return

FilterCriteriaBuilder — 새 빌더


newRichTextValue()

서식 있는 텍스트 값의 빌더를 만듭니다.

// Sets cell A1 to have the text "Hello world", with "Hello" bolded.
var cell = SpreadsheetApp.getActive().getRange('A1');
var bold = SpreadsheetApp.newTextStyle().setBold(true).build();
var value = SpreadsheetApp.newRichTextValue()
    .setText("Hello world")
    .setTextStyle(0, 5, bold)
    .build();
cell.setRichTextValue(value);

Return

RichTextValueBuilder — 새 빌더입니다.


newTextStyle()

텍스트 스타일의 빌더를 만듭니다.

// Sets range A1:B3 to have red, size 22, bolded, underlined text.
var range = SpreadsheetApp.getActive().getRange('A1:B3');
var style = SpreadsheetApp.newTextStyle()
    .setForegroundColor("red")
    .setFontSize(22)
    .setBold(true)
    .setUnderline(true)
    .build();
range.setTextStyle(style);

Return

TextStyleBuilder — 새 빌더입니다.


open(file)

지정된 파일 객체에 해당하는 스프레드시트를 엽니다.

// Get any starred spreadsheets from Google Drive, then open the spreadsheets and log the name
// of the first sheet within each spreadsheet.
var files = DriveApp.searchFiles(
    'starred = true and mimeType = "' + MimeType.GOOGLE_SHEETS + '"');
while (files.hasNext()) {
  var spreadsheet = SpreadsheetApp.open(files.next());
  var sheet = spreadsheet.getSheets()[0];
  Logger.log(sheet.getName());
}

매개변수

이름유형설명
fileFile열려는 파일입니다.

Return

Spreadsheet — 스프레드시트

승인

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

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

openById(id)

해당 ID로 스프레드시트를 엽니다. URL에서 스프레드시트 ID를 추출할 수 있습니다. 예를 들어 URL https://docs.google.com/spreadsheets/d/abc1234567/edit#gid=0의 스프레드시트 ID는 "abc1234567"입니다.

// The code below opens a spreadsheet using its ID and logs the name for it.
// Note that the spreadsheet is NOT physically opened on the client side.
// It is opened on the server only (for modification by the script).
var ss = SpreadsheetApp.openById("abc1234567");
Logger.log(ss.getName());

매개변수

이름유형설명
idString스프레드시트의 고유 식별자입니다.

Return

Spreadsheet: 지정된 ID가 있는 스프레드시트 객체

승인

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

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

openByUrl(url)

주어진 URL의 스프레드시트를 엽니다. URL이 존재하지 않거나 사용자에게 URL에 액세스할 권한이 없는 경우 스크립팅 예외가 발생합니다.

// The code below opens a spreadsheet using its id and logs the name for it.
// Note that the spreadsheet is NOT physically opened on the client side.
// It is opened on the server only (for modification by the script).
var ss = SpreadsheetApp.openByUrl(
    'https://docs.google.com/spreadsheets/d/abc1234567/edit');
Logger.log(ss.getName());

매개변수

이름유형설명
urlString스프레드시트의 URL입니다.

Return

Spreadsheet: 지정된 ID가 있는 스프레드시트 객체

승인

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

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

setActiveRange(range)

지정된 범위를 active range로 설정하고 범위의 왼쪽 상단 셀을 current cell로 설정합니다.

스프레드시트 UI에 선택한 범위가 포함된 시트가 표시되고 선택한 범위에 정의된 셀이 선택됩니다.

// The code below sets range C1:D4 in the first sheet as the active range.
var range = SpreadsheetApp.getActiveSpreadsheet().getSheets()[0].getRange('C1:D4');
SpreadsheetApp.setActiveRange(range);

var selection = SpreadsheetApp.getSelection();
// Current cell: C1
var currentCell = selection.getCurrentCell();
// Active Range: C1:D4
var activeRange = selection.getActiveRange();

매개변수

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

Return

Range: 새 활성 범위


setActiveRangeList(rangeList)

지정된 범위 목록을 active ranges로 설정합니다. 목록의 마지막 범위는 active range로 설정됩니다.

// The code below sets ranges [D4, B2:C4] in the active sheet as the active ranges.
var rangeList = SpreadsheetApp.getActiveSheet().getRanges(['D4', 'B2:C4']);
SpreadsheetApp.setActiveRangeList(rangeList);

var selection = SpreadsheetApp.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선택할 범위의 목록입니다.

Return

RangeList: 새로 선택한 범위 목록

승인

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

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

setActiveSheet(sheet)

스프레드시트에서 활성 시트를 설정합니다. 시트가 다른 스프레드시트에 속해 있지 않으면 Google Sheets UI에 선택한 시트가 표시됩니다.

// The code below makes the 2nd sheet active in the active spreadsheet.
var spreadsheet = SpreadsheetApp.getActiveSpreadsheet();
SpreadsheetApp.setActiveSheet(spreadsheet.getSheets()[1]);

매개변수

이름유형설명
sheetSheet새 활성 시트입니다.

Return

Sheet: 새 활성 시트가 된 시트입니다.


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새 활성 시트입니다.
restoreSelectionBooleantrue인 경우 새 시트가 활성화되면 가장 최근에 선택한 새 활성 시트가 다시 선택됩니다. false인 경우 현재 선택 항목을 변경하지 않고 새 시트가 활성화됩니다.

Return

Sheet: 새 활성 시트

승인

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

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

setActiveSpreadsheet(newActiveSpreadsheet)

활성 스프레드시트를 설정합니다.

// The code below makes the spreadsheet with key "1234567890" the active spreadsheet
var ss = SpreadsheetApp.openById("1234567890");
SpreadsheetApp.setActiveSpreadsheet(ss);

매개변수

이름유형설명
newActiveSpreadsheetSpreadsheet활성 스프레드시트로 만들 스프레드시트입니다.

setCurrentCell(cell)

지정된 셀을 current cell으로 설정합니다.

지정된 셀이 이미 선택된 범위에 있을 경우 이 범위는 해당 셀을 현재 셀로 사용하는 활성 범위가 됩니다.

지정된 셀이 선택한 범위에 없으면 기존 선택이 삭제되고 셀이 현재 셀 및 활성 범위가 됩니다.

참고:지정된 Range는 하나의 셀로 구성되어야 합니다. 그렇지 않으면 이 메서드가 예외를 발생시킵니다.

// The code below sets the cell B5 in the first sheet as the current cell.
var cell = SpreadsheetApp.getActiveSpreadsheet().getSheets()[0].getRange('B5');
SpreadsheetApp.setCurrentCell(cell);

var selection = SpreadsheetApp.getSelection();
// Current cell: B5
var currentCell = selection.getCurrentCell();

매개변수

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

Return

Range: 새로 설정된 현재 셀

승인

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

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