本帖最后由 Clark.Pan 于 2021-8-12 17:59 编辑
您可以使用下面的代码,通过请求一个xlsx的文件路径然后实现导入在SpreadJS显示- 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);
- }, {});
- }
- };
复制代码
详情参考这个链接的内容:https://gcdn.grapecity.com.cn/showtopic-37389-1-1.html
|