node-xlsx 記錄

從數據導出數據,存儲到本地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();
})
相關文章
相關標籤/搜索