Update library PHPExcel to version 1.7.4

This commit is contained in:
Dieter Adriaenssens
2010-09-11 16:18:42 +02:00
parent f5879655d5
commit adaa35a87f
129 changed files with 1553 additions and 907 deletions

View File

@@ -22,7 +22,7 @@
* @package PHPExcel_Writer
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.7.3c, 2010-06-01
* @version 1.7.4, 2010-08-26
*/
@@ -106,6 +106,8 @@ class PHPExcel_Writer_CSV implements PHPExcel_Writer_IWriter {
// Fetch sheet
$sheet = $this->_phpExcel->getSheet($this->_sheetIndex);
$saveDebugLog = PHPExcel_Calculation::getInstance()->writeDebugLog;
PHPExcel_Calculation::getInstance()->writeDebugLog = false;
$saveArrayReturnType = PHPExcel_Calculation::getArrayReturnType();
PHPExcel_Calculation::setArrayReturnType(PHPExcel_Calculation::RETURN_ARRAY_AS_VALUE);
@@ -132,6 +134,7 @@ class PHPExcel_Writer_CSV implements PHPExcel_Writer_IWriter {
fclose($fileHandle);
PHPExcel_Calculation::setArrayReturnType($saveArrayReturnType);
PHPExcel_Calculation::getInstance()->writeDebugLog = $saveDebugLog;
}
/**

View File

@@ -22,7 +22,7 @@
* @package PHPExcel_Writer_Excel2007
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.7.3c, 2010-06-01
* @version 1.7.4, 2010-08-26
*/
@@ -201,6 +201,8 @@ class PHPExcel_Writer_Excel2007 implements PHPExcel_Writer_IWriter
}
}
$saveDebugLog = PHPExcel_Calculation::getInstance()->writeDebugLog;
PHPExcel_Calculation::getInstance()->writeDebugLog = false;
$saveDateReturnType = PHPExcel_Calculation_Functions::getReturnDateType();
PHPExcel_Calculation_Functions::setReturnDateType(PHPExcel_Calculation_Functions::RETURNDATE_EXCEL);
@@ -331,6 +333,7 @@ class PHPExcel_Writer_Excel2007 implements PHPExcel_Writer_IWriter
}
PHPExcel_Calculation_Functions::setReturnDateType($saveDateReturnType);
PHPExcel_Calculation::getInstance()->writeDebugLog = $saveDebugLog;
// Close file
if ($objZip->close() === false) {

View File

@@ -22,7 +22,7 @@
* @package PHPExcel_Writer_Excel2007
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.7.3c, 2010-06-01
* @version 1.7.4, 2010-08-26
*/

View File

@@ -22,7 +22,7 @@
* @package PHPExcel_Writer_Excel2007
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.7.3c, 2010-06-01
* @version 1.7.4, 2010-08-26
*/

View File

@@ -22,7 +22,7 @@
* @package PHPExcel_Writer_Excel2007
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.7.3c, 2010-06-01
* @version 1.7.4, 2010-08-26
*/

View File

@@ -22,7 +22,7 @@
* @package PHPExcel_Writer_Excel2007
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.7.3c, 2010-06-01
* @version 1.7.4, 2010-08-26
*/

View File

@@ -22,7 +22,7 @@
* @package PHPExcel_Writer_Excel2007
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.7.3c, 2010-06-01
* @version 1.7.4, 2010-08-26
*/

View File

@@ -22,7 +22,7 @@
* @package PHPExcel_Writer_Excel2007
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.7.3c, 2010-06-01
* @version 1.7.4, 2010-08-26
*/

View File

@@ -22,7 +22,7 @@
* @package PHPExcel_Writer_Excel2007
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.7.3c, 2010-06-01
* @version 1.7.4, 2010-08-26
*/

View File

@@ -22,7 +22,7 @@
* @package PHPExcel_Writer_Excel2007
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.7.3c, 2010-06-01
* @version 1.7.4, 2010-08-26
*/

View File

@@ -22,7 +22,7 @@
* @package PHPExcel_Writer_Excel2007
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.7.3c, 2010-06-01
* @version 1.7.4, 2010-08-26
*/

View File

@@ -22,7 +22,7 @@
* @package PHPExcel_Writer_Excel2007
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.7.3c, 2010-06-01
* @version 1.7.4, 2010-08-26
*/
@@ -1002,7 +1002,18 @@ class PHPExcel_Writer_Excel2007_Worksheet extends PHPExcel_Writer_Excel2007_Writ
break;
case 'f': // Formula
$objWriter->writeElement('f', substr($pCell->getValue(), 1));
$attributes = $pCell->getFormulaAttributes();
if($attributes['t'] == 'array') {
$objWriter->startElement('f');
$objWriter->writeAttribute('t', 'array');
$objWriter->writeAttribute('ref', $pCell->getCoordinate());
$objWriter->writeAttribute('aca', '1');
$objWriter->writeAttribute('ca', '1');
$objWriter->text(substr($pCell->getValue(), 1));
$objWriter->endElement();
} else {
$objWriter->writeElement('f', substr($pCell->getValue(), 1));
}
if ($this->getParentWriter()->getOffice2003Compatibility() === false) {
if ($this->getParentWriter()->getPreCalculateFormulas()) {
$calculatedValue = $pCell->getCalculatedValue();

View File

@@ -22,7 +22,7 @@
* @package PHPExcel_Writer_Excel2007
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.7.3c, 2010-06-01
* @version 1.7.4, 2010-08-26
*/

View File

@@ -22,7 +22,7 @@
* @package PHPExcel_Writer_Excel5
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.7.3c, 2010-06-01
* @version 1.7.4, 2010-08-26
*/
@@ -91,6 +91,13 @@ class PHPExcel_Writer_Excel5 implements PHPExcel_Writer_IWriter
*/
private $_parser;
/**
* Identifier clusters for drawings. Used in MSODRAWINGGROUP record.
*
* @var array
*/
private $_IDCLs;
/**
* Create a new PHPExcel_Writer_Excel5
@@ -120,6 +127,8 @@ class PHPExcel_Writer_Excel5 implements PHPExcel_Writer_IWriter
// garbage collect
$this->_phpExcel->garbageCollect();
$saveDebugLog = PHPExcel_Calculation::getInstance()->writeDebugLog;
PHPExcel_Calculation::getInstance()->writeDebugLog = false;
$saveDateReturnType = PHPExcel_Calculation_Functions::getReturnDateType();
PHPExcel_Calculation_Functions::setReturnDateType(PHPExcel_Calculation_Functions::RETURNDATE_EXCEL);
@@ -130,6 +139,21 @@ class PHPExcel_Writer_Excel5 implements PHPExcel_Writer_IWriter
$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.
$this->_buildWorksheetEschers();
$this->_buildWorkbookEscher();
// add 15 identical cell style Xfs
// for now, we use the first cellXf instead of cellStyleXf
$cellXfCollection = $this->_phpExcel->getCellXfCollection();
@@ -146,19 +170,10 @@ class PHPExcel_Writer_Excel5 implements PHPExcel_Writer_IWriter
$workbookStreamName = ($this->_BIFF_version == 0x0600) ? 'Workbook' : 'Book';
$OLE = new PHPExcel_Shared_OLE_PPS_File(PHPExcel_Shared_OLE::Asc2Ucs($workbookStreamName));
// Initialise worksheet writers
$countSheets = $this->_phpExcel->getSheetCount();
// 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] = 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));
$this->_writerWorksheets[$i]->close();
$worksheetSizes[] = $this->_writerWorksheets[$i]->_datasize;
}
@@ -176,6 +191,7 @@ class PHPExcel_Writer_Excel5 implements PHPExcel_Writer_IWriter
$res = $root->save($pFilename);
PHPExcel_Calculation_Functions::setReturnDateType($saveDateReturnType);
PHPExcel_Calculation::getInstance()->writeDebugLog = $saveDebugLog;
}
/**
@@ -208,4 +224,253 @@ class PHPExcel_Writer_Excel5 implements PHPExcel_Writer_IWriter
$this->_preCalculateFormulas = $pValue;
}
private function _buildWorksheetEschers()
{
// 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
$spgrContainer = new PHPExcel_Shared_Escher_DgContainer_SpgrContainer();
$dgContainer->setSpgrContainer($spgrContainer);
// add one shape which is the group shape
$spContainer = new PHPExcel_Shared_Escher_DgContainer_SpgrContainer_SpContainer();
$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
$spContainer = new PHPExcel_Shared_Escher_DgContainer_SpgrContainer_SpContainer();
// 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);
}
}
/**
* Build the Escher object corresponding to the MSODRAWINGGROUP record
*/
private function _buildWorkbookEscher()
{
$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
$bstoreContainer = new PHPExcel_Shared_Escher_DggContainer_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
$blipType = PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE::BLIPTYPE_PNG;
$imageResource = imagecreatefromgif($filename);
ob_start();
imagepng($imageResource);
$blipData = ob_get_contents();
ob_end_clean();
break;
case 2: // JPEG
$blipType = PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE::BLIPTYPE_JPEG;
$blipData = file_get_contents($filename);
break;
case 3: // PNG
$blipType = PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE::BLIPTYPE_PNG;
$blipData = file_get_contents($filename);
break;
case 6: // Windows DIB (BMP), we convert to PNG
$blipType = PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE::BLIPTYPE_PNG;
$imageResource = PHPExcel_Shared_Drawing::imagecreatefrombmp($filename);
ob_start();
imagepng($imageResource);
$blipData = ob_get_contents();
ob_end_clean();
break;
default: continue 2;
}
$blip = new PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE_Blip();
$blip->setData($blipData);
$BSE = new PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE();
$BSE->setBlipType($blipType);
$BSE->setBlip($blip);
$bstoreContainer->addBSE($BSE);
} else if ($drawing instanceof PHPExcel_Worksheet_MemoryDrawing) {
switch ($drawing->getRenderingFunction()) {
case PHPExcel_Worksheet_MemoryDrawing::RENDERING_JPEG:
$blipType = PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE::BLIPTYPE_JPEG;
$renderingFunction = 'imagejpeg';
break;
case PHPExcel_Worksheet_MemoryDrawing::RENDERING_GIF:
case PHPExcel_Worksheet_MemoryDrawing::RENDERING_PNG:
case PHPExcel_Worksheet_MemoryDrawing::RENDERING_DEFAULT:
$blipType = PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE::BLIPTYPE_PNG;
$renderingFunction = 'imagepng';
break;
}
ob_start();
call_user_func($renderingFunction, $drawing->getImageResource());
$blipData = ob_get_contents();
ob_end_clean();
$blip = new PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE_Blip();
$blip->setData($blipData);
$BSE = new PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE();
$BSE->setBlipType($blipType);
$BSE->setBlip($blip);
$bstoreContainer->addBSE($BSE);
}
}
}
// Set the Escher object
$this->_writerWorkbook->setEscher($escher);
}
}

