ILIAS  eassessment Revision 61809
 All Data Structures Namespaces Files Functions Variables Groups Pages
PHPExcel_Writer_Excel5 Class Reference
+ Inheritance diagram for PHPExcel_Writer_Excel5:
+ Collaboration diagram for PHPExcel_Writer_Excel5:

Public Member Functions

 __construct (PHPExcel $phpExcel)
 Create a new PHPExcel_Writer_Excel5.
 save ($pFilename=null)
 Save PHPExcel to file.
 setTempDir ($pValue= '')
 Set temporary storage directory.
 getPreCalculateFormulas ()
 Get Pre-Calculate Formulas.
 setPreCalculateFormulas ($pValue=true)
 Set Pre-Calculate Formulas.

Private Member Functions

 _buildWorksheetEschers ()
 _buildWorkbookEscher ()
 Build the Escher object corresponding to the MSODRAWINGGROUP record.

Private Attributes

 $_preCalculateFormulas = true
 $_phpExcel
 $_BIFF_version = 0x0600
 $_str_total = 0
 $_str_unique = 0
 $_str_table = array()
 $_colors
 $_parser
 $_IDCLs

Detailed Description

Definition at line 36 of file Excel5.php.

Constructor & Destructor Documentation

PHPExcel_Writer_Excel5::__construct ( PHPExcel  $phpExcel)

Create a new PHPExcel_Writer_Excel5.

Parameters
PHPExcel$phpExcelPHPExcel object

Definition at line 107 of file Excel5.php.

{
$this->_phpExcel = $phpExcel;
$this->_parser = new PHPExcel_Writer_Excel5_Parser($this->_BIFF_version);
}

Member Function Documentation

PHPExcel_Writer_Excel5::_buildWorkbookEscher ( )
private

Build the Escher object corresponding to the MSODRAWINGGROUP record.

Definition at line 322 of file Excel5.php.

References $filename, PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE\BLIPTYPE_JPEG, PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE\BLIPTYPE_PNG, PHPExcel_Shared_Drawing\imagecreatefrombmp(), PHPExcel_Worksheet_MemoryDrawing\RENDERING_DEFAULT, PHPExcel_Worksheet_MemoryDrawing\RENDERING_GIF, PHPExcel_Worksheet_MemoryDrawing\RENDERING_JPEG, and PHPExcel_Worksheet_MemoryDrawing\RENDERING_PNG.

Referenced by save().

