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.getCell(0, c).value(h).backColor('#1565C0').foreColor('#ffffff').font('bold 12px sans-serif');
sheet.setColumnWidth(c, c === 0 ? 80 : 110);
});
sheet.setRowHeight(0, 36);
// 데이터 (일부 미달 점포 포함)
const rows = [
['강남점', 9200, 9.5, 3820, 108.2],
['홍대점', 7200, 5.9, 2910, 98.5],
['신촌점', 6100, 7.0, 2480, 93.2],
['부산점', 8100, 6.6, 3350, 102.4],
['대구점', 6700, 8.1, 2760, 88.7],
];
rows.forEach((row, r) => {
row.forEach((val, c) => sheet.setValue(r + 1, c, val));
sheet.setRowHeight(r + 1, 30);
if (r % 2 === 0) {
for (let c = 0; c < 5; c++) sheet.getCell(r + 1, c).backColor('#F5F9FF');
}
sheet.setFormatter(r + 1, 1, '#,##0');
sheet.setFormatter(r + 1, 2, '+0.0;-0.0');
sheet.setFormatter(r + 1, 3, '#,##0');
sheet.setFormatter(r + 1, 4, '0.0"%"');
});
const CF = GC.Spread.Sheets.ConditionalFormatting;
// 1. 색상 스케일 — 매출액 열 (낮을수록 빨강, 높을수록 녹색)
const scaleRule = new CF.ScaleRule();
scaleRule.ruleType(CF.RuleType.twoScaleRule);
scaleRule.ranges([new GC.Spread.Sheets.Range(1, 1, rows.length, 1)]);
scaleRule.minType(CF.ScaleValueType.lowestValue);
scaleRule.minColor('#EF9A9A');
scaleRule.maxType(CF.ScaleValueType.highestValue);
scaleRule.maxColor('#43A047');
sheet.conditionalFormats.addRule(scaleRule);
// 2. 데이터 바 — 전월比 열
const dbRule = new CF.DataBarRule(
CF.ScaleValueType.number, 0,
CF.ScaleValueType.number, 15,
'#42A5F5',
[new GC.Spread.Sheets.Range(1, 2, rows.length, 1)]
);
dbRule.showBorder(true);
dbRule.borderColor('#1976D2');
sheet.conditionalFormats.addRule(dbRule);
// 3. 아이콘 세트 — 달성률 열 (↑ 달성 / ↔ 보통 / ↓ 미달)
const iconRule = new CF.IconSetRule();
iconRule.ranges([new GC.Spread.Sheets.Range(1, 4, rows.length, 1)]);
iconRule.iconSetType(CF.IconSetType.threeArrowsColored);
sheet.conditionalFormats.addRule(iconRule);