JavaScript
const spread = new GC.Spread.Sheets.Workbook(document.getElementById('spreadContainer'));
const sheet = spread.getActiveSheet();
spread.options.tabStripVisible = false;
const CF = GC.Spread.Sheets.ConditionalFormatting;
const headers = ['행', '매출(만원)', '전월 대비(%)', 'AI 분류 점수'];
headers.forEach((h, c) => {
sheet.setValue(0, c, h);
sheet.getCell(0, c).backColor('#37474F').foreColor('#fff').font('bold 12px sans-serif');
sheet.setColumnWidth(c, [50, 110, 110, 110][c]);
});
const data = [
[1, 1250, 12.5, 85],
[2, 980, -21.6, 60],
[3, 1540, 57.1, 90],
[4, 320, -79.2, 15],
[5, 1680, 425.0, 45],
[6, 1420, -15.5, 72],
[7, 890, -37.3, 30],
];
data.forEach((row, r) => {
row.forEach((val, c) => sheet.setValue(r + 1, c, val));
sheet.setRowHeight(r + 1, 28);
});
sheet.setRowHeight(0, 32);
document.getElementById('btnHighlight')?.addEventListener('click', () => {
const scoreRange = [new GC.Spread.Sheets.Range(1, 3, 7, 1)];
// 이상값 (점수 < 40): 빨간 배경
const styleAnomaly = new GC.Spread.Sheets.Style();
styleAnomaly.backColor = '#FFCDD2';
styleAnomaly.foreColor = '#B71C1C';
sheet.conditionalFormats.addCellValueRule(
CF.ComparisonOperators.lessThan, 40, undefined, styleAnomaly, scoreRange
);
// 주의 (40 ≤ 점수 ≤ 69): 주황 배경
const styleWarn = new GC.Spread.Sheets.Style();
styleWarn.backColor = '#FFE0B2';
styleWarn.foreColor = '#E65100';
sheet.conditionalFormats.addCellValueRule(
CF.ComparisonOperators.between, 40, 69, styleWarn, scoreRange
);
// 정상 (점수 > 69): 초록 배경
const styleOk = new GC.Spread.Sheets.Style();
styleOk.backColor = '#C8E6C9';
styleOk.foreColor = '#1B5E20';
sheet.conditionalFormats.addCellValueRule(
CF.ComparisonOperators.greaterThan, 69, undefined, styleOk, scoreRange
);
spread.repaint();
});