스프레드시트 범위에 액세스하고 수정합니다. 범위는 시트의 단일 셀 또는 시트의 인접한 셀 그룹일 수 있습니다.
메서드
메서드 | 반환 유형 | 간략한 설명 |
---|---|---|
activate() | Range | 지정된 범위를 active range 로 설정하고 범위의 왼쪽 상단 셀을 current cell 로 설정합니다. |
activate | Range | 지정된 셀을 current cell 로 설정합니다. |
add | Range | 지정된 키가 있는 개발자 메타데이터를 범위에 추가합니다. |
add | Range | 지정된 키와 공개 상태를 사용하여 개발자 메타데이터를 범위에 추가합니다. |
add | Range | 지정된 키와 값을 사용하여 개발자 메타데이터를 범위에 추가합니다. |
add | Range | 지정된 키, 값, 공개 상태를 사용하여 개발자 메타데이터를 범위에 추가합니다. |
apply | Banding | 범위에 기본 열 밴딩 테마를 적용합니다. |
apply | Banding | 범위에 지정된 열 밴딩 테마를 적용합니다. |
apply | Banding | 지정된 헤더 및 바닥글 설정으로 범위에 지정된 열 밴딩 테마를 적용합니다. |
apply | Banding | 범위에 기본 행 밴딩 테마를 적용합니다. |
apply | Banding | 범위에 지정된 행 밴딩 테마를 적용합니다. |
apply | Banding | 지정된 행 밴딩 테마를 지정된 헤더 및 바닥글 설정이 있는 범위에 적용합니다. |
auto | void | 이 범위의 데이터를 기반으로 destination 를 데이터로 채웁니다. |
auto | void | 인접한 셀을 기반으로 새 데이터로 채울 범위를 계산하고 이 범위에 포함된 데이터를 기반으로 새 값으로 해당 범위를 자동으로 채웁니다. |
break | Range | 범위의 다중 열 셀을 다시 개별 셀로 분할합니다. |
can | Boolean | 사용자에게 범위의 모든 셀을 수정할 권한이 있는지 확인합니다. |
check() | Range | 범위의 체크박스 상태를 '선택됨'으로 변경합니다. |
clear() | Range | 콘텐츠와 형식의 범위를 지웁니다. |
clear(options) | Range | 지정된 고급 옵션에 따라 콘텐츠, 형식, 데이터 유효성 검사 규칙 또는 댓글의 범위를 지웁니다. |
clear | Range | 범위의 콘텐츠를 지우고 서식은 그대로 유지합니다. |
clear | Range | 범위의 데이터 확인 규칙을 지웁니다. |
clear | Range | 이 범위의 서식을 지웁니다. |
clear | Range | 지정된 셀의 메모를 지웁니다. |
collapse | Range | 범위 내에 완전히 포함된 모든 그룹을 접습니다. |
copy | void | 범위의 서식을 지정된 위치에 복사합니다. |
copy | void | 범위의 서식을 지정된 위치에 복사합니다. |
copy | void | 셀 범위의 데이터를 다른 셀 범위로 복사합니다. |
copy | void | 셀 범위의 데이터를 다른 셀 범위로 복사합니다. |
copy | void | 셀 범위의 데이터를 다른 셀 범위로 복사합니다. |
copy | void | 범위의 콘텐츠를 지정된 위치에 복사합니다. |
copy | void | 범위의 콘텐츠를 지정된 위치에 복사합니다. |
create | Data | 이 범위의 첫 번째 셀에 고정된 데이터 소스로부터 빈 데이터 소스 피벗 테이블을 만듭니다. |
create | Data | 이 범위의 첫 번째 셀에 고정된 데이터 소스에서 빈 데이터 소스 테이블을 만듭니다. |
create | Developer | 이 범위 내에서 개발자 메타데이터를 찾는 DeveloperMetadataFinderApi를 반환합니다. |
create | Filter | 필터를 만들어 시트의 지정된 범위에 적용합니다. |
create | Pivot | 이 범위의 첫 번째 셀에 고정된 지정된 source 에서 빈 피벗 테이블을 만듭니다. |
create | Text | 범위의 텍스트 찾기를 만듭니다. 이 범위에서 텍스트를 찾아 바꿀 수 있습니다. |
delete | void | 이 셀 범위를 삭제합니다. |
expand | Range | 범위 또는 제어 전환 버튼이 이 범위와 교차하는 접힌 그룹을 펼칩니다. |
getA1Notation() | String | 범위의 문자열 설명을 A1 표기법으로 반환합니다. |
get | String | 범위의 왼쪽 상단 셀 (예: '#ffffff' )의 배경색을 반환합니다. |
get | Color | 범위의 왼쪽 상단 셀의 배경색을 반환합니다. |
get | Color[][] | 범위 내 셀의 배경색을 반환합니다. |
get | String[][] | 범위의 셀 배경 색상을 반환합니다 (예: '#ffffff' ). |
get | Banding[] | 이 범위의 셀에 적용된 모든 밴딩을 반환합니다. |
get | Range | 범위 내의 지정된 셀을 반환합니다. |
get | Integer | 이 범위의 시작 열 위치를 반환합니다. |
get | Range | 데이터가 있는 모든 인접한 셀을 포함하도록 4개의 기본 Direction 방향으로 확장된 범위의 복사본을 반환합니다. |
get | Range | 지정된 측정기준이 Dimension.ROWS 인 경우 확장된 Direction.UP 및 Direction.DOWN 의 복사본을 반환하고, 측정기준이 Dimension.COLUMNS 인 경우 Direction.NEXT 및 Direction.PREVIOUS 를 반환합니다. |
get | Data | 범위의 첫 번째 셀에 대한 Data 를 반환하거나, 셀에 데이터 소스 수식이 포함되어 있지 않으면 null 를 반환합니다. |
get | Data | 범위 내 셀의 Data 을 반환합니다. |
get | Data | 범위와 교차하는 모든 데이터 소스 피벗 테이블을 가져옵니다. |
get | Data | 범위와 교차하는 모든 데이터 소스 테이블을 가져옵니다. |
get | String | 이 범위의 데이터를 위한 URL을 반환합니다. 이 URL은 차트와 쿼리를 만드는 데 사용할 수 있습니다. |
get | Data | 이 객체 내부의 데이터를 DataTable로 반환합니다. |
get | Data | 이 범위 내의 데이터를 DataTable로 반환합니다. |
get | Data | 범위의 왼쪽 상단 셀에 대한 데이터 확인 규칙을 반환합니다. |
get | Data | 범위의 모든 셀에 대한 데이터 확인 규칙을 반환합니다. |
get | Developer | 이 범위와 연결된 개발자 메타데이터를 가져옵니다. |
get | String | 범위의 왼쪽 상단 셀에 표시된 값을 반환합니다. |
get | String[][] | 이 범위의 값으로 된 직사각형 그리드를 반환합니다. |
get | Filter | 이 범위가 속한 시트의 필터를 반환하거나, 시트에 필터가 없는 경우 null 을 반환합니다. |
get | Color | 범위의 왼쪽 상단에 있는 셀의 글꼴 색상을 반환합니다. |
get | Color[][] | 범위 내 셀의 글꼴 색상을 반환합니다. |
get | String[][] | 범위 내 셀의 글꼴 모음을 반환합니다. |
get | String | 범위의 왼쪽 상단에 있는 셀의 글꼴 모음을 반환합니다. |
get | String | 범위의 왼쪽 상단에 있는 셀의 선 스타일을 가져옵니다 ('underline' , 'line-through' 또는 'none' ). |
get | String[][] | 범위의 셀의 선 스타일 ('underline' , 'line-through' 또는 'none' )을 가져옵니다. |
get | Integer | 범위의 왼쪽 상단에 있는 셀의 글꼴 크기를 포인트 단위로 반환합니다. |
get | Integer[][] | 범위 내 셀의 글꼴 크기를 반환합니다. |
get | String | 범위의 왼쪽 상단에 있는 셀의 글꼴 스타일 ('italic' 또는 'normal' )을 반환합니다. |
get | String[][] | 범위 내 셀의 글꼴 스타일을 반환합니다. |
get | String | 범위의 왼쪽 상단에 있는 셀의 글꼴 두께 (normal/bold)를 반환합니다. |
get | String[][] | 범위 내 셀의 글꼴 두께를 반환합니다. |
get | String | 범위의 왼쪽 상단 셀의 수식 (A1 표기법)을 반환하거나 셀이 비어 있거나 수식이 포함되어 있지 않으면 빈 문자열을 반환합니다. |
get | String | 지정된 셀의 수식 (R1C1 표기법)을 반환하거나 수식이 없는 경우 null 을 반환합니다. |
get | String[][] | 범위 내 셀의 수식 (A1 표기법)을 반환합니다. |
get | String[][] | 범위의 셀에 대한 수식 (R1C1 표기법)을 반환합니다. |
get | Integer | 범위의 상위 시트의 그리드 ID를 반환합니다. |
get | Integer | 범위의 높이를 반환합니다. |
get | String | 범위의 왼쪽 상단에 있는 셀의 텍스트 가로 정렬 (왼쪽/가운데/오른쪽)을 반환합니다. |
get | String[][] | 범위 내 셀의 가로 정렬을 반환합니다. |
get | Integer | 종료 열 위치를 반환합니다. |
get | Integer | 종료 행 위치를 반환합니다. |
get | Range[] | 현재 범위 내에 완전히 포함되거나 현재 범위의 셀을 하나 이상 포함하는 병합된 셀을 나타내는 Range 객체의 배열을 반환합니다. |
get | Range | 범위의 첫 번째 열과 행에 있는 셀에서 시작하여 데이터가 있는 연속된 셀 범위의 가장자리 또는 해당 방향의 스프레드시트 가장자리에 있는 셀인 지정된 방향의 다음 셀을 반환합니다. |
get | String | 지정된 범위와 연결된 메모를 반환합니다. |
get | String[][] | 범위의 셀과 연결된 메모를 반환합니다. |
get | Integer | 이 범위의 열 수를 반환합니다. |
get | Integer | 이 범위의 행 수를 반환합니다. |
get | String | 지정된 범위의 왼쪽 상단 셀의 숫자 또는 날짜 형식을 가져옵니다. |
get | String[][] | 범위 내 셀의 숫자 또는 날짜 형식을 반환합니다. |
get | Rich | 범위의 왼쪽 상단 셀의 서식 있는 텍스트 값을 반환합니다. 셀 값이 텍스트가 아닌 경우 null 을 반환합니다. |
get | Rich | 범위의 셀에 대한 서식 있는 텍스트 값을 반환합니다. |
get | Integer | 이 범위의 행 위치를 반환합니다. |
get | Integer | 이 범위의 행 위치를 반환합니다. |
get | Sheet | 이 범위가 속한 시트를 반환합니다. |
get | Text | 범위의 왼쪽 상단 셀의 텍스트 방향을 반환합니다. |
get | Text | 범위 내 셀의 텍스트 방향을 반환합니다. |
get | Text | 범위의 왼쪽 상단 셀의 텍스트 회전 설정을 반환합니다. |
get | Text | 범위 내 셀의 텍스트 회전 설정을 반환합니다. |
get | Text | 범위의 왼쪽 상단 셀의 텍스트 스타일을 반환합니다. |
get | Text | 범위 내 셀의 텍스트 스타일을 반환합니다. |
get | Object | 범위의 왼쪽 상단 셀 값을 반환합니다. |
get | Object[][] | 이 범위의 값으로 된 직사각형 그리드를 반환합니다. |
get | String | 범위의 왼쪽 상단에 있는 셀의 세로 정렬 (상단/중간/하단)을 반환합니다. |
get | String[][] | 범위 내 셀의 세로 정렬을 반환합니다. |
get | Integer | 범위의 너비를 열 단위로 반환합니다. |
get | Boolean | 셀의 텍스트가 줄바꿈되는지 여부를 반환합니다. |
get | Wrap | 범위 내 셀의 텍스트 줄바꿈 전략을 반환합니다. |
get | Wrap | 범위의 왼쪽 상단 셀의 텍스트 줄바꿈 전략을 반환합니다. |
get | Boolean[][] | 셀의 텍스트가 줄바꿈되는지 여부를 반환합니다. |
insert | Range | 이 범위에 빈 셀을 삽입합니다. |
insert | Range | 선택된 경우 true , 선택되지 않은 경우 false 로 구성된 체크박스를 범위의 각 셀에 삽입합니다. |
insert | Range | 범위의 각 셀에 체크박스를 삽입합니다. 선택된 경우 맞춤 값으로, 선택되지 않은 경우 빈 문자열로 구성됩니다. |
insert | Range | 선택 및 선택 해제 상태에 대한 맞춤 값으로 구성된 체크박스를 범위의 각 셀에 삽입합니다. |
is | Boolean | 범위가 완전히 비어 있으면 true 를 반환합니다. |
is | Boolean | 범위의 모든 셀의 체크박스 상태가 '선택됨'인지 여부를 반환합니다. |
is | Boolean | 범위의 끝이 특정 열에 바인드되는지 여부를 확인합니다. |
is | Boolean | 범위의 끝이 특정 행에 바인드되는지 여부를 확인합니다. |
is | Boolean | 현재 범위의 셀이 병합된 셀과 겹치면 true 을 반환합니다. |
is | Boolean | 범위의 시작이 특정 열에 바인드되는지 여부를 확인합니다. |
is | Boolean | 범위의 시작이 특정 행에 바인드되는지 여부를 확인합니다. |
merge() | Range | 범위의 셀을 하나의 블록으로 병합합니다. |
merge | Range | 범위의 열에 걸쳐 범위의 셀을 병합합니다. |
merge | Range | 범위의 셀을 병합합니다. |
move | void | 이 범위에서 대상 범위로 잘라내어 붙여넣습니다 (형식과 값 모두). |
offset(rowOffset, columnOffset) | Range | 이 범위에서 지정된 행과 열 수(음수일 수 있음)만큼 오프셋된 새 범위를 반환합니다. |
offset(rowOffset, columnOffset, numRows) | Range | 현재 범위에 상대적이고, 왼쪽 상단 점이 현재 범위에서 지정된 행과 열만큼 오프셋되어 있으며, 지정된 셀 높이를 갖는 새 범위를 반환합니다. |
offset(rowOffset, columnOffset, numRows, numColumns) | Range | 현재 범위와 관련이 있고, 왼쪽 상단 점이 현재 범위에서 지정된 행과 열만큼 오프셋되어 있으며, 지정된 높이와 너비(셀)를 갖는 새 범위를 반환합니다. |
protect() | Protection | 권한이 있는 사용자를 제외한 사용자가 범위를 수정하지 못하도록 보호할 수 있는 객체를 만듭니다. |
randomize() | Range | 지정된 범위의 행 순서를 무작위로 지정합니다. |
remove | Range | 범위에서 모든 체크박스를 삭제합니다. |
remove | Range | 이 범위 내에서 이전 행의 값과 중복되는 값이 포함된 행을 삭제합니다. |
remove | Range | 이 범위 내에서 지정된 열의 값이 이전 행의 값과 중복되는 행을 삭제합니다. |
set | Range | 범위의 모든 셀의 배경색을 CSS 표기법 (예: '#ffffff' 또는 'white' )으로 설정합니다. |
set | Range | 범위의 모든 셀의 배경 색상을 설정합니다. |
set | Range | 배경 색상의 직사각형 그리드를 설정합니다 (이 범위의 크기와 일치해야 함). |
set | Range | RGB 값 (0~255 사이의 정수)을 사용하여 배경을 지정된 색상으로 설정합니다. |
set | Range | 배경 색상의 직사각형 그리드를 설정합니다 (이 범위의 크기와 일치해야 함). |
set | Range | border 속성을 설정합니다. |
set | Range | 색상 또는 스타일을 사용하여 테두리 속성을 설정합니다. |
set | Range | 범위의 모든 셀에 하나의 데이터 유효성 검사 규칙을 설정합니다. |
set | Range | 범위의 모든 셀에 대한 데이터 유효성 검사 규칙을 설정합니다. |
set | Range | CSS 표기법 (예: '#ffffff' 또는 'white' )으로 글꼴 색상을 설정합니다. |
set | Range | 지정된 범위의 글꼴 색상을 설정합니다. |
set | Range | 글꼴 색상의 직사각형 그리드를 설정합니다 (이 범위의 크기와 일치해야 함). |
set | Range | 글꼴 색상의 직사각형 그리드를 설정합니다 (이 범위의 크기와 일치해야 함). |
set | Range | 글꼴 모음의 직사각형 그리드를 설정합니다 (이 범위의 크기와 일치해야 함). |
set | Range | 'Arial' 또는 'Helvetica'와 같은 글꼴 모음을 설정합니다. |
set | Range | 지정된 범위 ('underline' , 'line-through' 또는 'none' )의 글꼴 선 스타일을 설정합니다. |
set | Range | 선 스타일의 직사각형 그리드를 설정합니다 (이 범위의 크기와 일치해야 함). |
set | Range | 글꼴 크기를 설정합니다. 크기는 사용할 포인트 크기입니다. |
set | Range | 글꼴 크기의 직사각형 그리드를 설정합니다 (이 범위의 크기와 일치해야 함). |
set | Range | 지정된 범위 ('italic' 또는 'normal' )의 글꼴 스타일을 설정합니다. |
set | Range | 글꼴 스타일의 직사각형 그리드를 설정합니다 (이 범위의 크기와 일치해야 함). |
set | Range | 지정된 범위의 글꼴 두께를 설정합니다 (normal/bold). |
set | Range | 글꼴 두께의 직사각형 그리드를 설정합니다 (이 범위의 크기와 일치해야 함). |
set | Range | 이 범위의 수식을 업데이트합니다. |
set | Range | 이 범위의 수식을 업데이트합니다. |
set | Range | 수식의 직사각형 그리드를 설정합니다 (이 범위의 크기와 일치해야 함). |
set | Range | 수식의 직사각형 그리드를 설정합니다 (이 범위의 크기와 일치해야 함). |
set | Range | 지정된 범위의 가로 (왼쪽에서 오른쪽) 정렬을 설정합니다 (왼쪽/중앙/오른쪽). |
set | Range | 가로 정렬의 직사각형 그리드를 설정합니다. |
set | Range | 메모를 지정된 값으로 설정합니다. |
set | Range | 메모의 직사각형 그리드를 설정합니다 (이 범위의 크기와 일치해야 함). |
set | Range | 숫자 또는 날짜 형식을 지정된 형식 문자열로 설정합니다. |
set | Range | 숫자 또는 날짜 형식의 직사각형 그리드를 설정합니다 (이 범위의 측정기준과 일치해야 함). |
set | Range | 범위의 셀에 서식 있는 텍스트 값을 설정합니다. |
set | Range | 서식 있는 텍스트 값의 직사각형 그리드를 설정합니다. |
set | Range | 범위에 하이퍼링크를 표시할지 여부를 설정합니다. |
set | Range | 범위의 셀에 대한 텍스트 방향을 설정합니다. |
set | Range | 텍스트 방향의 직사각형 그리드를 설정합니다. |
set | Range | 범위의 셀에 대한 텍스트 회전 설정을 지정합니다. |
set | Range | 범위의 셀에 대한 텍스트 회전 설정을 지정합니다. |
set | Range | 텍스트 회전의 직사각형 그리드를 설정합니다. |
set | Range | 범위의 셀에 대한 텍스트 스타일을 설정합니다. |
set | Range | 텍스트 스타일의 직사각형 그리드를 설정합니다. |
set | Range | 범위의 값을 설정합니다. |
set | Range | 값의 직사각형 그리드를 설정합니다 (이 범위의 차원과 일치해야 함). |
set | Range | 지정된 범위의 세로 (상단에서 하단) 정렬을 설정합니다 (상단/중간/하단). |
set | Range | 세로 정렬의 직사각형 그리드를 설정합니다 (이 범위의 크기와 일치해야 함). |
set | Range | 범위 내 셀의 텍스트를 스택할지 여부를 설정합니다. |
set | Range | 지정된 범위의 셀 줄바꿈을 설정합니다. |
set | Range | 래핑 전략의 직사각형 그리드를 설정합니다. |
set | Range | 범위의 셀에 대한 텍스트 줄바꿈 전략을 설정합니다. |
set | Range | 단어 줄 바꿈 정책의 직사각형 그리드를 설정합니다 (이 범위의 크기와 일치해야 함). |
shift | Range | 범위의 열 그룹화 깊이를 지정된 양만큼 변경합니다. |
shift | Range | 범위의 행 그룹화 깊이를 지정된 양만큼 변경합니다. |
sort(sortSpecObj) | Range | 지정된 범위의 셀을 지정된 열과 순서에 따라 정렬합니다. |
split | void | 자동으로 감지된 구분 기호를 기반으로 텍스트 열을 여러 열로 분할합니다. |
split | void | 지정된 문자열을 맞춤 구분 기호로 사용하여 텍스트 열을 여러 열로 분할합니다. |
split | void | 지정된 구분 기호를 기준으로 텍스트 열을 여러 열로 분할합니다. |
trim | Range | 이 범위의 모든 셀에서 공백, 탭, 줄바꿈과 같은 공백을 자릅니다. |
uncheck() | Range | 범위의 체크박스 상태를 '선택 해제됨'으로 변경합니다. |
자세한 문서
activate()
지정된 범위를 active range
로 설정하고 범위의 왼쪽 상단 셀을 current cell
로 설정합니다.
const sheet = SpreadsheetApp.getActiveSpreadsheet().getSheets()[0]; const range = sheet.getRange('A1:D10'); range.activate(); const selection = sheet.getSelection(); // Current cell: A1 const currentCell = selection.getCurrentCell(); // Active Range: A1:D10 const activeRange = selection.getActiveRange();
리턴
Range
- 이 범위(연결용)
activate As Current Cell()
지정된 셀을 current cell
로 설정합니다.
지정된 셀이 기존 범위에 있으면 해당 범위가 셀을 현재 셀로 하여 활성 범위가 됩니다.
지정된 셀이 기존 범위에 없으면 기존 선택이 삭제되고 셀이 현재 셀 및 활성 범위가 됩니다.
참고: 지정된 Range
는 셀 하나로 구성되어야 합니다. 그렇지 않으면 예외가 발생합니다.
// Gets the first sheet of the spreadsheet. const sheet = SpreadsheetApp.getActiveSpreadsheet().getSheets()[0]; // Gets the cell B5 and sets it as the active cell. const range = sheet.getRange('B5'); const currentCell = range.activateAsCurrentCell(); // Logs the activated cell. console.log(currentCell.getA1Notation());
리턴
Range
- 이 범위(연결용)
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
add Developer Metadata(key)
지정된 키가 있는 개발자 메타데이터를 범위에 추가합니다.
// Opens the spreadsheet file by its URL. If you created your script from within // a Google Sheets file, you can use SpreadsheetApp.getActiveSpreadsheet() // instead. // TODO(developer): Replace the URL with your own. const ss = SpreadsheetApp.openByUrl( 'https://docs.google.com/spreadsheets/d/abc123456/edit', ); // Gets Sheet1 by its name. const sheet = ss.getSheetByName('Sheet1'); // Gets row 2 on the sheet. const range = sheet.getRange('2:2'); // Adds the key 'NAME' to the developer metadata for row 2. range.addDeveloperMetadata('NAME'); // Gets the metadata and logs it to the console. const developerMetaData = range.getDeveloperMetadata()[0]; console.log(developerMetaData.getKey());
매개변수
이름 | 유형 | 설명 |
---|---|---|
key | String | 새 개발자 메타데이터의 키입니다. |
리턴
Range
- 이 범위(연결용)
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
add Developer Metadata(key, visibility)
지정된 키와 공개 상태를 사용하여 개발자 메타데이터를 범위에 추가합니다.
// Opens the spreadsheet file by its URL. If you created your script from within // a Google Sheets file, you can use SpreadsheetApp.getActiveSpreadsheet() // instead. // TODO(developer): Replace the URL with your own. const ss = SpreadsheetApp.openByUrl( 'https://docs.google.com/spreadsheets/d/abc123456/edit', ); // Gets Sheet1 by its name. const sheet = ss.getSheetByName('Sheet1'); // Gets row 2 on Sheet1. const range = sheet.getRange('2:2'); // Adds the key 'NAME' and sets the developer metadata visibility to 'DOCUMENT' // for row 2 on Sheet1. range.addDeveloperMetadata( 'NAME', SpreadsheetApp.DeveloperMetadataVisibility.DOCUMENT, ); // Gets the updated metadata info and logs it to the console. const developerMetaData = range.getDeveloperMetadata()[0]; console.log(developerMetaData.getKey()); console.log(developerMetaData.getVisibility().toString());
매개변수
이름 | 유형 | 설명 |
---|---|---|
key | String | 새 개발자 메타데이터의 키입니다. |
visibility | Developer | 새 개발자 메타데이터의 공개 상태입니다. |
리턴
Range
- 이 범위(연결용)
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
add Developer Metadata(key, value)
지정된 키와 값을 사용하여 개발자 메타데이터를 범위에 추가합니다.
// Opens the spreadsheet file by its URL. If you created your script from within // a Google Sheets file, you can use SpreadsheetApp.getActiveSpreadsheet() // instead. // TODO(developer): Replace the URL with your own. const ss = SpreadsheetApp.openByUrl( 'https://docs.google.com/spreadsheets/d/abc123456/edit', ); // Gets Sheet1 by its name. const sheet = ss.getSheetByName('Sheet1'); // Gets row 2 of Sheet1. const range = sheet.getRange('2:2'); // Adds the key 'NAME' and sets the value to 'GOOGLE' for the metadata of row 2. range.addDeveloperMetadata('NAME', 'GOOGLE'); // Gets the metadata and logs it to the console. const developerMetaData = range.getDeveloperMetadata()[0]; console.log(developerMetaData.getKey()); console.log(developerMetaData.getValue());
매개변수
이름 | 유형 | 설명 |
---|---|---|
key | String | 새 개발자 메타데이터의 키입니다. |
value | String | 새 개발자 메타데이터의 값입니다. |
리턴
Range
- 이 범위(연결용)
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
add Developer Metadata(key, value, visibility)
지정된 키, 값, 공개 상태를 사용하여 개발자 메타데이터를 범위에 추가합니다.
// Opens the spreadsheet file by its URL. If you created your script from within // a Google Sheets file, you can use SpreadsheetApp.getActiveSpreadsheet() // instead. // TODO(developer): Replace the URL with your own. const ss = SpreadsheetApp.openByUrl( 'https://docs.google.com/spreadsheets/d/abc123456/edit', ); // Gets Sheet1 by its name. const sheet = ss.getSheetByName('Sheet1'); // Gets row 2 on the sheet. const range = sheet.getRange('2:2'); // Adds the key 'NAME', sets the value to 'GOOGLE', and sets the visibility // to PROJECT for row 2 on the sheet. range.addDeveloperMetadata( 'NAME', 'GOOGLE', SpreadsheetApp.DeveloperMetadataVisibility.PROJECT, ); // Gets the updated metadata info and logs it to the console. const developerMetaData = range.getDeveloperMetadata()[0]; console.log(developerMetaData.getKey()); console.log(developerMetaData.getValue()); console.log(developerMetaData.getVisibility().toString());
매개변수
이름 | 유형 | 설명 |
---|---|---|
key | String | 새 개발자 메타데이터의 키입니다. |
value | String | 새 개발자 메타데이터의 값입니다. |
visibility | Developer | 새 개발자 메타데이터의 공개 상태입니다. |
리턴
Range
- 이 범위(연결용)
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
apply Column Banding()
범위에 기본 열 밴딩 테마를 적용합니다. 기본적으로 밴딩에는 헤더가 있고 바닥글 색상은 없습니다.
// 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 Sheet1 by its name. const sheet = ss.getSheetByName('Sheet1'); // Gets row 2 on the sheet. const range = sheet.getRange('2:2'); // Applies column banding to row 2. const colBanding = range.applyColumnBanding(); // Gets the first banding on the sheet and logs the color of the header column. console.log( sheet.getBandings()[0] .getHeaderColumnColorObject() .asRgbColor() .asHexString(), ); // Gets the first banding on the sheet and logs the color of the second column. console.log( sheet.getBandings()[0] .getSecondColumnColorObject() .asRgbColor() .asHexString(), );
리턴
Banding
- 새로운 밴딩입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
apply Column Banding(bandingTheme)
범위에 지정된 열 밴딩 테마를 적용합니다. 기본적으로 밴딩에는 머리글이 있고 바닥글 색상은 없습니다.
// 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 Sheet1 by its name. const sheet = ss.getSheetByName('Sheet1'); // Gets row 2 on the sheet. const range = sheet.getRange('2:2'); // Applies the INDIGO color banding theme to the columns in row 2. const colBanding = range.applyColumnBanding(SpreadsheetApp.BandingTheme.INDIGO); // Gets the first banding on the sheet and logs the color of the second column. console.log( sheet.getBandings()[0] .getSecondColumnColorObject() .asRgbColor() .asHexString(), );
매개변수
이름 | 유형 | 설명 |
---|---|---|
banding | Banding | 범위의 열에 적용할 색상 테마입니다. |
리턴
Banding
- 새로운 밴딩입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
apply Column Banding(bandingTheme, showHeader, showFooter)
지정된 헤더 및 바닥글 설정으로 범위에 지정된 열 밴딩 테마를 적용합니다.
// 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 Sheet1 by its name. const sheet = ss.getSheetByName('Sheet1'); // Gets rows 12-22 on the sheet. const range = sheet.getRange('12:22'); // Applies the BLUE color banding theme to rows 12-22. // Sets the header visibility to false and the footer visibility to true. const colBanding = range.applyColumnBanding( SpreadsheetApp.BandingTheme.BLUE, false, true, ); // Gets the banding color and logs it to the console. console.log( sheet.getBandings()[0] .getSecondColumnColorObject() .asRgbColor() .asHexString(), ); // Gets the header color object and logs it to the console. Returns null because // the header visibility is set to false. console.log(sheet.getBandings()[0].getHeaderColumnColorObject()); // Gets the footer color and logs it to the console. console.log( sheet.getBandings()[0] .getFooterColumnColorObject() .asRgbColor() .asHexString(), );
매개변수
이름 | 유형 | 설명 |
---|---|---|
banding | Banding | 범위의 열에 적용할 색상 테마입니다. |
show | Boolean | true 인 경우 밴딩 테마 헤더 색상이 첫 번째 열에 적용됩니다. |
show | Boolean | true 인 경우 밴딩 테마 바닥글 색상이 마지막 열에 적용됩니다. |
리턴
Banding
- 새로운 밴딩입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
apply Row Banding()
범위에 기본 행 밴딩 테마를 적용합니다. 기본적으로 밴딩에는 헤더가 있고 바닥글 색상은 없습니다.
// Opens the spreadsheet 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 rows 1-30 on Sheet1. const range = sheet.getRange('1:30'); // Applies row banding to rows 1-30. range.applyRowBanding(); // Gets the hex color of the second banded row. const secondRowColor = range.getBandings()[0].getSecondRowColorObject().asRgbColor().asHexString(); // Logs the hex color to console. console.log(secondRowColor);
리턴
Banding
- 밴딩입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
apply Row Banding(bandingTheme)
범위에 지정된 행 밴딩 테마를 적용합니다. 기본적으로 밴딩에는 헤더가 있고 바닥글 색상은 없습니다.
// Opens the spreadsheet 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 rows 1-30 on Sheet1. const range = sheet.getRange('1:30'); // Applies the INDIGO row banding theme to rows 1-30. range.applyRowBanding(SpreadsheetApp.BandingTheme.INDIGO); // Gets the hex color of the second banded row. const secondRowColor = range.getBandings()[0].getSecondRowColorObject().asRgbColor().asHexString(); // Logs the hex color to console. console.log(secondRowColor);
매개변수
이름 | 유형 | 설명 |
---|---|---|
banding | Banding | 범위의 행에 적용할 색상 테마입니다. |
리턴
Banding
- 새로운 밴딩입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
apply Row Banding(bandingTheme, showHeader, showFooter)
지정된 행 밴딩 테마를 지정된 헤더 및 바닥글 설정이 있는 범위에 적용합니다.
// Opens the spreadsheet 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 rows 1-30 on Sheet1. const range = sheet.getRange('1:30'); // Applies the INDIGO row banding to rows 1-30 and // specifies to hide the header and show the footer. range.applyRowBanding(SpreadsheetApp.BandingTheme.INDIGO, false, true);
매개변수
이름 | 유형 | 설명 |
---|---|---|
banding | Banding | 범위의 행에 적용할 색상 테마입니다. |
show | Boolean | true 인 경우 밴딩 테마 헤더 색상이 첫 번째 행에 적용됩니다. |
show | Boolean | true 인 경우 밴딩 테마 바닥글 색상이 마지막 행에 적용됩니다. |
리턴
Banding
- 새로운 밴딩입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
auto Fill(destination, series)
이 범위의 데이터를 기반으로 destination
를 데이터로 채웁니다. 새 값도 지정된 series
유형에 따라 결정됩니다. 대상 범위는 이 범위를 포함하고 한 방향으로만 확장해야 합니다. 예를 들어 다음은 A1:A4
의 현재 값을 기반으로 증가하는 숫자 시리즈로 A1:A20
를 채웁니다.
const sheet = SpreadsheetApp.getActiveSheet(); // Has values [1, 2, 3, 4]. const sourceRange = sheet.getRange('A1:A4'); // The range to fill with values. const destination = sheet.getRange('A1:A20'); // Inserts new values in A5:A20, continuing the pattern expressed in A1:A4 sourceRange.autoFill(destination, SpreadsheetApp.AutoFillSeries.DEFAULT_SERIES);
매개변수
이름 | 유형 | 설명 |
---|---|---|
destination | Range | 값이 자동으로 채워질 범위입니다. 대상 범위는 이 범위를 포함하고 한 방향 (위, 아래, 왼쪽 또는 오른쪽)으로만 확장해야 합니다. |
series | Auto | 새 값을 계산하는 데 사용해야 하는 자동 완성 시리즈의 유형입니다. 이 계열의 효과는 소스 데이터의 유형과 양에 따라 다릅니다. |
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
auto Fill To Neighbor(series)
인접한 셀을 기반으로 새 데이터로 채울 범위를 계산하고 이 범위에 포함된 데이터를 기반으로 새 값으로 해당 범위를 자동으로 채웁니다. 이러한 새 값도 지정된 series
유형에 따라 결정됩니다.
계산된 대상 범위는 주변 데이터를 고려하여 새 값을 삽입해야 하는 위치를 결정합니다. 자동 완성되는 열의 바로 왼쪽이나 오른쪽에 데이터가 있는 경우 새 값은 이 인접 데이터까지만 확장됩니다.
예를 들어 A1:A20
에 증가하는 숫자가 채워져 있고 날짜가 포함된 범위 B1:B4
에서 이 메서드를 호출하면 새 값은 B5:B20
에만 삽입됩니다. 이렇게 하면 이러한 새 값이 A열의 값이 포함된 셀에 '고정'됩니다.
const sheet = SpreadsheetApp.getActiveSheet(); // A1:A20 has values [1, 2, 3, ... 20]. // B1:B4 has values [1/1/2017, 1/2/2017, ...] const sourceRange = sheet.getRange('B1:B4'); // Results in B5:B20 having values [1/5/2017, ... 1/20/2017] sourceRange.autoFillToNeighbor(SpreadsheetApp.AutoFillSeries.DEFAULT_SERIES);
매개변수
이름 | 유형 | 설명 |
---|---|---|
series | Auto | 새 값을 계산하는 데 사용해야 하는 자동 완성 시리즈의 유형입니다. 이 계열의 효과는 소스 데이터의 유형과 양에 따라 다릅니다. |
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
break Apart()
범위의 다중 열 셀을 다시 개별 셀로 분할합니다.
범위에서 이 함수를 호출하는 것은 범위를 선택하고 서식 > 셀 병합 > 병합 해제를 클릭하는 것과 같습니다.
// Opens the spreadsheet 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 range A1:C6 on Sheet1. const range = sheet.getRange('A1:C6'); // Unmerges the range A1:C6 into individual cells. range.breakApart();
리턴
Range
- 이 범위(연결용)
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
can Edit()
사용자에게 범위의 모든 셀을 수정할 권한이 있는지 확인합니다. 스프레드시트 소유자는 언제든지 보호된 범위와 시트를 수정할 수 있습니다.
// Opens the spreadsheet 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 range A1:C6 on Sheet1. const range = sheet.getRange('A1:C6'); // Logs whether the user has permission to edit every cell in the range. console.log(range.canEdit());
리턴
Boolean
- 사용자가 범위의 모든 셀을 수정할 권한이 있는 경우 true
, 그렇지 않은 경우 false
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
check()
범위의 체크박스 상태를 '선택됨'으로 변경합니다. 현재 선택됨 또는 선택되지 않음 값이 구성되어 있지 않은 범위의 셀은 무시됩니다.
// Changes the state of cells which currently contain either the checked or // unchecked value configured in the range A1:B10 to 'checked'. const range = SpreadsheetApp.getActive().getRange('A1:B10'); range.check();
리턴
Range
- 이 범위(연결용)
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
clear()
콘텐츠와 형식의 범위를 지웁니다.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; const range = sheet.getRange('A1:D10'); range.clear();
리턴
Range
- 이 범위(연결용)
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
clear(options)
지정된 고급 옵션에 따라 콘텐츠, 형식, 데이터 유효성 검사 규칙 또는 댓글의 범위를 지웁니다. 기본적으로 모든 데이터가 삭제됩니다.
// The code below clears range C2:G7 in the active sheet, but preserves the // format, data validation rules, and comments. SpreadsheetApp.getActiveSheet().getRange(2, 3, 6, 5).clear({ contentsOnly: true });
매개변수
이름 | 유형 | 설명 |
---|---|---|
options | Object | 아래에 나열된 고급 매개변수를 지정하는 JavaScript 객체입니다. |
고급 매개변수
이름 | 유형 | 설명 |
---|---|---|
comments | Boolean | 댓글만 삭제할지 여부입니다. |
contents | Boolean | 콘텐츠만 삭제할지 여부입니다. |
format | Boolean | 서식만 지울지 여부입니다. 서식을 지우면 데이터 유효성 검사 규칙도 지워집니다. |
validations | Boolean | 데이터 확인 규칙만 삭제할지 여부입니다. |
skip | Boolean | 필터링된 행을 삭제하지 않을지 여부입니다. |
리턴
Range
- 이 범위(연결용)
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
clear Content()
범위의 콘텐츠를 지우고 서식은 그대로 유지합니다.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; const range = sheet.getRange('A1:D10'); range.clearContent();
리턴
Range
- 이 범위(연결용)
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
clear Data Validations()
범위의 데이터 확인 규칙을 지웁니다.
// Clear the data validation rules for cells A1:B5. const range = SpreadsheetApp.getActive().getRange('A1:B5'); range.clearDataValidations();
리턴
Range
- 이 범위(연결용)
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
clear Format()
이 범위의 서식을 지웁니다.
이렇게 하면 범위의 셀에 적용된 텍스트 서식이 지워지지만 숫자 서식 규칙은 재설정되지 않습니다.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; const range = sheet.getRange('A1:D10'); range.clearFormat();
리턴
Range
- 이 범위(연결용)
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
clear Note()
지정된 셀의 메모를 지웁니다.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; const range = sheet.getRange('A1:D10'); range.clearNote();
리턴
Range
- 이 범위(연결용)
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
collapse Groups()
범위 내에 완전히 포함된 모든 그룹을 접습니다. 범위 내에 완전히 포함된 그룹이 없으면 범위 내에 부분적으로 포함된 가장 깊이 확장된 그룹이 축소됩니다.
const sheet = SpreadsheetApp.getActiveSpreadsheet().getSheets()[0]; const range = sheet.getActiveRange(); // All row and column groups within the range are collapsed. range.collapseGroups();
리턴
Range
- 이 범위(연결용)
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
copy Format To Range(gridId, column, columnEnd, row, rowEnd)
범위의 서식을 지정된 위치에 복사합니다. 대상 범위가 소스 범위보다 크거나 작은 경우 소스가 적절하게 반복되거나 잘립니다. 이 메서드는 서식만 복사합니다.
gridId 매개변수에 대한 자세한 설명은 get
를 참고하세요.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const source = ss.getSheets()[0]; const range = source.getRange('B2:D4'); // This copies the formatting in B2:D4 in the source sheet to // D4:F6 in the sheet with gridId 1555299895. Note that you can get the gridId // of a sheet by calling sheet.getSheetId() or range.getGridId(). range.copyFormatToRange(1555299895, 4, 6, 4, 6);
매개변수
이름 | 유형 | 설명 |
---|---|---|
grid | Integer | 위치와 관계없이 스프레드시트 내 시트의 고유 ID입니다. |
column | Integer | 타겟 범위의 첫 번째 열입니다. |
column | Integer | 타겟 범위의 끝 열입니다. |
row | Integer | 타겟 범위의 시작 행입니다. |
row | Integer | 타겟 범위의 끝 행입니다. |
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
참고 항목
copy Format To Range(sheet, column, columnEnd, row, rowEnd)
범위의 서식을 지정된 위치에 복사합니다. 대상 범위가 소스 범위보다 크거나 작은 경우 소스가 적절하게 반복되거나 잘립니다. 이 메서드는 서식만 복사합니다.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const source = ss.getSheets()[0]; const destination = ss.getSheets()[1]; const range = source.getRange('B2:D4'); // This copies the formatting in B2:D4 in the source sheet to // D4:F6 in the second sheet range.copyFormatToRange(destination, 4, 6, 4, 6);
매개변수
이름 | 유형 | 설명 |
---|---|---|
sheet | Sheet | 대상 시트입니다. |
column | Integer | 타겟 범위의 첫 번째 열입니다. |
column | Integer | 타겟 범위의 끝 열입니다. |
row | Integer | 타겟 범위의 시작 행입니다. |
row | Integer | 타겟 범위의 끝 행입니다. |
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
copy To(destination)
셀 범위의 데이터를 다른 셀 범위로 복사합니다. 값과 서식이 모두 복사됩니다.
// The code below copies the first 5 columns over to the 6th column. const sheet = SpreadsheetApp.getActiveSheet(); const rangeToCopy = sheet.getRange(1, 1, sheet.getMaxRows(), 5); rangeToCopy.copyTo(sheet.getRange(1, 6));
매개변수
이름 | 유형 | 설명 |
---|---|---|
destination | Range | 복사할 대상 범위입니다. 왼쪽 상단 셀 위치만 관련이 있습니다. |
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
copy To(destination, copyPasteType, transposed)
셀 범위의 데이터를 다른 셀 범위로 복사합니다.
// The code below copies only the values of the first 5 columns over to the 6th // column. const sheet = SpreadsheetApp.getActiveSheet(); sheet.getRange('A:E').copyTo( sheet.getRange('F1'), SpreadsheetApp.CopyPasteType.PASTE_VALUES, false, );
매개변수
이름 | 유형 | 설명 |
---|---|---|
destination | Range | 복사할 대상 범위입니다. 왼쪽 상단 셀 위치만 관련이 있습니다. |
copy | Copy | 범위 콘텐츠가 대상에 붙여넣어지는 방식을 지정하는 유형입니다. |
transposed | Boolean | 범위를 전치된 방향으로 붙여넣을지 여부입니다. |
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
copy To(destination, options)
셀 범위의 데이터를 다른 셀 범위로 복사합니다. 기본적으로 값과 서식이 모두 복사되지만 고급 인수를 사용하여 이를 재정의할 수 있습니다.
// The code below copies only the values of the first 5 columns over to the 6th // column. const sheet = SpreadsheetApp.getActiveSheet(); sheet.getRange('A:E').copyTo(sheet.getRange('F1'), {contentsOnly: true});
매개변수
이름 | 유형 | 설명 |
---|---|---|
destination | Range | 복사할 대상 범위입니다. 왼쪽 상단 셀 위치만 관련이 있습니다. |
options | Object | 아래에 나열된 고급 매개변수를 지정하는 JavaScript 객체입니다. |
고급 매개변수
이름 | 유형 | 설명 |
---|---|---|
format | Boolean | 형식만 복사해야 함을 나타냅니다. |
contents | Boolean | 콘텐츠만 복사해야 함을 나타냅니다. |
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
copy Values To Range(gridId, column, columnEnd, row, rowEnd)
범위의 콘텐츠를 지정된 위치에 복사합니다. 대상 범위가 소스 범위보다 크거나 작은 경우 소스가 적절하게 반복되거나 잘립니다.
gridId 매개변수에 대한 자세한 설명은 get
를 참고하세요.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const source = ss.getSheets()[0]; const range = source.getRange('B2:D4'); // This copies the data in B2:D4 in the source sheet to // D4:F6 in the sheet with gridId 0 range.copyValuesToRange(0, 4, 6, 4, 6);
매개변수
이름 | 유형 | 설명 |
---|---|---|
grid | Integer | 위치와 관계없이 스프레드시트 내 시트의 고유 ID입니다. |
column | Integer | 타겟 범위의 첫 번째 열입니다. |
column | Integer | 타겟 범위의 끝 열입니다. |
row | Integer | 타겟 범위의 시작 행입니다. |
row | Integer | 타겟 범위의 끝 행입니다. |
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
참고 항목
copy Values To Range(sheet, column, columnEnd, row, rowEnd)
범위의 콘텐츠를 지정된 위치에 복사합니다. 대상 범위가 소스 범위보다 크거나 작은 경우 소스가 적절하게 반복되거나 잘립니다.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const source = ss.getSheets()[0]; const destination = ss.getSheets()[1]; const range = source.getRange('B2:D4'); // This copies the data in B2:D4 in the source sheet to // D4:F6 in the second sheet range.copyValuesToRange(destination, 4, 6, 4, 6);
매개변수
이름 | 유형 | 설명 |
---|---|---|
sheet | Sheet | 대상 시트입니다. |
column | Integer | 타겟 범위의 첫 번째 열입니다. |
column | Integer | 타겟 범위의 끝 열입니다. |
row | Integer | 타겟 범위의 시작 행입니다. |
row | Integer | 타겟 범위의 끝 행입니다. |
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
create Data Source Pivot Table(dataSource)
이 범위의 첫 번째 셀에 고정된 데이터 소스로부터 빈 데이터 소스 피벗 테이블을 만듭니다.
이 예에서는 새 데이터 소스 피벗 테이블을 만들고 구성하는 방법을 보여줍니다.
const spreadsheet = SpreadsheetApp.getActiveSpreadsheet(); const anchorCell = spreadsheet.getSheets()[0].getRange('A1'); const dataSource = spreadsheet.getDataSources()[0]; const pivotTable = anchorCell.createDataSourcePivotTable(dataSource); pivotTable.addRowGroup('dataColumnA'); pivotTable.addColumnGroup('dataColumnB'); pivotTable.addPivotValue( 'dataColumnC', SpreadsheetApp.PivotTableSummarizeFunction.SUM, ); pivotTable.addFilter( 'dataColumnA', SpreadsheetApp.newFilterCriteria().whenTextStartsWith('A').build(), );
매개변수
이름 | 유형 | 설명 |
---|---|---|
data | Data | 피벗 테이블을 만들 데이터 소스입니다. |
리턴
Data
- 새로 만든 데이터 소스 피벗 테이블입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
create Data Source Table(dataSource)
이 범위의 첫 번째 셀에 고정된 데이터 소스에서 빈 데이터 소스 테이블을 만듭니다.
이 예에서는 새 데이터 소스 테이블을 만들고 구성하는 방법을 보여줍니다.
const spreadsheet = SpreadsheetApp.getActiveSpreadsheet(); const anchorCell = spreadsheet.getSheets()[0].getRange('A1'); const dataSource = spreadsheet.getDataSources()[0]; const dataSourceTable = anchorCell.createDataSourceTable(dataSource) .addColumns('dataColumnA', 'dataColumnB', 'dataColumnC') .addSortSpec('dataColumnA', true) // ascending=true .addSortSpec('dataColumnB', false); // ascending=false
매개변수
이름 | 유형 | 설명 |
---|---|---|
data | Data | 피벗 테이블을 만들 데이터 소스입니다. |
리턴
Data
- 새로 생성된 데이터 소스 표입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
create Developer Metadata Finder()
이 범위 내에서 개발자 메타데이터를 찾는 DeveloperMetadataFinderApi를 반환합니다. 메타데이터가 범위 내에 완전히 포함된 경우에만 범위 내에 있는 것입니다. 예를 들어 '3:3' 행과 연결된 메타데이터는 'A1:D5' 범위에 포함되지 않지만 '1:5' 범위에는 포함됩니다.
// 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 Sheet1 by its name. const sheet = ss.getSheetByName('Sheet1'); // Gets the range A1:C6. const range = sheet.getRange('A1:C6'); // Creates a developer metadata finder to search for metadata in the scope of // this range. const developerMetaDataFinder = range.createDeveloperMetadataFinder(); // Logs information about the developer metadata finder to the console. const developerMetaData = developerMetaDataFinder.find()[0]; console.log(developerMetaData.getKey()); console.log(developerMetaData.getValue()); console.log(developerMetaData.getVisibility().toString());
리턴
Developer
- 이 범위의 메타데이터를 검색하는 개발자 메타데이터 파인더입니다.
create Filter()
필터를 만들어 시트의 지정된 범위에 적용합니다. 시트에는 필터를 두 개 이상 만들 수 없습니다. 필터를 만든 후 액세스하고 수정하려면 get
또는 Sheet.getFilter()
를 사용하세요.
const ss = SpreadsheetApp.getActiveSheet(); const range = ss.getRange('A1:C20'); // Creates a new filter and applies it to the range A1:C20 on the active sheet. function createFilter() { range.createFilter(); } // Gets the filter and applies criteria that only shows cells that aren't empty. function getFilterAddCriteria() { const filter = range.getFilter(); const criteria = SpreadsheetApp.newFilterCriteria().whenCellNotEmpty().build(); filter.setColumnFilterCriteria(2, criteria); }
Grid
시트(기본 시트 유형)의 필터를 만듭니다.
그리드 시트는 데이터베이스에 연결되지 않은 시트입니다. 다른 유형의 필터를 만들려면 다음을 참고하세요.
Pivot
로 피벗 테이블 필터 만들기Table.addFilter(sourceDataColumn, filterCriteria) Data
로 데이터베이스에 연결된 시트의 필터 만들기Source Sheet.addFilter(columnName, filterCriteria) Data
를 사용하여 데이터베이스에 연결된 피벗 테이블의 필터를 만듭니다.Source Pivot Table.addFilter(columnName, filterCriteria)
리턴
Filter
- 새 필터입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
create Pivot Table(sourceData)
이 범위의 첫 번째 셀에 고정된 지정된 source
에서 빈 피벗 테이블을 만듭니다.
// 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 Sheet1 by its name. const sheet = ss.getSheetByName('Sheet1'); // Gets cell A1 as a range in order to place the pivot table. const range = sheet.getRange('A1'); // Gets the range of the source data for the pivot table. const dataRange = sheet.getRange('E12:G20'); // Creates an empty pivot table from the specified source data. const pivotTable = range.createPivotTable(dataRange); // Logs the values from the pivot table's source data to the console. console.log(pivotTable.getSourceDataRange().getValues());
매개변수
이름 | 유형 | 설명 |
---|---|---|
source | Range | 피벗 테이블을 만들 데이터입니다. |
리턴
Pivot
- 새로 생성된 Pivot
입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
create Text Finder(findText)
범위의 텍스트 찾기를 만듭니다. 이 범위에서 텍스트를 찾아 바꿀 수 있습니다.
const sheet = SpreadsheetApp.getActiveSpreadsheet().getSheets()[0]; const range = sheet.getActiveRange(); // Creates a text finder for the range. const textFinder = range.createTextFinder('dog'); // Returns the first occurrence of 'dog'. const firstOccurrence = textFinder.findNext(); // Replaces the last found occurrence of 'dog' with 'cat' and returns the number // of occurrences replaced. const numOccurrencesReplaced = textFinder.replaceWith('cat');
매개변수
이름 | 유형 | 설명 |
---|---|---|
find | String | 검색할 텍스트입니다. |
리턴
Text
- 범위의 Text
delete Cells(shiftDimension)
이 셀 범위를 삭제합니다. 제공된 측정기준을 따라 시트에 있는 기존 데이터가 삭제된 범위로 이동합니다.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; const range = sheet.getRange('A1:D10'); range.deleteCells(SpreadsheetApp.Dimension.COLUMNS);
매개변수
이름 | 유형 | 설명 |
---|---|---|
shift | Dimension | 기존 데이터를 이동할 차원입니다. |
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
expand Groups()
범위 또는 제어 전환 버튼이 이 범위와 교차하는 접힌 그룹을 펼칩니다. 제어 전환 위치는 설정에 따라 그룹 바로 앞이나 뒤에 제어 전환이 표시되는 색인입니다. 같은 위치에 그룹이 두 개 이상 있는 경우 가장 얕은 그룹이 펼쳐집니다.
const sheet = SpreadsheetApp.getActiveSpreadsheet().getSheets()[0]; const range = sheet.getActiveRange(); // All row and column groups within the range are expanded. range.expandGroups();
리턴
Range
- 이 범위(연결용)
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
getA1Notation()
범위의 문자열 설명을 A1 표기법으로 반환합니다.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; const range = sheet.getRange(1, 1, 2, 5); // Logs "A1:E2" Logger.log(range.getA1Notation());
리턴
String
- A1 표기법의 범위에 대한 문자열 설명입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
get Background()
범위의 왼쪽 상단 셀 (예: '#ffffff'
)의 배경색을 반환합니다.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; const cell = sheet.getRange('B5'); Logger.log(cell.getBackground());
리턴
String
- 배경의 색상 코드입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
get Background Object()
범위의 왼쪽 상단 셀의 배경색을 반환합니다.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; const cell = sheet.getRange('B5'); Logger.log(cell.getBackgroundObject().asRgbColor().asHexString());
리턴
Color
- 범위의 왼쪽 상단 셀의 배경색입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
get Background Objects()
범위 내 셀의 배경색을 반환합니다.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; const range = sheet.getRange('B5:C6'); const bgColors = range.getBackgroundObjects(); for (const i in bgColors) { for (const j in bgColors[i]) { Logger.log(bgColors[i][j].asRgbColor().asHexString()); } }
리턴
Color[][]
- 배경 색상의 2차원 배열입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
get Backgrounds()
범위의 셀 배경 색상을 반환합니다 (예: '#ffffff'
).
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; const range = sheet.getRange('B5:C6'); const bgColors = range.getBackgrounds(); for (const i in bgColors) { for (const j in bgColors[i]) { Logger.log(bgColors[i][j]); } }
리턴
String[][]
- 배경의 색상 코드 2차원 배열입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
get Bandings()
이 범위의 셀에 적용된 모든 밴딩을 반환합니다.
// Opens the spreadsheet file by its URL. If you created your script from within // a Google Sheets file, you can use SpreadsheetApp.getActiveSpreadsheet() // instead. // TODO(developer): Replace the URL with your own. const ss = SpreadsheetApp.openByUrl( 'https://docs.google.com/spreadsheets/d/abc123456/edit', ); // Gets Sheet1 by its name. const sheet = ss.getSheetByName('Sheet1'); // Sets a range. const range = sheet.getRange('A1:K50'); // Gets the banding info for the range. const bandings = range.getBandings(); // Logs the second row color for each banding to the console. for (const banding of bandings) { console.log(banding.getSecondRowColor()); }
리턴
Banding[]
- 이 범위의 셀에 적용된 모든 밴딩입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
get Cell(row, column)
범위 내의 지정된 셀을 반환합니다.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; const range = sheet.getRange('B2:D4'); // The row and column here are relative to the range // getCell(1,1) in this code returns the cell at B2 const cell = range.getCell(1, 1); Logger.log(cell.getValue());
매개변수
이름 | 유형 | 설명 |
---|---|---|
row | Integer | 범위를 기준으로 한 셀의 행입니다. |
column | Integer | 범위를 기준으로 한 셀의 열입니다. |
리턴
Range
- 지정된 좌표에 있는 단일 셀이 포함된 범위입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
get Column()
이 범위의 시작 열 위치를 반환합니다.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; const range = sheet.getRange('B2:D4'); // Logs "2.0" Logger.log(range.getColumn());
리턴
Integer
- 스프레드시트에서 범위의 시작 열 위치입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
get Data Region()
데이터가 있는 모든 인접한 셀을 포함하도록 4개의 기본 Direction
방향으로 확장된 범위의 복사본을 반환합니다. 범위가 대각선을 따라 있는 셀을 포함하지 않는 빈 셀로 둘러싸여 있으면 범위 자체가 반환됩니다. 이는 범위를 선택하고 편집기에 Ctrl+A
를 입력하는 것과 유사합니다.
// Assume the active spreadsheet is blank. const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; sheet.getRange('C2').setValue(100); sheet.getRange('B3').setValue(100); sheet.getRange('D3').setValue(100); sheet.getRange('C4').setValue(100); // Logs "B2:D4" Logger.log(sheet.getRange('C3').getDataRegion().getA1Notation());
리턴
Range
- 범위의 데이터 영역 또는 전체 스프레드시트의 범위입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
get Data Region(dimension)
지정된 측정기준이 Dimension.ROWS
인 경우 확장된 Direction.UP
및 Direction.DOWN
의 복사본을 반환하고, 측정기준이 Dimension.COLUMNS
인 경우 Direction.NEXT
및 Direction.PREVIOUS
를 반환합니다. 범위의 확장은 표와 같이 구성된 범위 옆의 데이터를 감지하는 것을 기반으로 합니다. 확장된 범위는 테이블 경계를 포함하여 지정된 차원을 따라 데이터가 있는 모든 인접한 셀을 포함합니다. 원래 범위가 지정된 차원을 따라 빈 셀로 둘러싸여 있으면 범위 자체가 반환됩니다. 이 방법은 편집기에서 범위를 선택하고 열의 경우
Ctrl+Space
, 행의 경우 Shift+Space
를 입력하는 것과 유사합니다.
// Assume the active spreadsheet is blank. const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; sheet.getRange('C2').setValue(100); sheet.getRange('B3').setValue(100); sheet.getRange('D3').setValue(100); sheet.getRange('C4').setValue(100); // Logs "C2:C4" Logger.log( sheet.getRange('C3') .getDataRegion(SpreadsheetApp.Dimension.ROWS) .getA1Notation(), ); // Logs "B3:D3" Logger.log( sheet.getRange('C3') .getDataRegion(SpreadsheetApp.Dimension.COLUMNS) .getA1Notation(), );
매개변수
이름 | 유형 | 설명 |
---|---|---|
dimension | Dimension | 범위를 확장할 방향입니다. |
리턴
Range
- 범위의 데이터 영역 또는 원래 범위에 걸쳐 있는 각 열 또는 각 행을 포함하는 범위입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
get Data Source Formula()
범위의 첫 번째 셀에 대한 Data
를 반환하거나, 셀에 데이터 소스 수식이 포함되어 있지 않으면 null
를 반환합니다.
// 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 the range A1 on Sheet1. const range = sheet.getRange('A1'); // Gets the data source formula from cell A1. const dataSourceFormula = range.getDataSourceFormula(); // Gets the formula. const formula = dataSourceFormula.getFormula(); // Logs the formula. console.log(formula);
리턴
Data
- 셀의 Data
입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
get Data Source Formulas()
범위 내 셀의 Data
을 반환합니다.
// 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 the range A1:B5 on Sheet1. const range = sheet.getRange('A1:B5'); // Gets an array of the data source formulas in the range A1:B5. const dataSourceFormulas = range.getDataSourceFormulas(); // Logs the first formula in the array. console.log(dataSourceFormulas[0].getFormula());
리턴
Data
- Data
의 배열입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
get Data Source Pivot Tables()
범위와 교차하는 모든 데이터 소스 피벗 테이블을 가져옵니다.
// Opens the spreadsheet file by its ID. If you created your script from a // Google Sheets file, use SpreadsheetApp.getActiveSpreadsheet(). // TODO(developer): Replace the ID with your own. const ss = SpreadsheetApp.openById('abc123456'); // Gets Sheet1 by its name. const sheet = ss.getSheetByName('Sheet1'); // Gets the range A1:G50 on Sheet1. const range = sheet.getRange('A1:G50'); // Gets an array of the data source pivot tables in the range A1:G50. const dataSourcePivotTables = range.getDataSourcePivotTables(); // Logs the last time that the first pivot table in the array was refreshed. console.log(dataSourcePivotTables[0].getStatus().getLastRefreshedTime());
리턴
Data
- 데이터 소스 피벗 테이블 목록입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
get Data Source Tables()
범위와 교차하는 모든 데이터 소스 테이블을 가져옵니다.
// Opens the spreadsheet file by its ID. If you created your script from a // Google Sheets file, use SpreadsheetApp.getActiveSpreadsheet(). // TODO(developer): Replace the ID with your own. const ss = SpreadsheetApp.openById('abc123456'); // Gets Sheet1 by its name. const sheet = ss.getSheetByName('Sheet1'); // Gets the range A1:G50 on Sheet1. const range = sheet.getRange('A1:G50'); // Gets the first data source table in the range A1:G50. const dataSourceTable = range.getDataSourceTables()[0]; // Logs the time of the last completed data execution on the data source table. console.log(dataSourceTable.getStatus().getLastExecutionTime());
리턴
Data
- 데이터 소스 테이블 목록입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
get Data Source Url()
이 범위의 데이터를 위한 URL을 반환합니다. 이 URL은 차트와 쿼리를 만드는 데 사용할 수 있습니다.
Code.gs
function doGet() { const ss = SpreadsheetApp.openById( '1khO6hBWTNNyvyyxvob7aoZTI9ZvlqqASNeq0e29Tw2c', ); const sheet = ss.getSheetByName('ContinentData'); const range = sheet.getRange('A1:B8'); const template = HtmlService.createTemplateFromFile('piechart'); template.dataSourceUrl = range.getDataSourceUrl(); return template.evaluate(); }
piechart.html
<!DOCTYPE html> <html> <head> <!--Load the AJAX API--> <script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script> <script type="text/javascript"> // Load the Visualization API and the corechart package. google.charts.load('current', {'packages': ['corechart']}); // Set a callback to run when the Google Visualization API is loaded. google.charts.setOnLoadCallback(queryData); function queryData() { var query = new google.visualization.Query('<?= dataSourceUrl ?>'); query.send(drawChart); } // Callback that creates and populates a data table, // instantiates the pie chart, passes in the data and // draws it. function drawChart(response) { if (response.isError()) { alert('Error: ' + response.getMessage() + ' ' + response.getDetailedMessage()); return; } var data = response.getDataTable(); // Set chart options. var options = { title: 'Population by Continent', width: 400, height: 300 }; // Instantiate and draw the chart, passing in some options. var chart = new google.visualization.PieChart(document.getElementById('chart_div')); chart.draw(data, options); } </script> </head> <body> <!-- Div that holds the pie chart. --> <div id="chart_div"></div> </body> </html>
리턴
String
- 차트와 같은 다른 API에 전달할 수 있는 데이터 소스로서 이 범위의 URL입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
get Data Table()
이 객체 내부의 데이터를 DataTable로 반환합니다.
// 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 the range A1:B7 on Sheet1. const range = sheet.getRange('A1:B7'); // Gets the range A1:B7 as a data table. The values in each column must be of // the same type. const datatable = range.getDataTable(); // Uses the Charts service to build a bar chart from the data table. // This doesn't build an embedded chart. To do that, use // sheet.newChart().addRange() instead. const chart = Charts.newBarChart() .setDataTable(datatable) .setOption('title', 'Your Chart Title Here') .build();
리턴
Data
- 데이터를 데이터 테이블로 표시합니다.
get Data Table(firstRowIsHeader)
이 범위 내의 데이터를 DataTable로 반환합니다.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; const range = sheet.getRange('A1:B7'); // Calling this method with "true" sets the first line to be the title of the // axes const datatable = range.getDataTable(true); // Note that this doesn't build an EmbeddedChart, so you can't just use // Sheet#insertChart(). To do that, use sheet.newChart().addRange() instead. const chart = Charts.newBarChart() .setDataTable(datatable) .setOption('title', 'Your Title Here') .build();
매개변수
이름 | 유형 | 설명 |
---|---|---|
first | Boolean | 첫 번째 행을 헤더로 처리할지 여부입니다. |
리턴
Data
- 데이터를 데이터 테이블로 나타냅니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
get Data Validation()
범위의 왼쪽 상단 셀에 대한 데이터 확인 규칙을 반환합니다. 셀에 데이터 확인이 설정되지 않은 경우 이 메서드는 null
을 반환합니다.
// Log information about the data validation rule for cell A1. const cell = SpreadsheetApp.getActive().getRange('A1'); const rule = cell.getDataValidation(); if (rule != null) { const criteria = rule.getCriteriaType(); const args = rule.getCriteriaValues(); Logger.log('The data validation rule is %s %s', criteria, args); } else { Logger.log('The cell does not have a data validation rule.'); }
리턴
Data
- 범위의 왼쪽 상단 셀에 대한 데이터 확인 규칙입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
get Data Validations()
범위의 모든 셀에 대한 데이터 확인 규칙을 반환합니다. 특정 셀에 데이터 검증이 설정되지 않은 경우 이 메서드는 배열에서 해당 셀의 위치에 대해 null
를 반환합니다.
// Change existing data validation rules that require a date in 2013 to require // a date in 2014. const oldDates = [new Date('1/1/2013'), new Date('12/31/2013')]; const newDates = [new Date('1/1/2014'), new Date('12/31/2014')]; const sheet = SpreadsheetApp.getActiveSheet(); const range = sheet.getRange(1, 1, sheet.getMaxRows(), sheet.getMaxColumns()); const rules = range.getDataValidations(); for (let i = 0; i < rules.length; i++) { for (let j = 0; j < rules[i].length; j++) { const rule = rules[i][j]; if (rule != null) { const criteria = rule.getCriteriaType(); const args = rule.getCriteriaValues(); if (criteria === SpreadsheetApp.DataValidationCriteria.DATE_BETWEEN && args[0].getTime() === oldDates[0].getTime() && args[1].getTime() === oldDates[1].getTime()) { // Create a builder from the existing rule, then change the dates. rules[i][j] = rule.copy().withCriteria(criteria, newDates).build(); } } } } range.setDataValidations(rules);
리턴
Data
- 범위의 셀과 연결된 데이터 유효성 검사 규칙의 2차원 배열입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
get Developer Metadata()
이 범위와 연결된 개발자 메타데이터를 가져옵니다.
// Opens the spreadsheet file by its URL. If you created your script from within // a Google Sheets file, you can use SpreadsheetApp.getActiveSpreadsheet() // instead. // TODO(developer): Replace the URL with your own. const ss = SpreadsheetApp.openByUrl( 'https://docs.google.com/spreadsheets/d/abc123456/edit', ); // Gets Sheet1 by its name. const sheet = ss.getSheetByName('Sheet1'); // Gets row 2 on Sheet1. const range = sheet.getRange('2:2'); // Adds metadata to row 2. range.addDeveloperMetadata('NAME', 'GOOGLE'); // Logs the metadata to console. for (const metadata of range.getDeveloperMetadata()) { console.log(`${metadata.getKey()}: ${metadata.getValue()}`); }
리턴
Developer
- 이 범위와 연결된 개발자 메타데이터입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
get Display Value()
범위의 왼쪽 상단 셀에 표시된 값을 반환합니다. 값은 String
입니다.
표시된 값은 스프레드시트의 언어 설정에 의해 자동으로 적용되는 형식을 비롯한 날짜, 시간, 통화 형식을 고려합니다. 빈 셀은 빈 문자열을 반환합니다.
// 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 Sheet1 by its name. const sheet = ss.getSheetByName('Sheet1'); // Gets cell A30 and sets its value to 'Test code.' const cell = sheet.getRange('A30'); cell.setValue('Test code'); // Gets the value and logs it to the console. console.log(cell.getDisplayValue());
리턴
String
: 이 셀에 표시된 값입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
get Display Values()
이 범위의 값으로 된 직사각형 그리드를 반환합니다.
행별, 열별로 색인이 지정된 표시 값의 2차원 배열을 반환합니다. 값은 String
객체입니다. 표시된 값은 스프레드시트의 언어 설정에 의해 자동으로 적용되는 형식을 비롯한 날짜, 시간, 통화 형식을 고려합니다. 빈 셀은 배열에서 빈 문자열로 표시됩니다. 범위 색인은 1, 1
에서 시작하지만 JavaScript 배열은 [0][0]
부터 색인이 생성됩니다.
// The code below gets the displayed values for the range C2:G8 // in the active spreadsheet. Note that this is a JavaScript array. const values = SpreadsheetApp.getActiveSheet().getRange(2, 3, 6, 4).getDisplayValues(); Logger.log(values[0][0]);
리턴
String[][]
- 값의 2차원 배열입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
get Filter()
이 범위가 속한 시트의 필터를 반환하거나, 시트에 필터가 없는 경우 null
을 반환합니다.
const ss = SpreadsheetApp.getActiveSheet(); const range = ss.getRange('A1:C20'); // Gets the existing filter on the sheet that the given range belongs to. const filter = range.getFilter();
리턴
Filter
- 필터
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
get Font Color Object()
범위의 왼쪽 상단에 있는 셀의 글꼴 색상을 반환합니다.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; const range = sheet.getRange('B2:D4'); Logger.log(range.getFontColorObject().asRgbColor().asHexString());
리턴
Color
- 범위의 왼쪽 상단 셀의 글꼴 색상입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
get Font Color Objects()
범위 내 셀의 글꼴 색상을 반환합니다.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; const range = sheet.getRange('B2:D4'); const results = range.getFontColorObjects(); for (const i in results) { for (const j in results[i]) { Logger.log(results[i][j].asRgbColor().asHexString()); } }
리턴
Color[][]
- 범위의 셀과 연결된 글꼴 색상의 2차원 배열입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
get Font Families()
범위 내 셀의 글꼴 모음을 반환합니다.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; const range = sheet.getRange('B2:D4'); const results = range.getFontFamilies(); for (const i in results) { for (const j in results[i]) { Logger.log(results[i][j]); } }
리턴
String[][]
- 범위의 셀과 연결된 글꼴 모음의 2차원 배열입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
get Font Family()
범위의 왼쪽 상단에 있는 셀의 글꼴 모음을 반환합니다.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; const range = sheet.getRange('B2:D4'); Logger.log(range.getFontFamily());
리턴
String
- 셀의 글꼴 모음입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
get Font Line()
범위의 왼쪽 상단에 있는 셀의 선 스타일을 가져옵니다 ('underline'
, 'line-through'
또는 'none'
).
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; const range = sheet.getRange('B2:D4'); Logger.log(range.getFontLine());
리턴
String
- 글꼴 줄입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
get Font Lines()
범위의 셀의 선 스타일 ('underline'
, 'line-through'
또는 'none'
)을 가져옵니다.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; const range = sheet.getRange('B2:D4'); const results = range.getFontLines(); for (const i in results) { for (const j in results[i]) { Logger.log(results[i][j]); } }
리턴
String[][]
- 범위의 셀과 연결된 글꼴 선의 2차원 배열입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
get Font Size()
범위의 왼쪽 상단에 있는 셀의 글꼴 크기를 포인트 단위로 반환합니다.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; const range = sheet.getRange('B2:D4'); Logger.log(range.getFontSize());
리턴
Integer
- 글꼴 크기(포인트)입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
get Font Sizes()
범위 내 셀의 글꼴 크기를 반환합니다.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; const range = sheet.getRange('B2:D4'); const results = range.getFontSizes(); for (const i in results) { for (const j in results[i]) { Logger.log(results[i][j]); } }
리턴
Integer[][]
- 범위의 셀과 연결된 텍스트의 글꼴 크기로 구성된 2차원 배열입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
get Font Style()
범위의 왼쪽 상단에 있는 셀의 글꼴 스타일 ('italic'
또는 'normal'
)을 반환합니다.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; const range = sheet.getRange('B2:D4'); Logger.log(range.getFontStyle());
리턴
String
- 셀의 텍스트 글꼴 스타일입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
get Font Styles()
범위 내 셀의 글꼴 스타일을 반환합니다.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; const range = sheet.getRange('B2:D4'); const results = range.getFontStyles(); for (const i in results) { for (const j in results[i]) { Logger.log(results[i][j]); } }
리턴
String[][]
- 범위의 셀과 연결된 텍스트의 글꼴 스타일로 구성된 2차원 배열입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
get Font Weight()
범위의 왼쪽 상단에 있는 셀의 글꼴 두께 (normal/bold)를 반환합니다.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; const range = sheet.getRange('B2:D4'); Logger.log(range.getFontWeight());
리턴
String
- 셀에 있는 텍스트의 글꼴 두께입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
get Font Weights()
범위 내 셀의 글꼴 두께를 반환합니다.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; const range = sheet.getRange('B2:D4'); const results = range.getFontWeights(); for (const i in results) { for (const j in results[i]) { Logger.log(results[i][j]); } }
리턴
String[][]
- 범위의 셀과 연결된 텍스트의 글꼴 두께를 나타내는 2차원 배열입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
get Formula()
범위의 왼쪽 상단 셀의 수식 (A1 표기법)을 반환하거나 셀이 비어 있거나 수식이 포함되어 있지 않으면 빈 문자열을 반환합니다.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; // This assumes you have a function in B5 that sums up // B2:B4 const range = sheet.getRange('B5'); // Logs the calculated value and the formula Logger.log( 'Calculated value: %s Formula: %s', range.getValue(), range.getFormula(), );
리턴
String
- 셀의 수식입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
get Formula R1C1()
지정된 셀의 수식 (R1C1 표기법)을 반환하거나 수식이 없는 경우 null
을 반환합니다.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; const range = sheet.getRange('B5'); const formula = range.getFormulaR1C1(); Logger.log(formula);
리턴
String
- R1C1 표기법의 수식입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
get Formulas()
범위 내 셀의 수식 (A1 표기법)을 반환합니다. 2D 배열의 항목은 수식이 없는 셀의 경우 빈 문자열입니다.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; const range = sheet.getRange('B5:C6'); const formulas = range.getFormulas(); for (const i in formulas) { for (const j in formulas[i]) { Logger.log(formulas[i][j]); } }
리턴
String[][]
- 문자열 형식의 수식으로 구성된 2차원 배열입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
get Formulas R1C1()
범위의 셀에 대한 수식 (R1C1 표기법)을 반환합니다. 2D 배열의 항목은 수식이 없는 셀의 경우 null
입니다.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; const range = sheet.getRange('B5:C6'); const formulas = range.getFormulasR1C1(); for (const i in formulas) { for (const j in formulas[i]) { Logger.log(formulas[i][j]); } }
리턴
String[][]
- R1C1 표기법의 수식으로 구성된 2차원 배열입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
get Grid Id()
범위의 상위 시트의 그리드 ID를 반환합니다. ID는 무작위 음수가 아닌 정수 값입니다.
// Log the grid ID of the first sheet (by tab position) in the spreadsheet. const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; const range = sheet.getRange('B2:D4'); Logger.log(range.getGridId());
리턴
Integer
: 상위 시트의 그리드 ID입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
get Height()
범위의 높이를 반환합니다.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; const range = sheet.getRange('B2:D4'); // logs 3.0 Logger.log(range.getHeight());
리턴
Integer
- 범위의 높이입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
get Horizontal Alignment()
범위의 왼쪽 상단에 있는 셀의 텍스트 가로 정렬 (왼쪽/가운데/오른쪽)을 반환합니다.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; const range = sheet.getRange('B2:D4'); Logger.log(range.getHorizontalAlignment());
리턴
String
- 셀의 텍스트 가로 정렬입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
get Horizontal Alignments()
범위 내 셀의 가로 정렬을 반환합니다.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; const range = sheet.getRange('B2:D4'); const results = range.getHorizontalAlignments(); for (const i in results) { for (const j in results[i]) { Logger.log(results[i][j]); } }
리턴
String[][]
- 범위의 셀과 연결된 텍스트의 가로 정렬을 나타내는 2차원 배열입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
get Last Column()
종료 열 위치를 반환합니다.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; const range = sheet.getRange('B2:D4'); // Logs "4.0" Logger.log(range.getLastColumn());
리턴
Integer
- 스프레드시트에서 범위의 끝 열 위치입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
get Last Row()
종료 행 위치를 반환합니다.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; const range = sheet.getRange('B2:D4'); // Logs "4.0" Logger.log(range.getLastRow());
리턴
Integer
- 스프레드시트에서 범위의 끝 행 위치입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
get Merged Ranges()
현재 범위 내에 완전히 포함되거나 현재 범위의 셀을 하나 이상 포함하는 병합된 셀을 나타내는 Range
객체의 배열을 반환합니다.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; const range = sheet.getRange('A1:B3'); const mergedRanges = range.getMergedRanges(); for (let i = 0; i < mergedRanges.length; i++) { Logger.log(mergedRanges[i].getA1Notation()); Logger.log(mergedRanges[i].getDisplayValue()); }
리턴
get Next Data Cell(direction)
범위의 첫 번째 열과 행에 있는 셀에서 시작하여 데이터가 있는 연속된 셀 범위의 가장자리 또는 해당 방향의 스프레드시트 가장자리에 있는 셀인 지정된 방향의 다음 셀을 반환합니다. 이는 편집기에
Ctrl+[arrow key]
를 입력하는 것과 같습니다.
// Assume the active spreadsheet is blank. const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; const range = sheet.getRange('C3:E5'); // Logs "C1" Logger.log(range.getNextDataCell(SpreadsheetApp.Direction.UP).getA1Notation());
매개변수
이름 | 유형 | 설명 |
---|---|---|
direction | Direction | 다음 데이터 영역 가장자리 셀을 찾을 방향입니다. |
리턴
Range
- 데이터 영역 가장자리 셀 또는 스프레드시트 가장자리의 셀입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
get Note()
지정된 범위와 연결된 메모를 반환합니다.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; const range = sheet.getRange('B2:D4'); Logger.log(range.getNote());
리턴
String
- 지정된 셀과 연결된 메모입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
get Notes()
범위의 셀과 연결된 메모를 반환합니다.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; const range = sheet.getRange('B2:D4'); const results = range.getNotes(); for (const i in results) { for (const j in results[i]) { Logger.log(results[i][j]); } }
리턴
String[][]
- 범위의 셀과 연결된 메모의 2차원 배열입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
get Num Columns()
이 범위의 열 수를 반환합니다.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; const range = sheet.getRange('B2:D5'); Logger.log(range.getNumColumns());
리턴
Integer
- 이 범위의 열 수입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
get Num Rows()
이 범위의 행 수를 반환합니다.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; const range = sheet.getRange('B2:D5'); Logger.log(range.getNumRows());
리턴
Integer
- 이 범위의 행 수입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
get Number Format()
지정된 범위의 왼쪽 상단 셀의 숫자 또는 날짜 형식을 가져옵니다. 반환된 형식 패턴은 Sheets API 문서에 설명되어 있습니다.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; const cell = sheet.getRange('C4'); Logger.log(cell.getNumberFormat());
리턴
String
- 범위의 왼쪽 상단 셀의 숫자 형식입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
get Number Formats()
범위 내 셀의 숫자 또는 날짜 형식을 반환합니다. 반환된 형식 패턴은 Sheets API 문서에 설명되어 있습니다.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; const range = sheet.getRange('B5:C6'); const formats = range.getNumberFormats(); for (const i in formats) { for (const j in formats[i]) { Logger.log(formats[i][j]); } }
리턴
String[][]
- 숫자 형식의 2차원 배열입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
get Rich Text Value()
범위의 왼쪽 상단 셀의 서식 있는 텍스트 값을 반환합니다. 셀 값이 텍스트가 아닌 경우 null
을 반환합니다.
// Gets the Rich Text value of cell D4. const sheet = SpreadsheetApp.getActiveSheet(); const range = sheet.getRange('D4:F6'); const richText = range.getRichTextValue(); console.log(richText.getText());
리턴
Rich
- 범위의 왼쪽 상단 셀의 서식 있는 텍스트 값입니다. 셀 값이 텍스트가 아닌 경우 null
입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
get Rich Text Values()
범위의 셀에 대한 서식 있는 텍스트 값을 반환합니다.
// Gets the Rich Text values for all cells in range B5:C6 const sheet = SpreadsheetApp.getActiveSheet(); const range = sheet.getRange('B5:C6'); const values = range.getRichTextValues(); for (let i = 0; i < values.length; i++) { for (let j = 0; j < values[i].length; j++) { console.log(values[i][j].getText()); } }
리턴
Rich
- 서식 있는 텍스트 값의 2차원 배열입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
get Row()
이 범위의 행 위치를 반환합니다. get
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; const range = sheet.getRange('B2'); Logger.log(range.getRow());
리턴
Integer
- 범위의 행 위치입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
get Row Index()
이 범위의 행 위치를 반환합니다. get
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; const range = sheet.getRange('B2'); Logger.log(range.getRowIndex());
리턴
Integer
- 범위의 행 위치입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
참고 항목
get Sheet()
이 범위가 속한 시트를 반환합니다.
// 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 Sheet1 by its name. const sheet = ss.getSheetByName('Sheet1'); // Gets the range A1:D10 on Sheet1. const range = sheet.getRange('A1:D10'); // Gets the sheet that the range belongs to. const rangeSheet = range.getSheet(); // Gets the sheet name and logs it to the console. console.log(rangeSheet.getName());
리턴
Sheet
- 이 범위가 속한 시트입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
get Text Direction()
범위의 왼쪽 상단 셀의 텍스트 방향을 반환합니다. 셀 텍스트 방향이 자동 감지로 결정되면 null
를 반환합니다.
// Get the text direction of cell B1. const sheet = SpreadsheetApp.getActiveSheet(); const range = sheet.getRange('B1:D4'); Logger.log(range.getTextDirection());
리턴
Text
- 범위의 왼쪽 상단 셀의 텍스트 방향입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
get Text Directions()
범위 내 셀의 텍스트 방향을 반환합니다. 2D 배열의 항목은 자동 감지를 사용하는 셀의 경우 null
입니다.
// Get the text directions for all cells in range B5:C6 const sheet = SpreadsheetApp.getActiveSheet(); const range = sheet.getRange('B5:C6'); const directions = range.getTextDirections(); for (let i = 0; i < directions.length; i++) { for (let j = 0; j < directions[i].length; j++) { Logger.log(directions[i][j]); } }
리턴
Text
- 텍스트 방향의 2차원 배열입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
get Text Rotation()
범위의 왼쪽 상단 셀의 텍스트 회전 설정을 반환합니다.
// Log the text rotation settings for a cell. const sheet = SpreadsheetApp.getActiveSheet(); const cell = sheet.getRange('A1'); Logger.log(cell.getTextRotation());
리턴
Text
- 텍스트 회전 설정입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
get Text Rotations()
범위 내 셀의 텍스트 회전 설정을 반환합니다.
const sheet = SpreadsheetApp.getActiveSheet(); const range = sheet.getRange('B2:D4'); const results = range.getTextRotations(); for (const i in results) { for (const j in results[i]) { const rotation = results[i][j]; Logger.log('Cell [%s, %s] has text rotation: %v', i, j, rotation); } }
리턴
Text
- 범위의 셀과 연결된 텍스트 회전의 2차원 배열입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
get Text Style()
범위의 왼쪽 상단 셀의 텍스트 스타일을 반환합니다.
// Get the text style of cell D4. const sheet = SpreadsheetApp.getActiveSheet(); const range = sheet.getRange('D4:F6'); const style = range.getTextStyle(); Logger.log(style);
리턴
Text
- 범위의 왼쪽 상단 셀의 텍스트 스타일입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
get Text Styles()
범위 내 셀의 텍스트 스타일을 반환합니다.
// Get the text styles for all cells in range B5:C6 const sheet = SpreadsheetApp.getActiveSheet(); const range = sheet.getRange('B5:C6'); const styles = range.getTextStyles(); for (let i = 0; i < styles.length; i++) { for (let j = 0; j < styles[i].length; j++) { Logger.log(styles[i][j]); } }
리턴
Text
- 텍스트 스타일의 2차원 배열입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
get Value()
범위의 왼쪽 상단 셀 값을 반환합니다. 셀의 값에 따라 값의 유형은 Number
, Boolean
, Date
또는 String
일 수 있습니다. 빈 셀은 빈 문자열을 반환합니다.
// 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 Sheet1 by its name. const sheet = ss.getSheetByName('Sheet1'); // Gets the range A1:D10 on Sheet1. const range = sheet.getRange('A1:D10'); // Gets the value of the top-left cell in the range and logs it to the console. console.log(range.getValue());
리턴
Object
- 이 셀의 값입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
get Values()
이 범위의 값으로 된 직사각형 그리드를 반환합니다.
행, 열 순으로 색인이 지정된 값의 2차원 배열을 반환합니다. 값은 셀의 값에 따라 Number
, Boolean
, Date
또는 String
유형일 수 있습니다. 빈 셀은 배열에서 빈 문자열로 표시됩니다. 범위 색인은 1, 1
에서 시작하지만 JavaScript 배열은 [0][0]
부터 색인이 생성됩니다.
// The code below gets the values for the range C2:G8 // in the active spreadsheet. Note that this is a JavaScript array. const values = SpreadsheetApp.getActiveSheet().getRange(2, 3, 6, 4).getValues(); Logger.log(values[0][0]);
Date
값은 유효한 매개변수가 아닙니다. 범위에 Date
값이 있는 셀이 포함된 경우 get Values()
가 웹 앱에 데이터를 반환하지 못합니다. 대신 시트에서 가져온 모든 값을 Number
, Boolean
, String
과 같은 지원되는 JavaScript 원시 값으로 변환합니다.리턴
Object[][]
- 값의 2차원 배열입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
get Vertical Alignment()
범위의 왼쪽 상단에 있는 셀의 세로 정렬 (상단/중간/하단)을 반환합니다.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; const range = sheet.getRange('B2:D4'); Logger.log(range.getVerticalAlignment());
리턴
String
- 셀의 텍스트 세로 정렬입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
get Vertical Alignments()
범위 내 셀의 세로 정렬을 반환합니다.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; const range = sheet.getRange('B2:D4'); const results = range.getVerticalAlignments(); for (const i in results) { for (const j in results[i]) { Logger.log(results[i][j]); } }
리턴
String[][]
- 범위의 셀과 연결된 텍스트의 세로 정렬을 나타내는 2차원 배열입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
get Width()
범위의 너비를 열 단위로 반환합니다.
// 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 Sheet1 by its name. const sheet = ss.getSheetByName('Sheet1'); // Gets the range A1:D10 on Sheet1. const range = sheet.getRange('A1:D10'); // Gets the width of the range in number of columns and logs it to the console. console.log(range.getWidth());
리턴
Integer
- 범위의 열 수입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
get Wrap()
셀의 텍스트가 줄바꿈되는지 여부를 반환합니다. 더 세부적인 텍스트 줄바꿈 전략을 얻으려면 get
를 사용하세요.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; const range = sheet.getRange('B2:D4'); Logger.log(range.getWrap());
리턴
Boolean
- 이 셀의 텍스트가 줄바꿈되는지 여부입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
get Wrap Strategies()
범위 내 셀의 텍스트 줄바꿈 전략을 반환합니다.
// Get the text wrapping strategies for all cells in range B5:C6 const sheet = SpreadsheetApp.getActiveSheet(); const range = sheet.getRange('B5:C6'); const strategies = range.getWrapStrategies(); for (let i = 0; i < strategies.length; i++) { for (let j = 0; j < strategies[i].length; j++) { Logger.log(strategies[i][j]); } }
리턴
Wrap
- 텍스트 줄바꿈 전략의 2차원 배열입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
get Wrap Strategy()
범위의 왼쪽 상단 셀의 텍스트 줄바꿈 전략을 반환합니다.
// Get the text wrapping strategy of cell B1. const sheet = SpreadsheetApp.getActiveSheet(); const range = sheet.getRange('B1:D4'); Logger.log(range.getWrapStrategy());
리턴
Wrap
- 범위의 왼쪽 상단 셀의 텍스트 줄 바꿈 전략입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
get Wraps()
셀의 텍스트가 줄바꿈되는지 여부를 반환합니다. 더 세부적인 텍스트 줄바꿈 전략을 얻으려면 get
를 사용하세요.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; const range = sheet.getRange('B2:D4'); const results = range.getVerticalAlignments(); for (const i in results) { for (const j in results[i]) { const isWrapped = results[i][j]; if (isWrapped) { Logger.log('Cell [%s, %s] has wrapped text', i, j); } } }
리턴
Boolean[][]
- 범위의 셀과 연결된 텍스트의 세로 정렬을 나타내는 2차원 배열입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
insert Cells(shiftDimension)
이 범위에 빈 셀을 삽입합니다. 새 셀은 이전에 이 범위를 차지했던 셀에 있던 서식을 유지합니다. 제공된 측정기준을 따라 시트에 있는 기존 데이터가 삽입된 범위에서 이동합니다.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; const range = sheet.getRange('A1:D10'); range.insertCells(SpreadsheetApp.Dimension.COLUMNS);
매개변수
이름 | 유형 | 설명 |
---|---|---|
shift | Dimension | 기존 데이터를 이동할 차원입니다. |
리턴
Range
- 이 범위(연결용)
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
insert Checkboxes()
선택된 경우 true
, 선택되지 않은 경우 false
로 구성된 체크박스를 범위의 각 셀에 삽입합니다. 범위의 모든 셀 값을 false
로 설정합니다.
const range = SpreadsheetApp.getActive().getRange('A1:B10'); // Inserts checkboxes into each cell in the range A1:B10 configured with 'true' // for checked and 'false' for unchecked. Also, sets the value of each cell in // the range A1:B10 to 'false'. range.insertCheckboxes();
리턴
Range
- 이 범위(연결용)
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
insert Checkboxes(checkedValue)
범위의 각 셀에 체크박스를 삽입합니다. 선택된 경우 맞춤 값으로, 선택되지 않은 경우 빈 문자열로 구성됩니다. 범위의 각 셀 값을 빈 문자열로 설정합니다.
const range = SpreadsheetApp.getActive().getRange('A1:B10'); // Inserts checkboxes into each cell in the range A1:B10 configured with 'yes' // for checked and the empty string for unchecked. Also, sets the value of each // cell in the range A1:B10 to // the empty string. range.insertCheckboxes('yes');
매개변수
이름 | 유형 | 설명 |
---|---|---|
checked | Object | 체크박스 데이터 유효성 검사의 선택된 값입니다. |
리턴
Range
- 이 범위(연결용)
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
insert Checkboxes(checkedValue, uncheckedValue)
선택 및 선택 해제 상태에 대한 맞춤 값으로 구성된 체크박스를 범위의 각 셀에 삽입합니다. 범위의 각 셀 값을 선택되지 않은 맞춤 값으로 설정합니다.
const range = SpreadsheetApp.getActive().getRange('A1:B10'); // Inserts checkboxes into each cell in the range A1:B10 configured with 'yes' // for checked and 'no' for unchecked. Also, sets the value of each cell in the // range A1:B10 to 'no'. range.insertCheckboxes('yes', 'no');
매개변수
이름 | 유형 | 설명 |
---|---|---|
checked | Object | 체크박스 데이터 유효성 검사의 선택된 값입니다. |
unchecked | Object | 체크박스 데이터 검증의 선택 해제된 값입니다. |
리턴
Range
- 이 범위(연결용)
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
is Blank()
범위가 완전히 비어 있으면 true
를 반환합니다.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; const range = sheet.getRange('B2:D4'); Logger.log(range.isBlank());
리턴
Boolean
- 범위가 비어 있으면 true
, 그렇지 않으면 false
입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
is Checked()
범위의 모든 셀의 체크박스 상태가 '선택됨'인지 여부를 반환합니다. 일부 셀이 선택되고 나머지는 선택되지 않았거나 일부 셀에 체크박스 데이터 유효성 검사가 없는 경우 null
를 반환합니다.
const range = SpreadsheetApp.getActive().getRange('A1:A3'); // Inserts checkboxes and sets each cell value to 'no' in the range A1:A3. range.insertCheckboxes('yes', 'no'); const range1 = SpreadsheetApp.getActive().getRange('A1'); range1.setValue('yes'); // Sets the value of isRange1Checked as true as it contains the checked value. const isRange1Checked = range1.isChecked(); const range2 = SpreadsheetApp.getActive().getRange('A2'); range2.setValue('no'); // Sets the value of isRange2Checked as false as it contains the unchecked // value. const isRange2Checked = range2.isChecked(); const range3 = SpreadsheetApp.getActive().getRange('A3'); range3.setValue('random'); // Sets the value of isRange3Checked as null, as it contains an invalid checkbox // value. const isRange3Checked = range3.isChecked();
리턴
Boolean
— 범위의 모든 셀이 선택된 경우 true
, 범위의 모든 셀이 선택 해제된 경우 false
, 셀이 선택 해제되었거나 체크박스 데이터 유효성 검사가 없는 경우 null
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
is End Column Bounded()
범위의 끝이 특정 열에 바인드되는지 여부를 확인합니다. 예를 들어 범위 끝의 열에 바인딩된 범위 A1:B10
또는 B:B
의 경우 이 메서드는 true
를 반환하고, 범위 끝의 특정 행에만 바인딩된 범위 3:7
또는 A1:5
의 경우 이 메서드는 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 Sheet1 by its name. const sheet = ss.getSheetByName('Sheet1'); // Gets the range A1:D10 on Sheet1. const range = sheet.getRange('A1:D10'); // Determines if the end of the range is bound to a particular column and logs // it to the console. console.log(range.isEndColumnBounded());
리턴
범위의 끝이 특정 열에 바인딩된 경우 Boolean
~true
, 그렇지 않은 경우 false
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
is End Row Bounded()
범위의 끝이 특정 행에 바인드되는지 여부를 확인합니다. 예를 들어 범위 끝의 행에 바인딩된 범위 A1:B10
또는 3:7
의 경우 이 메서드는 true
를 반환합니다. 범위 끝의 특정 열에만 바인딩된 범위 B:B
또는 A1:C
의 경우 이 메서드는 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 Sheet1 by its name. const sheet = ss.getSheetByName('Sheet1'); // Gets the range A1:D10 on Sheet1. const range = sheet.getRange('A1:D10'); // Determines if the end of the range is bound to a particular row and logs it // to the console. console.log(range.isEndRowBounded());
리턴
Boolean
- 범위의 끝이 특정 행에 바인드된 경우 true
, 그렇지 않은 경우 false
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
is Part Of Merge()
현재 범위의 셀이 병합된 셀과 겹치면 true
을 반환합니다.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; const range = sheet.getRange('A1:B3'); // True if any of the cells in A1:B3 is included in a merge. const isPartOfMerge = range.isPartOfMerge();
리턴
Boolean
- 범위가 병합된 셀과 겹치면 true
을 반환하고 그렇지 않으면 false
를 반환합니다.
is Start Column Bounded()
범위의 시작이 특정 열에 바인드되는지 여부를 확인합니다. 예를 들어 범위 시작 부분의 열에 바인드된 범위 A1:B10
또는 B:B
의 경우 이 메서드는 true
를 반환하고, 범위 시작 부분의 행에만 바인드된 범위 3:7
의 경우 이 메서드는 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 Sheet1 by its name. const sheet = ss.getSheetByName('Sheet1'); // Gets the range A1:D10 on Sheet1. const range = sheet.getRange('A1:D10'); // Determines if the start of the range is bound to a particular column and logs // it to the console. console.log(range.isStartColumnBounded());
리턴
Boolean
- 범위의 시작이 특정 열에 바인딩된 경우 true
, 그렇지 않은 경우 false
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
is Start Row Bounded()
범위의 시작이 특정 행에 바인드되는지 여부를 확인합니다. 예를 들어 범위 시작 부분의 행에 바인딩된 범위 A1:B10
또는 3:7
의 경우 이 메서드는 true
를 반환하고, 범위 시작 부분의 특정 열에만 바인딩된 범위 B:B
의 경우 이 메서드는 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 Sheet1 by its name. const sheet = ss.getSheetByName('Sheet1'); // Gets the range A1:D10 on Sheet1. const range = sheet.getRange('A1:D10'); // Determines if the start of the range is bound to a particular row and logs it // to the console. console.log(range.isStartRowBounded());
리턴
Boolean
- 범위의 시작이 특정 행에 바인딩된 경우 true
, 그렇지 않은 경우 false
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
merge()
범위의 셀을 하나의 블록으로 병합합니다.
const sheet = SpreadsheetApp.getActiveSheet(); // The code below 2-dimensionally merges the cells in A1 to B3 sheet.getRange('A1:B3').merge();
리턴
Range
- 이 범위(연결용)
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
merge Across()
범위의 열에 걸쳐 범위의 셀을 병합합니다.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; // The code below merges cells C5:E5 into one cell const range1 = sheet.getRange('C5:E5'); range1.mergeAcross(); // The code below creates 2 horizontal cells, F5:H5 and F6:H6 const range2 = sheet.getRange('F5:H6'); range2.mergeAcross();
리턴
Range
- 이 범위(연결용)
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
merge Vertically()
범위의 셀을 병합합니다.
const sheet = SpreadsheetApp.getActiveSheet(); // The code below vertically merges the cells in A1 to A10 sheet.getRange('A1:A10').mergeVertically(); // The code below creates 3 merged columns: B1 to B10, C1 to C10, and D1 to D10 sheet.getRange('B1:D10').mergeVertically();
리턴
Range
- 이 범위(연결용)
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
move To(target)
이 범위에서 대상 범위로 잘라내어 붙여넣습니다 (형식과 값 모두).
// The code below moves the first 5 columns over to the 6th column const sheet = SpreadsheetApp.getActiveSheet(); sheet.getRange('A1:E').moveTo(sheet.getRange('F1'));
매개변수
이름 | 유형 | 설명 |
---|---|---|
target | Range | 이 범위를 복사할 대상 범위입니다. 왼쪽 상단 셀 위치만 관련이 있습니다. |
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
offset(rowOffset, columnOffset)
이 범위에서 지정된 행과 열 수(음수일 수 있음)만큼 오프셋된 새 범위를 반환합니다. 새 범위는 원래 범위와 크기가 동일합니다.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; const cell = sheet.getRange('A1'); // newCell references B2 const newCell = cell.offset(1, 1);
매개변수
이름 | 유형 | 설명 |
---|---|---|
row | Integer | 범위의 왼쪽 상단 셀에서 아래로 이동한 행 수입니다. 음수 값은 범위의 왼쪽 상단 셀에서 위로 이동한 행 수를 나타냅니다. |
column | Integer | 범위의 왼쪽 상단 셀에서 오른쪽으로 떨어진 열 수입니다. 음수 값은 범위의 왼쪽 상단 셀에서 왼쪽으로 떨어진 열 수를 나타냅니다. |
리턴
Range
- 이 범위(연결용)
offset(rowOffset, columnOffset, numRows)
현재 범위에 상대적이고, 왼쪽 상단 점이 현재 범위에서 지정된 행과 열만큼 오프셋되어 있으며, 지정된 셀 높이를 갖는 새 범위를 반환합니다.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; const cell = sheet.getRange('A1'); // newCell references B2:B3 const newRange = cell.offset(1, 1, 2);
매개변수
이름 | 유형 | 설명 |
---|---|---|
row | Integer | 범위의 왼쪽 상단 셀에서 아래로 이동한 행 수입니다. 음수 값은 범위의 왼쪽 상단 셀에서 위로 이동한 행 수를 나타냅니다. |
column | Integer | 범위의 왼쪽 상단 셀에서 오른쪽으로 떨어진 열 수입니다. 음수 값은 범위의 왼쪽 상단 셀에서 왼쪽으로 떨어진 열 수를 나타냅니다. |
num | Integer | 새 범위의 높이(행 수)입니다. |
리턴
Range
- 이 범위(연결용)
offset(rowOffset, columnOffset, numRows, numColumns)
현재 범위와 관련이 있고, 왼쪽 상단 점이 현재 범위에서 지정된 행과 열만큼 오프셋되어 있으며, 지정된 높이와 너비(셀)를 갖는 새 범위를 반환합니다.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; const cell = sheet.getRange('A1'); // newCell references B2:C3 const newRange = cell.offset(1, 1, 2, 2);
매개변수
이름 | 유형 | 설명 |
---|---|---|
row | Integer | 범위의 왼쪽 상단 셀에서 아래로 이동한 행 수입니다. 음수 값은 범위의 왼쪽 상단 셀에서 위로 이동한 행 수를 나타냅니다. |
column | Integer | 범위의 왼쪽 상단 셀에서 오른쪽으로 떨어진 열 수입니다. 음수 값은 범위의 왼쪽 상단 셀에서 왼쪽으로 떨어진 열 수를 나타냅니다. |
num | Integer | 새 범위의 높이(행 수)입니다. |
num | Integer | 새 범위의 열 너비입니다. |
리턴
Range
- 이 범위(연결용)
protect()
권한이 있는 사용자를 제외한 사용자가 범위를 수정하지 못하도록 보호할 수 있는 객체를 만듭니다. 스크립트가 실제로 범위의 편집자 목록을 변경할 때까지 (Protection.removeEditor(emailAddress)
, Protection.removeEditor(user)
, Protection.removeEditors(emailAddresses)
, Protection.addEditor(emailAddress)
, Protection.addEditor(user)
, Protection.addEditors(emailAddresses)
를 호출하거나 Protection.setDomainEdit(editable)
의 새 값을 설정) 권한은 스프레드시트 자체의 권한을 반영하므로 범위가 보호되지 않은 상태로 유지됩니다. 범위가 이미 보호되어 있는 경우 이 메서드는 기존 범위와 겹치는 새 보호 범위를 만듭니다. 셀이 여러 보호 범위로 보호되고 그중 하나라도 특정 사용자가 셀을 수정하지 못하도록 하는 경우 해당 사용자는 셀을 수정할 수 없습니다.
// Protect range A1:B10, then remove all other users from the list of editors. const ss = SpreadsheetApp.getActive(); const range = ss.getRange('A1:B10'); const protection = range.protect().setDescription('Sample protected range'); // Ensure the current user is an editor before removing others. Otherwise, if // the user's edit permission comes from a group, the script throws an exception // upon removing the group. const me = Session.getEffectiveUser(); protection.addEditor(me); protection.removeEditors(protection.getEditors()); if (protection.canDomainEdit()) { protection.setDomainEdit(false); }
리턴
Protection
- 보호 설정을 나타내는 객체입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
randomize()
지정된 범위의 행 순서를 무작위로 지정합니다.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; const range = sheet.getRange('A1:C7'); // Randomizes the range range.randomize();
리턴
Range
- 이 범위(연결용)
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
remove Checkboxes()
범위에서 모든 체크박스를 삭제합니다. 각 셀의 데이터 유효성 검사를 지우고, 셀에 선택된 값 또는 선택되지 않은 값이 포함된 경우 해당 값도 지웁니다.
const range = SpreadsheetApp.getActive().getRange('A1:B10'); // Inserts checkboxes and sets each cell value to 'no' in the range A1:B10. range.insertCheckboxes('yes', 'no'); const range1 = SpreadsheetApp.getActive().getRange('A1'); range1.setValue('yes'); // Removes the checkbox data validation in cell A1 and clears its value. range1.removeCheckboxes(); const range2 = SpreadsheetApp.getActive().getRange('A2'); range2.setValue('random'); // Removes the checkbox data validation in cell A2 but does not clear its value. range2.removeCheckboxes();
리턴
Range
- 이 범위(연결용)
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
remove Duplicates()
이 범위 내에서 이전 행의 값과 중복되는 값이 포함된 행을 삭제합니다. 값은 동일하지만 대소문자, 형식, 수식이 다른 행도 중복으로 간주됩니다. 이 메서드는 뷰에서 숨겨진 중복 행도 삭제합니다 (예: 필터로 인해). 이 범위를 벗어나는 콘텐츠는 삭제되지 않습니다.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; const range = sheet.getRange('B1:D7'); // Remove duplicate rows in the range. range.removeDuplicates();
리턴
Range
- 중복 항목을 삭제한 후의 결과 범위입니다. 범위의 크기는 삭제된 행마다 한 행씩 줄어듭니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
remove Duplicates(columnsToCompare)
이 범위 내에서 지정된 열의 값이 이전 행의 값과 중복되는 행을 삭제합니다. 값은 동일하지만 대소문자, 형식, 수식이 다른 행도 중복으로 간주됩니다. 이 메서드는 뷰에서 숨겨진 중복 행도 삭제합니다 (예: 필터로 인해). 이 범위를 벗어나는 콘텐츠는 삭제되지 않습니다.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; const range = sheet.getRange('B1:D7'); // Remove rows which have duplicate values in column B. range.removeDuplicates([2]); // Remove rows which have duplicate values in both columns B and D. range.removeDuplicates([2, 4]);
매개변수
이름 | 유형 | 설명 |
---|---|---|
columns | Integer[] | 중복 값을 분석할 열입니다. 열이 제공되지 않으면 모든 열에서 중복이 분석됩니다. |
리턴
Range
- 중복 항목을 삭제한 후의 결과 범위입니다. 범위의 크기는 삭제된 행마다 한 행씩 줄어듭니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
set Background(color)
범위의 모든 셀의 배경색을 CSS 표기법 (예: '#ffffff'
또는 'white'
)으로 설정합니다.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; const range = sheet.getRange('B2:D5'); range.setBackground('red');
매개변수
이름 | 유형 | 설명 |
---|---|---|
color | String | CSS 표기법의 색상 코드 (예: '#ffffff' 또는 'white' ). null 값은 색상을 재설정합니다. |
리턴
Range
- 이 범위(연결용)
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
set Background Object(color)
범위의 모든 셀의 배경 색상을 설정합니다.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; const bgColor = SpreadsheetApp.newColor() .setThemeColor(SpreadsheetApp.ThemeColorType.BACKGROUND) .build(); const range = sheet.getRange('B2:D5'); range.setBackgroundObject(bgColor);
매개변수
이름 | 유형 | 설명 |
---|---|---|
color | Color | 설정할 배경색입니다. null 값을 사용하면 배경색이 재설정됩니다. |
리턴
Range
- 이 범위(연결용)
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
set Background Objects(color)
배경 색상의 직사각형 그리드를 설정합니다 (이 범위의 크기와 일치해야 함).
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; const colorAccent1 = SpreadsheetApp.newColor() .setThemeColor(SpreadsheetApp.ThemeColorType.ACCENT1) .build(); const colorAccent2 = SpreadsheetApp.newColor() .setThemeColor(SpreadsheetApp.ThemeColorType.ACCENT2) .build(); const colorAccent3 = SpreadsheetApp.newColor() .setThemeColor(SpreadsheetApp.ThemeColorType.ACCENT3) .build(); const colorAccent4 = SpreadsheetApp.newColor() .setThemeColor(SpreadsheetApp.ThemeColorType.ACCENT4) .build(); const colors = [ [colorAccent1, colorAccent2], [colorAccent3, colorAccent4], ]; const cell = sheet.getRange('B5:C6'); cell.setBackgroundObjects(colors);
매개변수
이름 | 유형 | 설명 |
---|---|---|
color | Color[][] | 색상의 2차원 배열입니다. null 값은 색상을 재설정합니다. |
리턴
Range
- 이 범위(연결용)
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
set Background RGB(red, green, blue)
RGB 값 (0~255 사이의 정수)을 사용하여 배경을 지정된 색상으로 설정합니다.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; const cell = sheet.getRange('B2'); // Sets the background to white cell.setBackgroundRGB(255, 255, 255); // Sets the background to red cell.setBackgroundRGB(255, 0, 0);
매개변수
이름 | 유형 | 설명 |
---|---|---|
red | Integer | RGB 표기법의 빨간색 값입니다. |
green | Integer | RGB 표기법의 녹색 값입니다. |
blue | Integer | RGB 표기법의 파란색 값입니다. |
리턴
Range
- 이 범위(연결용)
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
set Backgrounds(color)
배경 색상의 직사각형 그리드를 설정합니다 (이 범위의 크기와 일치해야 함). 색상은 CSS 표기법 (예: '#ffffff'
또는 'white'
)으로 표시됩니다.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; const colors = [ ['red', 'white', 'blue'], ['#FF0000', '#FFFFFF', '#0000FF'], // These are the hex equivalents ]; const cell = sheet.getRange('B5:D6'); cell.setBackgrounds(colors);
매개변수
이름 | 유형 | 설명 |
---|---|---|
color | String[][] | CSS 표기법의 색상으로 구성된 2차원 배열 (예: '#ffffff' 또는 'white' ). null 값은 색상을 재설정합니다. |
리턴
Range
- 이 범위(연결용)
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
set Border(top, left, bottom, right, vertical, horizontal)
border 속성을 설정합니다. 유효한 값은 true
(켜짐), false
(꺼짐), null
(변경 없음)입니다.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; const cell = sheet.getRange('B2'); // Sets borders on the top and bottom, but leaves the left and right unchanged cell.setBorder(true, null, true, null, false, false);
매개변수
이름 | 유형 | 설명 |
---|---|---|
top | Boolean | 테두리의 경우 true , 없음의 경우 false , 변경 없음의 경우 null |
left | Boolean | 테두리의 경우 true , 없음의 경우 false , 변경 없음의 경우 null |
bottom | Boolean | 테두리의 경우 true , 없음의 경우 false , 변경 없음의 경우 null |
right | Boolean | 테두리의 경우 true , 없음의 경우 false , 변경 없음의 경우 null |
vertical | Boolean | true (내부 세로 테두리), false (없음), null (변경 없음) |
horizontal | Boolean | 내부 가로 테두리의 경우 true , 없음의 경우 false , 변경 없음의 경우 null |
리턴
Range
- 이 범위(연결용)
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
set Border(top, left, bottom, right, vertical, horizontal, color, style)
색상 또는 스타일을 사용하여 테두리 속성을 설정합니다. 유효한 값은 true
(켜짐), false
(꺼짐), null
(변경 없음)입니다. 색상의 경우 CSS 표기법 (예: '#ffffff'
또는 'white'
)을 사용합니다.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; const cell = sheet.getRange('B2'); // Sets borders on the top and bottom, but leaves the left and right unchanged // Also sets the color to "red", and the border to "DASHED". cell.setBorder( true, null, true, null, false, false, 'red', SpreadsheetApp.BorderStyle.DASHED, );
매개변수
이름 | 유형 | 설명 |
---|---|---|
top | Boolean | 테두리의 경우 true , 없음의 경우 false , 변경 없음의 경우 null |
left | Boolean | 테두리의 경우 true , 없음의 경우 false , 변경 없음의 경우 null |
bottom | Boolean | 테두리의 경우 true , 없음의 경우 false , 변경 없음의 경우 null |
right | Boolean | 테두리의 경우 true , 없음의 경우 false , 변경 없음의 경우 null |
vertical | Boolean | true (내부 세로 테두리), false (없음), null (변경 없음) |
horizontal | Boolean | 내부 가로 테두리의 경우 true , 없음의 경우 false , 변경 없음의 경우 null |
color | String | CSS 표기법의 색상 (예: '#ffffff' 또는 'white' ), 기본 색상 (검은색)의 경우 null |
style | Border | 테두리 스타일입니다. 기본 스타일 (실선)은 null 입니다. |
리턴
Range
- 이 범위(연결용)
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
set Data Validation(rule)
범위의 모든 셀에 하나의 데이터 유효성 검사 규칙을 설정합니다.
// Set the data validation rule for cell A1 to require a value from B1:B10. const cell = SpreadsheetApp.getActive().getRange('A1'); const range = SpreadsheetApp.getActive().getRange('B1:B10'); const rule = SpreadsheetApp.newDataValidation().requireValueInRange(range).build(); cell.setDataValidation(rule);
매개변수
이름 | 유형 | 설명 |
---|---|---|
rule | Data | 설정할 데이터 유효성 검사 규칙 또는 데이터 유효성 검사를 삭제하려면 null 입니다. |
리턴
Range
- 이 범위(연결용)
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
set Data Validations(rules)
범위의 모든 셀에 대한 데이터 유효성 검사 규칙을 설정합니다. 이 메서드는 행별로, 열별로 색인이 지정된 2차원 데이터 유효성 검사 배열을 사용합니다. 배열 차원은 범위 차원과 일치해야 합니다.
// Set the data validation rules for Sheet1!A1:B5 to require a value from // Sheet2!A1:A10. const destinationRange = SpreadsheetApp.getActive().getSheetByName('Sheet1').getRange('A1:B5'); const sourceRange = SpreadsheetApp.getActive().getSheetByName('Sheet2').getRange('A1:A10'); const rule = SpreadsheetApp.newDataValidation().requireValueInRange(sourceRange).build(); const rules = destinationRange.getDataValidations(); for (let i = 0; i < rules.length; i++) { for (let j = 0; j < rules[i].length; j++) { rules[i][j] = rule; } } destinationRange.setDataValidations(rules);
매개변수
이름 | 유형 | 설명 |
---|---|---|
rules | Data | 설정할 데이터 검증 규칙의 2차원 배열입니다. null 값은 데이터 검증을 삭제합니다. |
리턴
Range
- 이 범위(연결용)
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
set Font Color(color)
CSS 표기법 (예: '#ffffff'
또는 'white'
)으로 글꼴 색상을 설정합니다.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; const cell = sheet.getRange('B2'); cell.setFontColor('red');
매개변수
이름 | 유형 | 설명 |
---|---|---|
color | String | CSS 표기법의 글꼴 색상 (예: '#ffffff' 또는 'white' ). null 값은 색상을 재설정합니다. |
리턴
Range
- 이 범위(연결용)
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
set Font Color Object(color)
지정된 범위의 글꼴 색상을 설정합니다.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; const color = SpreadsheetApp.newColor() .setThemeColor(SpreadsheetApp.ThemeColorType.TEXT) .build(); const cell = sheet.getRange('B2'); cell.setFontColor(color);
매개변수
이름 | 유형 | 설명 |
---|---|---|
color | Color | 설정할 글꼴 색상입니다. null 값을 사용하면 색상이 재설정됩니다. |
리턴
Range
- 이 범위(연결용)
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
set Font Color Objects(colors)
글꼴 색상의 직사각형 그리드를 설정합니다 (이 범위의 크기와 일치해야 함).
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; const colorAccent1 = SpreadsheetApp.newColor() .setThemeColor(SpreadsheetApp.ThemeColorType.ACCENT1) .build(); const colorAccent2 = SpreadsheetApp.newColor() .setThemeColor(SpreadsheetApp.ThemeColorType.ACCENT2) .build(); const colorAccent3 = SpreadsheetApp.newColor() .setThemeColor(SpreadsheetApp.ThemeColorType.ACCENT3) .build(); const colorAccent4 = SpreadsheetApp.newColor() .setThemeColor(SpreadsheetApp.ThemeColorType.ACCENT4) .build(); const colors = [ [colorAccent1, colorAccent2], [colorAccent3, colorAccent4], ]; const cell = sheet.getRange('B5:C6'); cell.setFontColorObjects(colors);
매개변수
이름 | 유형 | 설명 |
---|---|---|
colors | Color[][] | 색상의 2차원 배열입니다. null 값은 글꼴 색상을 재설정합니다. |
리턴
Range
- 이 범위(연결용)
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
set Font Colors(colors)
글꼴 색상의 직사각형 그리드를 설정합니다 (이 범위의 크기와 일치해야 함). 색상은 CSS 표기법 (예: '#ffffff'
또는 'white'
)으로 표시됩니다.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; const colors = [ ['red', 'white', 'blue'], ['#FF0000', '#FFFFFF', '#0000FF'], // These are the hex equivalents ]; const cell = sheet.getRange('B5:D6'); cell.setFontColors(colors);
매개변수
이름 | 유형 | 설명 |
---|---|---|
colors | Object[][] | CSS 표기법의 색상으로 구성된 2차원 배열 (예: '#ffffff' 또는 'white' ). null 값은 색상을 재설정합니다. |
리턴
Range
- 이 범위(연결용)
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
set Font Families(fontFamilies)
글꼴 모음의 직사각형 그리드를 설정합니다 (이 범위의 크기와 일치해야 함). 글꼴 패밀리의 예로는 'Arial' 또는 'Helvetica'가 있습니다.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; const fonts = [ ['Arial', 'Helvetica', 'Verdana'], ['Courier New', 'Arial', 'Helvetica'], ]; const cell = sheet.getRange('B2:D3'); cell.setFontFamilies(fonts);
매개변수
이름 | 유형 | 설명 |
---|---|---|
font | Object[][] | 글꼴 모음의 2차원 배열입니다. null 값은 글꼴 모음을 재설정합니다. |
리턴
Range
- 이 범위(연결용)
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
set Font Family(fontFamily)
'Arial' 또는 'Helvetica'와 같은 글꼴 모음을 설정합니다.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; const cell = sheet.getRange('B2'); cell.setFontFamily('Helvetica');
매개변수
이름 | 유형 | 설명 |
---|---|---|
font | String | 설정할 글꼴 모음입니다. null 값을 사용하면 글꼴 모음이 재설정됩니다. |
리턴
Range
- 이 범위(연결용)
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
set Font Line(fontLine)
지정된 범위 ('underline'
, 'line-through'
또는 'none'
)의 글꼴 선 스타일을 설정합니다.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; const cell = sheet.getRange('B2'); cell.setFontLine('line-through');
매개변수
이름 | 유형 | 설명 |
---|---|---|
font | String | 글꼴 선 스타일입니다. 'underline' , 'line-through' 또는 'none' 일 수 있습니다. null 값은 글꼴 선 스타일을 재설정합니다. |
리턴
Range
- 이 범위(연결용)
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
set Font Lines(fontLines)
선 스타일의 직사각형 그리드를 설정합니다 (이 범위의 크기와 일치해야 함).
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; // The size of the two-dimensional array must match the size of the range. const fontLines = [['underline', 'line-through', 'none']]; const range = sheet.getRange('B2:D2'); range.setFontLines(fontLines);
매개변수
이름 | 유형 | 설명 |
---|---|---|
font | Object[][] | 글꼴 선 스타일 ('underline' , 'line-through' 또는 'none' )의 2차원 배열입니다. null 값은 글꼴 선 스타일을 재설정합니다. |
리턴
Range
- 이 범위(연결용)
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
set Font Size(size)
글꼴 크기를 설정합니다. 크기는 사용할 포인트 크기입니다.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; const cell = sheet.getRange('B2'); cell.setFontSize(20);
매개변수
이름 | 유형 | 설명 |
---|---|---|
size | Integer | 포인트 크기의 글꼴 크기입니다. |
리턴
Range
- 이 범위(연결용)
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
set Font Sizes(sizes)
글꼴 크기의 직사각형 그리드를 설정합니다 (이 범위의 크기와 일치해야 함). 크기는 포인트 단위입니다.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; // The size of the two-dimensional array must match the size of the range. const fontSizes = [[16, 20, 24]]; const range = sheet.getRange('B2:D2'); range.setFontSizes(fontSizes);
매개변수
이름 | 유형 | 설명 |
---|---|---|
sizes | Object[][] | 크기의 2차원 배열입니다. |
리턴
Range
- 이 범위(연결용)
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
set Font Style(fontStyle)
지정된 범위 ('italic'
또는 'normal'
)의 글꼴 스타일을 설정합니다.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; const cell = sheet.getRange('B2'); cell.setFontStyle('italic');
매개변수
이름 | 유형 | 설명 |
---|---|---|
font | String | 글꼴 스타일('italic' 또는 'normal' ). null 값은 글꼴 스타일을 재설정합니다. |
리턴
Range
- 이 범위(연결용)
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
set Font Styles(fontStyles)
글꼴 스타일의 직사각형 그리드를 설정합니다 (이 범위의 크기와 일치해야 함).
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; // The size of the two-dimensional array must match the size of the range. const fontStyles = [['italic', 'normal']]; const range = sheet.getRange('B2:C2'); range.setFontStyles(fontStyles);
매개변수
이름 | 유형 | 설명 |
---|---|---|
font | Object[][] | 글꼴 스타일의 2차원 배열('italic' 또는 'normal' ); null 값은 글꼴 스타일을 재설정합니다. |
리턴
Range
- 이 범위(연결용)
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
set Font Weight(fontWeight)
지정된 범위의 글꼴 두께를 설정합니다 (normal/bold).
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; const cell = sheet.getRange('B2'); cell.setFontWeight('bold');
매개변수
이름 | 유형 | 설명 |
---|---|---|
font | String | 글꼴 두께('bold' 또는 'normal' )입니다. null 값은 글꼴 두께를 재설정합니다. |
리턴
Range
- 이 범위(연결용)
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
set Font Weights(fontWeights)
글꼴 두께의 직사각형 그리드를 설정합니다 (이 범위의 크기와 일치해야 함). 글꼴 두께의 예는 'bold'입니다.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; // The size of the two-dimensional array must match the size of the range. const fontStyles = [['bold', 'bold', 'normal']]; const range = sheet.getRange('B2:D2'); range.setFontWeights(fontStyles);
매개변수
이름 | 유형 | 설명 |
---|---|---|
font | Object[][] | 글꼴 두께의 2차원 배열('bold' 또는 'normal' ); null 값은 글꼴 두께를 재설정합니다. |
리턴
Range
- 이 범위(연결용)
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
set Formula(formula)
이 범위의 수식을 업데이트합니다. 제공된 수식은 A1 표기법이어야 합니다.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; const cell = sheet.getRange('B5'); cell.setFormula('=SUM(B3:B4)');
매개변수
이름 | 유형 | 설명 |
---|---|---|
formula | String | 셀에 설정할 수식을 나타내는 문자열입니다. |
리턴
Range
- 이 범위(연결용)
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
set Formula R1C1(formula)
이 범위의 수식을 업데이트합니다. 제공된 수식은 R1C1 표기법이어야 합니다.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; const cell = sheet.getRange('B5'); // This sets the formula to be the sum of the 3 rows above B5 cell.setFormulaR1C1('=SUM(R[-3]C[0]:R[-1]C[0])');
매개변수
이름 | 유형 | 설명 |
---|---|---|
formula | String | 문자열 수식입니다. |
리턴
Range
- 이 범위(연결용)
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
set Formulas(formulas)
수식의 직사각형 그리드를 설정합니다 (이 범위의 크기와 일치해야 함). 제공된 수식은 A1 표기법이어야 합니다. 이 메서드는 행별, 열별로 색인이 지정된 수식의 2차원 배열을 사용합니다. 배열 측정기준은 범위 측정기준과 일치해야 합니다.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; // This sets the formulas to be a row of sums, followed by a row of averages // right below. The size of the two-dimensional array must match the size of the // range. const formulas = [ ['=SUM(B2:B4)', '=SUM(C2:C4)', '=SUM(D2:D4)'], ['=AVERAGE(B2:B4)', '=AVERAGE(C2:C4)', '=AVERAGE(D2:D4)'], ]; const cell = sheet.getRange('B5:D6'); cell.setFormulas(formulas);
매개변수
이름 | 유형 | 설명 |
---|---|---|
formulas | String[][] | 수식의 2차원 문자열 배열입니다. |
리턴
Range
- 이 범위(연결용)
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
set Formulas R1C1(formulas)
수식의 직사각형 그리드를 설정합니다 (이 범위의 크기와 일치해야 함). 제공된 수식은 R1C1 표기법이어야 합니다.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; // This creates formulas for a row of sums, followed by a row of averages. const sumOfRowsAbove = '=SUM(R[-3]C[0]:R[-1]C[0])'; const averageOfRowsAbove = '=AVERAGE(R[-4]C[0]:R[-2]C[0])'; // The size of the two-dimensional array must match the size of the range. const formulas = [ [sumOfRowsAbove, sumOfRowsAbove, sumOfRowsAbove], [averageOfRowsAbove, averageOfRowsAbove, averageOfRowsAbove], ]; const cell = sheet.getRange('B5:D6'); // This sets the formula to be the sum of the 3 rows above B5. cell.setFormulasR1C1(formulas);
매개변수
이름 | 유형 | 설명 |
---|---|---|
formulas | String[][] | R1C1 형식의 수식으로 이루어진 2차원 배열입니다. |
리턴
Range
- 이 범위(연결용)
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
set Horizontal Alignment(alignment)
지정된 범위의 가로 (왼쪽에서 오른쪽) 정렬을 설정합니다 (왼쪽/중앙/오른쪽).
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; const cell = sheet.getRange('B2'); cell.setHorizontalAlignment('center');
매개변수
이름 | 유형 | 설명 |
---|---|---|
alignment | String | 정렬('left' , 'center' 또는 'normal' ); null 값은 정렬을 재설정합니다. |
리턴
Range
- 이 범위(연결용)
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
set Horizontal Alignments(alignments)
가로 정렬의 직사각형 그리드를 설정합니다. set
를 참고하세요.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; // The size of the two-dimensional array must match the size of the range. const horizontalAlignments = [['left', 'right', 'center']]; const range = sheet.getRange('B2:D2'); range.setHorizontalAlignments(horizontalAlignments);
매개변수
이름 | 유형 | 설명 |
---|---|---|
alignments | Object[][] | 정렬의 2차원 배열('left' , 'center' 또는 'normal' ); null 값은 정렬을 재설정합니다. |
리턴
Range
- 이 범위(연결용)
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
참고 항목
set Note(note)
메모를 지정된 값으로 설정합니다.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; const cell = sheet.getRange('B2'); cell.setNote('This is a note');
매개변수
이름 | 유형 | 설명 |
---|---|---|
note | String | 범위에 설정할 메모 값입니다. null 값은 메모를 삭제합니다. |
리턴
Range
- 이 범위(연결용)
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
set Notes(notes)
메모의 직사각형 그리드를 설정합니다 (이 범위의 크기와 일치해야 함).
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; // The size of the two-dimensional array must match the size of the range. const notes = [ ['it goes', 'like this', 'the fourth, the fifth'], ['the minor fall', 'and the', 'major lift'], ]; const cell = sheet.getRange('B2:D3'); cell.setNotes(notes);
매개변수
이름 | 유형 | 설명 |
---|---|---|
notes | Object[][] | 메모의 2차원 배열입니다. null 값을 사용하면 메모가 삭제됩니다. |
리턴
Range
- 이 범위(연결용)
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
참고 항목
set Number Format(numberFormat)
숫자 또는 날짜 형식을 지정된 형식 문자열로 설정합니다. 허용되는 형식 패턴은 Sheets API 문서에 설명되어 있습니다.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; const cell = sheet.getRange('B2'); // Always show 3 decimal points cell.setNumberFormat('0.000');
매개변수
이름 | 유형 | 설명 |
---|---|---|
number | String | 숫자 형식 문자열입니다. |
리턴
Range
- 이 범위(연결용)
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
set Number Formats(numberFormats)
숫자 또는 날짜 형식의 직사각형 그리드를 설정합니다 (이 범위의 측정기준과 일치해야 함). 값은 Sheets API 문서에 설명된 형식 패턴 문자열입니다.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; // The size of the two-dimensional array must match the size of the range. const formats = [['0.000', '0,000,000', '$0.00']]; const range = sheet.getRange('B2:D2'); range.setNumberFormats(formats);
매개변수
이름 | 유형 | 설명 |
---|---|---|
number | Object[][] | 숫자 형식의 2차원 배열입니다. |
리턴
Range
- 이 범위(연결용)
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
set Rich Text Value(value)
범위의 셀에 서식 있는 텍스트 값을 설정합니다.
// Sets all cells in range B2:D4 to have the text "Hello world", with "Hello" // bolded. const sheet = SpreadsheetApp.getActiveSheet(); const range = sheet.getRange('B2:D4'); const bold = SpreadsheetApp.newTextStyle().setBold(true).build(); const richText = SpreadsheetApp.newRichTextValue() .setText('Hello world') .setTextStyle(0, 5, bold) .build(); range.setRichTextValue(richText);
매개변수
이름 | 유형 | 설명 |
---|---|---|
value | Rich | 원하는 서식 있는 텍스트 값입니다. |
리턴
Range
- 이 범위(연결용)
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
set Rich Text Values(values)
서식 있는 텍스트 값의 직사각형 그리드를 설정합니다.
// Sets the cells in range A1:A2 to have Rich Text values. const sheet = SpreadsheetApp.getActiveSheet(); const range = sheet.getRange('A1:A2'); const bold = SpreadsheetApp.newTextStyle().setBold(true).build(); const italic = SpreadsheetApp.newTextStyle().setItalic(true).build(); const richTextA1 = SpreadsheetApp.newRichTextValue() .setText('This cell is bold') .setTextStyle(bold) .build(); const richTextA2 = SpreadsheetApp.newRichTextValue() .setText('bold words, italic words') .setTextStyle(0, 11, bold) .setTextStyle(12, 24, italic) .build(); range.setRichTextValues([[richTextA1], [richTextA2]]);
매개변수
이름 | 유형 | 설명 |
---|---|---|
values | Rich | 원하는 서식 있는 텍스트 값입니다. |
리턴
Range
- 이 범위(연결용)
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
set Show Hyperlink(showHyperlink)
범위에 하이퍼링크를 표시할지 여부를 설정합니다.
// 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 Sheet1 by its name. const sheet = ss.getSheetByName('Sheet1'); // Gets cell A30 and sets its hyperlink value. const range = sheet.getRange('A30'); range.setValue('https://www.example.com'); // Sets cell A30 to show hyperlinks. range.setShowHyperlink(true);
매개변수
이름 | 유형 | 설명 |
---|---|---|
show | Boolean | 하이퍼링크를 표시할지 여부입니다. |
리턴
Range
- 이 범위(연결용)
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
set Text Direction(direction)
범위의 셀에 대한 텍스트 방향을 설정합니다. 지정된 방향이 null
인 경우 방향이 추론된 후 설정됩니다.
// Sets right-to-left text direction for the range. const sheet = SpreadsheetApp.getActiveSheet(); const range = sheet.getRange('B5:C6'); range.setTextDirection(SpreadsheetApp.TextDirection.RIGHT_TO_LEFT);
매개변수
이름 | 유형 | 설명 |
---|---|---|
direction | Text | 원하는 텍스트 방향입니다. null 인 경우 방향은 설정 전에 추론됩니다. |
리턴
Range
- 이 범위(연결용)
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
set Text Directions(directions)
텍스트 방향의 직사각형 그리드를 설정합니다. 지정된 방향이 null
인 경우 방향이 추론된 후 설정됩니다.
// Copies all of the text directions from range A1:B2 over to range C5:D6. const sheet = SpreadsheetApp.getActiveSheet(); const range1 = sheet.getRange('A1:B2'); const range2 = sheet.getRange('C5:D6'); range2.setTextRotations(range1.getTextDirections());
매개변수
이름 | 유형 | 설명 |
---|---|---|
directions | Text | 원하는 텍스트 방향입니다. 지정된 방향이 null 인 경우 설정 전에 추론됩니다. |
리턴
Range
- 이 범위(연결용)
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
set Text Rotation(degrees)
범위의 셀에 대한 텍스트 회전 설정을 지정합니다. 입력은 표준 텍스트 방향과 원하는 방향 사이의 각도에 해당합니다. 0을 입력하면 텍스트가 표준 방향으로 설정됩니다.
왼쪽에서 오른쪽으로 텍스트 방향의 경우 양수 각도는 시계 반대 방향이고 오른쪽에서 왼쪽으로 텍스트 방향의 경우 시계 방향입니다.
// Sets all cell's in range B2:D4 to have text rotated up 45 degrees. const sheet = SpreadsheetApp.getActiveSheet(); const range = sheet.getRange('B2:D4'); range.setTextRotation(45);
매개변수
이름 | 유형 | 설명 |
---|---|---|
degrees | Integer | 표준 방향과 원하는 방향 사이의 원하는 각도입니다. 왼쪽에서 오른쪽으로 쓰는 텍스트의 경우 양수 각도는 시계 반대 방향입니다. |
리턴
Range
- 이 범위(연결용)
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
set Text Rotation(rotation)
범위의 셀에 대한 텍스트 회전 설정을 지정합니다.
// Sets all cell's in range B2:D4 to have the same text rotation settings as // cell A1. const sheet = SpreadsheetApp.getActiveSheet(); const rotation = sheet.getRange('A1').getTextRotation(); sheet.getRange('B2:D4').setTextRotation(rotation);
매개변수
이름 | 유형 | 설명 |
---|---|---|
rotation | Text | 원하는 텍스트 회전 설정입니다. |
리턴
Range
- 이 범위(연결용)
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
set Text Rotations(rotations)
텍스트 회전의 직사각형 그리드를 설정합니다.
// Copies all of the text rotations from range A1:B2 over to range C5:D6. const sheet = SpreadsheetApp.getActiveSheet(); const range1 = sheet.getRange('A1:B2'); const range2 = sheet.getRange('C5:D6'); range2.setTextRotations(range1.getTextRotations());
매개변수
이름 | 유형 | 설명 |
---|---|---|
rotations | Text | 원하는 텍스트 회전 설정입니다. |
리턴
Range
- 이 범위(연결용)
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
set Text Style(style)
범위의 셀에 대한 텍스트 스타일을 설정합니다.
// Sets the cells in range C5:D6 to have underlined size 15 font. const sheet = SpreadsheetApp.getActiveSheet(); const range = sheet.getRange('C5:D6'); const style = SpreadsheetApp.newTextStyle().setFontSize(15).setUnderline(true).build(); range.setTextStyle(style);
매개변수
이름 | 유형 | 설명 |
---|---|---|
style | Text | 원하는 텍스트 스타일입니다. |
리턴
Range
- 이 범위(연결용)
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
set Text Styles(styles)
텍스트 스타일의 직사각형 그리드를 설정합니다.
// Sets text styles for cells in range A1:B2 const sheet = SpreadsheetApp.getActiveSheet(); const range = sheet.getRange('A1:B2'); const bold = SpreadsheetApp.newTextStyle().setBold(true).build(); const otherStyle = SpreadsheetApp.newTextStyle() .setBold(true) .setUnderline(true) .setItalic(true) .setForegroundColor('#335522') .setFontSize(44) .build(); range.setTextStyles([ [bold, otherStyle], [otherStyle, bold], ]);
매개변수
이름 | 유형 | 설명 |
---|---|---|
styles | Text | 원하는 텍스트 스타일입니다. |
리턴
Range
- 이 범위(연결용)
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
set Value(value)
범위의 값을 설정합니다. 값은 숫자, 문자열, 불리언 또는 날짜일 수 있습니다. '='
로 시작하면 수식으로 해석됩니다.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; const cell = sheet.getRange('B2'); cell.setValue(100);
매개변수
이름 | 유형 | 설명 |
---|---|---|
value | Object | 범위의 값입니다. |
리턴
Range
- 이 범위(연결용)
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
set Values(values)
값의 직사각형 그리드를 설정합니다 (이 범위의 차원과 일치해야 함). 값이 =
로 시작하면 수식으로 해석됩니다.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; // The size of the two-dimensional array must match the size of the range. const values = [['2.000', '1,000,000', '$2.99']]; const range = sheet.getRange('B2:D2'); range.setValues(values);
매개변수
이름 | 유형 | 설명 |
---|---|---|
values | Object[][] | 값의 2차원 배열입니다. |
리턴
Range
- 이 범위(연결용)
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
set Vertical Alignment(alignment)
지정된 범위의 세로 (상단에서 하단) 정렬을 설정합니다 (상단/중간/하단).
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; const cell = sheet.getRange('B2'); cell.setVerticalAlignment('middle');
매개변수
이름 | 유형 | 설명 |
---|---|---|
alignment | String | 정렬('top' , 'middle' 또는 'bottom' ); null 값은 정렬을 재설정합니다. |
리턴
Range
- 이 범위(연결용)
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
set Vertical Alignments(alignments)
세로 정렬의 직사각형 그리드를 설정합니다 (이 범위의 크기와 일치해야 함).
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; // The size of the two-dimensional array must match the size of the range. const alignments = [['top', 'middle', 'bottom']]; const range = sheet.getRange('B2:D2'); range.setVerticalAlignments(alignments);
매개변수
이름 | 유형 | 설명 |
---|---|---|
alignments | Object[][] | 정렬의 2차원 배열('top' , 'middle' 또는 'bottom' ); null 값은 정렬을 재설정합니다. |
리턴
Range
- 이 범위(연결용)
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
참고 항목
set Vertical Text(isVertical)
범위 내 셀의 텍스트를 스택할지 여부를 설정합니다. 텍스트가 세로로 쌓여 있으면 각도 텍스트 회전 설정이 무시됩니다.
// Sets all cell's in range B2:D4 to have vertically stacked text. const sheet = SpreadsheetApp.getActiveSheet(); const range = sheet.getRange('B2:D4'); range.setVerticalText(true);
매개변수
이름 | 유형 | 설명 |
---|---|---|
is | Boolean | 텍스트를 스택할지 여부입니다. |
리턴
Range
- 이 범위(연결용)
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
set Wrap(isWrapEnabled)
지정된 범위의 셀 줄바꿈을 설정합니다.
줄바꿈이 사용 설정된 셀 (기본값)은 전체 콘텐츠를 표시하도록 크기가 조정됩니다. 텍스트 줄바꿈이 사용 중지된 셀은 크기를 조정하거나 여러 줄로 표시되지 않고 셀에 최대한 많이 표시됩니다.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; const cell = sheet.getRange('B2'); cell.setWrap(true);
매개변수
이름 | 유형 | 설명 |
---|---|---|
is | Boolean | 텍스트를 줄바꿈할지 여부입니다. |
리턴
Range
- 이 범위(연결용)
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
set Wrap Strategies(strategies)
래핑 전략의 직사각형 그리드를 설정합니다.
// Copies all of the wrap strategies from range A1:B2 over to range C5:D6. const sheet = SpreadsheetApp.getActiveSheet(); const range1 = sheet.getRange('A1:B2'); const range2 = sheet.getRange('C5:D6'); range2.setWrapStrategies(range1.getWrapStrategies());
매개변수
이름 | 유형 | 설명 |
---|---|---|
strategies | Wrap | 원하는 래핑 전략입니다. |
리턴
Range
- 이 범위(연결용)
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
set Wrap Strategy(strategy)
범위의 셀에 대한 텍스트 줄바꿈 전략을 설정합니다.
// Sets all cells in range B2:D4 to use the clip wrap strategy. const sheet = SpreadsheetApp.getActiveSheet(); const range = sheet.getRange('B2:D4'); range.setWrapStrategy(SpreadsheetApp.WrapStrategy.CLIP);
매개변수
이름 | 유형 | 설명 |
---|---|---|
strategy | Wrap | 원하는 줄바꿈 전략입니다. |
리턴
Range
- 이 범위(연결용)
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
set Wraps(isWrapEnabled)
단어 줄 바꿈 정책의 직사각형 그리드를 설정합니다 (이 범위의 크기와 일치해야 함). 줄바꿈이 사용 설정된 셀 (기본값)은 전체 콘텐츠를 표시하도록 크기가 조정됩니다. 텍스트 줄바꿈이 사용 중지된 셀은 크기를 조정하거나 여러 줄로 표시되지 않고 셀에 최대한 많이 표시됩니다.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; // The size of the two-dimensional array must match the size of the range. const wraps = [[true, true, false]]; const range = sheet.getRange('B2:D2'); range.setWraps(wraps);
매개변수
이름 | 유형 | 설명 |
---|---|---|
is | Object[][] | 셀의 텍스트를 래핑할지 여부를 결정하는 래핑 변수의 2차원 배열입니다. |
리턴
Range
- 이 범위(연결용)
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
참고 항목
shift Column Group Depth(delta)
범위의 열 그룹화 깊이를 지정된 양만큼 변경합니다.
이렇게 하면 범위와 교차하는 그룹이 생성, 수정 또는 삭제됩니다. 양수 델타의 경우 그룹이 생성되거나 수정되고, 음수 델타의 경우 그룹이 삭제되거나 수정됩니다.
그룹 깊이를 0 미만 또는 8 초과로 줄이면 아무런 영향을 미치지 않습니다.
column group control position
이 BEFORE
인 경우 첫 번째 행의 깊이를 이동하려고 하면 오류가 발생합니다.
const sheet = SpreadsheetApp.getActiveSpreadsheet().getSheets()[0]; const range = sheet.getActiveRange(); // The column grouping depth is increased by 1. range.shiftColumnGroupDepth(1); // The column grouping depth is decreased by 1. range.shiftColumnGroupDepth(-1);
매개변수
이름 | 유형 | 설명 |
---|---|---|
delta | Integer | 이 범위의 열 그룹 깊이를 변경할 양입니다. |
리턴
Range
- 이 범위(연결용)
생성 값
Error
- 제어 위치가 Group
일 때 첫 번째 열의 깊이를 이동하려고 할 때
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
shift Row Group Depth(delta)
범위의 행 그룹화 깊이를 지정된 양만큼 변경합니다.
이렇게 하면 범위와 교차하는 그룹이 생성, 수정 또는 삭제됩니다. 양수 델타의 경우 그룹이 생성되거나 수정되고, 음수 델타의 경우 그룹이 삭제되거나 수정됩니다.
그룹 깊이를 0 미만 또는 8 초과로 줄이면 아무런 영향을 미치지 않습니다.
row group control position
이 BEFORE
인 경우 첫 번째 행의 깊이를 이동하려고 하면 오류가 발생합니다.
const sheet = SpreadsheetApp.getActiveSpreadsheet().getSheets()[0]; const range = sheet.getActiveRange(); // The row grouping depth is increased by 1. range.shiftRowGroupDepth(1); // The row grouping depth is decreased by 1. range.shiftRowGroupDepth(-1);
매개변수
이름 | 유형 | 설명 |
---|---|---|
delta | Integer | 이 범위의 행 그룹 깊이를 변경할 양입니다. |
리턴
Range
- 이 범위(연결용)
생성 값
Error
- 제어 위치가 Group
일 때 첫 번째 행의 깊이를 이동하려고 할 때
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
sort(sortSpecObj)
지정된 범위의 셀을 지정된 열과 순서에 따라 정렬합니다.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; const range = sheet.getRange('A1:C7'); // Sorts by the values in the first column (A) range.sort(1); // Sorts by the values in the second column (B) range.sort(2); // Sorts descending by column B range.sort({column: 2, ascending: false}); // Sorts descending by column B, then ascending by column A // Note the use of an array range.sort([ {column: 2, ascending: false}, {column: 1, ascending: true}, ]); // For rows that are sorted in ascending order, the "ascending" parameter is // optional, and just an integer with the column can be used instead. Note that // in general, keeping the sort specification consistent results in more // readable code. You can express the earlier sort as: range.sort([{column: 2, ascending: false}, 1]); // Alternatively, if you want all columns to be in ascending order, you can use // the following (this makes column 2 ascending) range.sort([2, 1]); // ... which is equivalent to range.sort([ {column: 2, ascending: true}, {column: 1, ascending: true}, ]);
매개변수
이름 | 유형 | 설명 |
---|---|---|
sort | Object | 정렬할 열입니다. |
리턴
Range
- 이 범위(연결용)
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
split Text To Columns()
자동으로 감지된 구분 기호를 기반으로 텍스트 열을 여러 열로 분할합니다.
// A1:A3 has the following values: // A B C // 1 |one,one,one | | | // 2 |two,two,two | | | // 3 |three,three,three| | | const range = SpreadsheetApp.getActiveSheet().getRange('A1:A3'); range.splitTextToColumns(); // Result after splitting the text to columns: // A B C // 1 |one |one |one | // 2 |two |two |two | // 3 |three |three |three |
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
split Text To Columns(delimiter)
지정된 문자열을 맞춤 구분 기호로 사용하여 텍스트 열을 여러 열로 분할합니다.
// A1:A3 has the following values: // A B C // 1 |one#one#one | | | // 2 |two#two#two | | | // 3 |three#three#three| | | const range = SpreadsheetApp.getActiveSheet().getRange('A1:A3'); range.splitTextToColumns('#'); // Result after splitting the text to columns: // A B C // 1 |one |one |one | // 2 |two |two |two | // 3 |three |three |three |
매개변수
이름 | 유형 | 설명 |
---|---|---|
delimiter | String | 분할할 맞춤 구분 기호입니다. |
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
split Text To Columns(delimiter)
지정된 구분 기호를 기준으로 텍스트 열을 여러 열로 분할합니다.
// A1:A3 has the following values: // A B C // 1 |one;one;one | | | // 2 |two;two;two | | | // 3 |three;three;three| | | const range = SpreadsheetApp.getActiveSheet().getRange('A1:A3'); range.splitTextToColumns(SpreadsheetApp.TextToColumnsDelimiter.SEMICOLON); // Result after splitting the text to columns: // A B C // 1 |one |one |one | // 2 |two |two |two | // 3 |three |three |three |
매개변수
이름 | 유형 | 설명 |
---|---|---|
delimiter | Text | 분할할 사전 설정된 구분 기호입니다. |
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
trim Whitespace()
이 범위의 모든 셀에서 공백, 탭, 줄바꿈과 같은 공백을 자릅니다. 각 셀 텍스트의 시작과 끝에 있는 모든 공백을 삭제하고 남아 있는 공백 문자의 모든 후속 항목을 단일 공백으로 줄입니다.
const sheet = SpreadsheetApp.getActiveSpreadsheet().getSheets()[0]; const range = sheet.getRange('A1:A4'); range.activate(); range.setValues([ ' preceding space', 'following space ', 'two middle spaces', ' =SUM(1,2)', ]); range.trimWhitespace(); const values = range.getValues(); // Values are ['preceding space', 'following space', 'two middle spaces', // '=SUM(1,2)']
리턴
Range
- 이 범위(연결용)
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
uncheck()
범위의 체크박스 상태를 '선택 해제됨'으로 변경합니다. 현재 구성된 선택됨 또는 선택 해제됨 값이 포함되지 않은 범위의 셀은 무시됩니다.
// Changes the state of cells which currently contain either the checked or // unchecked value configured in the range A1:B10 to 'unchecked'. const range = SpreadsheetApp.getActive().getRange('A1:B10'); range.uncheck();
리턴
Range
- 이 범위(연결용)
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets