diff --git a/Classes/PHPExcel/IOFactory.php b/Classes/PHPExcel/IOFactory.php index f9607bc7..9f2fca46 100644 --- a/Classes/PHPExcel/IOFactory.php +++ b/Classes/PHPExcel/IOFactory.php @@ -70,7 +70,6 @@ class PHPExcel_IOFactory 'OOCalc', 'SYLK', 'Gnumeric', - 'Serialized', 'CSV', ); diff --git a/Classes/PHPExcel/Reader/Serialized.php b/Classes/PHPExcel/Reader/Serialized.php deleted file mode 100644 index b15c3aa5..00000000 --- a/Classes/PHPExcel/Reader/Serialized.php +++ /dev/null @@ -1,124 +0,0 @@ -fileSupportsUnserializePHPExcel($pFilename); - } - - /** - * Loads PHPExcel Serialized file - * - * @param string $pFilename - * @return PHPExcel - * @throws Exception - */ - public function load($pFilename) - { - // Check if file exists - if (!file_exists($pFilename)) { - throw new Exception("Could not open " . $pFilename . " for reading! File does not exist."); - } - - // Unserialize... First make sure the file supports it! - if (!$this->fileSupportsUnserializePHPExcel($pFilename)) { - throw new Exception("Invalid file format for PHPExcel_Reader_Serialized: " . $pFilename . "."); - } - - return $this->_loadSerialized($pFilename); - } - - /** - * Load PHPExcel Serialized file - * - * @param string $pFilename - * @return PHPExcel - */ - private function _loadSerialized($pFilename) { - $xmlData = simplexml_load_string(file_get_contents("zip://$pFilename#phpexcel.xml")); - $excel = unserialize(base64_decode((string)$xmlData->data)); - - // Update media links - for ($i = 0; $i < $excel->getSheetCount(); ++$i) { - for ($j = 0; $j < $excel->getSheet($i)->getDrawingCollection()->count(); ++$j) { - if ($excel->getSheet($i)->getDrawingCollection()->offsetGet($j) instanceof PHPExcl_Worksheet_BaseDrawing) { - $imgTemp =& $excel->getSheet($i)->getDrawingCollection()->offsetGet($j); - $imgTemp->setPath('zip://' . $pFilename . '#media/' . $imgTemp->getFilename(), false); - } - } - } - - return $excel; - } - - /** - * Does a file support UnserializePHPExcel ? - * - * @param string $pFilename - * @throws Exception - * @return boolean - */ - public function fileSupportsUnserializePHPExcel($pFilename = '') { - // Check if file exists - if (!file_exists($pFilename)) { - throw new Exception("Could not open " . $pFilename . " for reading! File does not exist."); - } - - // File exists, does it contain phpexcel.xml? - return PHPExcel_Shared_File::file_exists("zip://$pFilename#phpexcel.xml"); - } -} diff --git a/Classes/PHPExcel/Writer/Serialized.php b/Classes/PHPExcel/Writer/Serialized.php deleted file mode 100644 index 0393e671..00000000 --- a/Classes/PHPExcel/Writer/Serialized.php +++ /dev/null @@ -1,181 +0,0 @@ -setPHPExcel($pPHPExcel); - } - - /** - * Save PHPExcel to file - * - * @param string $pFileName - * @throws Exception - */ - public function save($pFilename = null) - { - if (!is_null($this->_spreadSheet)) { - // Garbage collect - $this->_spreadSheet->garbageCollect(); - - // Garbage collect... - foreach ($this->_spreadSheet->getAllSheets() as $sheet) { - $sheet->garbageCollect(); - } - - // Create new ZIP file and open it for writing - $objZip = new ZipArchive(); - - // Try opening the ZIP file - if ($objZip->open($pFilename, ZIPARCHIVE::OVERWRITE) !== true) { - if ($objZip->open($pFilename, ZIPARCHIVE::CREATE) !== true) { - throw new Exception("Could not open " . $pFilename . " for writing."); - } - } - - // Add media - $sheetCount = $this->_spreadSheet->getSheetCount(); - for ($i = 0; $i < $sheetCount; ++$i) { - for ($j = 0; $j < $this->_spreadSheet->getSheet($i)->getDrawingCollection()->count(); ++$j) { - if ($this->_spreadSheet->getSheet($i)->getDrawingCollection()->offsetGet($j) instanceof PHPExcel_Worksheet_BaseDrawing) { - $imgTemp = $this->_spreadSheet->getSheet($i)->getDrawingCollection()->offsetGet($j); - $objZip->addFromString('media/' . $imgTemp->getFilename(), file_get_contents($imgTemp->getPath())); - } - } - } - - // Add phpexcel.xml to the document, which represents a PHP serialized PHPExcel object - $objZip->addFromString('phpexcel.xml', $this->_writeSerialized($this->_spreadSheet, $pFilename)); - - // Close file - if ($objZip->close() === false) { - throw new Exception("Could not close zip file $pFilename."); - } - } else { - throw new Exception("PHPExcel object unassigned."); - } - } - - /** - * Get PHPExcel object - * - * @return PHPExcel - * @throws Exception - */ - public function getPHPExcel() { - if (!is_null($this->_spreadSheet)) { - return $this->_spreadSheet; - } else { - throw new Exception("No PHPExcel assigned."); - } - } - - /** - * Get PHPExcel object - * - * @param PHPExcel $pPHPExcel PHPExcel object - * @throws Exception - * @return PHPExcel_Writer_Serialized - */ - public function setPHPExcel(PHPExcel $pPHPExcel = null) { - $this->_spreadSheet = $pPHPExcel; - return $this; - } - - /** - * Serialize PHPExcel object to XML - * - * @param PHPExcel $pPHPExcel - * @param string $pFilename - * @return string XML Output - * @throws Exception - */ - private function _writeSerialized(PHPExcel $pPHPExcel = null, $pFilename = '') - { - // Clone $pPHPExcel - $pPHPExcel = clone $pPHPExcel; - - // Update media links - $sheetCount = $pPHPExcel->getSheetCount(); - for ($i = 0; $i < $sheetCount; ++$i) { - for ($j = 0; $j < $pPHPExcel->getSheet($i)->getDrawingCollection()->count(); ++$j) { - if ($pPHPExcel->getSheet($i)->getDrawingCollection()->offsetGet($j) instanceof PHPExcel_Worksheet_BaseDrawing) { - $imgTemp =& $pPHPExcel->getSheet($i)->getDrawingCollection()->offsetGet($j); - $imgTemp->setPath('zip://' . $pFilename . '#media/' . $imgTemp->getFilename(), false); - } - } - } - - // Create XML writer - $objWriter = new xmlWriter(); - $objWriter->openMemory(); - $objWriter->setIndent(true); - - // XML header - $objWriter->startDocument('1.0','UTF-8','yes'); - - // PHPExcel - $objWriter->startElement('PHPExcel'); - $objWriter->writeAttribute('version', '##VERSION##'); - - // Comment - $objWriter->writeComment('This file has been generated using PHPExcel v##VERSION## (http://www.codeplex.com/PHPExcel). It contains a base64 encoded serialized version of the PHPExcel internal object.'); - - // Data - $objWriter->startElement('data'); - $objWriter->writeCData( base64_encode(serialize($pPHPExcel)) ); - $objWriter->endElement(); - - $objWriter->endElement(); - - // Return - return $objWriter->outputMemory(true); - } -} diff --git a/Documentation/PHPExcel developer documentation.doc b/Documentation/PHPExcel developer documentation.doc index a364e6ee..c28ce4d8 100644 Binary files a/Documentation/PHPExcel developer documentation.doc and b/Documentation/PHPExcel developer documentation.doc differ diff --git a/Tests/12serializedfileformat.php b/Tests/12serializedfileformat.php deleted file mode 100644 index 19a2297c..00000000 --- a/Tests/12serializedfileformat.php +++ /dev/null @@ -1,60 +0,0 @@ -save(str_replace('.php', '.phpxl', __FILE__)); - - -// Read PHPExcel Serialized file -echo date('H:i:s') . " Read from PHPExcel Serialized format\n"; -$objPHPExcel = PHPExcel_IOFactory::load(str_replace('.php', '.phpxl', __FILE__)); - - -// Save Excel 2007 file -echo date('H:i:s') . " Write to Excel2007 format\n"; -$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007'); -$objWriter->save(str_replace('.php', '.xlsx', __FILE__)); - - -// Echo memory peak usage -echo date('H:i:s') . " Peak memory usage: " . (memory_get_peak_usage(true) / 1024 / 1024) . " MB\r\n"; - -// Echo done -echo date('H:i:s') . " Done writing file.\r\n"; diff --git a/changelog.txt b/changelog.txt index 02dc7603..5bdd44ad 100644 --- a/changelog.txt +++ b/changelog.txt @@ -70,6 +70,7 @@ Fixed in SVN: - General: (MBaker) Improved performance (speed), for building the Shared Strings table in the Excel2007 Writer. - General: (MBaker) Improved performance (speed), for PHP to Excel date conversions - General: (MBaker) Enhanced SheetViews element structures in the Excel2007 Writer for frozen panes. +- General: (MBaker) Removed Serialized Reader/Writer as these no longer work.