Nodejs Express RestAPI – Upload/Import Excel File to MySQL – using Read-Excel-File & Multer

nodejs-express-restapi-upload-import-excel-xlsx-file-to-mysql---feature-image

In the tutorial, Grokonez shows how to upload & import Excel File/Data to MySQL using read-excel-file and multer libs.

Related post:
Node.js Import Excel File to MySQL – using Read-Excel-File lib

Technologies

  • Nodejs
  • Express
  • Multer
  • Read-Excel-File
  • MySQL

Goal

We create a Node.js project as below structure:

nodejs-express-restapi-upload-import-excel-xlsx-file-to-mysql---project-structure

Excel File ->

nodejs-express-restapi-upload-import-excel-xlsx-file-to-mysql---excel-file

-> Results:

nodejs-express-restapi-upload-import-excel-xlsx-file-to-mysql---mysql-records

nodejs-express-restapi-upload-import-excel-xlsx-file-to-mysql---upload-client

Practice

Install Express, Read-Excel-File, Multer, MySQL

– Init package.json file by cmd: npm init -> Then install express, mysql, read-excel-file & multer libs:

Upload/Import Excel File/Data to MySQL

-> index.js file:

Sourcecode

– MySQL Script to create customer table:

– Sourcecode: Nodejs-Express-RestAPI-Upload-Import-Excel-XLSX-to-MySQL

By grokonez | March 9, 2019.



Related Posts


3 thoughts on “Nodejs Express RestAPI – Upload/Import Excel File to MySQL – using Read-Excel-File & Multer”

  1. Hello!
    Excellent tutorials!
    I’m trying to port the instructions to postgresql and got stuck on :
    “INSERT INTO customer (id, address, name, age) VALUES ?”

    With a error from /var/log/postgresql/postgresql-10-main.log :
    ERROR: syntax error at or near “?”
    STATEMENT: INSERT INTO customer (id, address, name, age) VALUES ?

    there is a major difference of syntax from Mysql to Postgresql?
    I’m a total newbie so maybe the question is too simple.. but I’ll appreciate any hint.
    Thanks!

    1. it call query binding, in Postgres using $
      for example :
      let query = ‘INSERT INTO customer (id, address, name, age) VALUES ($1, $2, $3, $4)’;

      if id is autoincrement, you can avoid it,
      let query = ‘INSERT INTO customer ( address, name, age) VALUES ($1, $2, $3)’;

      CMIIW

  2. I got an error: Cannot read property 'filename' at "req.file.filename" of undefined. Even I tried to copy-paste your source code 🙂

Got Something To Say:

Your email address will not be published. Required fields are marked *

*