View File

@@ -22,7 +22,7 @@
* @package PHPExcel_Writer_Excel5
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.7.3c, 2010-06-01
* @version 1.7.4, 2010-08-26
*/
// Original file header of PEAR::Spreadsheet_Excel_Writer_BIFFwriter (used as the base for this class):

View File

@@ -22,7 +22,7 @@
* @package PHPExcel_Writer_Excel5
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.7.3c, 2010-06-01
* @version 1.7.4, 2010-08-26
*/
@@ -106,9 +106,12 @@ class PHPExcel_Writer_Excel5_Escher
, $this->_object->getCSpSaved()
, $this->_object->getCDgSaved() // count total number of drawings saved
);
// add file identifier clusters (one per drawing)
for ($i = 0; $i < $this->_object->getCDgSaved(); ++$i) {
$dggData .= pack('VV', 0, 0);
$IDCLs = $this->_object->getIDCLs();
foreach ($IDCLs as $dgId => $maxReducedSpId) {
$dggData .= pack('VV', $dgId, $maxReducedSpId + 1);
}
$header = pack('vvV', $recVerInstance, $recType, strlen($dggData));

View File

@@ -22,7 +22,7 @@
* @package PHPExcel_Writer_Excel5
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.7.3c, 2010-06-01
* @version 1.7.4, 2010-08-26
*/

View File

@@ -22,7 +22,7 @@
* @package PHPExcel_Writer_Excel5
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.7.3c, 2010-06-01
* @version 1.7.4, 2010-08-26
*/
// Original file header of PEAR::Spreadsheet_Excel_Writer_Parser (used as the base for this class):
@@ -1148,6 +1148,9 @@ class PHPExcel_Writer_Excel5_Parser
case "<>":
return $token;
break;
case "^":
return $token;
break;
default:
// if it's a reference A1 or $A$1 or $A1 or A$1
if (preg_match('/^\$?[A-Ia-i]?[A-Za-z]\$?[0-9]+$/',$token) and
@@ -1288,19 +1291,30 @@ class PHPExcel_Writer_Excel5_Parser
$result2 = $this->_expression();
$result = $this->_createTree('ptgUminus', $result2, '');
return $result;
} elseif ($this->_current_token == "+") {
// catch "+" Term
$this->_advance();
$result2 = $this->_expression();
$result = $this->_createTree('ptgUplus', $result2, '');
return $result;
}
$result = $this->_term();
while (($this->_current_token == "+") or
($this->_current_token == "-")) {
($this->_current_token == "-") or
($this->_current_token == "^")) {
/**/
if ($this->_current_token == "+") {
$this->_advance();
$result2 = $this->_term();
$result = $this->_createTree('ptgAdd', $result, $result2);
} else {
} elseif ($this->_current_token == "-") {
$this->_advance();
$result2 = $this->_term();
$result = $this->_createTree('ptgSub', $result, $result2);
} else {
$this->_advance();
$result2 = $this->_term();
$result = $this->_createTree('ptgPower', $result, $result2);
}
}
return $result;

View File

@@ -22,7 +22,7 @@
* @package PHPExcel_Writer_Excel5
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.7.3c, 2010-06-01
* @version 1.7.4, 2010-08-26
*/
// Original file header of PEAR::Spreadsheet_Excel_Writer_Workbook (used as the base for this class):
@@ -182,6 +182,13 @@ class PHPExcel_Writer_Excel5_Workbook extends PHPExcel_Writer_Excel5_BIFFwriter
*/
private $_colors;
/**
* Escher object corresponding to MSODRAWINGGROUP
*
* @var PHPExcel_Shared_Escher
*/
private $_escher;
/**
* Class constructor
@@ -1400,143 +1407,9 @@ class PHPExcel_Writer_Excel5_Workbook extends PHPExcel_Writer_Excel5_BIFFwriter
*/
private function _writeMsoDrawingGroup()
{
// any drawings in this workbook?
$found = false;
foreach ($this->_phpExcel->getAllSheets() as $sheet) {
if (count($sheet->getDrawingCollection()) > 0) {
$found = true;
}
}
// if there are drawings, then we need to write MSODRAWINGGROUP record
if ($found) {
// create intermediate Escher object
$escher = new PHPExcel_Shared_Escher();
// dggContainer
$dggContainer = new PHPExcel_Shared_Escher_DggContainer();
$escher->setDggContainer($dggContainer);
// 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
$bstoreContainer = new PHPExcel_Shared_Escher_DggContainer_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
$blipType = PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE::BLIPTYPE_PNG;
$imageResource = imagecreatefromgif($filename);
ob_start();
imagepng($imageResource);
$blipData = ob_get_contents();
ob_end_clean();
break;
case 2: // JPEG
$blipType = PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE::BLIPTYPE_JPEG;
$blipData = file_get_contents($filename);
break;
case 3: // PNG
$blipType = PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE::BLIPTYPE_PNG;
$blipData = file_get_contents($filename);
break;
case 6: // Windows DIB (BMP), we convert to PNG
$blipType = PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE::BLIPTYPE_PNG;
$imageResource = PHPExcel_Shared_Drawing::imagecreatefrombmp($filename);
ob_start();
imagepng($imageResource);
$blipData = ob_get_contents();
ob_end_clean();
break;
default: continue 2;
}
$blip = new PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE_Blip();
$blip->setData($blipData);
$BSE = new PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE();
$BSE->setBlipType($blipType);
$BSE->setBlip($blip);
$bstoreContainer->addBSE($BSE);
} else if ($drawing instanceof PHPExcel_Worksheet_MemoryDrawing) {
switch ($drawing->getRenderingFunction()) {
case PHPExcel_Worksheet_MemoryDrawing::RENDERING_JPEG:
$blipType = PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE::BLIPTYPE_JPEG;
$renderingFunction = 'imagejpeg';
break;
case PHPExcel_Worksheet_MemoryDrawing::RENDERING_GIF:
case PHPExcel_Worksheet_MemoryDrawing::RENDERING_PNG:
case PHPExcel_Worksheet_MemoryDrawing::RENDERING_DEFAULT:
$blipType = PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE::BLIPTYPE_PNG;
$renderingFunction = 'imagepng';
break;
}
ob_start();
call_user_func($renderingFunction, $drawing->getImageResource());
$blipData = ob_get_contents();
ob_end_clean();
$blip = new PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE_Blip();
$blip->setData($blipData);
$BSE = new PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE();
$BSE->setBlipType($blipType);
$BSE->setBlip($blip);
$bstoreContainer->addBSE($BSE);
}
}
}
// write the Escher stream from the intermediate Escher object
$writer = new PHPExcel_Writer_Excel5_Escher($escher);
// write the Escher stream if necessary
if (isset($this->_escher)) {
$writer = new PHPExcel_Writer_Excel5_Escher($this->_escher);
$data = $writer->close();
$record = 0x00EB;
@@ -1544,7 +1417,30 @@ class PHPExcel_Writer_Excel5_Workbook extends PHPExcel_Writer_Excel5_BIFFwriter
$header = pack("vv", $record, $length);
return $this->writeData($header . $data);
} else {
return '';
}
}
/**
* Get Escher object
*
* @return PHPExcel_Shared_Escher
*/
public function getEscher()
{
return $this->_escher;
}
/**
* Set Escher object
*
* @param PHPExcel_Shared_Escher $pValue
*/
public function setEscher(PHPExcel_Shared_Escher $pValue = null)
{
$this->_escher = $pValue;
}
}

View File

@@ -22,7 +22,7 @@
* @package PHPExcel_Writer_Excel5
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.7.3c, 2010-06-01
* @version 1.7.4, 2010-08-26
*/
// Original file header of PEAR::Spreadsheet_Excel_Writer_Worksheet (used as the base for this class):
@@ -185,6 +185,13 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
*/
private $_countCellStyleXfs;
/**
* Escher object corresponding to MSODRAWING
*
* @var PHPExcel_Shared_Escher
*/
private $_escher;
/**
* Constructor
*
@@ -2693,143 +2700,83 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
$this->_append($header . $data);
}
/**
* Get Escher object
*
* @return PHPExcel_Shared_Escher
*/
public function getEscher()
{
return $this->_escher;
}
/**
* Set Escher object
*
* @param PHPExcel_Shared_Escher $pValue
*/
public function setEscher(PHPExcel_Shared_Escher $pValue = null)
{
$this->_escher = $pValue;
}
/**
* Write MSODRAWING record
*/
private function _writeMsoDrawing()
{
// check if there are any shapes for this sheet
if (count($this->_phpSheet->getDrawingCollection()) == 0) {
return;
}
// write the Escher stream if necessary
if (isset($this->_escher)) {
$writer = new PHPExcel_Writer_Excel5_Escher($this->_escher);
$data = $writer->close();
$spOffsets = $writer->getSpOffsets();
// create intermediate Escher object
$escher = new PHPExcel_Shared_Escher();
// write the neccesary MSODRAWING, OBJ records
// dgContainer
$dgContainer = new PHPExcel_Shared_Escher_DgContainer();
// split the Escher stream
$spOffsets[0] = 0;
$nm = count($spOffsets) - 1; // number of shapes excluding first shape
for ($i = 1; $i <= $nm; ++$i) {
// MSODRAWING record
$record = 0x00EC; // Record identifier
// set the drawing index (we use sheet index + 1)
$dgContainer->setDgId($this->_phpSheet->getParent()->getIndex($this->_phpSheet) + 1);
$escher->setDgContainer($dgContainer);
// chunk of Escher stream for one shape
// spgrContainer
$spgrContainer = new PHPExcel_Shared_Escher_DgContainer_SpgrContainer();
$dgContainer->setSpgrContainer($spgrContainer);
$dataChunk = substr($data, $spOffsets[$i -1], $spOffsets[$i] - $spOffsets[$i - 1]);
// add one shape which is the group shape
$spContainer = new PHPExcel_Shared_Escher_DgContainer_SpgrContainer_SpContainer();
$spContainer->setSpgr(true);
$spContainer->setSpType(0);
$spContainer->setSpId(($this->_phpSheet->getParent()->getIndex($this->_phpSheet) + 1) << 10);
$spgrContainer->addChild($spContainer);
$length = strlen($dataChunk);
$header = pack("vv", $record, $length);
// add the shapes
$this->_append($header . $dataChunk);
// outer loop is for determining BSE index
$blipIndex = 0; // 1-based index to BstoreContainer
// OBJ record
$record = 0x005D; // record identifier
$objData = '';
$countShapes = 0; // count number of shapes (minus group shape), in this sheet
// ftCmo
$objData .=
pack('vvvvvVVV'
, 0x0015 // 0x0015 = ftCmo
, 0x0012 // length of ftCmo data
, 0x0008 // object type, 0x0008 = picture
, $i // object id number, Excel seems to use 1-based index, local for the sheet
, 0x6011 // option flags, 0x6011 is what OpenOffice.org uses
, 0 // reserved
, 0 // reserved
, 0 // reserved
);
// ftEnd
$objData .=
pack('vv'
, 0x0000 // 0x0000 = ftEnd
, 0x0000 // length of ftEnd data
);
foreach ($this->_phpSheet->getParent()->getAllsheets() as $sheet) {
foreach ($sheet->getDrawingCollection() as $drawing) {
++$blipIndex;
if ($sheet === $this->_phpSheet) {
++$countShapes;
// add the shape
$spContainer = new PHPExcel_Shared_Escher_DgContainer_SpgrContainer_SpContainer();
// set the shape type
$spContainer->setSpType(0x004B);
// set the shape index (we combine 1-based sheet index and $countShapes to create unique shape index)
$spId = $countShapes
| ($this->_phpSheet->getParent()->getIndex($this->_phpSheet) + 1) << 10;
$spContainer->setSpId($spId);
// 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($this->_phpSheet, $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);
}
$length = strlen($objData);
$header = pack('vv', $record, $length);
$this->_append($header . $objData);
}
}
// set last shape index
$dgContainer->setLastSpId($lastSpId);
// write the Escher stream
$writer = new PHPExcel_Writer_Excel5_Escher($escher);
$data = $writer->close();
$spOffsets = $writer->getSpOffsets();
// write the neccesary MSODRAWING, OBJ records
// split the Escher stream
$spOffsets[0] = 0;
$nm = count($spOffsets) - 1; // number of shapes excluding first shape
for ($i = 1; $i <= $nm; ++$i) {
// MSODRAWING record
$record = 0x00EC; // Record identifier
// chunk of Escher stream for one shape
$dataChunk = substr($data, $spOffsets[$i -1], $spOffsets[$i] - $spOffsets[$i - 1]);
$length = strlen($dataChunk);
$header = pack("vv", $record, $length);
$this->_append($header . $dataChunk);
// OBJ record
$record = 0x005D; // record identifier
$objData = '';
// ftCmo
$objData .=
pack('vvvvvVVV'
, 0x0015 // 0x0015 = ftCmo
, 0x0012 // length of ftCmo data
, 0x0008 // object type, 0x0008 = picture
, $i // object id number, Excel seems to use 1-based index, local for the sheet
, 0x6011 // option flags, 0x6011 is what OpenOffice.org uses
, 0 // reserved
, 0 // reserved
, 0 // reserved
);
// ftEnd
$objData .=
pack('vv'
, 0x0000 // 0x0000 = ftEnd
, 0x0000 // length of ftEnd data
);
$length = strlen($objData);
$header = pack('vv', $record, $length);
$this->_append($header . $objData);
}
}
/**
@@ -3006,4 +2953,4 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
return 0;
}
}
}

View File

@@ -22,7 +22,7 @@
* @package PHPExcel_Writer_Excel5
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.7.3c, 2010-06-01
* @version 1.7.4, 2010-08-26
*/
// Original file header of PEAR::Spreadsheet_Excel_Writer_Format (used as the base for this class):

View File

@@ -22,7 +22,7 @@
* @package PHPExcel_Writer
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.7.3c, 2010-06-01
* @version 1.7.4, 2010-08-26
*/
@@ -152,6 +152,8 @@ class PHPExcel_Writer_HTML implements PHPExcel_Writer_IWriter {
// garbage collect
$this->_phpExcel->garbageCollect();
$saveDebugLog = PHPExcel_Calculation::getInstance()->writeDebugLog;
PHPExcel_Calculation::getInstance()->writeDebugLog = false;
$saveArrayReturnType = PHPExcel_Calculation::getArrayReturnType();
PHPExcel_Calculation::setArrayReturnType(PHPExcel_Calculation::RETURN_ARRAY_AS_VALUE);
@@ -182,6 +184,7 @@ class PHPExcel_Writer_HTML implements PHPExcel_Writer_IWriter {
fclose($fileHandle);
PHPExcel_Calculation::setArrayReturnType($saveArrayReturnType);
PHPExcel_Calculation::getInstance()->writeDebugLog = $saveDebugLog;
}
/**
@@ -330,7 +333,7 @@ class PHPExcel_Writer_HTML implements PHPExcel_Writer_IWriter {
// row min,max
$rowMin = $dimension[0][1];
$rowMax = $dimension[1][1];
// calculate start of <tbody>, <thead>
$tbodyStart = $rowMin;
$tbodyEnd = $rowMax;
@@ -338,7 +341,7 @@ class PHPExcel_Writer_HTML implements PHPExcel_Writer_IWriter {
$theadEnd = 0; // default: no </thead>
if ($sheet->getPageSetup()->isRowsToRepeatAtTopSet()) {
$rowsToRepeatAtTop = $sheet->getPageSetup()->getRowsToRepeatAtTop();
// we can only support repeating rows that start at top row
if ($rowsToRepeatAtTop[0] == 1) {
$theadStart = $rowsToRepeatAtTop[0];
@@ -346,7 +349,7 @@ class PHPExcel_Writer_HTML implements PHPExcel_Writer_IWriter {
$tbodyStart = $rowsToRepeatAtTop[1] + 1;
}
}
// Loop through cells
$rowData = null;
for ($row = $rowMin; $row <= $rowMax; ++$row) {

View File

@@ -22,7 +22,7 @@
* @package PHPExcel_Writer
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.7.3c, 2010-06-01
* @version 1.7.4, 2010-08-26
*/

View File

@@ -22,7 +22,7 @@
* @package PHPExcel_Writer
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.7.3c, 2010-06-01
* @version 1.7.4, 2010-08-26
*/

View File

@@ -22,7 +22,7 @@
* @package PHPExcel_Writer
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.7.3c, 2010-06-01
* @version 1.7.4, 2010-08-26
*/
@@ -163,10 +163,10 @@ class PHPExcel_Writer_Serialized implements PHPExcel_Writer_IWriter
// PHPExcel
$objWriter->startElement('PHPExcel');
$objWriter->writeAttribute('version', '1.7.3c');
$objWriter->writeAttribute('version', '1.7.4');
// Comment
$objWriter->writeComment('This file has been generated using PHPExcel v1.7.3c (http://www.codeplex.com/PHPExcel). It contains a base64 encoded serialized version of the PHPExcel internal object.');
$objWriter->writeComment('This file has been generated using PHPExcel v1.7.4 (http://www.codeplex.com/PHPExcel). It contains a base64 encoded serialized version of the PHPExcel internal object.');
// Data
$objWriter->startElement('data');