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

Public Member Functions

 __construct (PHPExcel $pPHPExcel=null)
 Create a new PHPExcel_Writer_Excel2007.
 getWriterPart ($pPartName= '')
 Get writer part.
 save ($pFilename=null)
 Save PHPExcel to file.
 getPHPExcel ()
 Get PHPExcel object.
 setPHPExcel (PHPExcel $pPHPExcel=null)
 Set PHPExcel object.
 getStringTable ()
 Get string table.
 getStylesConditionalHashTable ()
 Get PHPExcel_Style_Conditional HashTable.
 getFillHashTable ()
 Get PHPExcel_Style_Fill HashTable.
 getFontHashTable ()
 Get PHPExcel_Style_Font HashTable.
 getBordersHashTable ()
 Get PHPExcel_Style_Borders HashTable.
 getNumFmtHashTable ()
 Get PHPExcel_Style_NumberFormat HashTable.
 getDrawingHashTable ()
 Get PHPExcel_Worksheet_BaseDrawing HashTable.
 getPreCalculateFormulas ()
 Get Pre-Calculate Formulas.
 setPreCalculateFormulas ($pValue=true)
 Set Pre-Calculate Formulas.
 getOffice2003Compatibility ()
 Get Office2003 compatibility.
 setOffice2003Compatibility ($pValue=false)
 Set Pre-Calculate Formulas.
 getUseDiskCaching ()
 Get use disk caching where possible?
 setUseDiskCaching ($pValue=false, $pDirectory=null)
 Set use disk caching where possible?
 getDiskCachingDirectory ()
 Get disk caching directory.

Private Attributes

 $_preCalculateFormulas = true
 $_office2003compatibility = false
 $_writerParts
 $_spreadSheet
 $_stringTable
 $_stylesConditionalHashTable
 $_fillHashTable
 $_fontHashTable
 $_bordersHashTable
 $_numFmtHashTable
 $_drawingHashTable
 $_useDiskCaching = false
 $_diskCachingDirectory

Detailed Description

Definition at line 99 of file Excel2007.php.

Constructor & Destructor Documentation

PHPExcel_Writer_Excel2007::__construct ( PHPExcel  $pPHPExcel = null)

Create a new PHPExcel_Writer_Excel2007.

Parameters
PHPExcel$pPHPExcel

Definition at line 197 of file Excel2007.php.

References setPHPExcel().

{
// Assign PHPExcel
$this->setPHPExcel($pPHPExcel);
// Set up disk caching location
$this->_diskCachingDirectory = './';
// Initialise writer parts
$this->_writerParts['stringtable'] = new PHPExcel_Writer_Excel2007_StringTable();
$this->_writerParts['contenttypes'] = new PHPExcel_Writer_Excel2007_ContentTypes();
$this->_writerParts['docprops'] = new PHPExcel_Writer_Excel2007_DocProps();
$this->_writerParts['rels'] = new PHPExcel_Writer_Excel2007_Rels();
$this->_writerParts['theme'] = new PHPExcel_Writer_Excel2007_Theme();
$this->_writerParts['style'] = new PHPExcel_Writer_Excel2007_Style();
$this->_writerParts['workbook'] = new PHPExcel_Writer_Excel2007_Workbook();
$this->_writerParts['worksheet'] = new PHPExcel_Writer_Excel2007_Worksheet();
$this->_writerParts['drawing'] = new PHPExcel_Writer_Excel2007_Drawing();
$this->_writerParts['comments'] = new PHPExcel_Writer_Excel2007_Comments();
// Assign parent IWriter
foreach ($this->_writerParts as $writer) {
$writer->setParentWriter($this);
}
// Set HashTable variables
$this->_stringTable = array();
$this->_stylesConditionalHashTable = new PHPExcel_HashTable();
$this->_fillHashTable = new PHPExcel_HashTable();
$this->_fontHashTable = new PHPExcel_HashTable();
$this->_bordersHashTable = new PHPExcel_HashTable();
$this->_numFmtHashTable = new PHPExcel_HashTable();
$this->_drawingHashTable = new PHPExcel_HashTable();
}

