const spread = new GC.Spread.Sheets.Workbook(document.getElementById('spreadContainer'));
spread.options.tabStripVisible = false;
const sheet = spread.getActiveSheet();
const headers = ['사원번호', '성명', '부서', '기본급', '국민연금(4.5%)', '건강보험(3.545%)', '고용보험(0.9%)', '공제합계', '실수령액'];
const colWidths = [80, 65, 68, 90, 102, 108, 90, 80, 85];
headers.forEach((h, c) => {
sheet.setValue(0, c, h);
sheet.getCell(0, c)
.backColor('#1565C0').foreColor('#FFFFFF')
.font('bold 11px sans-serif')
.hAlign(GC.Spread.Sheets.HorizontalAlign.center);
sheet.setColumnWidth(c, colWidths[c]);
});
sheet.setRowHeight(0, 38);
const employees = [
['E-001', '김민준', '개발팀', 4200000],
['E-002', '이서연', '영업팀', 3800000],
['E-003', '박지호', '인사팀', 3500000],
['E-004', '최유진', '개발팀', 5100000],
['E-005', '정수민', '마케팅', 4600000],
['E-006', '강현우', '재무팀', 4000000],
['E-007', '윤지아', '개발팀', 5500000],
['E-008', '임도현', '영업팀', 3600000],
['E-009', '오수진', '인사팀', 3900000],
['E-010', '신재원', '개발팀', 4800000],
];
employees.forEach(([id, name, dept, salary], r) => {
const row = r + 1;
sheet.setValue(row, 0, id);
sheet.setValue(row, 1, name);
sheet.setValue(row, 2, dept);
sheet.setValue(row, 3, salary);
// 4대보험 계산 함수 (2024년 기준 요율)
sheet.setFormula(row, 4, `=ROUND(D${row + 1}*0.045,0)`);
sheet.setFormula(row, 5, `=ROUND(D${row + 1}*0.03545,0)`);
sheet.setFormula(row, 6, `=ROUND(D${row + 1}*0.009,0)`);
sheet.setFormula(row, 7, `=SUM(E${row + 1}:G${row + 1})`);
sheet.setFormula(row, 8, `=D${row + 1}-H${row + 1}`);
const bg = r % 2 === 0 ? '#FFFFFF' : '#F8F9FA';
for (let c = 0; c < 9; c++) sheet.getCell(row, c).backColor(bg);
for (let c = 3; c < 9; c++) {
sheet.getCell(row, c)
.formatter('#,##0')
.hAlign(GC.Spread.Sheets.HorizontalAlign.right);
}
sheet.setRowHeight(row, 28);
});
// 합계 행
const sumRow = 11;
sheet.setValue(sumRow, 1, '합 계');
['D', 'E', 'F', 'G', 'H', 'I'].forEach((col, i) => {
sheet.setFormula(sumRow, 3 + i, `=SUM(${col}2:${col}11)`);
sheet.getCell(sumRow, 3 + i)
.font('bold 11px sans-serif')
.backColor('#E3F2FD')
.formatter('#,##0')
.hAlign(GC.Spread.Sheets.HorizontalAlign.right);
});
[0, 1, 2].forEach(c => sheet.getCell(sumRow, c).backColor('#E3F2FD').font('bold 11px sans-serif'));
sheet.setRowHeight(sumRow, 32);