分享一下我老师大神的人工智能教程!零基础,通俗易懂!http://blog.csdn.net/jiangjunshow
也欢迎大家转载本篇文章。分享知识,造福人民,实现我们中华民族伟大复兴!
参考文章
http://librajt.github.io/2013/08/04/handle-excel-file-with-nodejs/
对比了 ExcelJS , https://github.com/guyonroche/exceljs#create-a-workbook
node-xlsx ,https://github.com/mgcrea/node-xlsx
等 nodejs 等现有组件,决定使用node-xlsx。
node-xlsx 基于现有前端强大组件 js-xlsx, https://github.com/SheetJS/js-xlsx
使用例子:
var express = require('express');var router = express.Router();var xlsx = require('node-xlsx');var fs = require('fs');/* GET import excel test. */router.get('/importExcel', function(req, res, next) { var filename='./public/test.xlsx'; console.error(filename); // read from a filevar obj = xlsx.parse(filename);console.log(JSON.stringify(obj)); res.send('import successfully!');});/* GET export excel test. */router.get('/exportExcel', function(req, res, next) {// writevar data = [[1,2,3],[true, false, null, 'sheetjs'],['foo','bar',new Date('2014-02-19T14:30Z'), '0.3'], ['baz', null, 'qux']];var buffer = xlsx.build([{name: "mySheetName", data: data}]);fs.writeFileSync('b.xlsx', buffer, 'binary');res.send('export successfully!');});
补充:
文件上传操作可以选择以下两种
fs https://github.com/jprichardson/node-fs-extra
formidable https://github.com/felixge/node-formidable
给我老师的人工智能教程打call!http://blog.csdn.net/jiangjunshow
![这里写图片描述](https://i-blog.csdnimg.cn/blog_migrate/2e19ffb3303a490d20ea5d00dd397156.gif)