+ Here is the call graph for this function:

Member Function Documentation

PHPExcel_Writer_Excel2007::getBordersHashTable ( )

Get PHPExcel_Style_Borders HashTable.

Returns
PHPExcel_HashTable

Definition at line 482 of file Excel2007.php.

References $_bordersHashTable.

PHPExcel_Writer_Excel2007::getDiskCachingDirectory ( )

Get disk caching directory.

Returns
string

Definition at line 577 of file Excel2007.php.

References $_diskCachingDirectory.

PHPExcel_Writer_Excel2007::getDrawingHashTable ( )

Get PHPExcel_Worksheet_BaseDrawing HashTable.

Returns
PHPExcel_HashTable

Definition at line 500 of file Excel2007.php.

References $_drawingHashTable.

Referenced by save().

+ Here is the caller graph for this function:

PHPExcel_Writer_Excel2007::getFillHashTable ( )

Get PHPExcel_Style_Fill HashTable.

Returns
PHPExcel_HashTable

Definition at line 464 of file Excel2007.php.

References $_fillHashTable.

{
}
PHPExcel_Writer_Excel2007::getFontHashTable ( )

Get PHPExcel_Style_Font HashTable.

Returns
PHPExcel_HashTable

Definition at line 473 of file Excel2007.php.

References $_fontHashTable.

{
}
PHPExcel_Writer_Excel2007::getNumFmtHashTable ( )

Get PHPExcel_Style_NumberFormat HashTable.

Returns
PHPExcel_HashTable

Definition at line 491 of file Excel2007.php.

References $_numFmtHashTable.

PHPExcel_Writer_Excel2007::getOffice2003Compatibility ( )

Get Office2003 compatibility.

Returns
boolean

Definition at line 527 of file Excel2007.php.

References $_office2003compatibility.

PHPExcel_Writer_Excel2007::getPHPExcel ( )

Get PHPExcel object.

Returns
PHPExcel
Exceptions
Exception

Definition at line 421 of file Excel2007.php.

References $_spreadSheet.

{
if (!is_null($this->_spreadSheet)) {
} else {
throw new Exception("No PHPExcel assigned.");
}
}
PHPExcel_Writer_Excel2007::getPreCalculateFormulas ( )

Get Pre-Calculate Formulas.

Returns
boolean

Definition at line 509 of file Excel2007.php.

References $_preCalculateFormulas.

PHPExcel_Writer_Excel2007::getStringTable ( )

Get string table.

Returns
string[]

Definition at line 446 of file Excel2007.php.

References $_stringTable.

{
}
PHPExcel_Writer_Excel2007::getStylesConditionalHashTable ( )
PHPExcel_Writer_Excel2007::getUseDiskCaching ( )

Get use disk caching where possible?

Returns
boolean

Definition at line 547 of file Excel2007.php.

References $_useDiskCaching.

PHPExcel_Writer_Excel2007::getWriterPart (   $pPartName = '')

Get writer part.

Parameters
string$pPartNameWriter part name
Returns
PHPExcel_Writer_Excel2007_WriterPart

Definition at line 238 of file Excel2007.php.

Referenced by save().

{
if ($pPartName != '' && isset($this->_writerParts[strtolower($pPartName)])) {
return $this->_writerParts[strtolower($pPartName)];
} else {
return null;
}
}

+ Here is the caller graph for this function:

PHPExcel_Writer_Excel2007::save (   $pFilename = null)

Save PHPExcel to file.

Parameters
string$pFileName
Exceptions
Exception

Implements PHPExcel_Writer_IWriter.

Definition at line 252 of file Excel2007.php.

References $_stringTable, getDrawingHashTable(), PHPExcel_Calculation_Functions\getReturnDateType(), getWriterPart(), PHPExcel_Calculation_Functions\RETURNDATE_EXCEL, and PHPExcel_Calculation_Functions\setReturnDateType().

