Page 1 of 1

how can i read excel sheet to our database

Posted: Fri Jul 14, 2006 1:42 am
by B.Murali Krishna
how, can i read the data in excel sheet to database,

Posted: Fri Jul 14, 2006 3:01 am
by JayBird
Export the Excel file to a CSV!?

Posted: Fri Jul 14, 2006 10:01 am
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);