ILIAS  Release_4_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
PHPExcel_Writer_Serialized Class Reference
+ Inheritance diagram for PHPExcel_Writer_Serialized:
+ Collaboration diagram for PHPExcel_Writer_Serialized:

Public Member Functions

 __construct (PHPExcel $pPHPExcel=null)
 Create a new PHPExcel_Writer_Serialized.
 save ($pFilename=null)
 Save PHPExcel to file.
 getPHPExcel ()
 Get PHPExcel object.
 setPHPExcel (PHPExcel $pPHPExcel=null)
 Get PHPExcel object.

Private Member Functions

 _writeSerialized (PHPExcel $pPHPExcel=null, $pFilename= '')
 Serialize PHPExcel object to XML.

Private Attributes

 $_spreadSheet

Detailed Description

Definition at line 63 of file Serialized.php.

Constructor & Destructor Documentation

PHPExcel_Writer_Serialized::__construct ( PHPExcel  $pPHPExcel = null)

Create a new PHPExcel_Writer_Serialized.

Parameters
PHPExcel$pPHPExcel

Definition at line 77 of file Serialized.php.

References setPHPExcel().

{
// Assign PHPExcel
$this->setPHPExcel($pPHPExcel);
}

+ Here is the call graph for this function:

Member Function Documentation

PHPExcel_Writer_Serialized::_writeSerialized ( PHPExcel  $pPHPExcel = null,
  $pFilename = '' 
)
private

Serialize PHPExcel object to XML.

Parameters
PHPExcel$pPHPExcel
string$pFilename
Returns
string XML Output
Exceptions
Exception

Definition at line 167 of file Serialized.php.

Referenced by save().

{
// 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', '1.7.0');
// Comment
$objWriter->writeComment('This file has been generated using PHPExcel v1.7.0 (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);
}

+ Here is the caller graph for this function:

PHPExcel_Writer_Serialized::getPHPExcel ( )

Get PHPExcel object.

Returns
PHPExcel
Exceptions
Exception

Definition at line 139 of file Serialized.php.

References $_spreadSheet.

{
if (!is_null($this->_spreadSheet)) {
} else {
throw new Exception("No PHPExcel assigned.");
}
}
PHPExcel_Writer_Serialized::save (   $pFilename = null)

Save PHPExcel to file.

Parameters
string$pFileName
Exceptions
Exception

Implements PHPExcel_Writer_IWriter.

Definition at line 89 of file Serialized.php.

References _writeSerialized().

{
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.");
}
}

+ Here is the call graph for this function:

PHPExcel_Writer_Serialized::setPHPExcel ( PHPExcel  $pPHPExcel = null)

Get PHPExcel object.

Parameters
PHPExcel$pPHPExcelPHPExcel object
Exceptions
Exception
Returns
PHPExcel_Writer_Serialized

Definition at line 154 of file Serialized.php.

Referenced by __construct().

{
$this->_spreadSheet = $pPHPExcel;
return $this;
}

+ Here is the caller graph for this function:

Field Documentation

PHPExcel_Writer_Serialized::$_spreadSheet
private

Definition at line 70 of file Serialized.php.

Referenced by getPHPExcel().


The documentation for this class was generated from the following file: