sheetjs-clone/demos/database/SheetJSMongo.js
2021-04-20 21:02:53 +05:30

14 lines
372 B
JavaScript

/* xlsx.js (C) 2013-present SheetJS -- http://sheetjs.com */
/* eslint-env node */
var XLSX = require("xlsx");
async function book_append_mongo(wb, coll, name) {
const aoo = await coll.find({}, {projection:{_id:0}}).toArray();
const ws = XLSX.utils.json_to_sheet(aoo);
XLSX.utils.book_append_sheet(wb, ws, name);
return ws;
}
module.exports = {
book_append_mongo
};