Uncaught exception 'Exception' with message 'Invalid cell coordinate.'

Topics: User Forum
Jan 20, 2010 at 11:14 PM


I stumbled across your project when I searched for ways to share my data with other users online.  I have created a spreadsheet to estimate paychecks for work (we have a rather confusing hourly system that has many pieces which leads to inconsistent paychecks).  This was all to basically assist those of us who like to budget our money and try to plan.

Anyway, the point is that I have an Excel 2007 spreadsheet with a lot of formulas and calculations in it.  I have written a simple HTML form to ask for the user variables and then place those values into the spreadsheet in the appropriate cells.  I want to then deliver the information to the user as webpages with specific paycheck information on them.  As a test to see if I knew what I was doing, I just have it write the values and then save the entire spreadsheet to disk.

It is giving me an error when it attempts to write to the disk.  And I don't know why.  I can't find any problem with my Excel file.

Thanks for your help!


I am using version 1.7.2

An example spreadsheet is available from http://www.fastnovahomes.com/FirePay/source_files/ALS%20A-Shift%202010.xlsx

The php that is running is




/** Error reporting */

/** PHPExcel */
require_once 'Classes/PHPExcel.php';

/** PHPExcel_IOFactory */
require_once 'Classes/PHPExcel/IOFactory.php';

/** Read in values **/
  $shift = "A";
$year = 2010;
 $state = "VA";
$isALS = 1;
$payrate = 16.7849;
$fedmarried = "S";
$fedwithhold = 0;
$fedexemption = 5; $statemarried = "S"; $statewithhold = 0; $stateexemption = 5; $deferred = array(); $pretax = array(); $posttax = array(); $taxadd = array(); $filename = "source_files/ALS A-Shift 2010.xlsx";
/** Load the Base File **/ echo date('H:i:s') . " Loading the saved file $filename\n"; $objPHPExcel = PHPExcel_IOFactory::load($filename); /** Set the values for our custom items **/ echo date('H:i:s') . " Setting your specified inputs\n"; $objPHPExcel->setActiveSheetIndex(0); $objPHPExcel->getActiveSheet()->setCellValue('F1', $payrate); $objPHPExcel->getActiveSheet()->setCellValue('N22', $fedexemption); $objPHPExcel->getActiveSheet()->setCellValue('O22', $fedwithhold); $objPHPExcel->getActiveSheet()->setCellValue('P22', $fedmarried); $objPHPExcel->getActiveSheet()->setCellValue('N23', $stateexemption); $objPHPExcel->getActiveSheet()->setCellValue('O23', $statewithhold); $objPHPExcel->getActiveSheet()->setCellValue('P23', $statemarried); for ($i=0;$i<9;$i++) { $currow = 21 + $i; $objPHPExcel->getActiveSheet()->setCellValue('F'.$currow, $pretax[$i]['name']); $objPHPExcel->getActiveSheet()->setCellValue('G'.$currow, $pretax[$i]['val']); $objPHPExcel->getActiveSheet()->setCellValue('H'.$currow, $posttax[$i]['name']); $objPHPExcel->getActiveSheet()->setCellValue('I'.$currow, $posttax[$i]['val']); $objPHPExcel->getActiveSheet()->setCellValue('J'.$currow, $taxadd[$i]['name']); $objPHPExcel->getActiveSheet()->setCellValue('K'.$currow, $taxadd[$i]['val']); } for ($i=0;$i<3;$i++) { $currow = 31 + $i; $objPHPExcel->getActiveSheet()->setCellValue('H'.$currow, $deferred[$i]['name']); $objPHPExcel->getActiveSheet()->setCellValue('I'.$currow, $deferred[$i]['val']); } print "First pay check regular earnings is: "; print $objPHPExcel->getActiveSheet()->getCell('E22')->getCalculatedValue(); print "\n"; /** Save the file **/ echo date('H:i:s') . " Saving your file as myfile.xlsx\n"; $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007'); $objWriter->save('myfile.xlsx'); // Echo memory peak usage echo date('H:i:s') . " Peak memory usage: " . (memory_get_peak_usage(true) / 1024 / 1024) . " MB\r\n"; // Echo done echo date('H:i:s') . " Done writing file.\r\n"; ?>

And the output from the script running is:

16:10:17 Loading the saved file source_files/ALS A-Shift 2010.xlsx
16:10:20 Setting your specified inputs
First pay check regular earnings is: 2101.488
16:10:20 Saving your file as myfile.xlsx
<br />
<b>Fatal error</b>: Uncaught exception 'Exception' with message 'Invalid cell coordinate.' in /home/content/64/4745964/html/FirePay/Classes/PHPExcel/Cell.php:519
Stack trace:
#0 /home/content/64/4745964/html/FirePay/Classes/PHPExcel/Cell.php(538): PHPExcel_Cell::coordinateFromString('A')
#1 /home/content/64/4745964/html/FirePay/Classes/PHPExcel/Writer/Excel2007/Workbook.php(351): PHPExcel_Cell::absoluteCoordinate('A')
#2 /home/content/64/4745964/html/FirePay/Classes/PHPExcel/Writer/Excel2007/Workbook.php(328): PHPExcel_Writer_Excel2007_Workbook-&gt;_writeDefinedNameForNamedRange(Object(PHPExcel_Shared_XMLWriter), Object(PHPExcel_NamedRange))
#3 /home/content/64/4745964/html/FirePay/Classes/PHPExcel/Writer/Excel2007/Workbook.php(297): PHPExcel_Writer_Excel2007_Workbook-&gt;_writeNamedRanges(Object(PHPExcel_Shared_XMLWriter), Object(PHPExcel))
#4 /home/content/64/4745964/html/FirePay/Classes/PHPExcel/Writer/Excel2007/Workbook.php(109): PHPExcel_Writer_Excel2007_Workbook-&gt;_writeDefinedNames(Object(PHPExcel_Shared_XMLWriter), Object(PHPEx in <b>/home/content/64/4745964/html/FirePay/Classes/PHPExcel/Cell.php</b> on line <b>519</b><br />


Jan 21, 2010 at 4:46 AM

I can confirm this error. There was a problem with Excel 2007 reader and defined names when there where multiple sheets in the workbook.

Should now be fixed: