Versión 1/4 - Siguiente » - Versión actual
Guillermo Zdanowicz, 18/10/2011 21:14


Codigo para armar planillas excel

public function executeMostraralumnos()
{
$idanio = $this->getRequestParameter('anio');
// Obtener nuevos inscriptos por anio
$resultado = AlumnosPeer::getAlumnosActivos($idanio);
//Creamos el archivo temporal de exportación
$file = 'al'.$idanio.'.csv';
$fh = fopen($file,"w+") or die ("unable to open file");
$titulo = "Nombre, Apellido, NroDoc, Carrera, FechaIngreso,"."\n";
fwrite($fh,$titulo);
foreach($resultado as $datos){
//Cabecera - Cambienla por sus necesidades
$row = $datos[0].",".$datos[1].",".$datos[2].",".$datos[3].",".$datos[4].","."\n";
fwrite($fh,$row);
}
// Close file            
fclose($fh);
header("Content-Type: application/vnd.ms-excel");
header("Content-Type: application/force-download");
header("Content-Transfer-Encoding: binary");
header("Content-Disposition: attachment;filename=".$file );
header("Content-Length: ".filesize($file));
header("Pragma: no-cache");
header("Expires: 0");
readfile($file);
return sfView::NONE; 
}
Redmine Appliance - Powered by TurnKey Linux