PHPExcel Load error - Cell coordinate must be a range of cells

1k Views Asked by At

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

1

There are 1 best solutions below

0
On

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