DEV Community

loading...

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

loizenai profile image loizenai ・2 min read

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

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

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

Technologies

  • Node.js
  • MySQL
  • exceljs

Goal

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

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

– MySQL Data:

nodejs-export-mysql-data-to-excel-file---using-exceljs---mysql-records

– Excel File:

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

Practice

Install MySQL & Exceljs
  • Init package.json file by cmd: npm init -> Then install mysql & exceljs libs:

$npm install --save mysql
$npm install --save exceljs

-> package.json file:


{
  "name": "nodejs-export-mysql-data-to-excel-file",
  "version": "1.0.0",
  "description": "Nodejs exports MySQL data to Excel file",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "start": "node index.js"
  },
  "keywords": [
    "Nodejs",
    "MySQL",
    "Excel"
  ],
  "author": "ozenero.com",
  "license": "ISC",
  "dependencies": {
    "exceljs": "^1.7.0",
    "mysql": "^2.16.0"
  }
}

Extract MySQL Data to Excel

More at:

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

Discussion (0)

pic
Editor guide