const spread = new GC.Spread.Sheets.Workbook(document.getElementById('spreadContainer'));
spread.options.tabStripVisible = false;
const sheet = spread.getActiveSheet();
spread.suspendPaint();
const headers = ['공정명', '진행 상태', '진도율(%)'];
[150, 110, 110].forEach((w, c) => {
sheet.setColumnWidth(c, w);
sheet.setValue(0, c, headers[c]);
sheet.getCell(0, c).backColor('#455A64').foreColor('#FFFFFF').font('bold 12px sans-serif').hAlign(GC.Spread.Sheets.HorizontalAlign.center);
});
sheet.setRowHeight(0, 36);
const data = [
['원재료 투입', '완료', 100],
['절단 가공', '완료', 100],
['용접', '진행중', 65],
['도장', '지연', 30],
['품질 검사', '대기', 0],
];
data.forEach((row, r) => {
row.forEach((val, c) => {
sheet.setValue(r + 1, c, val);
sheet.getCell(r + 1, c).hAlign(GC.Spread.Sheets.HorizontalAlign.center).vAlign(GC.Spread.Sheets.VerticalAlign.center);
});
sheet.setRowHeight(r + 1, 32);
});
const CF = GC.Spread.Sheets.ConditionalFormatting;
const textOp = CF.TextComparisonOperators;
const statusRange = [new GC.Spread.Sheets.Range(1, 1, 5, 1)];
const doneStyle = new GC.Spread.Sheets.Style();
doneStyle.backColor = '#C8E6C9'; doneStyle.foreColor = '#1B5E20'; doneStyle.font = 'bold 11px sans-serif';
sheet.conditionalFormats.addSpecificTextRule(textOp.contains, '완료', doneStyle, statusRange);
const inProgStyle = new GC.Spread.Sheets.Style();
inProgStyle.backColor = '#BBDEFB'; inProgStyle.foreColor = '#0D47A1'; inProgStyle.font = 'bold 11px sans-serif';
sheet.conditionalFormats.addSpecificTextRule(textOp.contains, '진행중', inProgStyle, statusRange);
const delStyle = new GC.Spread.Sheets.Style();
delStyle.backColor = '#FFCDD2'; delStyle.foreColor = '#B71C1C'; delStyle.font = 'bold 11px sans-serif';
sheet.conditionalFormats.addSpecificTextRule(textOp.contains, '지연', delStyle, statusRange);
// 진도율 3단 색상 스케일: 0%(빨강) → 50%(노랑) → 100%(녹색)
const SVT = CF.ScaleValueType;
sheet.conditionalFormats.add3ScaleRule(
SVT.number, 0, '#FFCDD2',
SVT.number, 50, '#FFF9C4',
SVT.number, 100, '#C8E6C9',
[new GC.Spread.Sheets.Range(1, 2, 5, 1)]
);
spread.resumePaint();