File "generarExcel.php"

Full Path: C:/wamp64/www/sistemas/NAS/generarExcel.php
File size: 957 bytes
MIME-type: text/x-php
Charset: utf-8

<?php
include("connection.php");
header("Content-Type: application/vnd.ms-excel");
header("Content-Disposition: attachment; filename=nas_".date('Y-m-d').".xls");

$con = connection();
$sql = "SELECT * FROM nas ORDER BY id DESC";
$query = $con->query($sql);

echo "<table border='1'>";
echo "<tr>
        <th>ID</th>
        <th>Nombre Colaborador</th>
        <th>Cargo Colaborador</th>
        <th>ID QNAS</th>
        <th>ContraseƱa</th>
        <th>Estado</th>
      </tr>";

while ($row = $query->fetch_assoc()) {
    echo "<tr>
            <td>".$row['id']."</td>
            <td>".htmlspecialchars($row['nombre_colaborador'])."</td>
            <td>".htmlspecialchars($row['cargo_colaborador'])."</td>
            <td>".htmlspecialchars($row['ID_QNAS'])."</td>
            <td>".htmlspecialchars($row['contrasena'])."</td>
            <td>".htmlspecialchars($row['estado'])."</td>
          </tr>";
}
echo "</table>";
?>