DEV Community

loizenai
loizenai

Posted on

Node.js Extract MongoDB Data to Excel(.xlsx) File – using exceljs

https://grokonez.com/node-js/node-js-extract-mongodb-data-to-excel-xlsx-file-using-exceljs

Node.js Extract MongoDB Data to Excel(.xlsx) File – using exceljs

In the tutorial, Grokonez shows how to extract data from MongoDB to Excel(.xlsx) File with Node.js using exceljs lib.

Technologies

  • Node.js
  • MongDB
  • exceljs

Goal

– We create a Node.js project as below structure:

Nodejs-export-mongodb-data-to-excel-file---using-exceljs---project-structure

– MongoDB Data:

nodejs-export-mongodb-data-to-csv-file---mongodb-records


{"_id":1,"name":"Jack Smith","address":"Massachusetts","age":23}
{"_id":2,"name":"Adam Johnson","address":"New York","age":27}
{"_id":3,"name":"Katherin Carter","address":"Washington DC","age":26}
{"_id":4,"name":"Jack London","address":"Nevada","age":33}
{"_id":5,"name":"Jason Bourne","address":"California","age":36}

– Excel File:

Nodejs-export-mongodb-data-to-excel-file---using-exceljs---results

Practice

Install MongoDB & Exceljs

Init package.json file by cmd: npm init -> Then install mongodb & exceljs libs:


$npm install --save mongodb
$npm install --save exceljs

-> package.json file:

More at:
https://grokonez.com/node-js/node-js-extract-mongodb-data-to-excel-xlsx-file-using-exceljs

Node.js Extract MongoDB Data to Excel(.xlsx) File – using exceljs

Top comments (0)