js implements the export of multiple table data to excel and supports merging cells

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;">&#xe61e;</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.

Insert image description here
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:
Insert image description here

Guess you like

Origin blog.csdn.net/weixin_40362806/article/details/130533205