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 oleread.inc file of this reader.php file.Download oleread.inc.
Here is the sample.xls file format.
How to read excel file using php
|$cell\n"; // get each cells values $y++; } echo "\t|
This is reading sheet1 details.If you want to read sheet 2 details, then change the sheets to sheets in both while loops.
Remember “sheets” is the array.Array begin from 0.You already know about it. 😀
Sheet1 -> sheets
Sheet2 -> sheets
Sheet3 -> sheets
How to read and save details to the database using php
DROP TABLE IF EXISTS `users_details`; CREATE TABLE `users_details` ( `id` int(11) NOT NULL auto_increment, `name` varchar(255) default NULL, `job` varchar(255) default NULL, `email` varchar(255) default NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=latin1;
Save Excel file details to the database
Download full source code(20 KB)