先初始化,SelectionChanged 可以作用,
initSpread(spread) { this.spread = spread; let spreadNS = GC.Spread.Sheets; let self = this; sheet = spread.sheets[0]; sheet.suspendPaint();
sheet.bind(spreadNS.Events.SelectionChanged, function () { let activeCell = sheet.getSelections()[0]; let path = sheet.getBindingPath(activeCell.row, activeCell.col); self.path = path || ""; let bindingitems = self.seachBindingInfoByKey(self.path); console.log('click',self.path,bindingitems); self.activeCell = activeCell; if(self.allowEditting) self.standardDialogVisible = true; }); sheet.resumePaint(); }
后加载excel, SelectionChanged就没有反应了
getexcel2(bindingResult){
var excelIo = new IO(); var excelFilePath = bindingResult.filepath; var xhr = new XMLHttpRequest(); xhr.open('GET', excelFilePath, true); xhr.responseType = 'blob'; var self = this; xhr.onload = function(e) { if (this.status == 200) { // get binary data as a response var blob = this.response; // convert Excel to JSON console.log(blob); excelIo.open(blob, function (json) { var workbookObj = json; self.spread.fromJSON(workbookObj);
}, function (e) { alert(e.errorMessage); }, {}); } } xhr.send();
},
后面尝试,重新绑定 SelectionChanged event, 但还不管用
getexcel2(bindingResult){
var excelIo = new IO(); var excelFilePath = bindingResult.filepath; var xhr = new XMLHttpRequest(); xhr.open('GET', excelFilePath, true); xhr.responseType = 'blob'; var self = this; xhr.onload = function(e) { if (this.status == 200) { // get binary data as a response var blob = this.response; // convert Excel to JSON console.log(blob); excelIo.open(blob, function (json) { var workbookObj = json; self.spread.fromJSON(workbookObj);
// 重新绑定 SelectionChanged event, 但还不管用 let spreadNS = GC.Spread.Sheets; let sheet = self.spread.sheets[0]; sheet.suspendPaint(); sheet.bind(spreadNS.Events.SelectionChanged, function () { let activeCell = sheet.getSelections()[0]; let path = sheet.getBindingPath(activeCell.row, activeCell.col); self.path = path || ""; let bindingitems = self.seachBindingInfoByKey(self.path); console.log('click',self.path,bindingitems); self.activeCell = activeCell; if(self.allowEditting) self.standardDialogVisible = true; }); sheet.resumePaint();
}, function (e) { alert(e.errorMessage); }, {}); } } xhr.send();
},
|