调试发现 this.spread方法,this是undefine,所以没有获取到Spread,参考以下的实现方法:
- loadExcel() {
- let self = this;
- // spread.fromJSON(dataSource);
- // let excelIo: GC.Spread.Excel.IO = new GC.Spread.Excel.IO();
- // const excelFile = document.getElementById("fileDemo").files[0];
- var excelIO = new ExcelIO.IO();
- console.log(excelIO);
- let excelFile = (document.getElementById('fileDemo') as HTMLInputElement).files[0]; // files[0]
- console.log('document.getElementById("fileDemo")',document.getElementById('fileDemo'));
- // here is excel IO API
- excelIO.open(excelFile, function (json) {
- let workbookObj = json;
- self.spread.fromJSON(workbookObj);
- }, function (e) {
- // process error
- alert(e.errorMessage);
- });
- }
复制代码
|