Reading Excel file & Insert data into MySQL Database using PHP

By | August 10, 2015



I have received many requests from my readers to write tutorial on Excel file import in MySQL database, so today I am going to give you this tutorial on how to read excel file and insert data into MySQL DB using PHP. I have used a php library php-excel-reader its a very simple and easy to understand library to get excel data in your MySQL database. You can also print data in same excel format in HTML and display on browser.

You can get that library from here.

Database Details:

database name => chainwebber
table name => excel


Database file run in your MySQL to create database and add data in table.


Edit this file as per your database credentials.


Contains HTML and PHP include library and insert records in database.

First of all it count your sheets in excel file then get rows of each sheet and print rows of each column in html table and insert it in database.

You can get excel_reader2.php by downloading source code.


That’s all for today’s tutorial i hope it helps. Please feel free to give us your feedback in comments.