/** * Re-bind parent * * @param PHPExcel $parent * @return PHPExcel_Worksheet */ public function rebindParent(PHPExcel $parent) { if ($this->_parent !== null) { $namedRanges = $this->_parent->getNamedRanges(); foreach ($namedRanges as $namedRange) { $parent->addNamedRange($namedRange); } $this->_parent->removeSheetByIndex($this->_parent->getIndex($this)); } $this->_parent = $parent; return $this; }