CotalkerPartners / mongo-xlsx

Convert Mongo data into Excel and vice versa @ Node.js. MongoDB Mongoose Dump to excel.
MIT License
99 stars 28 forks source link

Convert array of objects in different excel sheet in one excel #24

Open user1702 opened 5 years ago

user1702 commented 5 years ago

Using below code, not able to convert the data into one excel with mutiple sheets. I am getting all data in one sheet.

var  jsonXlsx = [[{ "Name": "Eddie", "Email": "edward@mail" }], [{ "Name": "Nico", "Email": "nicolas@mail" }]] ;
const sheets = ['a','b'];
var excelPageData = [];
/* Generate automatic model for processing (A static model should be used) */
var model = mongoXlsx.buildDynamicModel(jsonXlsx);

/* Generate Excel */
  excelPageData.push(mongoXlsx.mongoData2XlsxData(jsonXlsx, model));
  mongoXlsx.mongoData2XlsxMultiPage(excelPageData, sheets, function(err, data) {
    console.log(err)
  console.log('File saved at:', data.fullPath); 
  });