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

14

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.

Step-1

Creating the Database Connection

Step-2

Including files and libraries

My Excel file is like this.
php_read_excel_file

Step-3

Call to the functions to read excel file

Step-4

Display sheet data

Final result is like this.
php_read_excel_file_result

Step-5

Save details to the database

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

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

Note

-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)

Share.

About Author

Sumith Harshan is the Web Engineer Specializes in Java Script, JQuery, HTML4/5, CSS2/3, PHP, CodeIgniter, CakePHP, J2SE, J2EE, XML, Hacking & Security, Mobile Interface Developing, Magento, Wordpress, Joomla, Drupal,PHPBB,Facebook App Developing and Open cart...etc.