1. Convert the spreadsheet into CSV or tab delimited file using the "Save as" option.
2. Use the file() function to get every line in an array.
3. Explode the string at tab(/t) or comma(,).
4. Prepare the MySQL inset into query and execute.
Example usage:
The excel sheet saved as CSV file xls2mysql.php:
Code:
Amitabh Bachhan, 62, Male
Emma Watson, 18, Female
Daniel Radcliffe,18,Male
The PHP code:
PHP:
<?php
$xls=file("xls2mysql.csv");
foreach($xls as $row)
{
$fields=explode(",",$row);//comma if csv; /t(tab) if tab demilted.
echo "$fields[0] ";//instead of echoing the fileds, you should prepare the mysql insert query
echo "$fields[1] ";
echo "$fields[2] ";
echo "<br>";
}
?>
PS: I have written this code fro MySQL, but it WON'T differ for MS SQL