I'm generating a code that can read both ".xls" (Excel5) and ".xlsx" files (Excel2007) and it's funny, because the process I've generated gets the data from the ".xls" file correctly, but without However, if I try to read the data of the same document (same data and structure) but in ".xlsx" format (result of "Save as" the file ".xls" as ".xlsx") it does not work.
In this case, the message appears:
Fatal error: Uncaught exception 'PHPExcel_Exception' with message 'Invalid cell coordinate o1' in C: \ xampp \ htdocs \ CTS \ admin \ PHPExcel \ Classes \ PHPExcel \ Cell.php: 594 Stack trace: # 0 C: \ xampp \ htdocs \ CTS \ admin \ PHPExcel \ Classes \ PHPExcel \ ReferenceHelper.php (881): PHPExcel_Cell :: coordinateFromString ('o1') # 1 C: \ xampp \ htdocs \ CTS \ admin \ PHPExcel \ Classes \ PHPExcel \ ReferenceHelper .php (788): PHPExcel_ReferenceHelper-> updateSingleCellReference ('o1', 'A1', 0, 1) # 2 C: \ xampp \ htdocs \ CTS \ admin \ PHPExcel \ Classes \ PHPExcel \ ReferenceHelper.php (734): PHPExcel_ReferenceHelper- > updateCellReference ('o1', 'A1', 0, 1) # 3 C: \ xampp \ htdocs \ CTS \ admin \ PHPExcel \ Classes \ PHPExcel \ Reader \ Excel2007.php (295): PHPExcel_ReferenceHelper- > updateFormulaReferences ('= IF (AND ($ K8="Ho ...', 'A1', 0, 1) # 4 C: \ xampp \ htdocs \ CTS \ admin \ PHPExcel \ Classes \ PHPExcel \ Reader \ Excel2007.php (885): PHPExcel_Reader_Excel2007-> castToFormula (Object (SimpleXMLElement), 'W9', 'f', '=', '0', Array, 'castToString') # 5 C: \ xampp \ htdocs \ CTS \ admin \ You erFicheroExcel2.php (21): PHPExcel_Reader_Excel2007- > in C: \ xampp \ htdocs \ CTS \ admin \ PHPExcel \ Classes \ PHPExcel \ Cell.php on line 594
And I do not understand anything, because if I look at the file and search for "o1" I can not find any cell. The columns go from A to AC. And the rows from 1 to 184.
I have followed the code:
$archivo = $_FILES['fichero_usuario']['tmp_name'];
$inputFileType = PHPExcel_IOFactory::identify($archivo);
$objReader = PHPExcel_IOFactory::createReader($inputFileType);
$objPHPExcel = $objReader->load($archivo);
And I see that the error gives me in the line of the load:
$objPHPExcel = $objReader->load($archivo);
I do not understand if both files have the same structure and content, because with ".xls" it works and with ".xlsx" no.
The file type stored in "inputFileType" is correct (Excel5 for ".xls") and (Excel2007 for ".xlsx").
Please, can you help me with this topic? Do you know what could be causing the error?