admin管理员组文章数量:1609530
table2excel实例
- 使用插件:
table2excel.js
- 简介:
table2excel
可以转换和下载html上的表格,使他成为.xlsx格式,能够被Excel打开
实例代码
<head>
<!--js文件在文章末尾-->
<script src="table2excel.js"></script>
</head>
<body>
<!--table属性:data-excel-name设置该table在Excel的sheet名称-->
<table data-excel-name="Excel_sheet_name1">
<thead>
<tr>
<th>table_head</th>
</tr>
</thead>
<tbody>
<tr>
<td>table_data_cell</td>
</tr>
</tbody>
<tfoot>
<tr>
<td>table_foot_cell</td>
</tr>
</tfoot>
</table>
<table data-excel-name="Excel_sheet_name2">
<thead>
<tr>
<th>table_head</th>
</tr>
</thead>
<tbody>
<tr>
<td>table_data_cell</td>
</tr>
</tbody>
<tfoot>
<tr>
<td>table_foot_cell</td>
</tr>
</tfoot>
</table>
<!--输出excel文件按钮-->
<button id="export">Export_to_excel</button>
<script>
var table2excel = new Table2Excel();
// table2excel.export(table, table_name), table_name是你要输出的table文件名
document.getElementById('export').addEventListener('click',function(){
table2excel.export(document.querySelectorAll('table'),'table_name');
});
</script>
</body>
相关链接
来源:https://www.npmjs/package/table2excel
Demo:https://rusty1s.github.io/table2excel/demo/
table2excel.js:上面script加载的文件(点击下载)
Github了解更多:github/rusty1s/table2excel
版权声明:本文标题:html利用js生成excel表格(html表格标签生成excel)table2excel实例:一表格多sheets 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://www.elefans.com/dianzi/1728571352a1164222.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论