When I try to create a function that fills my data automatically with PHPExcel and a series of fixes, I get the following error:
" Fatal error: Uncaught PHPExcel_Exception: Cell coordinate can not be zero-length string in C: \ inetpub \ wwwroot \ QA \ shared \ PHPExcel \ Cell.php: 591 Stack trace: # 0 C: \ inetpub \ wwwroot \ QA \ shared \ PHPExcel \ Worksheet.php (1218): PHPExcel_Cell :: coordinateFromString ('') # 1 C: \ inetpub \ wwwroot \ QA \ shared \ PHPExcel \ Worksheet.php (1178): PHPExcel_Worksheet-> createNewCell ('') # 2 C: \ inetpub \ wwwroot \ QA \ shared \ PHPExcel \ Worksheet.php (1085): PHPExcel_Worksheet-> getCell ('') # 3 C: \ inetpub \ wwwroot \ QA \ ALP009.php (266): PHPExcel_Worksheet-> setCellValue (NULL, 'Table ID') # 4 {main} thrown in C: \ inetpub \ wwwroot \ QA \ shared \ PHPExcel \ Cell.php on line 591 "
I already looked for several sides and I do not give with the error, since I updated my version of PHPExcel since I read that that error was given in previous versions.
My code:
//Titulo de hoja ALP
$tituloHojaAlp = array(
'ID',
'línea',
'Modelo',
'Submodelo',
'Detalle1',
'Detalle2',
'Descripción',
'Compra Web',
'Formato',
'Moneda',
'Notas',
'Orden',
'Salto',
'Alcance',
'Amca',
'Hmx'
);
function crearTitulos($objPHPExcel,$arrayTitulos){
$columnasEx = array('A1','B1','C1','D1','E1','F1','G1','H1','I1','J1','K1','L1','M1','N1','O1','P1','Q1','R1','S1',
'T1','U1','V1','W1','X1','Y1','Z1');
$long = count($arrayTitulos);
$conColum = count($columnasEx);
//ALP
for ($i = 0; $i < $long; $i++) {
if ($long == $conColum) {
break;
} else {
$objPHPExcel->setActiveSheetIndex(0)->setCellValue($columnasEx[$i], $arrayTitulos[$i]);
// var_dump($columnasEx[$i].$d,$tituloHojaAlp[$i]);
}
}
}
//llamar la funcion y pasarle el arreglo
crearTitulos($objPHPExcel,$tituloHojaAlp);