error recognizing sheet index

Topics: Developer Forum
Feb 3, 2010 at 3:37 PM
Edited Feb 3, 2010 at 3:41 PM

Notice: Undefined property: PHPExcel::$getActiveSheet in DIRECTORY|FILE on line 481

Fatal error: Call to a member function setTitle() on a non-object in DIRECTORY|FILE on line 481

 

 

// Instantiate the module
$objPHPExcel = new PHPExcel();

$sheet = 0;
$sheetInterval = N; // User-defined, sanitized and validated int as well as greater then 1 elsewhere do { $result = myfunction($params); $objPHPExcel->createSheet(); $objPHPExcel->getActiveSheet->setTitle('_MYTITLE_'); <--- Line 481
foreach($result as $res)
{
$nextRow = $objPHPExcel->getActiveSheet()->getHighestRow()+1;
$objPHPExcel->getActiveSheet()->setCellValue('A'.$nextRow, $res['_KEY1_']);
$objPHPExcel->getActiveSheet()->setCellValue('B'.$nextRow, $res['_KEY2_']);
$objPHPExcel->getActiveSheet()->setCellValue('C'.$nextRow, $res['_KEY3_']);
// EtcEtc... } } while($sheet < $sheetInterval)

 

---------------------------------------------------

I have also tried using  $objPHPExcel->setActiveSheetIndex($sheet), however that yields the same results

Coordinator
Feb 3, 2010 at 4:57 PM

$objPHPExcel->getActiveSheet()->setTitle('_MYTITLE_'); <--- Line 481 

Note the extra brackets identifying that getActiveSheet is a method rather than an attribute

Feb 3, 2010 at 5:39 PM
Edited Feb 3, 2010 at 5:40 PM

YIKES, I've victim again to the typo!

 

Thanks, Solved