在Angular里用,纯js plugin js-xlsx插件生成excel报表

匿名 (未验证) 提交于 2019-12-03 00:30:01

在Angular里用,用纯js plugin插件生成excel报表,用到如下插件,
// Browser save file (compatibility) (click to show)
https://github.com/SheetJS/js-xlsx
https://github.com/eligrey/FileSaver.js

js-xlsx, 这个插件真的非常的强大,有免费社区版和Pro Version收费版,如果对所下载的报表的样式要求不高的话,用社区版完全可以实现需求,如果对样式有特殊要求,并且还不想用Pro Version不想花钱的话,也可以考虑用社区版填充数据,之后在excel里写vba宏来实现样式的定制化!!

  • Browser save file (compatibility) (click to show)
    XLSX.writeFile techniques work for most modern browsers as well as older IE. For much older browsers, there are workarounds implemented by wrapper libraries.
    FileSaver.js implements saveAs. Note: XLSX.writeFile will automatically call saveAs if available.
    /* bookType can be any supported output type */
    var wopts = { bookType:’xlsx’, bookSST:false, type:’array’ };
    var wbout = XLSX.write(workbook,wopts);
    /* the saveAs call downloads a file on the local machine */
    saveAs(new Blob([wbout],{type:”application/octet-stream”}), “test.xlsx”);
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!