Buenas tardes todos estoy generando un XLS y un PDF con las libreris de PHPExcel, en mi ambiente de desarrollo funciona perfecto, pero se contrato un hosting publique la aplicación y al generar los archivos el sistema los genera pero sin datos, cuando los voy a abrir el archivo que genera con 1K de tamaño me sale un error diciendo que el archivo no corresponde al tipo de formato o esta dañado, que puede ser? el codigo que genera el PDF es:
<?php
//Traemos las librerias necesarias
require_once("Classes/PHPExcel.php");
require_once("Classes/PHPExcel/Writer/Excel2007.php");
require_once('Classes/PHPExcel/IOFactory.php');
require_once('../../../raxan/pdi/autostart.php');
Raxan::loadConfig('../config.php'); // load external config file
Raxan::config('site.timezone','America/Toronto'); // set timezone
class NewPage extends RaxanWebPage {
protected $db;
protected function _config() {
$this->degradable = true;
// enable or disable debugging
$this->Raxan->config('debug', false);
try {
$this->db = $this->Raxan->connect('booking'); // connect to db
}
catch (Exception $e) {
$this->db = null;
$msg = $this->getView('connection-failed.html');
$this->flashmsg($msg,'bounce','rax-box error');
}
}
protected function _init() {
$idR = $this->get->intVal('idReserva');
$sql ='SELECT sum(totFulles) as tf, sum(totPiezas) as tp, sum(peso) as tps
FROM clientes1 where idReserva=? group by idReserva';
$rows = $this->db->execQuery($sql,$idR);
$tps=0;
$tp=0;
$tf=0;
$awb = '';
$fvuelo = '';
$etd = '';
$eta = '';
$ctd = '';
$cta = '';
$vuelo = '';
$tps = 0;
$tp = 0;
$tf = 0;
$shiper='';
if ($rows){
$tps = (double)$rows[0]['tps'];
$tp = (int)$rows[0]['tp'];
$tf = (double)$rows[0]['tf'];
}
$sql='SELECT * FROM reservageneral where idReserva=?';
$rows = $this->db->execQuery($sql,$idR);
if ($rows){
$awb = $rows[0]['awb'];
$fvuelo = $rows[0]['fvuelo'];
$etd = $rows[0]['ETD'];
$eta = $rows[0]['ETA'];
$ctd = $rows[0]['CTD'];
$cta = $rows[0]['CTA'];
$vuelo = $rows[0]['codigoVuelo'];
$shiper = $rows[0]['shipper'];
}
$fileType = 'Excel5';
$fileName = 'prealerta.xls';
//objeto de PHP Excel
//$objPHPExcel = new PHPExcel();
// Read the file
//$objReader = PHPExcel_IOFactory::createReader($fileType);
//$objPHPExcel = $objReader->load($fileName);
$objPHPExcel = PHPExcel_IOFactory::load($fileName);
// Change the file
$objPHPExcel->setActiveSheetIndex(0)
->setCellValue('B5', $awb)//Master
->setCellValue('B6', $fvuelo)//Fecha
->setCellValue('B7', $vuelo)//Vuelo
->setCellValue('B8', $tf)//Tot Fulles
->setCellValue('B9', $tp)//Tot Piezas
->setCellValue('B10', $tps)//Tot peso
->setCellValue('D4', $shiper)//Shipper
->setCellValue('D5', $etd)//ETD
->setCellValue('D6', $eta)//ETA
->setCellValue('F5', $ctd)//CTD
->setCellValue('F6', $cta);//CTA
//Detalle
$sql = 'SELECT idReserva,totFulles,totPiezas,octavos,cuartos,taba co,fulles,peso,hawb,tipo,consignee
FROM clientes1 where idReserva=? order by hawb';
$filas = $this->db->execQuery($sql,$idR);
$row = 14;
foreach($filas as $rows){
$objPHPExcel->getActiveSheet()->SetCellValue("A".$row, $rows['hawb']);//hawb
$objPHPExcel->getActiveSheet()->SetCellValue("B".$row, $rows['consignee']);//Consignee
$objPHPExcel->getActiveSheet()->setCellValue("C".$row, $rows['octavos']);//1/8
$objPHPExcel->getActiveSheet()->setCellValue("D".$row, $rows['cuartos']);//1/4
$objPHPExcel->getActiveSheet()->setCellValue("E".$row, $rows['tabaco']);//tabacos
$objPHPExcel->getActiveSheet()->setCellValue("F".$row, $rows['fulles']);//fulles
$objPHPExcel->getActiveSheet()->setCellValue("G".$row, $rows['totFulles']);//tot fules
$objPHPExcel->getActiveSheet()->setCellValue("H".$row, $rows['totPiezas']);//tot piezas
$objPHPExcel->getActiveSheet()->setCellValue("I".$row, $rows['peso']);//peso
$row++;
}
//Titulo del libro y seguridad
$objPHPExcel->getActiveSheet()->setTitle('Reporte');
$objPHPExcel->getSecurity()->setLockWindows(true);
$objPHPExcel->getSecurity()->setLockStructure(true);
$objPHPExcel->getActiveSheet()->setShowGridLines(false);
// Se modifican los encabezados del HTTP para indicar que se envia un archivo de PDF.
header('Content-Type: application/pdf');
header('Content-Disposition: attachment;filename="Reporte.pdf"');
header('Cache-Control: max-age=0');
$rendererName = PHPExcel_Settings::PDF_RENDERER_MPDF;
$rendererLibrary = 'mPDF5.4';
$rendererLibraryPath = dirname(__FILE__).'\Classes\PDF\\'. $rendererLibrary;//
if (!PHPExcel_Settings::setPdfRenderer(
$rendererName,
$rendererLibraryPath
)) {
die(
'Please set the $rendererName and $rendererLibraryPath values' .
PHP_EOL .
' as appropriate for your directory structure'
);
}
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'PDF');
$objWriter->save('php://output');
// Echo memory peak usage
echo date('H:i:s') . " Peak memory usage: " . (memory_get_peak_usage(true) / 1024 / 1024) . " MBrn";
// Echo done
echo date('H:i:s') . " Done writing files.rn";
//$objWriter->save('php://output');
exit;
}
}
?>