getcell variable row and column

Topics: Developer Forum
Aug 22, 2011 at 9:42 PM

I'm trying to make a variable for both column and row for the getcell. Row is easy since its just a simple number $j is the current row

$objPHPExcel->getActiveSheet()->getCell('J'.$j)->getCalculatedValue()

Which works just fine, but when I also try to make the column a variable, it stops working

$objPHPExcel->getActiveSheet()->getCell($letter.$j)->getCalculatedValue()

(btw $letter = 'K' currently, and its my understanding that doing $letter++ will make that an L, is that correct?)

Aug 22, 2011 at 10:13 PM

right + + adds 1 to the letter
example:

for ($a="K"; $a=="Z";$a++){
$objPHPExcel->setActiveSheetIndex(0)->setCellValue($a.1, 'TITLE');
}

Aug 23, 2011 at 2:18 AM
Edited Aug 23, 2011 at 7:52 AM

Does anyone know why the second code doesn't work?

 

$objPHPExcel->getActiveSheet()->getCell($letter.$j)->getCalculatedValue()


EDIT: If it helps here is the error message

 

Fatal error: Uncaught exception 'Exception' with message 'Invalid cell coordinate.' in /home1/flashdr1/public_html/blueloyal.com/Classes/PHPExcel/Cell.php:490 Stack trace: #0 /home1/flashdr1/public_html/blueloyal.com/Classes/PHPExcel/Worksheet.php(940): PHPExcel_Cell::coordinateFromString('14') #1 /home1/flashdr1/public_html/blueloyal.com/manager/import_to_db.php(94): PHPExcel_Worksheet->getCell('14') #2 {main} thrown in /home1/flashdr1/public_html/blueloyal.com/Classes/PHPExcel/Cell.php on line 490

 

Line 94 is this

$size_str .= '<td>'.number_format($objPHPExcel->getActiveSheet()->getCell($letter.$j)->getCalculatedValue(),2).'</td>';