{
$escher = null;
// any drawings in this workbook?
$found = false;
foreach ($this->_phpExcel->getAllSheets() as $sheet) {
if (count($sheet->getDrawingCollection()) > 0) {
$found = true;
}
}
// nothing to do if there are no drawings
if (!$found) {
return;
}
// if we reach here, then there are drawings in the workbook
$escher = new PHPExcel_Shared_Escher();
// dggContainer
$dggContainer = new PHPExcel_Shared_Escher_DggContainer();
$escher->setDggContainer($dggContainer);
// set IDCLs (identifier clusters)
$dggContainer->setIDCLs($this->_IDCLs);
// this loop is for determining maximum shape identifier of all drawing
$spIdMax = 0;
$totalCountShapes = 0;
$countDrawings = 0;
foreach ($this->_phpExcel->getAllsheets() as $sheet) {
$sheetCountShapes = 0; // count number of shapes (minus group shape), in sheet
if (count($sheet->getDrawingCollection()) > 0) {
++$countDrawings;
foreach ($sheet->getDrawingCollection() as $drawing) {
++$sheetCountShapes;
++$totalCountShapes;
$spId = $sheetCountShapes
| ($this->_phpExcel->getIndex($sheet) + 1) << 10;
$spIdMax = max($spId, $spIdMax);
}
}
}
$dggContainer->setSpIdMax($spIdMax + 1);
$dggContainer->setCDgSaved($countDrawings);
$dggContainer->setCSpSaved($totalCountShapes + $countDrawings); // total number of shapes incl. one group shapes per drawing
// bstoreContainer
$dggContainer->setBstoreContainer($bstoreContainer);
// the BSE's (all the images)
foreach ($this->_phpExcel->getAllsheets() as $sheet) {
foreach ($sheet->getDrawingCollection() as $drawing) {
if ($drawing instanceof PHPExcel_Worksheet_Drawing) {
$filename = $drawing->getPath();
list($imagesx, $imagesy, $imageFormat) = getimagesize($filename);
switch ($imageFormat) {
case 1: // GIF, not supported by BIFF8, we convert to PNG
ob_start();
imagepng(imagecreatefromgif($filename));
$blipData = ob_get_contents();
ob_end_clean();
break;
case 2: // JPEG
$blipData = file_get_contents($filename);
break;
case 3: // PNG
$blipData = file_get_contents($filename);
break;
case 6: // Windows DIB (BMP), we convert to PNG
ob_start();
$blipData = ob_get_contents();
ob_end_clean();
break;
default: continue 2;
}
$blip->setData($blipData);
$BSE->setBlipType($blipType);
$BSE->setBlip($blip);
$bstoreContainer->addBSE($BSE);
} else if ($drawing instanceof PHPExcel_Worksheet_MemoryDrawing) {
switch ($drawing->getRenderingFunction()) {
$renderingFunction = 'imagejpeg';
break;
$renderingFunction = 'imagepng';
break;
}
ob_start();
call_user_func($renderingFunction, $drawing->getImageResource());
$blipData = ob_get_contents();
ob_end_clean();
$blip->setData($blipData);
$BSE->setBlipType($blipType);
$BSE->setBlip($blip);
$bstoreContainer->addBSE($BSE);
}
}
}
// Set the Escher object
$this->_writerWorkbook->setEscher($escher);
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

PHPExcel_Writer_Excel5::_buildWorksheetEschers ( )
private

Definition at line 221 of file Excel5.php.

References PHPExcel_Shared_Excel5\oneAnchor2twoAnchor().

Referenced by save().

{
// 1-based index to BstoreContainer
$blipIndex = 0;
foreach ($this->_phpExcel->getAllsheets() as $sheet) {
// sheet index
$sheetIndex = $sheet->getParent()->getIndex($sheet);
$escher = null;
// check if there are any shapes for this sheet
if (count($sheet->getDrawingCollection()) == 0) {
continue;
}
// create intermediate Escher object
$escher = new PHPExcel_Shared_Escher();
// dgContainer
$dgContainer = new PHPExcel_Shared_Escher_DgContainer();
// set the drawing index (we use sheet index + 1)
$dgId = $sheet->getParent()->getIndex($sheet) + 1;
$dgContainer->setDgId($dgId);
$escher->setDgContainer($dgContainer);
// spgrContainer
$dgContainer->setSpgrContainer($spgrContainer);
// add one shape which is the group shape
$spContainer->setSpgr(true);
$spContainer->setSpType(0);
$spContainer->setSpId(($sheet->getParent()->getIndex($sheet) + 1) << 10);
$spgrContainer->addChild($spContainer);
// add the shapes
$countShapes[$sheetIndex] = 0; // count number of shapes (minus group shape), in sheet
foreach ($sheet->getDrawingCollection() as $drawing) {
++$blipIndex;
++$countShapes[$sheetIndex];
// add the shape
// set the shape type
$spContainer->setSpType(0x004B);
// set the shape index (we combine 1-based sheet index and $countShapes to create unique shape index)
$reducedSpId = $countShapes[$sheetIndex];
$spId = $reducedSpId
| ($sheet->getParent()->getIndex($sheet) + 1) << 10;
$spContainer->setSpId($spId);
// keep track of last reducedSpId
$lastReducedSpId = $reducedSpId;
// keep track of last spId
$lastSpId = $spId;
// set the BLIP index
$spContainer->setOPT(0x4104, $blipIndex);
// set coordinates and offsets, client anchor
$coordinates = $drawing->getCoordinates();
$offsetX = $drawing->getOffsetX();
$offsetY = $drawing->getOffsetY();
$width = $drawing->getWidth();
$height = $drawing->getHeight();
$twoAnchor = PHPExcel_Shared_Excel5::oneAnchor2twoAnchor($sheet, $coordinates, $offsetX, $offsetY, $width, $height);
$spContainer->setStartCoordinates($twoAnchor['startCoordinates']);
$spContainer->setStartOffsetX($twoAnchor['startOffsetX']);
$spContainer->setStartOffsetY($twoAnchor['startOffsetY']);
$spContainer->setEndCoordinates($twoAnchor['endCoordinates']);
$spContainer->setEndOffsetX($twoAnchor['endOffsetX']);
$spContainer->setEndOffsetY($twoAnchor['endOffsetY']);
$spgrContainer->addChild($spContainer);
}
// identifier clusters, used for workbook Escher object
$this->_IDCLs[$dgId] = $lastReducedSpId;
// set last shape index
$dgContainer->setLastSpId($lastSpId);
// set the Escher object
$this->_writerWorksheets[$sheetIndex]->setEscher($escher);
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

PHPExcel_Writer_Excel5::getPreCalculateFormulas ( )

Get Pre-Calculate Formulas.

Returns
boolean

Definition at line 208 of file Excel5.php.

References $_preCalculateFormulas.

PHPExcel_Writer_Excel5::save (   $pFilename = null)

Save PHPExcel to file.

Parameters
string$pFileName
Exceptions
Exception

Implements PHPExcel_Writer_IWriter.

Definition at line 119 of file Excel5.php.

References $res, _buildWorkbookEscher(), _buildWorksheetEschers(), PHPExcel_Shared_OLE\Asc2Ucs(), PHPExcel_Calculation\getInstance(), PHPExcel_Calculation_Functions\getReturnDateType(), PHPExcel_Calculation_Functions\RETURNDATE_EXCEL, and PHPExcel_Calculation_Functions\setReturnDateType().

{
// garbage collect
$this->_phpExcel->garbageCollect();
$saveDebugLog = PHPExcel_Calculation::getInstance()->writeDebugLog;
PHPExcel_Calculation::getInstance()->writeDebugLog = false;
// initialize colors array
$this->_colors = array();
// Initialise workbook writer
$this->_writerWorkbook = new PHPExcel_Writer_Excel5_Workbook($this->_phpExcel, $this->_BIFF_version,
$this->_str_total, $this->_str_unique, $this->_str_table, $this->_colors, $this->_parser);
// Initialise worksheet writers
$countSheets = $this->_phpExcel->getSheetCount();
for ($i = 0; $i < $countSheets; ++$i) {
$this->_writerWorksheets[$i] = new PHPExcel_Writer_Excel5_Worksheet($this->_BIFF_version,
$this->_str_total, $this->_str_unique,
$this->_str_table, $this->_colors,
$this->_parser,
$this->_preCalculateFormulas,
$this->_phpExcel->getSheet($i));
}
// build Escher objects. Escher objects for workbooks needs to be build before Escher object for workbook.
// add 15 identical cell style Xfs
// for now, we use the first cellXf instead of cellStyleXf
$cellXfCollection = $this->_phpExcel->getCellXfCollection();
for ($i = 0; $i < 15; ++$i) {
$this->_writerWorkbook->addXfWriter($cellXfCollection[0], true);
}
// add all the cell Xfs
foreach ($this->_phpExcel->getCellXfCollection() as $style) {
$this->_writerWorkbook->addXfWriter($style, false);
}
// initialize OLE file
$workbookStreamName = ($this->_BIFF_version == 0x0600) ? 'Workbook' : 'Book';
// Write the worksheet streams before the global workbook stream,
// because the byte sizes of these are needed in the global workbook stream
$worksheetSizes = array();
for ($i = 0; $i < $countSheets; ++$i) {
$this->_writerWorksheets[$i]->close();
$worksheetSizes[] = $this->_writerWorksheets[$i]->_datasize;
}
// add binary data for global workbook stream
$OLE->append( $this->_writerWorkbook->writeWorkbook($worksheetSizes) );
// add binary data for sheet streams
for ($i = 0; $i < $countSheets; ++$i) {
$OLE->append($this->_writerWorksheets[$i]->getData());
}
$root = new PHPExcel_Shared_OLE_PPS_Root(time(), time(), array($OLE));
// save the OLE file
$res = $root->save($pFilename);
PHPExcel_Calculation::getInstance()->writeDebugLog = $saveDebugLog;
}

+ Here is the call graph for this function:

PHPExcel_Writer_Excel5::setPreCalculateFormulas (   $pValue = true)

Set Pre-Calculate Formulas.

Parameters
boolean$pValuePre-Calculate Formulas?

Definition at line 217 of file Excel5.php.

{
$this->_preCalculateFormulas = $pValue;
}
PHPExcel_Writer_Excel5::setTempDir (   $pValue = '')

Set temporary storage directory.

Deprecated:
Parameters
string$pValueTemporary storage directory
Exceptions
ExceptionException when directory does not exist
Returns
PHPExcel_Writer_Excel5

Definition at line 199 of file Excel5.php.

{
return $this;
}

Field Documentation

PHPExcel_Writer_Excel5::$_BIFF_version = 0x0600
private

Definition at line 57 of file Excel5.php.

PHPExcel_Writer_Excel5::$_colors
private

Definition at line 85 of file Excel5.php.

PHPExcel_Writer_Excel5::$_IDCLs
private

Definition at line 99 of file Excel5.php.

PHPExcel_Writer_Excel5::$_parser
private

Definition at line 92 of file Excel5.php.

PHPExcel_Writer_Excel5::$_phpExcel
private

Definition at line 50 of file Excel5.php.

PHPExcel_Writer_Excel5::$_preCalculateFormulas = true
private

Definition at line 43 of file Excel5.php.

Referenced by getPreCalculateFormulas().

PHPExcel_Writer_Excel5::$_str_table = array()
private

Definition at line 78 of file Excel5.php.

PHPExcel_Writer_Excel5::$_str_total = 0
private

Definition at line 64 of file Excel5.php.

PHPExcel_Writer_Excel5::$_str_unique = 0
private

Definition at line 71 of file Excel5.php.


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