demo 示例 (具体下载附件)
ExcelDemo.js
let path = require("path");
let fs = require("fs");
let xlsx = require('node-xlsx');
let dirPath = './excel';
let outPath = './excel/config.json';
let jsonDt = {};
function getPath(dir, file) {
return path.resolve(__dirname, dir, file);
}
//解析excel文件数据,支持 xls xlsx 格式
function parseExcel(param) {
console.log(param);
let excelDt = xlsx.parse(param);
excelDt.forEach((value, index) => {
let sheetName = value.name;
let sheetData = value.data;
let sheetDt = [];
let nameArr = sheetData.splice(0, 1)[0];
let typeArr = sheetData.splice(0, 1)[0]
sheetDt.push(nameArr);
for (let s in sheetData) {
let arr = [];
for (let t in typeArr) {
let gezi = sheetData[s][t];
switch (typeArr[t])