Buen día, me sale un error que no entiendo al usar Php Excel
, alguien me puede ayudar.
Fatal error: Uncaught PHPExcel_Exception: Cell coordinate can not be zero-length string in C:\xampp\htdocs\Unificada\library\PHPExcel-1.8\Classes\PHPExcel\Cell.php:591 Stack trace: #0 C:\xampp\htdocs\Unificada\library\PHPExcel-1.8\Classes\PHPExcel\Style.php(228): PHPExcel_Cell::coordinateFromString('') #1 C:\xampp\htdocs\Unificada\view\Load.php(164): PHPExcel_Style->applyFromArray(Array) #2 {main} thrown in C:\xampp\htdocs\Unificada\library\PHPExcel-1.8\Classes\PHPExcel\Cell.php on line 591
error_reporting(E_ALL); ini_set('display_errors', TRUE); ini_set('display_startup_errors', TRUE); date_default_timezone_set('America/Bogota'); require_once '../library/PHPExcel-1.8/Classes/PHPExcel.php'; require '../controller/Conexion.php'; $objPHPExcel = new PHPExcel(); $objPHPExcel->getProperties()->setCreator("") ->setLastModifiedBy("") ->setTitle("Office 2010 XLSX Documento de Excel") ->setSubject("Office 2010 XLSX Documento de Excel") ->setDescription("Documento de Excel para Office 2010 XLSX.") ->setKeywords("office 2010 openxml php") ->setCategory("Archivo con resultado de Excel"); $objPHPExcel->setActiveSheetIndex(0)->mergeCells('A1:E1'); $objPHPExcel->setActiveSheetIndex(0) ->setCellValue('A1', 'PROD ESC') ->setCellValue('A2', 'Identificacion TXT') ->setCellValue('B2', 'Producto') ->setCellValue('C2', 'Credito') ->setCellValue('D2', 'Credito_2') ->setCellValue('E2', 'Saldo Capital'); $boldArray = array('font' => array('bold' => true,), 'alignment' => array('horizontal' => PHPExcel_Style_Alignment::HORIZONTAL_CENTER)); $objPHPExcel->getActiveSheet()->getStyle('A1:E2')->applyFromArray($boldArray); $objPHPExcel->getActiveSheet()->getColumnDimension('A')->setWidth(20); $objPHPExcel->getActiveSheet()->getColumnDimension('B')->setWidth(30); $objPHPExcel->getActiveSheet()->getColumnDimension('C')->setWidth(30); $objPHPExcel->getActiveSheet()->getColumnDimension('D')->setWidth(30); $objPHPExcel->getActiveSheet()->getColumnDimension('E')->setWidth(30); $sql = "SELECT * FROM `prod esc`"; $query = mysqli_query($conexion, $sql); $cel = 3; while ($row = mysqli_fetch_array($query)) { $A1 = $row['IdentificacionTXT']; $B1 = $row['Producto']; $C1 = $row['Credito']; $D1 = $row['Credito2']; $E1 = $row['SaldoCapital']; $a = "A" . $cel; $b = "B" . $cel; $c = "C" . $cel; $d = "D" . $cel; $e = "E" . $cel; $objPHPExcel->setActiveSheetIndex(0) ->setCellValue($a, $A1) ->setCellValue($b, $B1) ->setCellValue($c, $C1) ->setCellValue($d, $D1) ->setCellValue($e, $E1); $cel += 1; } $rango = "A2:'$e'"; $styleArray = array('font' => array('name' => 'Arial', 'size' => 12), 'borders' => array('allborders' => array('style' => PHPExcel_Style_Border::BORDER_THIN, 'color' => array('argb' => 'FFF')))); $objPHPExcel->getActiveSheet()->getStyle($rango)->applyFromArray($styleArray); $objPHPExcel->getActiveSheet()->setTitle('Prod esc'); $objPHPExcel->setActiveSheetIndex(0); header('Content-Type: application/vnd.ms-excel'); header('Content-Disposition: attachment;filename="reporte.xls"'); header('Cache-Control: max-age=0'); header('Cache-Control: max-age=1'); header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); // Date in the past header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); // always modified header('Cache-Control: cache, must-revalidate'); // HTTP/1.1 header('Pragma: public'); // HTTP/1.0 $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5'); $objWriter->save('php://output'); exit; ?>
Gracias de antemano.