您好,看了您的Demo,Demo中包含有绑定的单元格和表格,
获取绑定单元格的方法,之前已经讨论过,可以使用getBindingPath即可获取,
关于获取绑定表格的方法,我补充了一下之前贴出的示例。
实际上,表格绑定路径的获取,需要先获取到表格对象,然后调用range()方法获取表格所在区域,
对应的,调用table.bindingPath()可以获取到这部分区域绑定的数据源,请参考完整代码:
- var spread = GC.Spread.Sheets.findControl("ss");
- function ngAfterViewInit() {
- // // 工作簿
- const source = new GC.Spread.Sheets.Bindings.CellBindingSource({});
- spread.getActiveSheet().setDataSource(source);
- getBindingPathKeys();
- }
- function getBindingPathKeys() {
- const sheet = spread.getActiveSheet();
- sheet.suspendPaint();
- const rowCount = sheet.getRowCount();
- const columnCount = sheet.getColumnCount();
- const tables = sheet.tables.all();
- let bindingPathKey;
- const bindingPathArray = [];
- for (let i = 0; i < rowCount; i++) {
- for (let j = 0; j < columnCount; j++) {
- bindingPathKey = sheet.getBindingPath(i, j);
- if (bindingPathKey) {
- bindingPathArray.push({
- bindingPath: bindingPathKey,
- row:i,
- col:j
- });
- }
- }
- }
-
- if(tables && tables.length > 0){
- for(let i=0; i<tables.length; i++){
- bindingPathArray.push({
- bindingPath: tables[i].bindingPath(),
- range: tables[i].range()
- });
- }
- }
- sheet.resumePaint();
- console.log(bindingPathArray);
- }
- ngAfterViewInit();
复制代码
|