{
if (!is_null($this->_spreadSheet)) {
// garbage collect
$this->_spreadSheet->garbageCollect();
// If $pFilename is php://output or php://stdout, make it a temporary file...
$originalFilename = $pFilename;
if (strtolower($pFilename) == 'php://output' || strtolower($pFilename) == 'php://stdout') {
$pFilename = @tempnam('./', 'phpxltmp');
if ($pFilename == '') {
$pFilename = $originalFilename;
}
}
// Create string lookup table
$this->_stringTable = array();
for ($i = 0; $i < $this->_spreadSheet->getSheetCount(); ++$i) {
$this->_stringTable = $this->getWriterPart('StringTable')->createStringTable($this->_spreadSheet->getSheet($i), $this->_stringTable);
}
// Create styles dictionaries
$this->_stylesConditionalHashTable->addFromSource( $this->getWriterPart('Style')->allConditionalStyles($this->_spreadSheet) );
$this->_fillHashTable->addFromSource( $this->getWriterPart('Style')->allFills($this->_spreadSheet) );
$this->_fontHashTable->addFromSource( $this->getWriterPart('Style')->allFonts($this->_spreadSheet) );
$this->_bordersHashTable->addFromSource( $this->getWriterPart('Style')->allBorders($this->_spreadSheet) );
$this->_numFmtHashTable->addFromSource( $this->getWriterPart('Style')->allNumberFormats($this->_spreadSheet) );
// Create drawing dictionary
$this->_drawingHashTable->addFromSource( $this->getWriterPart('Drawing')->allDrawings($this->_spreadSheet) );
// 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 [Content_Types].xml to ZIP file
$objZip->addFromString('[Content_Types].xml', $this->getWriterPart('ContentTypes')->writeContentTypes($this->_spreadSheet));
// Add relationships to ZIP file
$objZip->addFromString('_rels/.rels', $this->getWriterPart('Rels')->writeRelationships($this->_spreadSheet));
$objZip->addFromString('xl/_rels/workbook.xml.rels', $this->getWriterPart('Rels')->writeWorkbookRelationships($this->_spreadSheet));
// Add document properties to ZIP file
$objZip->addFromString('docProps/app.xml', $this->getWriterPart('DocProps')->writeDocPropsApp($this->_spreadSheet));
$objZip->addFromString('docProps/core.xml', $this->getWriterPart('DocProps')->writeDocPropsCore($this->_spreadSheet));
// Add theme to ZIP file
$objZip->addFromString('xl/theme/theme1.xml', $this->getWriterPart('Theme')->writeTheme($this->_spreadSheet));
// Add string table to ZIP file
$objZip->addFromString('xl/sharedStrings.xml', $this->getWriterPart('StringTable')->writeStringTable($this->_stringTable));
// Add styles to ZIP file
$objZip->addFromString('xl/styles.xml', $this->getWriterPart('Style')->writeStyles($this->_spreadSheet));
// Add workbook to ZIP file
$objZip->addFromString('xl/workbook.xml', $this->getWriterPart('Workbook')->writeWorkbook($this->_spreadSheet));
// Add worksheets
for ($i = 0; $i < $this->_spreadSheet->getSheetCount(); ++$i) {
$objZip->addFromString('xl/worksheets/sheet' . ($i + 1) . '.xml', $this->getWriterPart('Worksheet')->writeWorksheet($this->_spreadSheet->getSheet($i), $this->_stringTable));
}
// Add worksheet relationships (drawings, ...)
for ($i = 0; $i < $this->_spreadSheet->getSheetCount(); ++$i) {
// Add relationships
$objZip->addFromString('xl/worksheets/_rels/sheet' . ($i + 1) . '.xml.rels', $this->getWriterPart('Rels')->writeWorksheetRelationships($this->_spreadSheet->getSheet($i), ($i + 1)));
// Add drawing relationship parts
if ($this->_spreadSheet->getSheet($i)->getDrawingCollection()->count() > 0) {
// Drawing relationships
$objZip->addFromString('xl/drawings/_rels/drawing' . ($i + 1) . '.xml.rels', $this->getWriterPart('Rels')->writeDrawingRelationships($this->_spreadSheet->getSheet($i)));
// Drawings
$objZip->addFromString('xl/drawings/drawing' . ($i + 1) . '.xml', $this->getWriterPart('Drawing')->writeDrawings($this->_spreadSheet->getSheet($i)));
}
// Add comment relationship parts
if (count($this->_spreadSheet->getSheet($i)->getComments()) > 0) {
// VML Comments
$objZip->addFromString('xl/drawings/vmlDrawing' . ($i + 1) . '.vml', $this->getWriterPart('Comments')->writeVMLComments($this->_spreadSheet->getSheet($i)));
// Comments
$objZip->addFromString('xl/comments' . ($i + 1) . '.xml', $this->getWriterPart('Comments')->writeComments($this->_spreadSheet->getSheet($i)));
}
// Add header/footer relationship parts
if (count($this->_spreadSheet->getSheet($i)->getHeaderFooter()->getImages()) > 0) {
// VML Drawings
$objZip->addFromString('xl/drawings/vmlDrawingHF' . ($i + 1) . '.vml', $this->getWriterPart('Drawing')->writeVMLHeaderFooterImages($this->_spreadSheet->getSheet($i)));
// VML Drawing relationships
$objZip->addFromString('xl/drawings/_rels/vmlDrawingHF' . ($i + 1) . '.vml.rels', $this->getWriterPart('Rels')->writeHeaderFooterDrawingRelationships($this->_spreadSheet->getSheet($i)));
// Media
foreach ($this->_spreadSheet->getSheet($i)->getHeaderFooter()->getImages() as $image) {
$objZip->addFromString('xl/media/' . $image->getIndexedFilename(), file_get_contents($image->getPath()));
}
}
}
// Add media
for ($i = 0; $i < $this->getDrawingHashTable()->count(); ++$i) {
if ($this->getDrawingHashTable()->getByIndex($i) instanceof PHPExcel_Worksheet_Drawing) {
$imageContents = null;
$imagePath = $this->getDrawingHashTable()->getByIndex($i)->getPath();
if (strpos($imagePath, 'zip://') !== false) {
$imagePath = substr($imagePath, 6);
$imagePathSplitted = explode('#', $imagePath);
$imageZip = new ZipArchive();
$imageZip->open($imagePathSplitted[0]);
$imageContents = $imageZip->getFromName($imagePathSplitted[1]);
$imageZip->close();
unset($imageZip);
} else {
$imageContents = file_get_contents($imagePath);
}
$objZip->addFromString('xl/media/' . str_replace(' ', '_', $this->getDrawingHashTable()->getByIndex($i)->getIndexedFilename()), $imageContents);
} else if ($this->getDrawingHashTable()->getByIndex($i) instanceof PHPExcel_Worksheet_MemoryDrawing) {
ob_start();
call_user_func(
$this->getDrawingHashTable()->getByIndex($i)->getRenderingFunction(),
$this->getDrawingHashTable()->getByIndex($i)->getImageResource()
);
$imageContents = ob_get_contents();
ob_end_clean();
$objZip->addFromString('xl/media/' . str_replace(' ', '_', $this->getDrawingHashTable()->getByIndex($i)->getIndexedFilename()), $imageContents);
}
}
// Close file
if ($objZip->close() === false) {
throw new Exception("Could not close zip file $pFilename.");
}
// If a temporary file was used, copy it to the correct file stream
if ($originalFilename != $pFilename) {
if (copy($pFilename, $originalFilename) === false) {
throw new Exception("Could not copy temporary zip file $pFilename to $originalFilename.");
}
@unlink($pFilename);
}
} else {
throw new Exception("PHPExcel object unassigned.");
}
}

