Skip to content

Instantly share code, notes, and snippets.

@bilashcse
Created May 19, 2019 17:41
Show Gist options
  • Save bilashcse/eff3dcc0652c434d6ec906c3c7e04124 to your computer and use it in GitHub Desktop.
Save bilashcse/eff3dcc0652c434d6ec906c3c7e04124 to your computer and use it in GitHub Desktop.
Multiple excel sheet generate using NodeJs
const XLSX = require('xlsx');
function multipleSheetExcel(excelData) {
try {
let wb = XLSX.utils.book_new();
Object.keys(excelData).forEach(function(item) {
let ws = XLSX.utils.json_to_sheet(excelData[item]);
XLSX.utils.book_append_sheet(wb, ws, item);
});
let wbout = XLSX.write(wb, { bookType: 'xlsx', type: 'buffer' });
return (new Buffer.from(wbout));
} catch (err) {
throw err;
}
}
module.exports = {
multipleSheetExcel
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment