Read Excel file and save details to database using PHP


How can you read and display excel file using php and save that details to the database? You can use this simple php class to do this.That is read row by row while reading column by column.While reading like this it gets each cells details.Look at this example that is simply describes this process and you can understand this better.

First download excel reader.php class file. You can download reader.php file here.
Also you must include this file of this reader.php file.Download

Here is the sample.xls file format.

How to read excel file using php

This is reading sheet1 details.If you want to read sheet 2 details, then change the sheets[0] to sheets[1] in both while loops.
while($x<=$excel->sheets[0]['numRows']) {

Remember “sheets” is the array.Array begin from 0.You already know about it. 😀
Sheet1 -> sheets[0]
Sheet2 -> sheets[1]
Sheet3 -> sheets[2]

How to read and save details to the database using php

Table structure

That’s only.

Download full source code(20 KB)


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.