700字范文,内容丰富有趣,生活中的好帮手!
700字范文 > 将json数据转化为excel表格文件

将json数据转化为excel表格文件

时间:2024-07-26 09:18:03

相关推荐

将json数据转化为excel表格文件

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();

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。