-3

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

1 Answer 1

0
<?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>

Download full example with source code

Sign up to request clarification or add additional context in comments.

2 Comments

I can't apply this for format .xlsx with 700.000 row. I have tried this anytime, and it's not work.
it's depend on your server, because its process time is huge.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.