简单的 DEMO 示例、JS 库使用 SheetJS
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
| <table id="tb"> <thead> <tr> <th>团队名称</th> <th>负责人</th> <th>签约总数</th> <th>重点人群数</th> <th>履约总数</th> </tr> </thead> <tbody> <tr> <td>1...</td> <td>2...</td> <td>3...</td> <td>4...</td> <td>5...</td> </tr> </tbody> </table>
<div> <a href="javascript:;" onclick="btn_export()"> <i class="ace-icon fa fa-download bigger-125"></i>下载 </a> </div>
<script src="~/assets/js/xlsx.full.min.js"></script> <script src="~/assets/js/xlsx-export.js"></script>
<script> function btn_export() { var table = document.querySelector("#tb"); var sheet = XLSX.utils.table_to_sheet(table);
var name = "文件名.." + new Date().Format("yyyyMMddhhmmss") + ".xlsx"; openDownloadDialog(sheet2blob(sheet), name); } </script>
|