const spread = new GC.Spread.Sheets.Workbook(document.getElementById('spreadContainer'));
const sheet = spread.getActiveSheet();
// 헤더 설정
const headers = ['프로젝트', '담당자', '목표(만원)', '실적(만원)', '달성률(%)'];
headers.forEach((h, c) => {
sheet.setValue(0, c, h);
sheet.getCell(0, c).backColor('#1565C0').foreColor('#ffffff').font('bold 12px sans-serif');
});
// 샘플 데이터
const data = [
['웹앱 리뉴얼', '김민준', 3000, 3150],
['ERP 연동', '이서연', 5000, 4200],
['모바일 앱', '박지호', 2000, 2100],
['대시보드 개발', '최유진', 4000, 3800],
['API 게이트웨이', '정수민', 1500, 1600],
];
data.forEach((row, r) => {
const [project, person, target, actual] = row;
const rate = Math.round((actual / target) * 100);
sheet.setValue(r + 1, 0, project);
sheet.setValue(r + 1, 1, person);
sheet.setValue(r + 1, 2, target);
sheet.setValue(r + 1, 3, actual);
sheet.setValue(r + 1, 4, rate);
});
// ✅ 조건부 서식 — addCellValueRule 올바른 패턴
const cf = sheet.conditionalFormats;
const styleGreen = new GC.Spread.Sheets.Style();
styleGreen.backColor = '#C8E6C9';
styleGreen.foreColor = '#2E7D32';
cf.addCellValueRule(
GC.Spread.Sheets.ConditionalFormatting.ComparisonOperators.greaterThanOrEqualsTo,
100, 0, styleGreen, [new GC.Spread.Sheets.Range(1, 4, 5, 1)]
);
const styleRed = new GC.Spread.Sheets.Style();
styleRed.backColor = '#FFCDD2';
styleRed.foreColor = '#C62828';
cf.addCellValueRule(
GC.Spread.Sheets.ConditionalFormatting.ComparisonOperators.lessThan,
85, 0, styleRed, [new GC.Spread.Sheets.Range(1, 4, 5, 1)]
);
[120, 80, 90, 90, 80].forEach((w, c) => sheet.setColumnWidth(c, w));
sheet.setRowHeight(0, 36);
spread.options.tabStripVisible = false;