nodejs+express解析excel

https://segmentfault.com/a/1190000011424511

 

file元素的name=uploadExcel必须设置

建立public/files目录

const formidable = require('formidable');
const path = require('path');
var form = new formidable.IncomingForm();
var targetFile = path.join(__dirname,'../public/files');
form.uploadDir = targetFile;
form.parse(req,function(err,fields,files){});

 获取方法

files.uploadExcel.path

解析excel

var xlsx = require('node-xlsx');

var obj = xlsx.parse(path);//配置excel文件的路径

var excelObj=obj[0].data;
 

你可能感兴趣的:(nodejs+express解析excel)