抱歉,刚才回复有误,SpreadJS提供toJSON和fromJSON方法,可以参考如下代码:- activeSheet.getCell(0,0).value(123);
- var jsonStr = null;
- //export
- jsonStr = JSON.stringify(spread.toJSON());
- //import
- spread.fromJSON(JSON.parse(jsonStr));
- alert(jsonStr);
- //alert(jsonStr[0]);
复制代码
另外,有关数据源绑定的问题,有如下示例:- 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);
复制代码
想起情况可以参见文档:http://helpcentral.componentone. ... e.html#binding.html |