// 특정 열 전체 잠금: C열(col 2) 전체
sheet.getRange(-1, 2, -1, 1).locked(true);
// 특정 행 전체 잠금: 2번째 행(row 1) 전체
sheet.getRange(1, -1, 1, -1).locked(true);
// 비밀번호 없이 보호 ↔ 비밀번호 포함 보호
sheet.options.isProtected = true; // 비밀번호 없음
sheet.protect('myPassword2026'); // 비밀번호 포함
// 비밀번호 확인 후 해제
if (sheet.hasPassword()) {
const success = sheet.unprotect(userInput);
if (!success) alert('비밀번호가 올바르지 않습니다.');
} else {
sheet.unprotect(); // 비밀번호 없이 해제
}
// 세부 보호 옵션 조합 (결재 완료 후 잠금 예시)
sheet.options.protectionOptions = {
allowSelectLockedCells: true, // 잠긴 셀 선택 허용 (읽기 가능)
allowSelectUnlockedCells: true,
allowSort: true, // 정렬은 허용
allowFilter: true, // 필터는 허용
allowResizeRows: false, // 행 높이 변경 금지
allowResizeColumns: false, // 열 너비 변경 금지
allowInsertRows: false, // 행 삽입 금지
allowDeleteRows: false // 행 삭제 금지
};