回复 3楼1594202459的帖子
首先,SpreadJSDesigner生成的js文件,假设名字是.(test.js).
下面代码展示了Link test.js 到html页面:
- $(“#ss”).wijspread();
- var spread = $(“#ss”).wijspread(“spread”)
- spread.fromJSON(test);
- var activeSheet = spread.getActiveSheet();
- //数据源
- var datasource = [
- { name: "Alice", age: 27, birthday: "1985/08/31", position: "PM" },
- { name: "Aimee", age: 28, birthday: "1984/07/31", position: "TL" },
- { name: "Charles", age: 29, birthday: "1983/03/31", position: "QC" },
- { name: "Fred", age: 30, birthday: "1982/02/20", position: "DL" },
- { name: "Angelia", age: 31, birthday: "1981/05/30", position: "QC" },
- { name: "Peter", age: 32, birthday: "1980/11/08", position: "QC" }
- ];
- var nameColInfo = { name: "name", displayName: "Name", size: 70 };
- var ageColInfo = { name: "age", displayName: "Age", size: 40, resizable: false };
- var birthdayColInfo = { name: "birthday", displayName: "Birthday",formatter:"d/M/yy", size: 120 };
- var positionColInfo = { name: "position", displayName: "Position", size: 50, visible: false };
- activeSheet.autoGenerateColumns = true;
- activeSheet.setDataSource(datasource);
- activeSheet.bindColumn(0, nameColInfo);
- activeSheet.bindColumn(1, ageColInfo);
- activeSheet.bindColumn(2, birthdayColInfo);
- activeSheet.bindColumn(3, positionColInfo);
复制代码
spread.fromJSON(test);//导入test.js到页面。
activeSheet.setDataSource(datasource);//设置数据源。
我们的产品文档Binding to Data里可以找到答案:
http://helpcentral.componentone. ... e.html#binding.html |