从数据导出数据,存储到本地excel格式数据
mong是数据格式
将数据按照数组格式排列
使用node-xlsx
方法导出数据node
const xlsx = require("node-xlsx") const fs = require("fs") const mong = require("./ThomDate.js") let json = [ { "name" : "800条数据", "data" : [] } ] mong.find({url:{}},(err,result)=>{ result.map((i)=>{ let list = [] list.push( i.title ) list.push( i.des ) list.push( i.url ) json[0]["data"].push(list) }) let file = xlsx.build( json ) fs.writeFileSync("./info2.xlsx",file) process.exit(); })