思路用前端页面提交数据 用node进行写入
数据的过滤逻辑在index.html中完成 node只进行写入操作
文件目录如下
需要现在根目录下启动index.js
node index.js
默认端口号是8081
前端页面显示如下
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=Chrome">
<title>Document</title>
<style>
img {
width: 50px;
height: 50px;
}
input[type='file'] {
display: none;
}
</style>
</head>
<body>
<h2>转换后的文件保存在transform目录中</h2>
<h4>需要在json()和 xlsx()方法中把data过滤成自己需要的方式</h2>
<label for="jsonFile">
editJson <img src="file.gif" alt="">
</label>
<input type="file" id="jsonFile" multiple accept="application/json">
<br>
<br>
<label for="xlsxFile">
xlsxToJson <img src="file.gif" alt="">
</label>
<input type="file" id="xlsxFile" multiple accept="application/vnd.ms-excel">
</body>
<script src="shim.min.js"></script>
<script src="xlsx.full.min.js"></script>
<script>
jsonFile.onchange = jsonFileChanged;
xlsxFile.onchange = xlsxFileChanged;
function xlsxFileChanged() {
if (this.files.length > 0) {
let fileData = {};
let reader = fileReader(this.files, readAs = 'readAsBinaryString', fi