您好,您是不是想要了解如何在SpreadJS初始化就直接加载某个路径的Excel?
如果是这样,您可以将Excel上传到您的服务器上,之后通过XMLHttpRequest请求直接获取并加载
参考代码:
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();
|