1.安装
npm i js-export-excel
2.使用
//导入ExportJsonExcel包const ExportJsonExcel = require("js-export-excel");//表头1const columns1: any = [{title: "姓名", dataIndex: "region" },{title: "性别", dataIndex: "accountingSubject" },{title: "昵称", dataIndex: "accountName" },];//表头2const columns2: any = [{title: "上班时间", dataIndex: "region" },{title: "下班时间", dataIndex: "accountingSubject" },{title: "累计", dataIndex: "accountName" },];//文件名字option.fileName = "玛卡巴卡";//文件内容option.datas = [{//json数据sheetData: json1,//表1名字sheetName: "员工信息",//表格内容sheetFilter: columns1.map((v: any) => (v.dataIndex)),//表头sheetHeader: columns1.map((v: any) => (v.title))},{//json数据sheetData: json2,//表2名字sheetName: "个人考勤",sheetFilter: columns2.map((v: any) => (v.dataIndex)),sheetHeader: columns2.map((v: any) => (v.title))}];const toExcel = new ExportJsonExcel(option);toExcel.saveExcel();