...
使用 bindColumn 方法来绑定特定的列。
查看以下文章来获取更多信息:
- Binding Cells绑定单元格
- Using the 在数据绑定中使用 Spread.Sheets Designer Template with Cell Binding设计器模版
示例代码
以下代码使用 bindColumn 方法绑定了特定的列。
Code Block | ||||
---|---|---|---|---|
|
...
Copy Code
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); |
示例代码
以下代码使用 bindColumn 绑定了特定的列。
Code Block | ||||
---|---|---|---|---|
|
...
Copy Code
var test = |
...
[ {"Series0":2,"Series1":1}, |
...
{"Series0":4,"Series1":2}, |
...
{"Series0":3,"Series1":4} |
...
]; |
...
activeSheet.setDataSource(test); |
...
activeSheet.bindColumn(1,"Series0"); |
...
activeSheet.bindColumn(0,"Series1"); |
示例代码
以下代码使用 以下代码使用 setDataSource 将数据和工作表绑定在了一起。 将数据和工作表绑定在了一起。
Code Block | ||||
---|---|---|---|---|
|
...
Copy Code
var test = |
...
[ {"Series0":2,"Series1":1}, |
...
{"Series0":4,"Series1":2}, |
...
{"Series0":3,"Series1":4} |
...
]; |
...
activeSheet.setDataSource(test, true); |
...
//activeSheet.setDataSource(test); |
示例代码
以下代码示例了如何绑定到一个 JSON 格式的数据源。
Code Block | ||||
---|---|---|---|---|
|
...
Copy Code
var jasonArray = '{"phoneNumbers": [{"type": "home","number": "212 555-1234"},{"type": "fax","number": "646 555-4567"}]}'; |
...
var arr = JSON.parse(jasonArray); |
...
activeSheet.setDataSource(arr.phoneNumbers); |
另见更多信息
Binding Tables