• spreadjs 小记


    首先声明一个容器

    <div id="ss" class="sample-spreadsheets" style="margin:1px 1px 1px 1px;">

    </div>

    然后初始化表格

    var spreadNS = GC.Spread.Sheets;
    var spread = new GC.Spread.Sheets.Workbook(document.getElementById("ss"), {
    sheetCount: 1,
    newTabVisible: false
    });

    导入数据

     spread.fromJSON(stylejs);--参数模板数据。json字符串

    是否隐藏行头列头,true/false

    sheet.options.rowHeaderVisible = true;
    sheet.options.colHeaderVisible = true;

    spread.options.allowExtendPasteRange = true;

    复制样式
    spread.options.allowCopyPasteExcelStyle = true;

    自动行高
    spread.options.highlightInvalidData = true;

    暂时挂起表格

     spread.suspendPaint();

    重新绘制

     spread.resumePaint();

    //隐藏标签
    spread.options.tabStripVisible = false;
    spread.options.newTabVisible = false;

    PDF导出

    function prot_PDF() {
    var pdfp = document.createElement('div');
    pdfp.className = 'expro';
    var pdfc = document.createTextNode("导出PDF");
    pdfp.appendChild(pdfc);
    return pdfp;
    }

    //#region pdf字体注册

    function addFontsToFontManager(fontsObj) {
    var fonts = {
    normal: fontsObj["simkai.ttf"]
    };
    GC.Spread.Sheets.PDF.PDFFontsManager.fallbackFont = function (font) {
    var fontInfoArray = font.split(' ');
    var fontName = fontInfoArray[fontInfoArray.length - 1];
    if (fontName === '宋体') {
    return fonts.normal;
    }
    }
    }

    //pdf字体设置
    var fontsObj = fonts;
    registerCustomFont(fontsObj);
    addFontsToFontManager(fontsObj);

    记得引用字体样式.css

    映射键盘

    spread.commandManager().register('myCmd',function ColorAction() {}

    spread.commandManager().setShortcutKey('myCmd', GC.Spread.Commands.Key.del, false, false, false, false);

  • 相关阅读:
    2019.5.28
    蓝桥杯2017Java B组---分巧克力and承压计算
    看似忙碌的背后我都干了点什么
    3.9个人总结
    3.2个人总结
    2.23个人总结
    2.16个人总结
    2019.01.27个人总结
    1.19个人总结
    12.22个人总结
  • 原文地址:https://www.cnblogs.com/yeyuqian/p/10750221.html
Copyright © 2020-2023  润新知