2024 GUIA PRACTICAS MICROBIOLOGIA- UNA 2017 (1).pdf
Reportes en php
1. EXPORTAR REPORTES CON PHP
Exportar Reportes en PDF
Exportar Reportes en EXCEL
Exportar Reportes en WORD
Este es el reporte en .doc
El documento index.php es
<head>
<title>EJEMPLO REPORTES EN PHP</title>
</head>
<body>
<center><img src="imagenes/sello.jpg" width="650" height="76" /></center>
<p><br />
<table border="2" width="500" bgcolor="#00CCFF" align="center">
<tr>
<td align="center" colspan="2">
<strong>EXPORTAR REPORTES CON PHP</strong>
</td>
<tr>
<td width="439"><strong>Exportar Reportes en PDF</strong></td>
<td width="145" align="center"><a href="reporte_pdf.php"><img src="imagenes/pdf.png"
width="30" height="25"/></a></td>
</tr>
2. <tr>
<td><strong>Exportar Reportes en EXCEL</strong></td>
<td align="center"><a href="reporte_excel.php"><img src="imagenes/excel.png"
width="30" height="25"/></a></td>
</tr>
<tr>
<td><strong>Exportar Reportes en WORD</strong></td>
<td align="center"><a href="reporte_word.php"><img src="imagenes/word.png"
width="30" height="25"/></a></td>
</tr>
</table>
</body>
</html>
Los documentos php para generar los reportes en Word, pdf y Excel son
<?php
header("Content-type: application/vnd.ms-word");
header("Content-Disposition: attachment;
filename=Reporte_Personal_usuarios.doc");
$conexion=mysql_connect("localhost","root","");
mysql_select_db("ejemplo_pdf",$conexion);
?>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"
/>
<title>LISTA DE USUARIOS</title>
</head>
<body>
<table width="100%" border="1" cellspacing="0" cellpadding="0">
<tr>
<td colspan="6" bgcolor="skyblue"><CENTER><strong>REPORTE DE
LA TABLA USUARIOS</strong></CENTER></td>
</tr>
<tr bgcolor="red">
<td><strong>CODIGO</strong></td>
<td><strong>NOMBRE</strong></td>
<td><strong>APELLIDO</strong></td>
<td><strong>PAIS</strong></td>
<td><strong>EDAD</strong></td>
<td><strong>DNI</strong></td>
</tr>
<?PHP
5. </head>
<body>
<table width="100%" border="1" cellspacing="0" cellpadding="0">
<tr>
<td colspan="6" bgcolor="skyblue"><CENTER><strong>REPORTE DE
LA TABLA USUARIOS</strong></CENTER></td>
</tr>
<tr bgcolor="red">
<td><strong>CODIGO</strong></td>
<td><strong>NOMBRE</strong></td>
<td><strong>APELLIDO</strong></td>
<td><strong>PAIS</strong></td>
<td><strong>EDAD</strong></td>
<td><strong>DNI</strong></td>
</tr>
<?PHP
$sql=mysql_query("select cod_usu,nombre,Apellido,Pais,edad,dni
from usuarios");
while($res=mysql_fetch_array($sql)){
$codigo=$res["cod_usu"];
$nombre=$res["nombre"];
$Apellido=$res["Apellido"];
$Pais=$res["Pais"];
$edad=$res["edad"];
$dni=$res["dni"];
?>
<tr>
<td><?php echo $codigo; ?></td>
<td><?php echo $nombre; ?></td>
<td><?php echo $Apellido; ?></td>
<td><?php echo $Pais; ?></td>
<td><?php echo $edad; ?></td>
<td><?php echo $dni; ?></td>
</tr>
<?php
}
?>
</table>
</body>
</html>
Para los íconos de word, pdf y excel, pueden utilizar google y descargarla desde internet y
colocarla en la carpeta de imágenes y disenar el aviso que se encuentra en la parte superior
del index.html
Este es el código para exportar a pdf con dompdf