Excel File/Data – Nodejs Express RestAPI – Download/Extract Excel(.xlsx) Data/File from MySQL
Tags: mysql, excel, node
Published: 2021-04-11 14:05:38

https://ozenero.com/excel-file-data-nodejs-express-restapi-download-extract-excel-xlsx-data-file-from-mysql

Excel File/Data – Nodejs Express RestAPI – Download/Extract Excel(.xlsx) Data/File from MySQL

In the tutorial, Grokonez shows how to download & extract Excel(.xlsx) File/Data from MySQL with Nodejs Express and <code>exceljs</code> lib.

Related posts:
- <a href="https://ozenero.com/node-js/node-js-extract-mysql-data-to-excel-xlsx-file-using-exceljs">Node.js Extract MySQL Data to Excel(.xlsx) File – using exceljs</a>

<!--more-->
<h2>Technologies</h2>
<ul>
<li>nodejs</li>
<li>express</li>
<li>exceljs</li>
<li>mysql</li>
</ul>
<h2>Goal</h2>
– We create a Node.js project as below structure:

<img src="https://ozenero.com/wp-content/uploads/2019/03/nodejs-express-restapi-download-extract-csv-file-from-mysql-data-project-structure-1.png" alt="nodejs-express-restapi-download-extract-csv-file-from-mysql-data---project-structure" width="608" height="151" class="alignnone size-full wp-image-17375" />

– MySQL Data:

<img src="https://ozenero.com/wp-content/uploads/2019/03/nodejs-express-restapi-download-extract-csv-file-from-mysql-data-mysql-records-1.png" alt="nodejs-express-restapi-download-extract-csv-file-from-mysql-data---mysql-records" width="734" height="487" class="alignnone size-full wp-image-17376" />

- Results:

<img src="https://ozenero.com/wp-content/uploads/2019/03/nodejs-express-restapi-download-extract-excel-file-xlsx-from-mysql-download-file.png" alt="nodejs-express-restapi-download-extract-excel-file-xlsx-from-mysql---download-file" width="523" height="338" class="alignnone size-full wp-image-17377" />

<img src="https://ozenero.com/wp-content/uploads/2019/03/nodejs-express-restapi-download-extract-excel-file-xlsx-from-mysql-excel-file.png" alt="nodejs-express-restapi-download-extract-excel-file-xlsx-from-mysql---excel-file" width="649" height="160" class="alignnone size-full wp-image-17378" />
<h2>Practice</h2>
<h3>Install Express, MySQL & Exceljs</h3>
Init <code>package.json</code> file by cmd: <code>npm init</code> -> Then install <code>express</code>, <code>mysql</code> & <code>exceljs</code> libs:

<pre>
$ npm install epxress exceljs mysql --save
</pre>

-> <code>package.json</code> file:

<pre><code class="language-javascript">
{
  "name": "node.js-express-restapi-download-extract-excel-file-from-mysql",
  "version": "1.0.0",
  "description": "Nodejs Express RestAPI Download/Extract Excel-Data-File-from-MySQL",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
	"start": "node index.js"
  },
  "keywords": [
    "Nodejs",
    "Express",
    "RestAPI",
    "RestAPI",
    "Download-File",
    "MySQL"
  ],
  "author": "ozenero.com",
  "license": "ISC",
  "dependencies": {
    "exceljs": "^1.7.0",
    "express": "^4.16.4",
    "mysql": "^2.16.0"
  }
}</code></pre>
<h3>RestAPI Download/Extract Excel data from MySQL</h3>
-> <code>index.js</code> file:

More at:

https://ozenero.com/excel-file-data-nodejs-express-restapi-download-extract-excel-xlsx-data-file-from-mysql