I want to generate an excel report of my markup query. but I could not.
I get the following error in the excel.
<b>Fatal error</b>: Class 'Conexion' not found in <b>C:\xampp\htdocs\intragarzon2.0\formatosTH\marcaje\core\bin\ajax\goFech.php</b> on line <b>16</b><br />
this is my connection
<?php
class Conectar{
public static function conexion($host){
try{
$conect=new PDO('mssql:host='.$host.'; dbname=Empleados', 'sa', '');
// $conect=new PDO('mssql:host=192.168.20.207; dbname=Empleados', 'sa', '');
$conect->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
// $conect->exec("SET CHARACTER UTF8");
}catch(Exception $e){
die ("Error " . $e->getMessage());
echo "Línea del Error " . $e->getLine();
}
return $conect;
}
}
?>
and this is code to export the query
<?php
header('Pragma: public');
header('Expires: Sat, 26 Jul 1997 05:00:00 GMT'); // Date in the past
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
header('Cache-Control: no-store, no-cache, must-revalidate'); // HTTP/1.1
header('Cache-Control: pre-check=0, post-check=0, max-age=0'); // HTTP/1.1
header('Pragma: no-cache');
header('Expires: 0');
header('Content-Transfer-Encoding: none');
header('Content-Type: application/vnd.ms-excel'); // This should work for IE & Opera
header('Content-type: application/x-msexcel'); // This should work for the rest
header('Content-Disposition: attachment; filename="Reporte Marcaje.xls"');
$adam = new Conexion();
$re=$adam->conectar();
$desde = $_POST['desde'];
$hasta = $_POST['hasta'];
if(isset($desde) == false) {
$desde = $hasta;
}
if(isset($hasta)==false) {
$hasta = $desde;
}
// $j=0;
$confech=$re->query("SELECT * FROM marcaje WHERE fechRevista BETWEEN '$desde' AND '$hasta'");
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Document</title>
</head>
<body>
<div class="contariner">
<div class="row">
<table width="60%" border="0" align="center" cellpadding="0" cellspacing="0" class="table table-condensed" id="ocultarFecha">
<tr>
<td class="nombreNegrita">Fecha Entrada</td>
<td class="nombreNegrita">Hora Entrada</td>
<td class="nombreNegrita">Cédula</td>
<td class="nombreNegrita">Nombre</td>
<td class="nombreNegrita">Cargo</td>
<td class="nombreNegrita">Departamento</td>
<td class="col-sm-5 nombreNegrita">Fecha de Revista</td>
<td class="nombreNegrita">Hora de Revista</td>
<td class="nombreNegrita">Encargado</td>
<td class="nombreNegrita">Cargo</td>
<td class="nombreNegrita">Departamento</td>
<td class="nombreNegrita">Sucursal</td>
<td><a href="formatosTH/marcaje/core/bin/ajax/goFech.php" class="btn btn-success">Exportar</a></td>
</tr>
<?php
while($row=$confech->fetch(PDO::FETCH_ASSOC)) {
?>
<tr>
<td><?php echo $row['fechEntrada']; ?></td>
<td><?php echo $row['horaEntrada']; ?></td>
<td><?php echo $row['cedula']; ?></td>
<td><?php echo $row['nombre']; ?></td>
<td><?php echo $row['cargo']; ?></td>
<td><?php echo $row['departamento'] ?></td>
<td><?php echo $row['fechRevista']; ?></td>
<td><?php echo $row['horaRevista']; ?></td>
<td><?php echo $row['usuario_sesion']; ?></td>
<td><?php echo $row['cargo_sesion']; ?></td>
<td><?php echo $row['departamento_sesion']; ?></td>
<td><?php echo $row['sucursal_sesion']; ?></td>
</tr>
<?php } ?>
</table>
</div>
</div>
</body>
</html>
Also, on the page I do not get the results of the query? why will it be?