+ Here is the call graph for this function:

PHPExcel_Writer_Excel2007::setOffice2003Compatibility (   $pValue = false)

Set Pre-Calculate Formulas.

Parameters
boolean$pValueOffice2003 compatibility?
Returns
PHPExcel_Writer_Excel2007

Definition at line 537 of file Excel2007.php.

{
$this->_office2003compatibility = $pValue;
return $this;
}
PHPExcel_Writer_Excel2007::setPHPExcel ( PHPExcel  $pPHPExcel = null)

Set PHPExcel object.

Parameters
PHPExcel$pPHPExcelPHPExcel object
Exceptions
Exception
Returns
PHPExcel_Writer_Excel2007

Definition at line 436 of file Excel2007.php.

Referenced by __construct().

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

+ Here is the caller graph for this function:

PHPExcel_Writer_Excel2007::setPreCalculateFormulas (   $pValue = true)

Set Pre-Calculate Formulas.

Parameters
boolean$pValuePre-Calculate Formulas?

Definition at line 518 of file Excel2007.php.

{
$this->_preCalculateFormulas = $pValue;
}
PHPExcel_Writer_Excel2007::setUseDiskCaching (   $pValue = false,
  $pDirectory = null 
)

Set use disk caching where possible?

Parameters
boolean$pValue
string$pDirectoryDisk caching directory
Exceptions
ExceptionException when directory does not exist
Returns
PHPExcel_Writer_Excel2007

