PHP - Problemas con PHPExcel

 
Vista:
sin imagen de perfil

Problemas con PHPExcel

Publicado por Diego (2 intervenciones) el 15/09/2015 22:29:48
Hola, me gustaría que me ayudaran con un problema que tengo al exportar un reporte de 24 y cerca de 10000 filas. Utilizo la librería de PHPExcel en su versión mas actual.

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
error_reporting(E_ALL);
 
require_once("./../lib/Library.inc");
 
$program = "Report_Transmissions.php";
 
require_libs($program);
 
$www_session = NULL;
 
$www_userid  = NULL;
 
$www_option  = NULL;
 
$www_reg     = NULL;
 
$www_last    = NULL;
 
$error 	     = NULL;
 
$www_regs    = NULL;
 
$www_prev    = NULL;
 
$www_delete  = NULL;
 
$www_criteria= NULL;
 
$www_order   = NULL;
 
$db		 = NULL;
 
$error = new ErrorHandler;
 
	$s = new SessionHandler;
 
	$s->Resume_Session();
 
//$s->Resume_Session();
 
$www_order   = trim($_REQUEST['w_e']);//
 
$www_session = trim($_REQUEST['w_s']);
 
$www_userid  = trim($_REQUEST['w_u']);
 
$www_option  = trim($_REQUEST['w_o']);
 
$www_reg     = trim($_REQUEST['w_r']);
 
$www_last    = trim($_REQUEST['w_l']);
 
$www_first   = trim($_REQUEST['w_f']);
 
$www_regs    = trim($_REQUEST['w_a']);
 
$www_prev    = trim($_REQUEST['w_t']);
 
$www_delete  = trim($_REQUEST['w_d']);
 
$www_criteria= trim($_REQUEST['w_c']);
 
$initdate   = trim($_REQUEST['wf_0']);
 
$enddate = trim($_REQUEST['wf_1']);
 
//---- Variables Agregadas -------- 
 
$array2 = NULL;
 
 
//echo $_REQUEST['cons'];
$cons = $_REQUEST['cons'];
 
$tmp2 = urldecode($cons);
 
$tmp2 = unserialize($tmp2);
 
$array2 = $tmp2;
 
if(is_array($array2)){
	$van=false;
 
}
else{
	$van = true;
}
 
$nom = trim ($_REQUEST['name']);
 
$title = trim ($_REQUEST['title']);
 
$total=$_REQUEST['total'];
 
$arrays = $_REQUEST['ary'];
 
$tmp = stripslashes($arrays);
 
$tmp = urldecode($tmp);
 
$tmp = unserialize($tmp);
 
$array = $tmp;
 
 
if ( !strlen($www_session) || !strlen($www_userid) )
 
{
 
	$login_again = new LoginDialog;
 
		$login_again->Login("Possible atttack, Please login again");
 
 
 
		$error->Report($program, 9998, "parameters expected by $program");
 
}
 
else
 
{
 
//print_r($array2);
	$currenttime = date('d-m-Y');
	require_once ("Classes/PHPExcel.php");
	$objphp = new PHPExcel();
	$objphp->getProperties();
 
	$objphp = new PHPExcel();
	$objphp->getActiveSheet()->setTitle('Import'.$currenttime.'');
 
	$rownum = 1;
	$objphp->getActiveSheet()->setCellValue('A'.$rownum,$title);
	$rownum++;
 
	$objphp->getActiveSheet()->fromArray(array($array),NULL,'A'.$rownum);
	$rownum++;
 
	$nume=1;
 
	if($van){
		$conexion  = new mysqli("localhost","user","password","db");
		if ($conexion->connect_errno) {
			printf("La conexión con el servidor de base de datos falló: %s\n", $conexion->connect_error);
			exit();
		}
		if($result = $conexion->query($cons) or die ($conexion->error))
		{
			while($row = $result->fetch_row()){
				$col = 'A';
				if($ultimo=='E' || $ultimo=='D'){
				$nuevo=array_pop($row);}
 
				array_unshift($row,$nume);
				$nume++;
 
				foreach($row as $cell){
////print_r($row);
					$objphp->getActiveSheet()->setCellValue($col.$rownum,utf8_encode($cell));
					//$objphp->getActiveSheet()->getColumnDimension($col)->setAutoSize('true');
					$col++;
				}
 
				$ultimo=$col--;
				if($ultimo=='E' || $ultimo=='D'){
				$objphp->getActiveSheet()->setCellValue('D'.$rownum,'=(C'.$rownum.'*100)/'.$total);}
 
				$rownum++;
			}
		}
	}
	else{
		for( $y1=0; $y1<count($array2); $y1++){//count($array2)
			$col='A';
 
			array_unshift($array2[$y1],$nume);
			$nume++;
//print_r($array2);
 
			for( $x=0; $x<count($array); $x++){
				$cell1=$array2[$y1][$x];
 
				$objphp->getActiveSheet()->setCellValue($col.$rownum,$cell1);
//print($array2[$y1][$x]);
//echo " - ";
				$col++;
 
			}
			$rownum++;
//echo "</br>";
		}
//print_r($array2);
	}
	header("Last-Modified: ".$currenttime."GMT");
	header("Cache-Control: no-store, no-cache, must-revalidate");
	header("Cache-Control: post-check=0, pre-check=0", false);
	header("Pragma: no-cache");
	header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
 
	header('Content-Disposition: attachment;filename="'.$nom.'.xlsx"');
	header('Cache-Control: max-age=0');
 
	$objwrite = PHPExcel_IOFactory::createWriter($objphp,'Excel2007');
 
	$objwrite->save('php://output');
	exit();
}
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
Imágen de perfil de xve
Val: 3.943
Oro
Ha mantenido su posición en PHP (en relación al último mes)
Gráfica de PHP

Problemas con PHPExcel

Publicado por xve (6935 intervenciones) el 16/09/2015 08:36:29
Hola Diego, y que problema tienes?
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
sin imagen de perfil

Problemas con PHPExcel

Publicado por diego (2 intervenciones) el 17/09/2015 16:14:22
Hola, el problema es cuando quiero exportar una tabla con 24 columnas y mas de 7000 filas, se pone en blanco la pantalla y a veces me cierra la secion del sistema, adjunto reporte con menos de 7000 filas del mismo reporte.
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