建议您参考这段代码open应该传的是一个blob,另外文件传输需要filesaver.js
- var excelIo = new GC.Spread.Excel.IO();
- var excelFilePath = 'resources/Excel/importExcel.xlsx';
- var xhr = new XMLHttpRequest();
- xhr.open('GET', excelFilePath, true);
- xhr.responseType = 'blob';
- xhr.onload = function(e) {
- if (this.status == 200) {
- // get binary data as a response
- var blob = this.response;
- // convert Excel to JSON
- excelIo.open(blob, function (json) {
- var workbookObj = json;
- spread.fromJSON(workbookObj);
- }, function (e) {
- // process error
- alert(e.errorMessage);
- }, {});
- }
- };
-
- xhr.send();
复制代码
|