您好,登錄后才能下訂單哦!
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;//取消頭跟左側(cè)工具欄 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(); });
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。