使用designer设计器提前设备了一个模板绑定好了表格数据源。
然后显示的时候想在模板数据源位置显示表格数据。但是失败了。
以下是代码:
tabledata是designer设计器导出的包含表格数据源绑定的模板数据。
people 是需要加载的数据源。
- const workbookInitialized = (spread : any) =>{
- var tableData = {"version":"14.2.5","font":"12pt Arial","customList":[],"sheetCount":1,"sheets":{"Sheet1":{"name":"Sheet1","isSelected":true,"activeRow":11,"activeCol":3,"frozenTrailingRowStickToEdge":true,"frozenTrailingColumnStickToEdge":true,"theme":"Office2007","data":{"defaultDataNode":{"style":{"themeFont":"Body"}},"dataTable":{}},"rowHeaderData":{"defaultDataNode":{"style":{"themeFont":"Body"}}},"colHeaderData":{"defaultDataNode":{"style":{"themeFont":"Body"}}},"leftCellIndex":0,"topCellIndex":0,"selections":{"0":{"row":11,"rowCount":1,"col":3,"colCount":1},"length":1},"rowOutlines":{"items":[]},"columnOutlines":{"items":[]},"cellStates":{},"states":{},"outlineColumnOptions":{},"autoMergeRangeInfos":[],"printInfo":{"paperSize":{"width":850,"height":1100,"kind":1}},"tables":[{"name":"gcTable0","row":5,"col":3,"rowCount":2,"colCount":2,"style":{"buildInName":"Medium2"},"autoGenerateColumns":false,"bindingPath":"table","rowFilter":{"range":{"row":6,"rowCount":1,"col":3,"colCount":2},"typeName":"HideRowFilter","dialogVisibleInfo":{},"filterButtonVisibleInfo":{"0":true,"1":true},"showFilterButton":true},"columns":[{"id":0,"name":"name","dataField":"name"},{"id":1,"name":"age","dataField":"age"}]}],"shapeCollectionOption":{"snapMode":0},"index":0}}};
-
- spread.fromJSON(tableData)
- var activeSheet = spread.getActiveSheet();
- var table = activeSheet.tables.add('myTable',4,6,3,3);
- table.bindingPath('user');
- /*测试数据源 */
- var people = {
- user: [
- {name: "yaojia", age: 40, },
- {name: "lili", age: 22 , },
- {name: "coco", age: 222 , }
- ]}
- var source = new GC.Spread.Sheets.Bindings.CellBindingSource(people)
- activeSheet.setDataSource(source)
复制代码
|