PHP - Error al exportar de excel a php

 
Vista:

Error al exportar de excel a php

Publicado por Andres (1 intervención) el 25/01/2019 13:00:38
Buenas mi duda es la siguiente:

tengo una base de datos en excel con mas de 2000 registros y tengo que pasarla a mysql, cuando la estoy exportando me da error y solo me sube 1000 registros del excel; dejo aca mi codigo para que me ayuden a encontrar el error

codigo html:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
<div class="outer-container">
        <form action="" method="post"
            name="frmExcelImport" id="frmExcelImport" enctype="multipart/form-data">
            <div>
                <label>Elija Archivo Excel</label> <input type="file" name="file"
                    id="file" accept=".xls,.xlsx">
                <button type="submit" id="submit" name="import"
                    class="btn-submit">Importar Registros</button>
 
            </div>
 
        </form>
 
    </div>

codigo php:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<?php
include('dbconect.php');
require_once('vendor/php-excel-reader/excel_reader2.php');
require_once('vendor/SpreadsheetReader.php');
 
if (isset($_POST["import"]))
{
 
$allowedFileType = ['application/vnd.ms-excel','text/xls','text/xlsx','application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'];
 
  if(in_array($_FILES["file"]["type"],$allowedFileType)){
 
        $targetPath = 'subidas/'.$_FILES['file']['name'];
        move_uploaded_file($_FILES['file']['tmp_name'], $targetPath);
 
        $Reader = new SpreadsheetReader($targetPath);
 
        $sheetCount = count($Reader->sheets());
        for($i=0;$i<$sheetCount;$i++)
        {
 
            $Reader->ChangeSheet($i);
 
            foreach ($Reader as $Row)
            {
 
                $Fecha = "";
                if(isset($Row[0])) {
                    $Fecha = mysqli_real_escape_string($con,$Row[0]);
                }
 
                $Nombre = "";
                if(isset($Row[1])) {
                    $Nombre = mysqli_real_escape_string($con,$Row[1]);
                }
 
                $Zona = "";
                if(isset($Row[2])) {
                    $Zona = mysqli_real_escape_string($con,$Row[2]);
                }
 
                $Tipo = "";
                if(isset($Row[3])) {
                    $Tipo = mysqli_real_escape_string($con,$Row[3]);
                }
 
                if (!empty($Fecha) || !empty($Nombre) || !empty($Zona) || !empty($Tipo)) {
                    $query = "INSERT INTO `conso`(`Fecha`, `Nombre`, `Zona`, `Tipo`) values('".$Fecha."','".$Nombre."','".$Zona."','".$Tipo."')";
                    $resultados = mysqli_query($con, $query);
 
                    if (! empty($resultados)) {
                        $type = "success";
                        $message = "Excel importado correctamente";
                    } else {
                        $type = "error";
                        $message = "Hubo un problema al importar registros";
                    }
                }
             }
 
         }
  }
  else
  {
        $type = "error";
        $message = "El archivo enviado es invalido. Por favor vuelva a intentarlo";
  }
}
?>

eror:
1
2
3
4
5
6
7
Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in C:\xampp\htdocs\Importar\vendor\SpreadsheetReader_XLSX.php on line 581
 
Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in C:\xampp\htdocs\Importar\vendor\SpreadsheetReader_XLSX.php on line 1049
 
Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in C:\xampp\htdocs\Importar\vendor\SpreadsheetReader_XLSX.php on line 1083
 
Fatal error: Maximum execution time of 30 seconds exceeded in C:\xampp\htdocs\Importar\index.php on line 87

Gracias por su tiempo.
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder