/** * Clone the cell collection * * @param \PHPExcel\Worksheet $parent The new worksheet that we're copying to */ public function copyCellCollection(\PHPExcel\Worksheet $parent) { parent::copyCellCollection($parent); $newCollection = array(); foreach ($this->cellCache as $k => &$cell) { $newCollection[$k] = clone $cell; $newCollection[$k]->attach($this); } $this->cellCache = $newCollection; }
/** * Clone the cell collection * * @param \PHPExcel\Worksheet $parent The new worksheet that we're copying to */ public function copyCellCollection(\PHPExcel\Worksheet $parent) { parent::copyCellCollection($parent); // Open a new stream for the cell cache data $newFileHandle = fopen('php://temp/maxmemory:' . $this->memoryCacheSize, 'a+'); // Copy the existing cell cache data to the new stream fseek($this->fileHandle, 0); while (!feof($this->fileHandle)) { fwrite($newFileHandle, fread($this->fileHandle, 1024)); } $this->fileHandle = $newFileHandle; }
/** * Clone the cell collection * * @param \PHPExcel\Worksheet $parent The new worksheet that we're copying to * @throws \PHPExcel\Exception */ public function copyCellCollection(\PHPExcel\Worksheet $parent) { parent::copyCellCollection($parent); // Get a new id for the new file name $baseUnique = $this->getUniqueID(); $newCachePrefix = substr(md5($baseUnique), 0, 8) . '.'; $cacheList = $this->getCellList(); foreach ($cacheList as $cellID) { if ($cellID != $this->currentObjectID) { $success = false; $obj = wincache_ucache_get($this->cachePrefix . $cellID . '.cache', $success); if ($success === false) { // Entry no longer exists in WinCache, so clear it from the cache array parent::deleteCacheData($cellID); throw new \PHPExcel\Exception('Cell entry ' . $cellID . ' no longer exists in Wincache'); } if (!wincache_ucache_add($newCachePrefix . $cellID . '.cache', $obj, $this->cacheTime)) { $this->__destruct(); throw new \PHPExcel\Exception('Failed to store cell ' . $cellID . ' in Wincache'); } } } $this->cachePrefix = $newCachePrefix; }
/** * Clone the cell collection * * @param \PHPExcel\Worksheet $parent The new worksheet that we're copying to * @throws \PHPExcel\Exception */ public function copyCellCollection(\PHPExcel\Worksheet $parent) { parent::copyCellCollection($parent); // Get a new id for the new file name $baseUnique = $this->getUniqueID(); $newCachePrefix = substr(md5($baseUnique), 0, 8) . '.'; $cacheList = $this->getCellList(); foreach ($cacheList as $cellID) { if ($cellID != $this->currentObjectID) { $obj = $this->memcache->get($this->cachePrefix . $cellID . '.cache'); if ($obj === false) { // Entry no longer exists in Memcache, so clear it from the cache array parent::deleteCacheData($cellID); throw new \PHPExcel\Exception("Cell entry {$cellID} no longer exists in MemCache"); } if (!$this->memcache->add($newCachePrefix . $cellID . '.cache', $obj, null, $this->cacheTime)) { $this->__destruct(); throw new \PHPExcel\Exception("Failed to store cell {$cellID} in MemCache"); } } } $this->cachePrefix = $newCachePrefix; }
/** * Clone the cell collection * * @param \PHPExcel\Worksheet $parent The new worksheet that we're copying to */ public function copyCellCollection(\PHPExcel\Worksheet $parent) { parent::copyCellCollection($parent); // Get a new id for the new file name $baseUnique = $this->getUniqueID(); $newFileName = $this->cacheDirectory . '/PHPExcel.' . $baseUnique . '.cache'; // Copy the existing cell cache file copy($this->fileName, $newFileName); $this->fileName = $newFileName; // Open the copied cell cache file $this->fileHandle = fopen($this->fileName, 'a+'); }