JavaScript
const spread = new GC.Spread.Sheets.Workbook(document.getElementById('spreadContainer'));
const sheet = spread.getActiveSheet();
spread.options.tabStripVisible = false;
const headers = ['월', '매출(만원)', '전월 대비(%)'];
headers.forEach((h, c) => {
sheet.setValue(0, c, h);
sheet.getCell(0, c).backColor('#1565C0').foreColor('#fff').font('bold 12px sans-serif');
sheet.setColumnWidth(c, [60, 110, 110][c]);
});
const rows = [
['1월', 1250, 12.5],
['2월', 980, -21.6],
['3월', 1540, 57.1],
['4월', 320, -79.2],
['5월', 1680, 425.0],
];
rows.forEach((row, r) => {
row.forEach((val, c) => sheet.setValue(r + 1, c, val));
sheet.setRowHeight(r + 1, 28);
});
sheet.setRowHeight(0, 32);
// 모의 AI 분석 결과 (실제 구현에서는 LLM API 응답으로 대체)
const aiResults = [
{ row: 2, col: 1, text: '📉 AI: 2월 급감. 계절성 또는 경쟁사 프로모션 의심', color: '#FFF3E0' },
{ row: 4, col: 1, text: '⚠️ AI: 4월 이상치(-79.2%). 데이터 오류 또는 특이 사건 확인 필요', color: '#FFEBEE' },
{ row: 5, col: 1, text: '📈 AI: 5월 최고 매출. 프로모션 효과, 6월 유지 전략 권장', color: '#E8F5E9' },
];
document.getElementById('btnAddComments')?.addEventListener('click', () => {
aiResults.forEach(({ row, col, text, color }) => {
// 기존 메모 제거 후 새 메모 추가
sheet.comments.remove(row, col);
const comment = sheet.comments.add(row, col, text);
comment.backColor(color);
comment.autoSize(true);
comment.displayMode(GC.Spread.Sheets.Comments.DisplayMode.alwaysShown);
comment.width(240);
});
spread.repaint();
});