Free----js download location:
https://download.csdn.net/download/weixin_40362806/87759578
<button class="layui-btn layui-bg-normal iconfont icon-daochu layui-bg-blue" id="btnExport" title="导出Excel"><i class="layui-icon" style="font-size: 25px; color: #FFFFFF;"></i>导出</button>
<table class="layui-table" id="t1"> </table>
<table class="layui-table" id="t2"> </table>
This picture is an example and has nothing to do with the exported data in the picture below.
Click the export button to implement. To export the two tables to excel,
first reference the js file:
<script src="~/js/exportexcel.js"></script>
Calling method: You need to download js and then quote it, then call exportToExcel
$("#btnExport").click(function () {
var excelInfo = {
name: '汇总',//文件名
sheets: [
{
name: "收入类支付汇总", content: "t1" },
{
name: "分类收入汇总", content: "t2" }
],
};
exportToExcel(excelInfo);
});
The effect after export is as follows: