JavaScript
// 1단계: Workbook 초기화 (sheetCount:0 — TableSheet를 수동으로 추가)
const spread = new GC.Spread.Sheets.Workbook(
document.getElementById('spreadContainer'),
{ sheetCount: 0 }
);
// 2단계: DataManager에 데이터 테이블 등록
const dataManager = spread.dataManager();
const employeeTable = dataManager.addTable('employees', {
data: [
{ id: 1, name: '김민준', dept: '개발팀', position: '시니어', salary: 6500000 },
{ id: 2, name: '이서연', dept: '기획팀', position: '매니저', salary: 7200000 },
{ id: 3, name: '박지호', dept: '개발팀', position: '주니어', salary: 4800000 },
{ id: 4, name: '최유진', dept: '영업팀', position: '시니어', salary: 6100000 },
{ id: 5, name: '정수민', dept: '개발팀', position: '매니저', salary: 7500000 },
{ id: 6, name: '한지원', dept: '기획팀', position: '주니어', salary: 4500000 },
{ id: 7, name: '신동현', dept: '영업팀', position: '주니어', salary: 4600000 },
{ id: 8, name: '오수아', dept: '개발팀', position: '시니어', salary: 6800000 },
]
});
// 3단계: TableSheet 생성
const sheet = spread.addSheetTab(0, '인사 대장', GC.Spread.Sheets.SheetType.tableSheet);
// 4단계: View 정의 + 5단계: TableSheet에 바인딩
employeeTable.fetch().then(() => {
const view = employeeTable.addView('employeeView', [
{ value: 'id', caption: 'ID', width: 60 },
{ value: 'name', caption: '이름', width: 110 },
{ value: 'dept', caption: '부서', width: 100 },
{ value: 'position', caption: '직급', width: 90 },
{ value: 'salary', caption: '급여(원)', width: 130 },
]);
sheet.setDataView(view);
});