PHP - Error de lenguaje al exportar a Excel/PDF

 
Vista:
Imágen de perfil de Argimiro

Error de lenguaje al exportar a Excel/PDF

Publicado por Argimiro (20 intervenciones) el 12/11/2014 18:55:42
Muy buenas tardes amigos, aquí con una nueva consulta, he realizado la función para exportar ciertos reportes tanto en excel como en pdf, el punto radica en que los acentos o Ñ me los cambia o anula en el archivo exportado, como puedo corregirlo?

De antemano mil gracias

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="es" lang="es">
<head profile="http://gmpg.org/xfn/11">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="stylesheet" href="scripts/style.css" type="text/css">
</head>
<body>
<?php
	require_once("../scripts/funciones.php");
	//include("../MPDF52/mpdf.php");
	date_default_timezone_set("America/Mexico_City");
	$html = "";
	$header = "";
 
	if(isset($_GET["fi"]) && isset($_GET["fi"])){
		$fi = $_GET["fi"];
		$ft = $_GET["ft"];
		$nt = $_GET["nt"];
		header('Content-type: application/vnd.ms-excel');
		header("Content-Disposition: attachment; filename=reporte_pedidos_trabajador_$fi-$ft.xls");
		header("Pragma: no-cache");
		header("Expires: 0");
		$sql = "select menu.descuento,(menu.costo - menu.descuento) as subtotal, platillo.descripcion,menu.fecha
		from 
			menu_detalle,apartado,menu,platillo
		where 
			apartado.idP = menu_detalle.idP  and menu_detalle.fecha = apartado.fecha and menu.fecha = menu_detalle.fecha and apartado.fecha >='$fi' and apartado.fecha <= '$ft' and platillo.idP = menu_detalle.idP and apartado.nT = '$nt'";
//		echo $sql;
		$c = consulta($sql);
		$html = "";
		if(num_fila($c) > 0){
			$sql = "select concat(apellidos,' ',nombre) as nombre from trabajador where nT = '$nt'";
			$t = objetos(consulta($sql));
			$html .= "<table border='1' cellpadding='0' style='font-family:arial;' cellspacing='0' width='100%' align='center' class='tabla'>";
			if($fi == $ft)
				$ti ="Resumen del Empleado $t->nombre en la fecha  ".fecha($fi);
			else
				$ti ="Resumen del Empleado $t->nombre en el periodo del ".fecha($fi)." al ".fecha($ft)."";
		$html .= "
			<tr align='center'> 
				<th style='border:0px solid #FFF;font-family:arial;' align='center' colspan='5'>$ti</th>
			</tr>
			<tr align='center' bgcolor='#999999'> 
				<th width='30' align='center'>No</th>
				<th  width='90' align='center'>FECHA</th>
				<th>DESCRIPCIÓN</th>
				<th  width='100' align='center'>GASTO EMPRESA</th>
				<th  width='120' align='center'>GASTO TRABAJADOR</th>
			</tr>";
			$x = 1;
			$descuentoE = 0;
			$descuentoT = 0;
			while($r = objetos($c)){
				$html.="<tr >
					<td align='center'>$x</td>
					<td align='center'>$r->fecha</td>
					<td>$r->descripcion</td>
					<td align='center'>$ $r->descuento</td>
					<td align='center'>$ $r->subtotal</td>
				</tr>";
				$descuentoE += $r->descuento;
				$descuentoT += $r->subtotal;
				$x ++;
			}
			$html.="<tr>
				<td colspan='3' align=\"right\"><b>TOTAL:</b></td>
				<td align='center'>$ $descuentoE</td>
				<td align='center'>$ $descuentoT</td>
			</tr>";
			$html .= "</table>";
//			echo utf8_decode($html);
			
		}else
			$html .= "<h1 align='center'>No se encontro ningun resultado</h1>";
	}
//	$html = utf8_decode($html);
	/*$mpdf=new mPDF('c','LETTER',$default_font_size=0,$default_font='',$mgl=15,$mgr=15,$mgt=15,$mgb=16,$mgh=9,$mgf=9); 
	$mpdf->AddPage('P');
	$mpdf->SetDisplayMode('fullpage');
	$mpdf->list_indent_first_level = 0;	
	$mpdf->WriteHTML($stylesheet,1);	
	$mpdf->SetHTMLHeader($hadder,'',true);
	$mpdf->WriteHTML($html,2);
	$mpdf->Output("reporte trabajador $fi.pdf",'I');
	exit;*/
	echo $html
?>
</body>
</html>
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder

Error de lenguaje al exportar a Excel/PDF

Publicado por mario (1 intervención) el 21/10/2015 02:37:06
Es el formato del documento usa UTF SIN BOOM
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar