Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- echo '<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /></head><body>';
- echo '<h2>CARGAR EXCEL</h2>
- <form method="post" enctype="multipart/form-data">
- *.XLSX <input type="file" name="file" /> <input type="submit" value="Procesar..." />
- </form>';
- echo "<h3>FAVOR DE RESPETAR EL FORMATO DE EXCEL DE 3 COLUMNAS : MATRÍCULA - NOMBRES , CONDICIÓN</h3>";
- if (isset($_FILES['file'])) {
- $host = "xxxxxxxxxxxx";
- $user = "xxxxxxt";
- $password = 'xxxxxxxxxxxxxxxxxxxxxxx';
- $database = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
- $link = mysqli_connect($host, $user, $password, $database);
- mysqli_query($link, "truncate estadodecolegiados;");
- require_once __DIR__ . '/simplexlsx.class.php';
- if ($xlsx = SimpleXLSX::parse($_FILES['file']['tmp_name'])) {
- $array = $xlsx->rows();
- foreach ($array as $key => $value) {
- $sql = "insert into estadodecolegiados(matricula,nombre,condicion) values('".$value[0]."','". utf8_decode($value[1])."','".$value[2]."');";
- mysqli_query($link, $sql);
- }
- echo '<h2>RESULTADOS</h2>';
- echo '<table border="1" cellpadding="3" style="border-collapse: collapse">';
- list( $cols, ) = $xlsx->dimension();
- foreach ( $xlsx->rows() as $k => $r ) {
- // if ($k == 0) continue; // skip first row
- echo '<tr>';
- for ( $i = 0; $i < $cols; $i ++ ) {
- echo '<td>' . ( ( isset( $r[ $i ] ) ) ? $r[ $i ] : ' ' ) . '</td>';
- }
- echo '</tr>';
- }
- echo '</table>';
- }else {
- echo SimpleXLSX::parse_error();
- }
- mysqli_close($link);
- }
- echo '</body></html>';
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement