JSON数据导出Excel

版权声明:转载请附上地址,谢谢! https://blog.csdn.net/LiuQjie/article/details/84870816

1、下载插件

   1.1、百度云盘下载:https://pan.baidu.com/s/1WSCTS3auENWJj-aO2gJtww 提取码: ijq3 

   1.2、引入jsonExportExcel.js

<script type="text/javascript" src="${ctxStatic}/common/JsonExportExcel.min.js"></script>

2、实现代码 

<button type="button" onclick="downloadExcel()" class="btn green" style="width:150px;font-size: 14px">导出</button>
function downloadExcel() {
        //JSON数据
        var showList=[{"AAE140":"城镇企业职工基本养老保险","AAE041":"198105","AAE042":"199406","AAE180":"330","AAE022":"0","AAE023":"1042.8","AAE020":"9124.5","AAE021":"0","BAE230":"本金","TOTAL":"10167.3"},{"AAE140":"城镇企业职工基本养老保险","AAE041":"199407","AAE042":"199506","AAE180":"235","AAE022":"0","AAE023":"56.4","AAE020":"493.56","AAE021":"0","BAE230":"本金","TOTAL":"549.96"},{"AAE140":"城镇企业职工基本养老保险","AAE041":"199507","AAE042":"199606","AAE180":"283","AAE022":"0","AAE023":"67.92","AAE020":"594.36","AAE021":"0","BAE230":"本金","TOTAL":"662.28"},{"AAE140":"城镇企业职工基本养老保险","AAE041":"199607","AAE042":"199706","AAE180":"310","AAE022":"0","AAE023":"111.6","AAE020":"651","AAE021":"0","BAE230":"本金","TOTAL":"762.6"},{"AAE140":"城镇企业职工基本养老保险","AAE041":"199707","AAE042":"199806","AAE180":"325","AAE022":"0","AAE023":"117","AAE020":"682.56","AAE021":"0","BAE230":"本金","TOTAL":"799.56"},{"AAE140":"城镇企业职工基本养老保险","AAE041":"199607","AAE042":"199706","AAE180":"310","AAE022":"0","AAE023":"111.6","AAE020":"651","AAE021":"0","BAE230":"本金","TOTAL":"762.6"},{"AAE140":"城镇企业职工基本养老保险","AAE041":"199707","AAE042":"199806","AAE180":"325","AAE022":"0","AAE023":"117","AAE020":"682.56","AAE021":"0","BAE230":"本金","TOTAL":"799.56"},{"AAE140":"城镇企业职工基本养老保险","AAE041":"199707","AAE042":"199806","AAE180":"325","AAE022":"0","AAE023":"117","AAE020":"682.56","AAE021":"0","BAE230":"本金","TOTAL":"799.56"},{"AAE140":"城镇企业职工基本养老保险","AAE041":"199607","AAE042":"199706","AAE180":"310","AAE022":"0","AAE023":"111.6","AAE020":"651","AAE021":"0","BAE230":"本金","TOTAL":"762.6"},{"AAE140":"城镇企业职工基本养老保险","AAE041":"199707","AAE042":"199806","AAE180":"325","AAE022":"0","AAE023":"117","AAE020":"682.56","AAE021":"0","BAE230":"本金","TOTAL":"799.56"},{"AAE140":"","AAE041":"198105","AAE042":"201705","AAE180":"","AAE022":"6094","AAE023":"32125.88","AAE020":"102460.55","AAE021":"3092.89","BAE230":"","TOTAL":"143773.32"}];

        var option={};
        //Excel文件名
        option.fileName = '导出缴费明细';
        
        option.datas=[
            {
                //sheet名称
                sheetName:'sheet',
                //表头行
                sheetHeader:["险种类型", "开始日期", "结束日期", "缴费基数", "个人应缴统筹金额", "个人应缴划入账户金额", "单位应缴统筹金额", "单位应缴划入账户金额", "费用大类", "合计"],
            }
        ];
          
        option.datas[0].sheetData = showList;
        console.log(option);

        var toExcel=new ExportJsonExcel(option);

        toExcel.saveExcel();
    }

3、已验证浏览器:IE11、Chrome、百度, 其它浏览器暂未验证


猜你喜欢

转载自blog.csdn.net/LiuQjie/article/details/84870816