我解决了我把我代码贴一下:
- var exceldata;
- function exportExcel() {
- var json = window.spread.toJSON({ includeBindingSource: true });
- const jsondata = exceldata || json;
- console.log("🚀 ~ exportExcel ~ json:", jsondata);
- const excelIO = new GC.Spread.Excel.IO();
- excelIO.save(jsondata, function (blob) {
- if (isSafari) {
- const reader = new FileReader();
- reader.onloadend = function () {
- $("#download").show();
- const link = $("#downloadlink");
- link[0].href = reader.result;
- };
- reader.readAsDataURL(blob);
- } else {
- saveAs(blob, "acca.xlsx");
- }
- }, function (e) {
- alert(JSON.stringify(e));
- }, { password: '' });
- }
- //传输JSON
- $(document).ready(function () {
- var spreadNS = GC.Spread.Sheets;
- window.spreadNS = spreadNS
- window.spread = spread
- spread.bind(spreadNS.Events.SelectionChanging, function () {
- var json = spread.toJSON({ includeBindingSource: true })
- exceldata = json;
- vm.s = JSON.stringify(json);
- });
- //初始化excel中的内容以及禁止用户新开sheet
- // var sheet = spread.getActiveSheet()
- // sheet.setValue(0,0,'2017');
- // sheet.setValue(1,1,'omg,shit,wtf');
- // sheet.setArray(4, 2, [[1, 2, 3], [4, 5, 6], [7, 8, 9]]);
- spread.options.newTabVisible = false;
- $('#selectBar').on('change', (e) => {
- var sheet = spread.getActiveSheet();
- let num = $('#selectBar option:selected').val();
- console.log(num);
- sheet.zoom(num)
- })
- });
复制代码 |