Ver Mensaje Individual
  #10 (permalink)  
Antiguo 13/03/2009, 09:55
karis_fibbo
 
Fecha de Ingreso: febrero-2009
Mensajes: 47
Antigüedad: 15 años, 2 meses
Puntos: 2
De acuerdo Respuesta: Generar reportes en excel desde php + postgres

Oiie yo tengo este codigo me funciona la perfeciión... me cuentaas!
Código:
<?php
	include("../componentes/conexion.php");
	$conexion=conectar();
	
	$consulta2="select usuario.cedula, usuario.nombres, seccion.nombre_seccion, tipo_usuario.cargo, func_hor.fecha, func_hor.ent1, func_hor.sal1, func_hor.ent2, func_hor.sal2
	from usuario, tipo_usuario, func_hor, seccion
	where usuario.cedula=tipo_usuario.ced
	and tipo_usuario.cod_usuario=func_hor.cod_usuar
	and tipo_usuario.cod_seccion=func_hor.cod_seccion
	and func_hor.cod_seccion=seccion.cod_seccion
	and tipo_usuario.cod_seccion=seccion.cod_seccion order by fecha, cedula, nombres";
	
	$ejecutar2=pg_exec($conexion, $consulta2);
	$registro2=pg_num_rows($ejecutar2);
	
	if ($registro2==0) 
		echo '<script>alert("No hay registros");window.history.back();</script>';
	else
		{
header('Content-type: application/vnd.ms-excel');
header("Content-Disposition: attachment; filename=Horarios.xls");
header("Pragma: no-cache");
header("Expires: 0");
echo "<table border=1>\n";
echo "<tr>\n";
echo "<th>Cedula</th>\n";
echo "<th>Nombre</th>\n";
echo "<th>Seccion</th>\n";
echo "<th>Cargo</th>\n";
echo "<th>Fecha Horario</th>\n";
echo "<th>Entrada 1</th>\n";
echo "<th>Salida 1</th>\n";
echo "<th>Entrada 2</th>\n";
echo "<th>Salida 2</th>\n";
echo "</tr>\n";
$row=0;
do
    {
	    $myrow=pg_fetch_row($ejecutar2,$row);
		$row++;
		$n0=$myrow["0"];
		$n1=$myrow["1"];
$n2=$myrow["2"];
$n3=$myrow["3"];
$n4=$myrow["4"];
$n5=$myrow["5"];
$n6=$myrow["6"];
$n7=$myrow["7"];
$n8=$myrow["8"];

echo "<tr>\n";
echo "<td>".$n0."</td>\n";
echo "<td>".$n1."</td>\n";
echo "<td>".$n2."</td>\n";
echo "<td>".$n3."</td>\n";
echo "<td>".$n4."</td>\n";
echo "<td>".$n5."</td>\n";
echo "<td>".$n6."</td>\n";
echo "<td>".$n7."</td>\n";
echo "<td>".$n8."</td>\n";
echo "</tr>\n";
}//finDo
	while($row < $registro2);

echo "</table>\n";
}//fin else
if ($registro2<>0)
?>