how can i read excel sheet to our database

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
B.Murali Krishna
Forum Commoner
Posts: 28
Joined: Fri May 12, 2006 2:05 am
Location: Hyderabad,India
Contact:

how can i read excel sheet to our database

Post by B.Murali Krishna »

how, can i read the data in excel sheet to database,
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post by JayBird »

Export the Excel file to a CSV!?
Ward
Forum Commoner
Posts: 74
Joined: Thu Jul 13, 2006 10:01 am

Post by Ward »

I remember finding an XLS file parser at one point (search google), but as I remember it was a beta, and still buggy. You would be better off saving the file as a CSV. Then it's just plain text, and easy to parse.

This script will load a csv file into a 2-dimensional array called csv_data:

Code: Select all

$csv_file = "my_csv_file.csv";
$csv_data = array();


$f = fopen($csv_file,"r");
while ($line = fgetcsv($f,1024,",","\""))
{
     array_push($csv_data,$line);
}
fclose($f);
Post Reply