# v8: GemEgg 예실관리 - 조건부 서식 적용 ## 조건부 서식 설계 ### 1. 차이 (差異) 열 색상 코딩 | 조건 | 색상 | 의미 | |------|------|------| | 값 > 0 | 연한 초록색 (#b7e1cd) | 실적이 예산 초과 (긍정) | | 값 < 0 | 연한 빨간색 (#f4c7c3) | 실적이 예산 미달 (부정) | | 값 = 0 | 기본색 | 예산과 동일 | ### 2. 달성률 열 색상 코딩 | 조건 | 색상 | 의미 | |------|------|------| | 값 >= 100% | 연한 초록색 | 목표 달성 | | 값 >= 80% | 연한 노란색 | 목표 근접 | | 값 < 80% | 연한 빨간색 | 미달 | ## Google Sheets API 구현 ### 조건부 서식 규칙 추가 ```javascript async function applyConditionalFormatting(sheets, sheetId) { await sheets.spreadsheets.batchUpdate({ spreadsheetId: SPREADSHEET_ID, requestBody: { requests: [ // 차이 양수 (초록색) { addConditionalFormatRule: { rule: { ranges: [{ sheetId, startRowIndex: 5, endRowIndex: 40, startColumnIndex: 4, // E열 (차이) endColumnIndex: 50 }], booleanRule: { condition: { type: 'NUMBER_GREATER', values: [{ userEnteredValue: '0' }] }, format: { backgroundColor: { red: 0.72, green: 0.88, blue: 0.80 } } } }, index: 0 } }, // 차이 음수 (빨간색) { addConditionalFormatRule: { rule: { ranges: [{ sheetId, startRowIndex: 5, endRowIndex: 40, startColumnIndex: 4, endColumnIndex: 50 }], booleanRule: { condition: { type: 'NUMBER_LESS', values: [{ userEnteredValue: '0' }] }, format: { backgroundColor: { red: 0.96, green: 0.78, blue: 0.76 } } } }, index: 1 } }, // 달성률 100% 이상 (초록색) { addConditionalFormatRule: { rule: { ranges: [{ sheetId, startRowIndex: 5, endRowIndex: 40, startColumnIndex: 5, // F열 (달성률) endColumnIndex: 50 }], booleanRule: { condition: { type: 'NUMBER_GREATER_THAN_EQ', values: [{ userEnteredValue: '1' }] }, format: { backgroundColor: { red: 0.72, green: 0.88, blue: 0.80 } } } }, index: 2 } } ] } }); } ``` ## 숫자 서식 ### 통화 형식 ```javascript { repeatCell: { range: { sheetId, startRowIndex: 5, endRowIndex: 40, startColumnIndex: 2, endColumnIndex: 50 }, cell: { userEnteredFormat: { numberFormat: { type: 'NUMBER', pattern: '#,##0' } } }, fields: 'userEnteredFormat.numberFormat' } } ``` ### 백분율 형식 ```javascript { repeatCell: { range: { sheetId, startRowIndex: 5, endRowIndex: 40, startColumnIndex: 5, endColumnIndex: 6 }, // 달성률 열 cell: { userEnteredFormat: { numberFormat: { type: 'PERCENT', pattern: '0%' } } }, fields: 'userEnteredFormat.numberFormat' } } ``` ## 결과 미리보기 ``` ┌────────────────────────────────────────────────────┐ │ 項目 │ 予算 │ 実績 │ 差異 │ 率 │ ├───────────┼──────────┼──────────┼──────────┼──────┤ │ 売上高 │ 0 │1,267,940 │[초록] │ - │ │ 役員報酬 │ 0 │ 413,755 │[초록] │ - │ │ 営業損益 │ 0 │ -191,830 │[빨강] │ - │ └────────────────────────────────────────────────────┘ [초록] = 배경색 #b7e1cd [빨강] = 배경색 #f4c7c3 ``` ## 다음 단계 v9에서는: - Google Apps Script 자동화 - 트리거 설정 --- **작성일**: 2025-12-05 **상태**: 완료 **다음**: v9 - 자동화 및 트리거