您好,登录后才能下订单哦!
密码登录
登录注册
点击 登录注册 即表示同意《亿速云用户服务条款》
spreadjs的用法
var spreadNS = GC.Spread.Sheets; var spread = new spreadNS.Workbook($("#spreadjsExc")[0], {sheetCount:0}); var excelIO = new GC.Spread.Excel.IO(); var fbx = new spreadNS.FormulaTextBox.FormulaTextBox(document.getElementById('formulabox')); fbx.workbook(spread); var _blob = parent.$("#fileImportIO").data("fileIO"); var readonly = parent.$("#fileImportIO").attr('readonly'); excelIO.open(_blob, function (spreadJson) { function updateActiveCells() { for (var i = 0; i < spread.getSheetCount(); i++) { var sheet = spread.getSheet(i); columnIndex = sheet.getActiveColumnIndex(), rowIndex = sheet.getActiveRowIndex(); if (columnIndex !== undefined && rowIndex !== undefined) { spread.getSheet(i).setActiveCell(rowIndex, columnIndex); } else { spread.getSheet(i).setActiveCell(0, 0); } if(readonly == "true"){ sheet.options.isProtected = true;//禁止编辑 sheet.options.colHeaderVisible = false; sheet.options.rowHeaderVisible = false;//取消头跟左侧工具栏 spread.options.newTabVisible = false;//取消新建sheet按钮 }else{ sheet.options.isProtected = false; } } } if (spreadJson.version && spreadJson.sheets) { spread.unbindAll(); spread.fromJSON(spreadJson); //attachSpreadEvents(true); updateActiveCells(); spread.focus(); fbx.workbook(spread); onCellSelected(); //syncSpreadPropertyValues(); //syncSheetPropertyValues(); } }, function (e) { if (e.errorCode === 0 || e.errorCode === 1) { //alert("error"); } }); if(readonly == "true"){ $("#saveFile").remove(); $("#close").remove(); } //spread.print();打印 function onCellSelected() { $("#addslicer").addClass("hidden"); var sheet = spread.getActiveSheet(), row = sheet.getActiveRowIndex(), column = sheet.getActiveColumnIndex(); if (showSparklineSetting(row, column)) { setActiveTab("sparklineEx"); return; } var cellInfo = getCellInfo(sheet, row, column), cellType = cellInfo.type; syncCellRelatedItems(); updatePositionBox(sheet); updateCellStyleState(sheet, row, column); var tabType = "cell"; clearCachedItems(); // add map from cell type to tab type here if (cellType === "table") { tabType = "table"; syncTablePropertyValues(sheet, cellInfo.object); $("#addslicer").removeClass("hidden"); } else if (cellType === "comment") { tabType = "comment"; syncCommentPropertyValues(sheet, cellInfo.object); } setActiveTab(tabType); } $("#saveFile").click(function(e){ e.preventDefault(); var json = spread.toJSON({includeBindingSource: true}); json = JSON.stringify(json); var xhr = new XMLHttpRequest(); var buttonid = parent.$("#fileImportIO").attr("buttonid"); var _beanid = parent.$("#fileImportIO").attr("_beanid"); var url = '/map/download!save?_beanid='+_beanid+'&buttonid='+buttonid; xhr.open("POST", url , true); xhr.onload = function (oEvent) { if(this.status == 200){ if(this.response == "success"){ alert('保存成功'); } } }; xhr.send(json); /*excelIO.save(json, function (blob) { }, function (e) { //alert(e); });*/ }); $("#printFile").click(function(e){ e.preventDefault(); spread.print(); }); $("#exportFile").click(function(e){ e.preventDefault(); var json = spread.toJSON({includeBindingSource: true}); var _fname = parent.$("#fileImportIO").attr("filename"); excelIO.save(json, function (blob) { saveAs(blob,_fname+".xlsx"); }, function (e) { alert(e); }); }); $("#close").click(function(e){ e.preventDefault(); var _beanid = parent.$("#fileImportIO").attr("_beanid"); var buttonid = parent.$("#fileImportIO").attr("buttonid"); var url = '/map/download!delete?_beanid='+_beanid+'&buttonid='+buttonid; var _ajax = { url : url, success : function(data){ parent.$("#fileImportIO").closest("#wapper").find(".ui-dialog-titlebar").find(".ui-dialog-titlebar-close").click(); } }; $.ajax(_ajax); }); $("#closes").click(function(e){ parent.$("#fileImportIO").closest("#wapper").find(".ui-dialog-titlebar").find(".ui-dialog-titlebar-close").click(); });
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。