1.创建项目文件夹,添加数据源
2.npm初始化
3.安装xlsx包
4.创建index.js文件并编辑代码
const fs = require('fs')
const XLSX = require('xlsx')
const getJson = {}
const workBook = XLSX.readFile('./source.xlsx')
const sheetName = workBook.SheetNames[0]
const worksheet = workBook.Sheets[sheetName]
const jsonData = XLSX.utils.sheet_to_json(worksheet, { header: 0, defval: "" })
fs.writeFileSync('./dist.json', JSON.stringify(jsonData))
5.执行index.js
6.获得json