0

Good Afternoon All,

I am working on an issue in PHPExcel. Using the following code:

try {
                    $inputFileType = PHPExcel_IOFactory::identify($fileLocation);
                    $objReader = PHPExcel_IOFactory::createReader($inputFileType);
                    $objReader->setReadDataOnly(true);
                    $objPHPExcel = $objReader->load($fileLocation);
            } catch(Exception $e) {
                    die('ERROR LOADING FILE: "'.print_r(pathinfo($fileLocation),true).'": '.$e->getMessage());
            } # end try catch

This responses with a this error message: ERROR LOADING FILE: "Array ( [dirname] => upload [basename] => d10f8...188 [filename] => d10f8....188 ) ": Cell coordinate must be a range of cells.

Which makes no sense since I am not reading the file yet, only loading it. This code has been in place and working without issue for months (Probably 100+ uses), only one file is causing this error. The file is a Office2007 XLSX (Just like all the others), I have converted the file to multiple other formats (xls, xlt, xlsm) but none of copies will load either. I have found nothing of interest in the file that could explain this behavior.

I have not found anything in my logs and am at a loss to understand the error message of 'Cell coordinate must be a range of cells'. I have isolated the code and made sure that this error message is being generated during this try/catch and is not coming from somewhere else.

Any help would be greatly appreciated,

Paul

  • You do realise that "loading a file" entails ___reading___ and parsing the file..... reading isn't simply something that you do when you're accessing data from the PHPExcel object, all the "reading" has already been done before you can do that – Mark Baker Mar 01 '16 at 09:31
  • As for the error itself, I can't help you much without knowing where in the codebase that error is occurring..... `$e` should give you a [getTrace()](http://www.php.net/manual/en/exception.gettrace.php) method that can help identify the potential cause of the problem – Mark Baker Mar 01 '16 at 09:33
  • @Mark-Baker,This all occurs in the first 10 line of the script which is loading the file. i added the some debugging to mycatch and got these results: `code` EXCEPTION Cell coordinate must be a range of cells. originates: /var/www/stage/custom/k/phpexcel/PHPExcel/Worksheet/PageSetup.php (649) /var/www/stage/custom/k/phpexcel/PHPExcel/Reader/Excel2007.php (1702) /var/www/stage/custom/modules/Excel_ExcelReader/metadata/listviewdefs.php (69) All of which point to function regarding the print area of the document. That does not make a lot of sense to me. Any ideas? And thanks for any help! – Paul Reilly Mar 01 '16 at 12:41
  • @MarkBaker: Thanks for Pointing me to the getTrace! That showed me that the error was in PHPExcel handling of a print area. Removed all print areas and the file now works! – Paul Reilly Mar 01 '16 at 13:01

1 Answers1

1

This error was caused by a print area being defined in one of sheets. I removed all print areas using these instructions (https://support.office.com/en-us/article/Change-or-clear-a-print-area-on-a-worksheet-deed3c1f-d2ca-4b78-b28d-9c17f0b5de34#bmclearprintarea) and then reran the upload and everything worked. Thanks to MarkBaker for his assistance. Paul