I can upload files. xlsx but no. xls

Topics: Developer Forum
Jan 18, 2012 at 2:32 PM

when I load a file. xlsx, goes well. But when I try with a file. Xls, get error in the line: $objPHPExcel = $ objReader-> load ($ filename).

 

require_once("../../Classes/PHPExcel.php");

if ($tipo_archivo=="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet") {

require_once("../../Classes/PHPExcel/Reader/Excel2007.php");           

$objReader = new PHPExcel_Reader_Excel2007();                   

} else {           

require_once("../../Classes/PHPExcel/Reader/Excel5.php");           

$objReader = new PHPExcel_Reader_Excel5();       

}               

$objPHPExcel = $objReader->load($nombre_archivo);       

$objPHPExcel->setActiveSheetIndex(0);       

$i=13;       

while($objPHPExcel->getActiveSheet()->getCell("B".$i)->getValue() != '')        {             

  $sexo = $objPHPExcel->getActiveSheet()->getCell("F".$i)->getValue();           

$tipodoc = $objPHPExcel->getActiveSheet()->getCell("G".$i)->getValue();           

$numdoc = $objPHPExcel->getActiveSheet()->getCell("H".$i)->getValue();            

$carga = mysql_query("insert into temphv (sexo,tipodoc,numdoc)  values('$sexo','$tipodoc','$numdoc')",$db);                       

$i++;       

}

Coordinator
Jan 18, 2012 at 5:58 PM

Telling us what error you get might help

Jan 18, 2012 at 7:14 PM

This is the error:

Fatal error: Call to a member function getNestingLevel() on a non-object in C:\wamp\www\iecasd\Classes\PHPExcel\Reader\Excel5.php on line 842

Coordinator
Jan 18, 2012 at 7:57 PM

There's something in the specific file that you're testing with that PHPExcel expects, but isn't finding.... quite what I couldn't say without seeing the file itself.