想要把sjs转成ssjson,在获取到sjs blob后spreads.open(blob)失败提示信息“Incorrect file format.”,LicenseKey有设置前端使用的key。代码如下
app.get('/getSsjson', (request, response) => {
const fd = new FormData();
fd.append('fileType', 0);
axios({
method: 'get',
url: `http://${hostname}:${port}/export.sjs`,
data: fd,
responseType: 'blob',
headers: {
cache: false,
processData: false,
'Access-Control-Allow-Origin': '*',
'X-Requested-With': 'XMLHttpRequest',
crossDomain: true,
},
}).then(
(res) => {
const spreads = new GC.Spread.Sheets.Workbook();
const blob = new Blob([res.data], {type:'application/zip'});
console.log('**--**blob', blob, res.data);
spreads.open(
blob,
function (data) {
console.log('***getSsjson', data);
},
function (error) {
console.log('error***getSsjson', error);
},
{ incrementalLoad: true },
);
},
(err) => {
console.log('err----getSsjson');
},
);
});
|
|