Trouble with copySheet and addcellvalue

Topics: Developer Forum, Project Management Forum, User Forum
Dec 7, 2010 at 4:53 PM

Hi , my name is ildefonso I'm from Mexico, I recently start to use PHPExcel and I have a little problem.

I have a template, and I copy the fist sheet then I add to the woorkbook, like this.

 

$reader = new PHPExcel_Reader_Excel5();
$excel = $reader->load("pta-plantilla.xls");

$sheet = $excel->getActiveSheet();
$nuevo =  clone $sheet;

$excel->removeSheetByIndex(0);


$otro = clone $nuevo;

$titulo= "META 1";
$otro->setCellValue('BG11',1)->setCellValue('A21', $metas[0])->setCellValue('BA11', 33);
$otro->setTitle($titulo);
$excel->addSheet($otro);


$otro1= clone $nuevo;

$otro1->setCellValue('BG11',2)->setCellValue('A21', $metas[1])->setCellValue('BA11', 33);
//unset($nuevo);
$titulo= "META 2";
$otro1->setTitle($titulo);
$excel->addSheet($otro1);

$excel->setActiveSheetIndex(0);  
$objWriter = PHPExcel_IOFactory::createWriter($excel, 'Excel5');
$objWriter->save('php://output');
exit;

Then the result is 2 sheets One with title="Meta 1" the other one with title="Meta 2"     but here is the thing,  two sheet shows me the same info,  in this case the info contain in "META 2"

 

Thanks, I dont know if it is a bug o what is going on ...

Coordinator
Dec 7, 2010 at 10:30 PM

Please see my latest response to this discussion