Read Excel file and save details to database using PHP-Repost

How can you read excel file using php and save that details to the database? My other post is describing Read Excel file and save details to database using PHP.But it is not properly working in new version of excel 2007..etc.My readers are asked to do this for other excel versions.So I’m going to show how to read any format of excel file like 97-2003(xls) or 2007 (xlsx) formats excel files. Also I’ll show how to create/write excel file using php.

In here I’m using different library to do this.That is the “PHPExcel” Library.


Creating the Database Connection


Including files and libraries

My Excel file is like this.


Call to the functions to read excel file


Display sheet data

Final result is like this.


Save details to the database

Here, I’m customizing the above loop to insert details to the database.
This is the table structure.

That’s only. All are done.

Additional Details

Set Sheet number

Get number of rows

Get number of columns

Get specific cell address value/text

Get specific cell calculated value/formula value


-This is working for excel 97-2003 , 2007 and latest format of the excel files.
-If you have suggestions, idea, questions…etc please leave a comment below.
-I am suggesting check the library files and folders then you can get the more information than this.
-In the next post, I’ll show you how to write/create excel file and insert data to it using php.

Here is the full source code to download.
Download Read Excel file Full source Code (920 KB)