本帖最后由 LIUZHIPENG 于 2023-2-22 13:52 编辑
能给我一个怎么引入sjs的例子嘛,我是通过直接请求服务器文件去加载的
- spreadObj.suspendPaint()
- spreadObj.suspendCalcService(true)
- let self = this
- const loading = this.$loading({
- lock: true,
- text: '请稍候',
- background: 'rgba(255,255,255,0.5)'
- })
- var excelFilePath = '/spreadExcel/upload/template/volume/bigFile.sjs'
- // var excelFilePath = '/spreadExcel/upload/' + SSJsonName
- // var excelFilePath = ssJsonAddress+'/upload/' + SSJsonName
- var xhr = new XMLHttpRequest()
- xhr.open('GET', excelFilePath, true)
- xhr.responseType = 'arraybuffer'
- //清除之前的status
- document.getElementById('statusBar').innerHTML = ''
- //增量加载
- let statusBar = new GC.Spread.Sheets.StatusBar.StatusBar(document.getElementById('statusBar'))
- statusBar.bind(spreadObj)
- statusBar.remove('cellMode')
- let loadingStatus = new LoadingStatus('LoadingStatus', { tipText: 'LoadingStatus' })
- statusBar.add(loadingStatus)
- xhr.onload = async function (e) {
- if (this.status == 200) {
- spreadObj.import(
- this.response,
- function () {
- console.log("success");
- // success callback to do something
- },
- function (e) {
- console.log(e); // error callback
- },
- );
- // await spreadObj.fromJSON(this.response,{
- // doNotRecalculateAfterLoad: false,
- // incrementalLoading: {
- // loading: function (progress) {
- // loadingStatus.updateProgress(progress)
- // },
- // loaded: function () {
- // loadingStatus.updateText('Ready')
- // loading.close()
- // self.dataEntry()
- // }
- // }
- // })
-
- } else {
- loading.close()
- self.$message.error('加载模板失败,请联系系统管理员')
- }
- }
- xhr.send()
- //按需求执行计算
- spreadObj.options.calcOnDemand = true
- //spread 恢复绘制、恢复计算
- spreadObj.resumeCalcService(true)
- spreadObj.resumePaint()
复制代码
|