Definition at line 559 of file Excel2007.php.

{
$this->_useDiskCaching = $pValue;
if (!is_null($pDirectory)) {
if (is_dir($pDirectory)) {
$this->_diskCachingDirectory = $pDirectory;
} else {
throw new Exception("Directory does not exist: $pDirectory");
}
}
return $this;
}

Field Documentation

PHPExcel_Writer_Excel2007::$_bordersHashTable
private

Definition at line 162 of file Excel2007.php.

Referenced by getBordersHashTable().

PHPExcel_Writer_Excel2007::$_diskCachingDirectory
private

Definition at line 190 of file Excel2007.php.

Referenced by getDiskCachingDirectory().

PHPExcel_Writer_Excel2007::$_drawingHashTable
private

Definition at line 176 of file Excel2007.php.

Referenced by getDrawingHashTable().

PHPExcel_Writer_Excel2007::$_fillHashTable
private

Definition at line 148 of file Excel2007.php.

Referenced by getFillHashTable().

PHPExcel_Writer_Excel2007::$_fontHashTable
private

Definition at line 155 of file Excel2007.php.

Referenced by getFontHashTable().

PHPExcel_Writer_Excel2007::$_numFmtHashTable
private

Definition at line 169 of file Excel2007.php.

Referenced by getNumFmtHashTable().

PHPExcel_Writer_Excel2007::$_office2003compatibility = false
private

Definition at line 113 of file Excel2007.php.

Referenced by getOffice2003Compatibility().

PHPExcel_Writer_Excel2007::$_preCalculateFormulas = true
private

Definition at line 106 of file Excel2007.php.

Referenced by getPreCalculateFormulas().

PHPExcel_Writer_Excel2007::$_spreadSheet
private

Definition at line 127 of file Excel2007.php.

Referenced by getPHPExcel().

PHPExcel_Writer_Excel2007::$_stringTable
private

Definition at line 134 of file Excel2007.php.

Referenced by getStringTable(), and save().

PHPExcel_Writer_Excel2007::$_stylesConditionalHashTable
private

Definition at line 141 of file Excel2007.php.

Referenced by getStylesConditionalHashTable().

PHPExcel_Writer_Excel2007::$_useDiskCaching = false
private

Definition at line 183 of file Excel2007.php.

Referenced by getUseDiskCaching().

PHPExcel_Writer_Excel2007::$_writerParts
private

Definition at line 120 of file Excel2007.php.


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