How to import file excel 2007 into phpmyadmin using php? I have a large file excel in .xlsx format (40MB) and i want to import this file to phpmyadmin.
3
-
See webimpulse.wordpress.com/2011/04/19/hello-world.Mihai8– Mihai82014-06-16 17:09:54 +00:00Commented Jun 16, 2014 at 17:09
-
Thankyou for the answer. But how to apply it using php code?Detta– Detta2014-06-16 17:11:30 +00:00Commented Jun 16, 2014 at 17:11
-
For that you must use some library, as you can see in major.io/2008/11/07/importing-excel-files-into-mysql-with-php or stackoverflow.com/questions/2066961/….Mihai8– Mihai82014-06-16 17:16:56 +00:00Commented Jun 16, 2014 at 17:16
Add a comment
|
1 Answer
<?php
if(isset($_POST['form_submit']))
{
include("db.php");
require_once 'Classes/excel_reader.php';
$file1 = $_FILES['excelfile']['tmp_name'];
$data = new Spreadsheet_Excel_Reader($file1);
$sheet = $data->sheets[0];
$rows = $sheet['cells'];
$rowCount = count($rows);
for($i=2;$i<=$rowCount;$i++)
{
$name = $data->val($i,1);
$email = $data->val($i,2);
$password = $data->val($i,3);
$sql = "insert into $tabel_name (`name`,`email`,`password`) values ('$name','$email','$password')";
mysql_query($sql);
}
}
?>
<html>
<head>
<title>How To Import Excel (.xls) File To MySql Database Using PHP</title>
</head>
<body>
<center><h1>zero-error-script.blogspot.in</h1></center>
<form name="import_export_form" method="post" action="import.php" enctype="multipart/form-data">
<label>Select Excel File : </label><input type="file" name="excelfile"/><br>
<input type="submit" name="form_submit"/>
</form>
</body>
</html>
2 Comments
Detta
I can't apply this for format .xlsx with 700.000 row. I have tried this anytime, and it's not work.
Mahesh Cheliya
it's depend on your server, because its process time is huge.