Excel in php report

0

 aqui es el que genera el reporte php

<?php
require "../conexion.php";

 $mos ="";
				  
	  if(($_GET['fechaini']=="") && ($_GET['fechafin']==""))
	  {
	  $consulta="";
	  }else
	     { 
		   $consulta="AND s.fecha BETWEEN '".$_GET['fechaini']."' AND '".$_GET['fechafin']."'";
		  }
      $so ="SELECT s.Id_folio, s.fecha, d.id_departamento, d.nombre,s.descripcion_trabajo, s.observaciones, s.Id_servicio,s.tipo_solicitud, s.costo,  s.id_vehiculo, u.Empleado_Nombre, u.Empleado_id, t.Id_servicio, t.Nombre_servicio,s.Autoriza_Soli,s.Autoriza_Ger,s.Autoriza_GerIs,s.Autoriza_trab,s.Autoriza_termi FROM solicitud as s, departamento as d ,usuarios as u, tipo_servicio as t  WHERE s.id_departamento=d.id_departamento and s.Empleado_id =u.Empleado_id and s.Id_servicio =t.Id_servicio and  Autoriza_Soli=1 and Autoriza_Ger =2 and Autoriza_GerIs=3 and Autoriza_trab=4 and Autoriza_termi=5 ".$consulta."";
                  

$mostrarso=mysql_query($so);

$mos.="<table >


<tr>
        
        <th scope='col' bgcolor='#008000'>Solicitud Servicio</th>
		   <th scope='col' bgcolor='#008000'>Folio</th>
        <th scope='col' bgcolor='#008000'>Fecha</th>
        <th scope='col' bgcolor='#008000'>Mes</th>
        <th scope='col' bgcolor='#008000'>Departamento</th>
        <th scope='col' bgcolor='#008000'>Area</th>
        <th scope='col' bgcolor='#008000'>Tipo Servicio</th>
        <th scope='col' bgcolor='#008000'>Descripción del trabajo</th>
        <th scope='col' bgcolor='#008000'>Observaciones</th>
		<th scope='col' bgcolor='#008000'>Unidad</th>
        <th scope='col' bgcolor='#008000'>Costo</th>
     
      </tr><tr><td></td></tr>
      ";

           
  while($i=mysql_fetch_array($mostrarso)){
      
       $mos .= "<tr><td>".$i["tipo_solicitud"]."</td>";
	    $mos .= "<td>".$i["Id_folio"]."</td>";
      $mos .= "<td>".$i["fecha"]."</td>"; 
       $mos .= "<td>".$i["fecha"]."</td>";
       $mos .="<td>".$i["nombre"]."</td>";
      $mos .="<td>".$i["nombre"]."</td>";
       $mos .= "<td>".$i["Nombre_servicio"]."</td>";
       $mos .= "<td>".utf8_decode($i["descripcion_trabajo"])."</td>"; 
       $mos .= "<td>".utf8_decode($i["observaciones"])."</td>"; 
       $mos .= "<td>".$i["id_vehiculo"]."</td>";
       $mos .= "<td>".$i["costo"]."</td>";
      
	  
	  

	}
$mos.="</table>";
					  header("content-type: application/octet-stream");
					  header("content-Dispositio:attachment; filename=Reporte.xls");
					  header("pragma: no-cache");
					  header("Expires: 0");
					 echo $mos;
	?>
	

Hi, I'm generating an excel report from php but I find it so weird that I can take away the ñ the accent libraries and ñ I put them on, any suggestions

    
asked by Esther 15.11.2018 в 21:30
source

1 answer

0

I had the same problem in a report, if your view has HTML I recommend placing the charset = iso-8859-1 encoding in the meta:

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1 " />

If you are doing it with data from the database, as Elias says in the comment, you can place it with utf8_decode in the following way:

$mos .="<td>".utf8_decode($i["nombre"])."</td>";

And that way in each column that you require ...
I hope it will help you.
Greetings.

    
answered by 15.11.2018 в 21:44