- $("#saveSsjson").click(function () {
- var spread2 = new GC.Spread.Sheets.Workbook();
- spread2.fromJSON(spread.toJSON());
- for(let i = 0;i<spread2.getSheetCount();i++){
- let currentSheet = spread2.getSheet(i);
- let row = currentSheet.getRowCount(),col = currentSheet.getColumnCount();
- for(let j = 0;j<row;j++){
- for(let k = 0;k<col;k++){
- if(currentSheet.getCellType(j,k) instanceof GC.Spread.Sheets.CellTypes.ComboBox) {
- currentSheet.getCellType(j, k).editorValueType(GC.Spread.Sheets.CellTypes.EditorValueType.text);
- }
- }
- }
- }
- funDownload(JSON.stringify(spread2.toJSON()), "test.ssjson");
- });
- var funDownload = function (content, filename) {
- console.time('saveSSJSON')
- var eleLink = document.createElement('a');
- eleLink.download = filename;
- eleLink.style.display = 'none';
- // 字符内容转变成blob地址
- var blob = new Blob([content]);
- eleLink.href = URL.createObjectURL(blob);
- // 触发点击
- document.body.appendChild(eleLink);
- eleLink.click();
- // 然后移除
- document.body.removeChild(eleLink);
- console.timeEnd('saveSSJSON')
- };
复制代码 |