
descarga en Excel
Publicado por Hugo (37 intervenciones) el 08/10/2022 21:24:23
Hola, buenas tardes estimados.
Estoy teniendo un problema con una emisión de reportes en Excel.
Resulta que en intento descargar una consulta en Excel la cual en mi localhost se descarga correctamente, pero cuando lo intento hacer en el Servidor, no lo descarga y me muestra la consulta realizada en HTML.
Lo cierto es que le doy vueltas y no encuentro el porqué.
Agradecería mucho si alguien me pudiese echar una mano para resolverlo.
Copio el código:
reporte_faltas.php:
Estoy teniendo un problema con una emisión de reportes en Excel.
Resulta que en intento descargar una consulta en Excel la cual en mi localhost se descarga correctamente, pero cuando lo intento hacer en el Servidor, no lo descarga y me muestra la consulta realizada en HTML.
Lo cierto es que le doy vueltas y no encuentro el porqué.
Agradecería mucho si alguien me pudiese echar una mano para resolverlo.
Copio el código:
reporte_faltas.php:
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
<?php
session_start();
?>
<html>
<head>
<title>Intranet</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<link rel="stylesheet" type="text/css" href="../../../Cabecera/cabecera.css">
<link rel="stylesheet" type="text/css" href="../../gsa.css">
<link rel="stylesheet" type="text/css" href="../Reclamos de Sueldo/reporte_reclamos.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Kaisei+HarunoUmi:wght@500&display=swap" rel="stylesheet">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/limonte-sweetalert2/6.11.0/sweetalert2.css"/>
<script src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/limonte-sweetalert2/6.11.0/sweetalert2.js"></script>
</head>
<body>
<?php
include ("../../../Conexion/conexion.php");
?>
<div id="Logo">
<img src= "../../../logo_Univ.jpg" class="soc"/>
</div>
<div id="Cabecera">
<img src= "../../../gsa.png" class="gsa"/>
<?php
require ("../../../Login/iniciar_session.php");
?>
</div>
<div id="Contenedor">
<div id="formulario">
<form action="excel_faltas.php" method="post" class="form">
<div class="formulario">
<h2 class="titulo">Reporte de Faltas con Aviso</h2><br><br>
<div class="fechas">
<span class="Desde">Desde:
<input type="date" name="desde" class="fecha" required/></span>
<span class="Hasta">Hasta:
<input type="date" name="hasta" class="fecha" required/></span>
<br><br><br><br><br><br>
<div class="boton">
<button type="submit" name="ver" class="btn btn-primary btn-lg btn-block boton">Descargar</button><br><br><br>
<a href="../emision_reportes.php"><button type="button" class="btn btn-danger btn-lg btn-block boton">Volver</button></a>
</div>
</div>
</div>
</form>
<?php
//error_reporting(E_ERROR | E_WARNING | E_PARSE);
date_default_timezone_set("America/Montevideo");
if(isset($_POST['ver'])){
$desde=$_POST['desde'];
$hasta=$_POST['hasta'];
$datos="SELECT * FROM faltas WHERE (fechaDesde>='$desde' && fechaDesde<='$hasta') ORDER BY fechaDesde DESC";
$query_datos=$conexion->query($datos);
?>
<div class="col-md-8-sm">
<br><table class="table table-striped table-responsive table-sm table-hover table-bordered">
<thead class="encabezado" >
<tr>
<th>N° Solic.</th>
<th>N° Func.</th>
<th>Nombre</th>
<th>Apellido</th>
<th>Sección</th>
<th>Tipo</th>
<th>Desde</th>
<th>Hasta</th>
<th>Cant. de Días</th>
<th>Fecha de Solicitud</th>
<th>Hora de Solicitud</th>
</tr>
</thead>
<tbody>
<?php
while($array_datos=$query_datos->fetch_assoc()){
$fecha_desde=$array_datos['fechaDesde'];
$desde=strtotime($fecha_desde);
$f_desde=date('d-m-Y',$desde);
$fecha_hasta=$array_datos['fechaHasta'];
$hasta=strtotime($fecha_hasta);
$f_hasta=date('d-m-Y',$hasta);
$fecha_solicitud=$array_datos['fechaSolicitud'];
$solic=strtotime($fecha_solicitud);
$f_solic=date('d-m-Y',$solic);
?>
<tr>
<td><?php echo $array_datos['idSolic']?></td>
<td><?php echo $array_datos['numFunc']?></td>
<td><?php echo $array_datos['nombre']?></td>
<td><?php echo $array_datos['apellido']?></td>
<td><?php echo $array_datos['seccion']?></td>
<td><?php echo $array_datos['tipo']?></td>
<td><?php echo $f_desde?></td>
<td><?php echo $f_hasta?></td>
<td><?php echo $array_datos['cantDias']?></td>
<td><?php echo $f_solic?></td>
<td><?php echo $array_datos['horaSolic']?></td>
</tr>
<?php
}
?>
</tbody>
</table>
<?php
}
?>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</div>
</div>
</body>
</html>
excel_faltas.php:
<?php
session_start();
?>
<meta charset="utf-8">
<?php
header("Content-Type: application/xls");
header("Content-Disposition: attachment; filename= faltas.xls");
?>
<table class="table table-striped table-responsive table-sm table-hover table-bordered">
<thead class="encabezado" >
<h3>Faltas con aviso</h3>
<tr>
</tr>
<tr>
<th>N° Solic.</th>
<th>N° Func.</th>
<th>Nombre</th>
<th>Apellido</th>
<th>Sección</th>
<th>Tipo</th>
<th>Desde</th>
<th>Hasta</th>
<th>Cant. de Días</th>
<th>Fecha de Solicitud</th>
<th>Hora de Solicitud</th>
</tr>
</thead>
<tbody>
<?php
include ("../../../Conexion/conexion.php");
//error_reporting(E_ERROR | E_WARNING | E_PARSE);
if(isset($_POST['ver'])){
$desde=$_POST['desde'];
$hasta=$_POST['hasta'];
$datos="SELECT * FROM faltas WHERE (fechaDesde>='$desde' && fechaDesde<='$hasta') ORDER BY fechaDesde DESC";
$query_datos=$conexion->query($datos);
?>
<?php
$fec_desde=strtotime($desde);
$fecha_des=date('d-m-Y',$fec_desde);
$fec_hasta=strtotime($hasta);
$fecha_has=date('d-m-Y',$fec_hasta);
echo '<p>'.'Período: '.$fecha_des.' - '.$fecha_has.'</p>';
?>
<?php
while($array_datos=$query_datos->fetch_assoc()){
$fecha_desde=$array_datos['fechaDesde'];
$desde=strtotime($fecha_desde);
$f_desde=date('d-m-Y',$desde);
$fecha_hasta=$array_datos['fechaHasta'];
$hasta=strtotime($fecha_hasta);
$f_hasta=date('d-m-Y',$hasta);
$fecha_solicitud=$array_datos['fechaSolicitud'];
$solic=strtotime($fecha_solicitud);
$f_solic=date('d-m-Y',$solic);
?>
<tr>
<td><?php echo $array_datos['idSolic']?></td>
<td><?php echo $array_datos['numFunc']?></td>
<td><?php echo $array_datos['nombre']?></td>
<td><?php echo $array_datos['apellido']?></td>
<td><?php echo $array_datos['seccion']?></td>
<td><?php echo $array_datos['tipo']?></td>
<td><?php echo $f_desde?></td>
<td><?php echo $f_hasta?></td>
<td><?php echo $array_datos['cantDias']?></td>
<td><?php echo $f_solic?></td>
<td><?php echo $array_datos['horaSolic']?></td>
</tr>
<?php
}
?>
</tbody>
</table>
<?php
}
?>
Valora esta pregunta


0