Clone Worksheet throwing unusual error

Topics: Developer Forum, Project Management Forum, User Forum
Jul 4, 2013 at 3:30 PM
I am trying to clone a worksheet and am getting a fatal error.

__Fatal error: clone method called on non-object in C:\wamp\www\sites\techwaterlabs\application\controllers\admin\reports.php on line 119

Here is my code:
$gwreader = new PHPExcel_Reader_Excel5();
$gwswPHPExcel = $gwreader->load(APPPATH."files/gwsw.xls");

$clone = clone $gwswPHPExcel->getSheetByName('0');
$clone->setTitle("$title");
$gwswPHPExcel->addSheet($clone, $title);
$title++;
The file reader works just fine. When I var_dump $gwswPHPExcel it is perfect. The clone is the only thing breaking.

I also use the clone in this same function and works fine. No differences in the code.
Jul 4, 2013 at 3:48 PM
The name of the sheet is actually '0'?
It seems to me reading something about the names of worksheets only in numbers...
Can you use the index (by getSheet())?
Jul 4, 2013 at 4:01 PM
Got it. Stupid mistake. The sheet name was '1' not '0'
Coordinator
Jul 4, 2013 at 4:14 PM
Edited Jul 4, 2013 at 4:15 PM
Work Item #19803 has been fixed in the develop branch on github: you may want to pull that if you are using clone, which affects cloning; but this message suggests there is no worksheet with the name '0'