diff --git a/COPYRIGHT b/COPYRIGHT index 8ce95782942..c684c3028af 100644 --- a/COPYRIGHT +++ b/COPYRIGHT @@ -19,7 +19,7 @@ FPDI 1.5.2 Apache Software License 2.0 Yes GeoIP 1.4 LGPL-2.1+ Yes Sample code to make geoip convert (not into deb package) NuSoap 0.9.5 LGPL 2.1+ Yes Library to develop SOAP Web services (not into rpm and deb package) odtPHP 1.0.1 GPL-2+ b Yes Library to build/edit ODT files -PHPExcel 1.7.8 LGPL-2.1+ Yes Read/Write XLS files, read ODS files +PHPExcel 1.8.0 LGPL-2.1+ Yes Read/Write XLS files, read ODS files php-iban 1.4.6 LGPL-3+ Yes Parse and validate IBAN (and IIBAN) bank account information in PHP PHPPrintIPP 1.3 GPL-2+ Yes Library to send print IPP requests TCPDF 6.0.093 LGPL-3+ Yes PDF generation diff --git a/htdocs/includes/phpexcel/PHPExcel.php b/htdocs/includes/phpexcel/PHPExcel.php index f0b39e7961a..bf6f60f5fd0 100644 --- a/htdocs/includes/phpexcel/PHPExcel.php +++ b/htdocs/includes/phpexcel/PHPExcel.php @@ -2,7 +2,7 @@ /** * PHPExcel * - * Copyright (c) 2006 - 2012 PHPExcel + * Copyright (c) 2006 - 2014 PHPExcel * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,16 +20,16 @@ * * @category PHPExcel * @package PHPExcel - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version 1.7.8, 2012-10-12 + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) + * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @version 1.8.0, 2014-03-02 */ /** PHPExcel root directory */ if (!defined('PHPEXCEL_ROOT')) { - define('PHPEXCEL_ROOT', dirname(__FILE__) . '/'); - require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php'); + define('PHPEXCEL_ROOT', dirname(__FILE__) . '/'); + require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php'); } @@ -38,165 +38,441 @@ if (!defined('PHPEXCEL_ROOT')) { * * @category PHPExcel * @package PHPExcel - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) */ class PHPExcel { - /** - * Document properties + /** + * Unique ID + * + * @var string + */ + private $_uniqueID; + + /** + * Document properties + * + * @var PHPExcel_DocumentProperties + */ + private $_properties; + + /** + * Document security + * + * @var PHPExcel_DocumentSecurity + */ + private $_security; + + /** + * Collection of Worksheet objects + * + * @var PHPExcel_Worksheet[] + */ + private $_workSheetCollection = array(); + + /** + * Calculation Engine * - * @var PHPExcel_DocumentProperties + * @var PHPExcel_Calculation */ - private $_properties; + private $_calculationEngine = NULL; + + /** + * Active sheet index + * + * @var int + */ + private $_activeSheetIndex = 0; + + /** + * Named ranges + * + * @var PHPExcel_NamedRange[] + */ + private $_namedRanges = array(); + + /** + * CellXf supervisor + * + * @var PHPExcel_Style + */ + private $_cellXfSupervisor; + + /** + * CellXf collection + * + * @var PHPExcel_Style[] + */ + private $_cellXfCollection = array(); + + /** + * CellStyleXf collection + * + * @var PHPExcel_Style[] + */ + private $_cellStyleXfCollection = array(); /** - * Document security - * - * @var PHPExcel_DocumentSecurity - */ - private $_security; + * _hasMacros : this workbook have macros ? + * + * @var bool + */ + private $_hasMacros = FALSE; /** - * Collection of Worksheet objects - * - * @var PHPExcel_Worksheet[] - */ - private $_workSheetCollection = array(); + * _macrosCode : all macros code (the vbaProject.bin file, this include form, code, etc.), NULL if no macro + * + * @var binary + */ + private $_macrosCode=NULL; + /** + * _macrosCertificate : if macros are signed, contains vbaProjectSignature.bin file, NULL if not signed + * + * @var binary + */ + private $_macrosCertificate=NULL; /** - * Active sheet index - * - * @var int - */ - private $_activeSheetIndex = 0; + * _ribbonXMLData : NULL if workbook is'nt Excel 2007 or not contain a customized UI + * + * @var NULL|string + */ + private $_ribbonXMLData=NULL; /** - * Named ranges - * - * @var PHPExcel_NamedRange[] - */ - private $_namedRanges = array(); + * _ribbonBinObjects : NULL if workbook is'nt Excel 2007 or not contain embedded objects (picture(s)) for Ribbon Elements + * ignored if $_ribbonXMLData is null + * + * @var NULL|array + */ + private $_ribbonBinObjects=NULL; /** - * CellXf supervisor - * - * @var PHPExcel_Style - */ - private $_cellXfSupervisor; + * The workbook has macros ? + * + * @return true if workbook has macros, false if not + */ + public function hasMacros(){ + return $this->_hasMacros; + } /** - * CellXf collection - * - * @var PHPExcel_Style[] - */ - private $_cellXfCollection = array(); + * Define if a workbook has macros + * + * @param true|false + */ + public function setHasMacros($hasMacros=false){ + $this->_hasMacros=(bool)$hasMacros; + } /** - * CellStyleXf collection - * - * @var PHPExcel_Style[] - */ - private $_cellStyleXfCollection = array(); + * Set the macros code + * + * @param binary string|null + */ + public function setMacrosCode($MacrosCode){ + $this->_macrosCode=$MacrosCode; + $this->setHasMacros(!is_null($MacrosCode)); + } /** + * Return the macros code + * + * @return binary|null + */ + public function getMacrosCode(){ + return $this->_macrosCode; + } + + /** + * Set the macros certificate + * + * @param binary|null + */ + public function setMacrosCertificate($Certificate=NULL){ + $this->_macrosCertificate=$Certificate; + } + + /** + * Is the project signed ? + * + * @return true|false + */ + public function hasMacrosCertificate(){ + return !is_null($this->_macrosCertificate); + } + + /** + * Return the macros certificate + * + * @return binary|null + */ + public function getMacrosCertificate(){ + return $this->_macrosCertificate; + } + + /** + * Remove all macros, certificate from spreadsheet + * + * @param none + * @return void + */ + public function discardMacros(){ + $this->_hasMacros=false; + $this->_macrosCode=NULL; + $this->_macrosCertificate=NULL; + } + + /** + * set ribbon XML data + * + */ + public function setRibbonXMLData($Target=NULL, $XMLData=NULL){ + if(!is_null($Target) && !is_null($XMLData)){ + $this->_ribbonXMLData=array('target'=>$Target, 'data'=>$XMLData); + }else{ + $this->_ribbonXMLData=NULL; + } + } + + /** + * retrieve ribbon XML Data + * + * return string|null|array + */ + public function getRibbonXMLData($What='all'){//we need some constants here... + $ReturnData=NULL; + $What=strtolower($What); + switch($What){ + case 'all': + $ReturnData=$this->_ribbonXMLData; + break; + case 'target': + case 'data': + if(is_array($this->_ribbonXMLData) && array_key_exists($What,$this->_ribbonXMLData)){ + $ReturnData=$this->_ribbonXMLData[$What]; + }//else $ReturnData stay at null + break; + }//default: $ReturnData at null + return $ReturnData; + } + + /** + * store binaries ribbon objects (pictures) + * + */ + public function setRibbonBinObjects($BinObjectsNames=NULL, $BinObjectsData=NULL){ + if(!is_null($BinObjectsNames) && !is_null($BinObjectsData)){ + $this->_ribbonBinObjects=array('names'=>$BinObjectsNames, 'data'=>$BinObjectsData); + }else{ + $this->_ribbonBinObjects=NULL; + } + } + /** + * return the extension of a filename. Internal use for a array_map callback (php<5.3 don't like lambda function) + * + */ + private function _getExtensionOnly($ThePath){ + return pathinfo($ThePath, PATHINFO_EXTENSION); + } + + /** + * retrieve Binaries Ribbon Objects + * + */ + public function getRibbonBinObjects($What='all'){ + $ReturnData=NULL; + $What=strtolower($What); + switch($What){ + case 'all': + return $this->_ribbonBinObjects; + break; + case 'names': + case 'data': + if(is_array($this->_ribbonBinObjects) && array_key_exists($What, $this->_ribbonBinObjects)){ + $ReturnData=$this->_ribbonBinObjects[$What]; + } + break; + case 'types': + if(is_array($this->_ribbonBinObjects) && array_key_exists('data', $this->_ribbonBinObjects) && is_array($this->_ribbonBinObjects['data'])){ + $tmpTypes=array_keys($this->_ribbonBinObjects['data']); + $ReturnData=array_unique(array_map(array($this,'_getExtensionOnly'), $tmpTypes)); + }else + $ReturnData=array();//the caller want an array... not null if empty + break; + } + return $ReturnData; + } + + /** + * This workbook have a custom UI ? + * + * @return true|false + */ + public function hasRibbon(){ + return !is_null($this->_ribbonXMLData); + } + + /** + * This workbook have additionnal object for the ribbon ? + * + * @return true|false + */ + public function hasRibbonBinObjects(){ + return !is_null($this->_ribbonBinObjects); + } + + /** + * Check if a sheet with a specified code name already exists + * + * @param string $pSheetCodeName Name of the worksheet to check + * @return boolean + */ + public function sheetCodeNameExists($pSheetCodeName) + { + return ($this->getSheetByCodeName($pSheetCodeName) !== NULL); + } + + /** + * Get sheet by code name. Warning : sheet don't have always a code name ! + * + * @param string $pName Sheet name + * @return PHPExcel_Worksheet + */ + public function getSheetByCodeName($pName = '') + { + $worksheetCount = count($this->_workSheetCollection); + for ($i = 0; $i < $worksheetCount; ++$i) { + if ($this->_workSheetCollection[$i]->getCodeName() == $pName) { + return $this->_workSheetCollection[$i]; + } + } + + return null; + } + + /** * Create a new PHPExcel with one Worksheet */ public function __construct() { + $this->_uniqueID = uniqid(); + $this->_calculationEngine = PHPExcel_Calculation::getInstance($this); + // Initialise worksheet collection and add one worksheet $this->_workSheetCollection = array(); $this->_workSheetCollection[] = new PHPExcel_Worksheet($this); $this->_activeSheetIndex = 0; - // Create document properties - $this->_properties = new PHPExcel_DocumentProperties(); + // Create document properties + $this->_properties = new PHPExcel_DocumentProperties(); - // Create document security - $this->_security = new PHPExcel_DocumentSecurity(); + // Create document security + $this->_security = new PHPExcel_DocumentSecurity(); - // Set named ranges - $this->_namedRanges = array(); + // Set named ranges + $this->_namedRanges = array(); - // Create the cellXf supervisor - $this->_cellXfSupervisor = new PHPExcel_Style(true); - $this->_cellXfSupervisor->bindParent($this); + // Create the cellXf supervisor + $this->_cellXfSupervisor = new PHPExcel_Style(true); + $this->_cellXfSupervisor->bindParent($this); - // Create the default style - $this->addCellXf(new PHPExcel_Style); - $this->addCellStyleXf(new PHPExcel_Style); - } + // Create the default style + $this->addCellXf(new PHPExcel_Style); + $this->addCellStyleXf(new PHPExcel_Style); + } + /** + * Code to execute when this worksheet is unset() + * + */ + public function __destruct() { + PHPExcel_Calculation::unsetInstance($this); + $this->disconnectWorksheets(); + } // function __destruct() + + /** + * Disconnect all worksheets from this PHPExcel workbook object, + * typically so that the PHPExcel object can be unset + * + */ + public function disconnectWorksheets() + { + $worksheet = NULL; + foreach($this->_workSheetCollection as $k => &$worksheet) { + $worksheet->disconnectCells(); + $this->_workSheetCollection[$k] = null; + } + unset($worksheet); + $this->_workSheetCollection = array(); + } /** - * Disconnect all worksheets from this PHPExcel workbook object, - * typically so that the PHPExcel object can be unset + * Return the calculation engine for this worksheet * + * @return PHPExcel_Calculation */ - public function disconnectWorksheets() { - foreach($this->_workSheetCollection as $k => &$worksheet) { - $worksheet->disconnectCells(); - $this->_workSheetCollection[$k] = null; - } - unset($worksheet); - $this->_workSheetCollection = array(); - } - - /** - * Get properties - * - * @return PHPExcel_DocumentProperties - */ - public function getProperties() + public function getCalculationEngine() { - return $this->_properties; - } + return $this->_calculationEngine; + } // function getCellCacheController() - /** - * Set properties - * - * @param PHPExcel_DocumentProperties $pValue - */ - public function setProperties(PHPExcel_DocumentProperties $pValue) - { - $this->_properties = $pValue; - } + /** + * Get properties + * + * @return PHPExcel_DocumentProperties + */ + public function getProperties() + { + return $this->_properties; + } - /** - * Get security - * - * @return PHPExcel_DocumentSecurity - */ - public function getSecurity() - { - return $this->_security; - } + /** + * Set properties + * + * @param PHPExcel_DocumentProperties $pValue + */ + public function setProperties(PHPExcel_DocumentProperties $pValue) + { + $this->_properties = $pValue; + } - /** - * Set security - * - * @param PHPExcel_DocumentSecurity $pValue - */ - public function setSecurity(PHPExcel_DocumentSecurity $pValue) - { - $this->_security = $pValue; - } + /** + * Get security + * + * @return PHPExcel_DocumentSecurity + */ + public function getSecurity() + { + return $this->_security; + } - /** - * Get active sheet - * - * @return PHPExcel_Worksheet - */ - public function getActiveSheet() - { - return $this->_workSheetCollection[$this->_activeSheetIndex]; - } + /** + * Set security + * + * @param PHPExcel_DocumentSecurity $pValue + */ + public function setSecurity(PHPExcel_DocumentSecurity $pValue) + { + $this->_security = $pValue; + } + + /** + * Get active sheet + * + * @return PHPExcel_Worksheet + */ + public function getActiveSheet() + { + return $this->_workSheetCollection[$this->_activeSheetIndex]; + } /** * Create sheet and add it to this workbook * - * @param int|null $iSheetIndex Index where sheet should go (0,1,..., or null for last) + * @param int|null $iSheetIndex Index where sheet should go (0,1,..., or null for last) * @return PHPExcel_Worksheet - * @throws Exception + * @throws PHPExcel_Exception */ public function createSheet($iSheetIndex = NULL) { @@ -206,33 +482,35 @@ class PHPExcel } /** - * Chech if a sheet with a specified name already exists + * Check if a sheet with a specified name already exists * - * @param string $pSheetName Name of the worksheet to check + * @param string $pSheetName Name of the worksheet to check * @return boolean */ public function sheetNameExists($pSheetName) { - return ($this->getSheetByName($pSheetName) !== NULL); + return ($this->getSheetByName($pSheetName) !== NULL); } /** * Add sheet * - * @param PHPExcel_Worksheet $pSheet - * @param int|null $iSheetIndex Index where sheet should go (0,1,..., or null for last) + * @param PHPExcel_Worksheet $pSheet + * @param int|null $iSheetIndex Index where sheet should go (0,1,..., or null for last) * @return PHPExcel_Worksheet - * @throws Exception + * @throws PHPExcel_Exception */ public function addSheet(PHPExcel_Worksheet $pSheet, $iSheetIndex = NULL) { - if ($this->sheetNameExists($pSheet->getTitle())) { - throw new Exception("Workbook already contains a worksheet named '{$pSheet->getTitle()}'. Rename this worksheet first."); - } + if ($this->sheetNameExists($pSheet->getTitle())) { + throw new PHPExcel_Exception( + "Workbook already contains a worksheet named '{$pSheet->getTitle()}'. Rename this worksheet first." + ); + } if($iSheetIndex === NULL) { if ($this->_activeSheetIndex < 0) { - $this->_activeSheetIndex = 0; + $this->_activeSheetIndex = 0; } $this->_workSheetCollection[] = $pSheet; } else { @@ -244,104 +522,120 @@ class PHPExcel array($pSheet) ); - // Adjust active sheet index if necessary - if ($this->_activeSheetIndex >= $iSheetIndex) { - ++$this->_activeSheetIndex; - } + // Adjust active sheet index if necessary + if ($this->_activeSheetIndex >= $iSheetIndex) { + ++$this->_activeSheetIndex; + } } - return $pSheet; + + if ($pSheet->getParent() === null) { + $pSheet->rebindParent($this); + } + + return $pSheet; } - /** - * Remove sheet by index - * - * @param int $pIndex Active sheet index - * @throws Exception - */ - public function removeSheetByIndex($pIndex = 0) - { - if ($pIndex > count($this->_workSheetCollection) - 1) { - throw new Exception("Sheet index is out of bounds."); - } else { - array_splice($this->_workSheetCollection, $pIndex, 1); - } - // Adjust active sheet index if necessary - if (($this->_activeSheetIndex >= $pIndex) && - ($pIndex > count($this->_workSheetCollection) - 1)) { - --$this->_activeSheetIndex; - } + /** + * Remove sheet by index + * + * @param int $pIndex Active sheet index + * @throws PHPExcel_Exception + */ + public function removeSheetByIndex($pIndex = 0) + { - } + $numSheets = count($this->_workSheetCollection); - /** - * Get sheet by index - * - * @param int $pIndex Sheet index - * @return PHPExcel_Worksheet - * @throws Exception - */ - public function getSheet($pIndex = 0) - { - if ($pIndex > count($this->_workSheetCollection) - 1) { - throw new Exception("Sheet index is out of bounds."); - } else { - return $this->_workSheetCollection[$pIndex]; - } - } + if ($pIndex > $numSheets - 1) { + throw new PHPExcel_Exception( + "You tried to remove a sheet by the out of bounds index: {$pIndex}. The actual number of sheets is {$numSheets}." + ); + } else { + array_splice($this->_workSheetCollection, $pIndex, 1); + } + // Adjust active sheet index if necessary + if (($this->_activeSheetIndex >= $pIndex) && + ($pIndex > count($this->_workSheetCollection) - 1)) { + --$this->_activeSheetIndex; + } - /** - * Get all sheets - * - * @return PHPExcel_Worksheet[] - */ - public function getAllSheets() - { - return $this->_workSheetCollection; - } - - /** - * Get sheet by name - * - * @param string $pName Sheet name - * @return PHPExcel_Worksheet - * @throws Exception - */ - public function getSheetByName($pName = '') - { - $worksheetCount = count($this->_workSheetCollection); - for ($i = 0; $i < $worksheetCount; ++$i) { - if ($this->_workSheetCollection[$i]->getTitle() == $pName) { - return $this->_workSheetCollection[$i]; - } - } - - return null; - } - - /** - * Get index for sheet - * - * @param PHPExcel_Worksheet $pSheet - * @return Sheet index - * @throws Exception - */ - public function getIndex(PHPExcel_Worksheet $pSheet) - { - foreach ($this->_workSheetCollection as $key => $value) { - if ($value->getHashCode() == $pSheet->getHashCode()) { - return $key; - } - } - } + } /** - * Set index for sheet by sheet name. - * - * @param string $sheetName Sheet name to modify index for - * @param int $newIndex New index for the sheet - * @return New sheet index - * @throws Exception - */ + * Get sheet by index + * + * @param int $pIndex Sheet index + * @return PHPExcel_Worksheet + * @throws PHPExcel_Exception + */ + public function getSheet($pIndex = 0) + { + + $numSheets = count($this->_workSheetCollection); + + if ($pIndex > $numSheets - 1) { + throw new PHPExcel_Exception( + "Your requested sheet index: {$pIndex} is out of bounds. The actual number of sheets is {$numSheets}." + ); + } else { + return $this->_workSheetCollection[$pIndex]; + } + } + + /** + * Get all sheets + * + * @return PHPExcel_Worksheet[] + */ + public function getAllSheets() + { + return $this->_workSheetCollection; + } + + /** + * Get sheet by name + * + * @param string $pName Sheet name + * @return PHPExcel_Worksheet + */ + public function getSheetByName($pName = '') + { + $worksheetCount = count($this->_workSheetCollection); + for ($i = 0; $i < $worksheetCount; ++$i) { + if ($this->_workSheetCollection[$i]->getTitle() === $pName) { + return $this->_workSheetCollection[$i]; + } + } + + return NULL; + } + + /** + * Get index for sheet + * + * @param PHPExcel_Worksheet $pSheet + * @return Sheet index + * @throws PHPExcel_Exception + */ + public function getIndex(PHPExcel_Worksheet $pSheet) + { + foreach ($this->_workSheetCollection as $key => $value) { + if ($value->getHashCode() == $pSheet->getHashCode()) { + return $key; + } + } + + throw new PHPExcel_Exception("Sheet does not exist."); + } + + /** + * Set index for sheet by sheet name. + * + * @param string $sheetName Sheet name to modify index for + * @param int $newIndex New index for the sheet + * @return New sheet index + * @throws PHPExcel_Exception + */ public function setIndexByName($sheetName, $newIndex) { $oldIndex = $this->getIndex($this->getSheetByName($sheetName)); @@ -349,475 +643,497 @@ class PHPExcel $this->_workSheetCollection, $oldIndex, 1 - ); + ); array_splice( $this->_workSheetCollection, $newIndex, 0, $pSheet - ); + ); return $newIndex; } - /** - * Get sheet count - * - * @return int - */ - public function getSheetCount() - { - return count($this->_workSheetCollection); - } + /** + * Get sheet count + * + * @return int + */ + public function getSheetCount() + { + return count($this->_workSheetCollection); + } - /** - * Get active sheet index - * - * @return int Active sheet index - */ - public function getActiveSheetIndex() - { - return $this->_activeSheetIndex; - } + /** + * Get active sheet index + * + * @return int Active sheet index + */ + public function getActiveSheetIndex() + { + return $this->_activeSheetIndex; + } - /** - * Set active sheet index - * - * @param int $pIndex Active sheet index - * @throws Exception - * @return PHPExcel_Worksheet - */ - public function setActiveSheetIndex($pIndex = 0) - { - if ($pIndex > count($this->_workSheetCollection) - 1) { - throw new Exception("Active sheet index is out of bounds."); - } else { - $this->_activeSheetIndex = $pIndex; - } - return $this->getActiveSheet(); - } + /** + * Set active sheet index + * + * @param int $pIndex Active sheet index + * @throws PHPExcel_Exception + * @return PHPExcel_Worksheet + */ + public function setActiveSheetIndex($pIndex = 0) + { + $numSheets = count($this->_workSheetCollection); - /** - * Set active sheet index by name - * - * @param string $pValue Sheet title - * @return PHPExcel_Worksheet - * @throws Exception - */ - public function setActiveSheetIndexByName($pValue = '') - { - if (($worksheet = $this->getSheetByName($pValue)) instanceof PHPExcel_Worksheet) { - $this->setActiveSheetIndex($this->getIndex($worksheet)); - return $worksheet; - } + if ($pIndex > $numSheets - 1) { + throw new PHPExcel_Exception( + "You tried to set a sheet active by the out of bounds index: {$pIndex}. The actual number of sheets is {$numSheets}." + ); + } else { + $this->_activeSheetIndex = $pIndex; + } + return $this->getActiveSheet(); + } - throw new Exception('Workbook does not contain sheet:' . $pValue); - } + /** + * Set active sheet index by name + * + * @param string $pValue Sheet title + * @return PHPExcel_Worksheet + * @throws PHPExcel_Exception + */ + public function setActiveSheetIndexByName($pValue = '') + { + if (($worksheet = $this->getSheetByName($pValue)) instanceof PHPExcel_Worksheet) { + $this->setActiveSheetIndex($this->getIndex($worksheet)); + return $worksheet; + } - /** - * Get sheet names - * - * @return string[] - */ - public function getSheetNames() - { - $returnValue = array(); - $worksheetCount = $this->getSheetCount(); - for ($i = 0; $i < $worksheetCount; ++$i) { - $returnValue[] = $this->getSheet($i)->getTitle(); - } + throw new PHPExcel_Exception('Workbook does not contain sheet:' . $pValue); + } - return $returnValue; - } + /** + * Get sheet names + * + * @return string[] + */ + public function getSheetNames() + { + $returnValue = array(); + $worksheetCount = $this->getSheetCount(); + for ($i = 0; $i < $worksheetCount; ++$i) { + $returnValue[] = $this->getSheet($i)->getTitle(); + } - /** - * Add external sheet - * - * @param PHPExcel_Worksheet $pSheet External sheet to add - * @param int|null $iSheetIndex Index where sheet should go (0,1,..., or null for last) - * @throws Exception - * @return PHPExcel_Worksheet - */ - public function addExternalSheet(PHPExcel_Worksheet $pSheet, $iSheetIndex = null) { - if ($this->sheetNameExists($pSheet->getTitle())) { - throw new Exception("Workbook already contains a worksheet named '{$pSheet->getTitle()}'. Rename the external sheet first."); - } + return $returnValue; + } - // count how many cellXfs there are in this workbook currently, we will need this below - $countCellXfs = count($this->_cellXfCollection); + /** + * Add external sheet + * + * @param PHPExcel_Worksheet $pSheet External sheet to add + * @param int|null $iSheetIndex Index where sheet should go (0,1,..., or null for last) + * @throws PHPExcel_Exception + * @return PHPExcel_Worksheet + */ + public function addExternalSheet(PHPExcel_Worksheet $pSheet, $iSheetIndex = null) { + if ($this->sheetNameExists($pSheet->getTitle())) { + throw new PHPExcel_Exception("Workbook already contains a worksheet named '{$pSheet->getTitle()}'. Rename the external sheet first."); + } - // copy all the shared cellXfs from the external workbook and append them to the current - foreach ($pSheet->getParent()->getCellXfCollection() as $cellXf) { - $this->addCellXf(clone $cellXf); - } + // count how many cellXfs there are in this workbook currently, we will need this below + $countCellXfs = count($this->_cellXfCollection); - // move sheet to this workbook - $pSheet->rebindParent($this); + // copy all the shared cellXfs from the external workbook and append them to the current + foreach ($pSheet->getParent()->getCellXfCollection() as $cellXf) { + $this->addCellXf(clone $cellXf); + } - // update the cellXfs - foreach ($pSheet->getCellCollection(false) as $cellID) { - $cell = $pSheet->getCell($cellID); - $cell->setXfIndex( $cell->getXfIndex() + $countCellXfs ); - } + // move sheet to this workbook + $pSheet->rebindParent($this); - return $this->addSheet($pSheet, $iSheetIndex); - } + // update the cellXfs + foreach ($pSheet->getCellCollection(false) as $cellID) { + $cell = $pSheet->getCell($cellID); + $cell->setXfIndex( $cell->getXfIndex() + $countCellXfs ); + } - /** - * Get named ranges - * - * @return PHPExcel_NamedRange[] - */ - public function getNamedRanges() { - return $this->_namedRanges; - } + return $this->addSheet($pSheet, $iSheetIndex); + } - /** - * Add named range - * - * @param PHPExcel_NamedRange $namedRange - * @return PHPExcel - */ - public function addNamedRange(PHPExcel_NamedRange $namedRange) { - if ($namedRange->getScope() == null) { - // global scope - $this->_namedRanges[$namedRange->getName()] = $namedRange; - } else { - // local scope - $this->_namedRanges[$namedRange->getScope()->getTitle().'!'.$namedRange->getName()] = $namedRange; - } - return true; - } + /** + * Get named ranges + * + * @return PHPExcel_NamedRange[] + */ + public function getNamedRanges() { + return $this->_namedRanges; + } - /** - * Get named range - * - * @param string $namedRange - * @param PHPExcel_Worksheet|null $pSheet Scope. Use null for global scope - * @return PHPExcel_NamedRange|null - */ - public function getNamedRange($namedRange, PHPExcel_Worksheet $pSheet = null) { - $returnValue = null; + /** + * Add named range + * + * @param PHPExcel_NamedRange $namedRange + * @return PHPExcel + */ + public function addNamedRange(PHPExcel_NamedRange $namedRange) { + if ($namedRange->getScope() == null) { + // global scope + $this->_namedRanges[$namedRange->getName()] = $namedRange; + } else { + // local scope + $this->_namedRanges[$namedRange->getScope()->getTitle().'!'.$namedRange->getName()] = $namedRange; + } + return true; + } - if ($namedRange != '' && ($namedRange !== NULL)) { - // first look for global defined name - if (isset($this->_namedRanges[$namedRange])) { - $returnValue = $this->_namedRanges[$namedRange]; - } + /** + * Get named range + * + * @param string $namedRange + * @param PHPExcel_Worksheet|null $pSheet Scope. Use null for global scope + * @return PHPExcel_NamedRange|null + */ + public function getNamedRange($namedRange, PHPExcel_Worksheet $pSheet = null) { + $returnValue = null; - // then look for local defined name (has priority over global defined name if both names exist) - if (($pSheet !== NULL) && isset($this->_namedRanges[$pSheet->getTitle() . '!' . $namedRange])) { - $returnValue = $this->_namedRanges[$pSheet->getTitle() . '!' . $namedRange]; - } - } + if ($namedRange != '' && ($namedRange !== NULL)) { + // first look for global defined name + if (isset($this->_namedRanges[$namedRange])) { + $returnValue = $this->_namedRanges[$namedRange]; + } - return $returnValue; - } + // then look for local defined name (has priority over global defined name if both names exist) + if (($pSheet !== NULL) && isset($this->_namedRanges[$pSheet->getTitle() . '!' . $namedRange])) { + $returnValue = $this->_namedRanges[$pSheet->getTitle() . '!' . $namedRange]; + } + } - /** - * Remove named range - * - * @param string $namedRange - * @param PHPExcel_Worksheet|null $pSheet Scope: use null for global scope. - * @return PHPExcel - */ - public function removeNamedRange($namedRange, PHPExcel_Worksheet $pSheet = null) { - if ($pSheet === NULL) { - if (isset($this->_namedRanges[$namedRange])) { - unset($this->_namedRanges[$namedRange]); - } - } else { - if (isset($this->_namedRanges[$pSheet->getTitle() . '!' . $namedRange])) { - unset($this->_namedRanges[$pSheet->getTitle() . '!' . $namedRange]); - } - } - return $this; - } + return $returnValue; + } - /** - * Get worksheet iterator - * - * @return PHPExcel_WorksheetIterator - */ - public function getWorksheetIterator() { - return new PHPExcel_WorksheetIterator($this); - } + /** + * Remove named range + * + * @param string $namedRange + * @param PHPExcel_Worksheet|null $pSheet Scope: use null for global scope. + * @return PHPExcel + */ + public function removeNamedRange($namedRange, PHPExcel_Worksheet $pSheet = null) { + if ($pSheet === NULL) { + if (isset($this->_namedRanges[$namedRange])) { + unset($this->_namedRanges[$namedRange]); + } + } else { + if (isset($this->_namedRanges[$pSheet->getTitle() . '!' . $namedRange])) { + unset($this->_namedRanges[$pSheet->getTitle() . '!' . $namedRange]); + } + } + return $this; + } - /** - * Copy workbook (!= clone!) - * - * @return PHPExcel - */ - public function copy() { - $copied = clone $this; + /** + * Get worksheet iterator + * + * @return PHPExcel_WorksheetIterator + */ + public function getWorksheetIterator() { + return new PHPExcel_WorksheetIterator($this); + } - $worksheetCount = count($this->_workSheetCollection); - for ($i = 0; $i < $worksheetCount; ++$i) { - $this->_workSheetCollection[$i] = $this->_workSheetCollection[$i]->copy(); - $this->_workSheetCollection[$i]->rebindParent($this); - } + /** + * Copy workbook (!= clone!) + * + * @return PHPExcel + */ + public function copy() { + $copied = clone $this; - return $copied; - } + $worksheetCount = count($this->_workSheetCollection); + for ($i = 0; $i < $worksheetCount; ++$i) { + $this->_workSheetCollection[$i] = $this->_workSheetCollection[$i]->copy(); + $this->_workSheetCollection[$i]->rebindParent($this); + } - /** - * Implement PHP __clone to create a deep clone, not just a shallow copy. - */ - public function __clone() { - foreach($this as $key => $val) { - if (is_object($val) || (is_array($val))) { - $this->{$key} = unserialize(serialize($val)); - } - } - } + return $copied; + } - /** - * Get the workbook collection of cellXfs - * - * @return PHPExcel_Style[] - */ - public function getCellXfCollection() - { - return $this->_cellXfCollection; - } + /** + * Implement PHP __clone to create a deep clone, not just a shallow copy. + */ + public function __clone() { + foreach($this as $key => $val) { + if (is_object($val) || (is_array($val))) { + $this->{$key} = unserialize(serialize($val)); + } + } + } - /** - * Get cellXf by index - * - * @param int $pIndex - * @return PHPExcel_Style - */ - public function getCellXfByIndex($pIndex = 0) - { - return $this->_cellXfCollection[$pIndex]; - } + /** + * Get the workbook collection of cellXfs + * + * @return PHPExcel_Style[] + */ + public function getCellXfCollection() + { + return $this->_cellXfCollection; + } - /** - * Get cellXf by hash code - * - * @param string $pValue - * @return PHPExcel_Style|false - */ - public function getCellXfByHashCode($pValue = '') - { - foreach ($this->_cellXfCollection as $cellXf) { - if ($cellXf->getHashCode() == $pValue) { - return $cellXf; - } - } - return false; - } + /** + * Get cellXf by index + * + * @param int $pIndex + * @return PHPExcel_Style + */ + public function getCellXfByIndex($pIndex = 0) + { + return $this->_cellXfCollection[$pIndex]; + } - /** - * Get default style - * - * @return PHPExcel_Style - * @throws Exception - */ - public function getDefaultStyle() - { - if (isset($this->_cellXfCollection[0])) { - return $this->_cellXfCollection[0]; - } - throw new Exception('No default style found for this workbook'); - } + /** + * Get cellXf by hash code + * + * @param string $pValue + * @return PHPExcel_Style|false + */ + public function getCellXfByHashCode($pValue = '') + { + foreach ($this->_cellXfCollection as $cellXf) { + if ($cellXf->getHashCode() == $pValue) { + return $cellXf; + } + } + return false; + } - /** - * Add a cellXf to the workbook - * - * @param PHPExcel_Style $style - */ - public function addCellXf(PHPExcel_Style $style) - { - $this->_cellXfCollection[] = $style; - $style->setIndex(count($this->_cellXfCollection) - 1); - } + /** + * Check if style exists in style collection + * + * @param PHPExcel_Style $pCellStyle + * @return boolean + */ + public function cellXfExists($pCellStyle = null) + { + return in_array($pCellStyle, $this->_cellXfCollection, true); + } - /** - * Remove cellXf by index. It is ensured that all cells get their xf index updated. - * - * @param int $pIndex Index to cellXf - * @throws Exception - */ - public function removeCellXfByIndex($pIndex = 0) - { - if ($pIndex > count($this->_cellXfCollection) - 1) { - throw new Exception("CellXf index is out of bounds."); - } else { - // first remove the cellXf - array_splice($this->_cellXfCollection, $pIndex, 1); + /** + * Get default style + * + * @return PHPExcel_Style + * @throws PHPExcel_Exception + */ + public function getDefaultStyle() + { + if (isset($this->_cellXfCollection[0])) { + return $this->_cellXfCollection[0]; + } + throw new PHPExcel_Exception('No default style found for this workbook'); + } - // then update cellXf indexes for cells - foreach ($this->_workSheetCollection as $worksheet) { - foreach ($worksheet->getCellCollection(false) as $cellID) { - $cell = $worksheet->getCell($cellID); - $xfIndex = $cell->getXfIndex(); - if ($xfIndex > $pIndex ) { - // decrease xf index by 1 - $cell->setXfIndex($xfIndex - 1); - } else if ($xfIndex == $pIndex) { - // set to default xf index 0 - $cell->setXfIndex(0); - } - } - } - } - } + /** + * Add a cellXf to the workbook + * + * @param PHPExcel_Style $style + */ + public function addCellXf(PHPExcel_Style $style) + { + $this->_cellXfCollection[] = $style; + $style->setIndex(count($this->_cellXfCollection) - 1); + } - /** - * Get the cellXf supervisor - * - * @return PHPExcel_Style - */ - public function getCellXfSupervisor() - { - return $this->_cellXfSupervisor; - } + /** + * Remove cellXf by index. It is ensured that all cells get their xf index updated. + * + * @param int $pIndex Index to cellXf + * @throws PHPExcel_Exception + */ + public function removeCellXfByIndex($pIndex = 0) + { + if ($pIndex > count($this->_cellXfCollection) - 1) { + throw new PHPExcel_Exception("CellXf index is out of bounds."); + } else { + // first remove the cellXf + array_splice($this->_cellXfCollection, $pIndex, 1); - /** - * Get the workbook collection of cellStyleXfs - * - * @return PHPExcel_Style[] - */ - public function getCellStyleXfCollection() - { - return $this->_cellStyleXfCollection; - } + // then update cellXf indexes for cells + foreach ($this->_workSheetCollection as $worksheet) { + foreach ($worksheet->getCellCollection(false) as $cellID) { + $cell = $worksheet->getCell($cellID); + $xfIndex = $cell->getXfIndex(); + if ($xfIndex > $pIndex ) { + // decrease xf index by 1 + $cell->setXfIndex($xfIndex - 1); + } else if ($xfIndex == $pIndex) { + // set to default xf index 0 + $cell->setXfIndex(0); + } + } + } + } + } - /** - * Get cellStyleXf by index - * - * @param int $pIndex - * @return PHPExcel_Style - */ - public function getCellStyleXfByIndex($pIndex = 0) - { - return $this->_cellStyleXfCollection[$pIndex]; - } + /** + * Get the cellXf supervisor + * + * @return PHPExcel_Style + */ + public function getCellXfSupervisor() + { + return $this->_cellXfSupervisor; + } - /** - * Get cellStyleXf by hash code - * - * @param string $pValue - * @return PHPExcel_Style|false - */ - public function getCellStyleXfByHashCode($pValue = '') - { - foreach ($this->_cellXfStyleCollection as $cellStyleXf) { - if ($cellStyleXf->getHashCode() == $pValue) { - return $cellStyleXf; - } - } - return false; - } + /** + * Get the workbook collection of cellStyleXfs + * + * @return PHPExcel_Style[] + */ + public function getCellStyleXfCollection() + { + return $this->_cellStyleXfCollection; + } - /** - * Add a cellStyleXf to the workbook - * - * @param PHPExcel_Style $pStyle - */ - public function addCellStyleXf(PHPExcel_Style $pStyle) - { - $this->_cellStyleXfCollection[] = $pStyle; - $pStyle->setIndex(count($this->_cellStyleXfCollection) - 1); - } + /** + * Get cellStyleXf by index + * + * @param int $pIndex + * @return PHPExcel_Style + */ + public function getCellStyleXfByIndex($pIndex = 0) + { + return $this->_cellStyleXfCollection[$pIndex]; + } - /** - * Remove cellStyleXf by index - * - * @param int $pIndex - * @throws Exception - */ - public function removeCellStyleXfByIndex($pIndex = 0) - { - if ($pIndex > count($this->_cellStyleXfCollection) - 1) { - throw new Exception("CellStyleXf index is out of bounds."); - } else { - array_splice($this->_cellStyleXfCollection, $pIndex, 1); - } - } + /** + * Get cellStyleXf by hash code + * + * @param string $pValue + * @return PHPExcel_Style|false + */ + public function getCellStyleXfByHashCode($pValue = '') + { + foreach ($this->_cellXfStyleCollection as $cellStyleXf) { + if ($cellStyleXf->getHashCode() == $pValue) { + return $cellStyleXf; + } + } + return false; + } - /** - * Eliminate all unneeded cellXf and afterwards update the xfIndex for all cells - * and columns in the workbook - */ - public function garbageCollect() - { - // how many references are there to each cellXf ? - $countReferencesCellXf = array(); - foreach ($this->_cellXfCollection as $index => $cellXf) { - $countReferencesCellXf[$index] = 0; - } + /** + * Add a cellStyleXf to the workbook + * + * @param PHPExcel_Style $pStyle + */ + public function addCellStyleXf(PHPExcel_Style $pStyle) + { + $this->_cellStyleXfCollection[] = $pStyle; + $pStyle->setIndex(count($this->_cellStyleXfCollection) - 1); + } - foreach ($this->getWorksheetIterator() as $sheet) { + /** + * Remove cellStyleXf by index + * + * @param int $pIndex + * @throws PHPExcel_Exception + */ + public function removeCellStyleXfByIndex($pIndex = 0) + { + if ($pIndex > count($this->_cellStyleXfCollection) - 1) { + throw new PHPExcel_Exception("CellStyleXf index is out of bounds."); + } else { + array_splice($this->_cellStyleXfCollection, $pIndex, 1); + } + } - // from cells - foreach ($sheet->getCellCollection(false) as $cellID) { - $cell = $sheet->getCell($cellID); - ++$countReferencesCellXf[$cell->getXfIndex()]; - } + /** + * Eliminate all unneeded cellXf and afterwards update the xfIndex for all cells + * and columns in the workbook + */ + public function garbageCollect() + { + // how many references are there to each cellXf ? + $countReferencesCellXf = array(); + foreach ($this->_cellXfCollection as $index => $cellXf) { + $countReferencesCellXf[$index] = 0; + } - // from row dimensions - foreach ($sheet->getRowDimensions() as $rowDimension) { - if ($rowDimension->getXfIndex() !== null) { - ++$countReferencesCellXf[$rowDimension->getXfIndex()]; - } - } + foreach ($this->getWorksheetIterator() as $sheet) { - // from column dimensions - foreach ($sheet->getColumnDimensions() as $columnDimension) { - ++$countReferencesCellXf[$columnDimension->getXfIndex()]; - } - } + // from cells + foreach ($sheet->getCellCollection(false) as $cellID) { + $cell = $sheet->getCell($cellID); + ++$countReferencesCellXf[$cell->getXfIndex()]; + } - // remove cellXfs without references and create mapping so we can update xfIndex - // for all cells and columns - $countNeededCellXfs = 0; - foreach ($this->_cellXfCollection as $index => $cellXf) { - if ($countReferencesCellXf[$index] > 0 || $index == 0) { // we must never remove the first cellXf - ++$countNeededCellXfs; - } else { - unset($this->_cellXfCollection[$index]); - } - $map[$index] = $countNeededCellXfs - 1; - } - $this->_cellXfCollection = array_values($this->_cellXfCollection); + // from row dimensions + foreach ($sheet->getRowDimensions() as $rowDimension) { + if ($rowDimension->getXfIndex() !== null) { + ++$countReferencesCellXf[$rowDimension->getXfIndex()]; + } + } - // update the index for all cellXfs - foreach ($this->_cellXfCollection as $i => $cellXf) { - $cellXf->setIndex($i); - } + // from column dimensions + foreach ($sheet->getColumnDimensions() as $columnDimension) { + ++$countReferencesCellXf[$columnDimension->getXfIndex()]; + } + } - // make sure there is always at least one cellXf (there should be) - if (empty($this->_cellXfCollection)) { - $this->_cellXfCollection[] = new PHPExcel_Style(); - } + // remove cellXfs without references and create mapping so we can update xfIndex + // for all cells and columns + $countNeededCellXfs = 0; + foreach ($this->_cellXfCollection as $index => $cellXf) { + if ($countReferencesCellXf[$index] > 0 || $index == 0) { // we must never remove the first cellXf + ++$countNeededCellXfs; + } else { + unset($this->_cellXfCollection[$index]); + } + $map[$index] = $countNeededCellXfs - 1; + } + $this->_cellXfCollection = array_values($this->_cellXfCollection); - // update the xfIndex for all cells, row dimensions, column dimensions - foreach ($this->getWorksheetIterator() as $sheet) { + // update the index for all cellXfs + foreach ($this->_cellXfCollection as $i => $cellXf) { + $cellXf->setIndex($i); + } - // for all cells - foreach ($sheet->getCellCollection(false) as $cellID) { - $cell = $sheet->getCell($cellID); - $cell->setXfIndex( $map[$cell->getXfIndex()] ); - } + // make sure there is always at least one cellXf (there should be) + if (empty($this->_cellXfCollection)) { + $this->_cellXfCollection[] = new PHPExcel_Style(); + } - // for all row dimensions - foreach ($sheet->getRowDimensions() as $rowDimension) { - if ($rowDimension->getXfIndex() !== null) { - $rowDimension->setXfIndex( $map[$rowDimension->getXfIndex()] ); - } - } + // update the xfIndex for all cells, row dimensions, column dimensions + foreach ($this->getWorksheetIterator() as $sheet) { - // for all column dimensions - foreach ($sheet->getColumnDimensions() as $columnDimension) { - $columnDimension->setXfIndex( $map[$columnDimension->getXfIndex()] ); - } - } + // for all cells + foreach ($sheet->getCellCollection(false) as $cellID) { + $cell = $sheet->getCell($cellID); + $cell->setXfIndex( $map[$cell->getXfIndex()] ); + } - // also do garbage collection for all the sheets - foreach ($this->getWorksheetIterator() as $sheet) { - $sheet->garbageCollect(); - } - } + // for all row dimensions + foreach ($sheet->getRowDimensions() as $rowDimension) { + if ($rowDimension->getXfIndex() !== null) { + $rowDimension->setXfIndex( $map[$rowDimension->getXfIndex()] ); + } + } + + // for all column dimensions + foreach ($sheet->getColumnDimensions() as $columnDimension) { + $columnDimension->setXfIndex( $map[$columnDimension->getXfIndex()] ); + } + + // also do garbage collection for all the sheets + $sheet->garbageCollect(); + } + } + + /** + * Return the unique ID value assigned to this spreadsheet workbook + * + * @return string + */ + public function getID() { + return $this->_uniqueID; + } } diff --git a/htdocs/includes/phpexcel/PHPExcel/Autoloader.php b/htdocs/includes/phpexcel/PHPExcel/Autoloader.php index 15193278b63..a36dfcc905e 100644 --- a/htdocs/includes/phpexcel/PHPExcel/Autoloader.php +++ b/htdocs/includes/phpexcel/PHPExcel/Autoloader.php @@ -2,7 +2,7 @@ /** * PHPExcel * - * Copyright (c) 2006 - 2012 PHPExcel + * Copyright (c) 2006 - 2014 PHPExcel * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,18 +20,18 @@ * * @category PHPExcel * @package PHPExcel - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version 1.7.8, 2012-10-12 + * @version 1.8.0, 2014-03-02 */ PHPExcel_Autoloader::Register(); -// As we always try to run the autoloader before anything else, we can use it to do a few -// simple checks and initialisations -PHPExcel_Shared_ZipStreamWrapper::register(); +// As we always try to run the autoloader before anything else, we can use it to do a few +// simple checks and initialisations +//PHPExcel_Shared_ZipStreamWrapper::register(); // check mbstring.func_overload if (ini_get('mbstring.func_overload') & 2) { - throw new Exception('Multibyte function overloading in PHP must be disabled for string functions (2).'); + throw new PHPExcel_Exception('Multibyte function overloading in PHP must be disabled for string functions (2).'); } PHPExcel_Shared_String::buildCharacterSets(); @@ -39,47 +39,47 @@ PHPExcel_Shared_String::buildCharacterSets(); /** * PHPExcel_Autoloader * - * @category PHPExcel - * @package PHPExcel - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @category PHPExcel + * @package PHPExcel + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) */ class PHPExcel_Autoloader { - /** - * Register the Autoloader with SPL - * - */ - public static function Register() { - if (function_exists('__autoload')) { - // Register any existing autoloader function with SPL, so we don't get any clashes - spl_autoload_register('__autoload'); - } - // Register ourselves with SPL - return spl_autoload_register(array('PHPExcel_Autoloader', 'Load')); - } // function Register() + /** + * Register the Autoloader with SPL + * + */ + public static function Register() { + if (function_exists('__autoload')) { + // Register any existing autoloader function with SPL, so we don't get any clashes + spl_autoload_register('__autoload'); + } + // Register ourselves with SPL + return spl_autoload_register(array('PHPExcel_Autoloader', 'Load')); + } // function Register() - /** - * Autoload a class identified by name - * - * @param string $pClassName Name of the object to load - */ - public static function Load($pClassName){ - if ((class_exists($pClassName,FALSE)) || (strpos($pClassName, 'PHPExcel') !== 0)) { - // Either already loaded, or not a PHPExcel class request - return FALSE; - } + /** + * Autoload a class identified by name + * + * @param string $pClassName Name of the object to load + */ + public static function Load($pClassName){ + if ((class_exists($pClassName,FALSE)) || (strpos($pClassName, 'PHPExcel') !== 0)) { + // Either already loaded, or not a PHPExcel class request + return FALSE; + } - $pClassFilePath = PHPEXCEL_ROOT . - str_replace('_',DIRECTORY_SEPARATOR,$pClassName) . - '.php'; + $pClassFilePath = PHPEXCEL_ROOT . + str_replace('_',DIRECTORY_SEPARATOR,$pClassName) . + '.php'; - if ((file_exists($pClassFilePath) === false) || (is_readable($pClassFilePath) === false)) { - // Can't load - return FALSE; - } + if ((file_exists($pClassFilePath) === FALSE) || (is_readable($pClassFilePath) === FALSE)) { + // Can't load + return FALSE; + } - require($pClassFilePath); - } // function Load() + require($pClassFilePath); + } // function Load() -} \ No newline at end of file +} diff --git a/htdocs/includes/phpexcel/PHPExcel/CachedObjectStorage/APC.php b/htdocs/includes/phpexcel/PHPExcel/CachedObjectStorage/APC.php index 9dab5581480..0fbf8874c5e 100644 --- a/htdocs/includes/phpexcel/PHPExcel/CachedObjectStorage/APC.php +++ b/htdocs/includes/phpexcel/PHPExcel/CachedObjectStorage/APC.php @@ -2,7 +2,7 @@ /** * PHPExcel * - * Copyright (c) 2006 - 2012 PHPExcel + * Copyright (c) 2006 - 2014 PHPExcel * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,9 +20,9 @@ * * @category PHPExcel * @package PHPExcel_CachedObjectStorage - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version 1.7.8, 2012-10-12 + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) + * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @version 1.8.0, 2014-03-02 */ @@ -31,250 +31,265 @@ * * @category PHPExcel * @package PHPExcel_CachedObjectStorage - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) */ class PHPExcel_CachedObjectStorage_APC extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache { - /** - * Prefix used to uniquely identify cache data for this worksheet - * - * @access private - * @var string - */ - private $_cachePrefix = null; + /** + * Prefix used to uniquely identify cache data for this worksheet + * + * @access private + * @var string + */ + private $_cachePrefix = null; - /** - * Cache timeout - * - * @access private - * @var integer - */ - private $_cacheTime = 600; + /** + * Cache timeout + * + * @access private + * @var integer + */ + private $_cacheTime = 600; /** * Store cell data in cache for the current cell object if it's "dirty", * and the 'nullify' the current cell object * - * @access private - * @return void - * @throws Exception + * @access private + * @return void + * @throws PHPExcel_Exception */ - private function _storeData() { - if ($this->_currentCellIsDirty) { - $this->_currentObject->detach(); + protected function _storeData() { + if ($this->_currentCellIsDirty && !empty($this->_currentObjectID)) { + $this->_currentObject->detach(); - if (!apc_store($this->_cachePrefix.$this->_currentObjectID.'.cache',serialize($this->_currentObject),$this->_cacheTime)) { - $this->__destruct(); - throw new Exception('Failed to store cell '.$this->_currentObjectID.' in APC'); - } - $this->_currentCellIsDirty = false; - } - $this->_currentObjectID = $this->_currentObject = null; - } // function _storeData() + if (!apc_store($this->_cachePrefix.$this->_currentObjectID.'.cache',serialize($this->_currentObject),$this->_cacheTime)) { + $this->__destruct(); + throw new PHPExcel_Exception('Failed to store cell '.$this->_currentObjectID.' in APC'); + } + $this->_currentCellIsDirty = false; + } + $this->_currentObjectID = $this->_currentObject = null; + } // function _storeData() /** * Add or Update a cell in cache identified by coordinate address * - * @access public - * @param string $pCoord Coordinate address of the cell to update - * @param PHPExcel_Cell $cell Cell to update - * @return void - * @throws Exception + * @access public + * @param string $pCoord Coordinate address of the cell to update + * @param PHPExcel_Cell $cell Cell to update + * @return void + * @throws PHPExcel_Exception */ - public function addCacheData($pCoord, PHPExcel_Cell $cell) { - if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) { - $this->_storeData(); - } - $this->_cellCache[$pCoord] = true; + public function addCacheData($pCoord, PHPExcel_Cell $cell) { + if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) { + $this->_storeData(); + } + $this->_cellCache[$pCoord] = true; - $this->_currentObjectID = $pCoord; - $this->_currentObject = $cell; - $this->_currentCellIsDirty = true; + $this->_currentObjectID = $pCoord; + $this->_currentObject = $cell; + $this->_currentCellIsDirty = true; - return $cell; - } // function addCacheData() + return $cell; + } // function addCacheData() - /** - * Is a value set in the current PHPExcel_CachedObjectStorage_ICache for an indexed cell? - * - * @access public - * @param string $pCoord Coordinate address of the cell to check - * @return void - * @return boolean - */ - public function isDataSet($pCoord) { - // Check if the requested entry is the current object, or exists in the cache - if (parent::isDataSet($pCoord)) { - if ($this->_currentObjectID == $pCoord) { - return true; - } - // Check if the requested entry still exists in apc - $success = apc_fetch($this->_cachePrefix.$pCoord.'.cache'); - if ($success === false) { - // Entry no longer exists in APC, so clear it from the cache array - parent::deleteCacheData($pCoord); - throw new Exception('Cell entry '.$pCoord.' no longer exists in APC'); - } - return true; - } - return false; - } // function isDataSet() + /** + * Is a value set in the current PHPExcel_CachedObjectStorage_ICache for an indexed cell? + * + * @access public + * @param string $pCoord Coordinate address of the cell to check + * @return void + * @return boolean + */ + public function isDataSet($pCoord) { + // Check if the requested entry is the current object, or exists in the cache + if (parent::isDataSet($pCoord)) { + if ($this->_currentObjectID == $pCoord) { + return true; + } + // Check if the requested entry still exists in apc + $success = apc_fetch($this->_cachePrefix.$pCoord.'.cache'); + if ($success === FALSE) { + // Entry no longer exists in APC, so clear it from the cache array + parent::deleteCacheData($pCoord); + throw new PHPExcel_Exception('Cell entry '.$pCoord.' no longer exists in APC cache'); + } + return true; + } + return false; + } // function isDataSet() /** * Get cell at a specific coordinate * - * @access public - * @param string $pCoord Coordinate of the cell - * @throws Exception - * @return PHPExcel_Cell Cell that was found, or null if not found + * @access public + * @param string $pCoord Coordinate of the cell + * @throws PHPExcel_Exception + * @return PHPExcel_Cell Cell that was found, or null if not found */ - public function getCacheData($pCoord) { - if ($pCoord === $this->_currentObjectID) { - return $this->_currentObject; - } - $this->_storeData(); + public function getCacheData($pCoord) { + if ($pCoord === $this->_currentObjectID) { + return $this->_currentObject; + } + $this->_storeData(); - // Check if the entry that has been requested actually exists - if (parent::isDataSet($pCoord)) { - $obj = apc_fetch($this->_cachePrefix.$pCoord.'.cache'); - if ($obj === false) { - // Entry no longer exists in APC, so clear it from the cache array - parent::deleteCacheData($pCoord); - throw new Exception('Cell entry '.$pCoord.' no longer exists in APC'); - } - } else { - // Return null if requested entry doesn't exist in cache - return null; + // Check if the entry that has been requested actually exists + if (parent::isDataSet($pCoord)) { + $obj = apc_fetch($this->_cachePrefix.$pCoord.'.cache'); + if ($obj === FALSE) { + // Entry no longer exists in APC, so clear it from the cache array + parent::deleteCacheData($pCoord); + throw new PHPExcel_Exception('Cell entry '.$pCoord.' no longer exists in APC cache'); + } + } else { + // Return null if requested entry doesn't exist in cache + return null; + } + + // Set current entry to the requested entry + $this->_currentObjectID = $pCoord; + $this->_currentObject = unserialize($obj); + // Re-attach this as the cell's parent + $this->_currentObject->attach($this); + + // Return requested entry + return $this->_currentObject; + } // function getCacheData() + + + /** + * Get a list of all cell addresses currently held in cache + * + * @return array of string + */ + public function getCellList() { + if ($this->_currentObjectID !== null) { + $this->_storeData(); } - // Set current entry to the requested entry - $this->_currentObjectID = $pCoord; - $this->_currentObject = unserialize($obj); - // Re-attach the parent worksheet - $this->_currentObject->attach($this->_parent); - - // Return requested entry - return $this->_currentObject; - } // function getCacheData() + return parent::getCellList(); + } /** * Delete a cell in cache identified by coordinate address * - * @access public - * @param string $pCoord Coordinate address of the cell to delete - * @throws Exception + * @access public + * @param string $pCoord Coordinate address of the cell to delete + * @throws PHPExcel_Exception */ - public function deleteCacheData($pCoord) { - // Delete the entry from APC - apc_delete($this->_cachePrefix.$pCoord.'.cache'); + public function deleteCacheData($pCoord) { + // Delete the entry from APC + apc_delete($this->_cachePrefix.$pCoord.'.cache'); - // Delete the entry from our cell address array - parent::deleteCacheData($pCoord); - } // function deleteCacheData() + // Delete the entry from our cell address array + parent::deleteCacheData($pCoord); + } // function deleteCacheData() - /** - * Clone the cell collection - * - * @access public - * @param PHPExcel_Worksheet $parent The new worksheet - * @return void - */ - public function copyCellCollection(PHPExcel_Worksheet $parent) { - parent::copyCellCollection($parent); - // Get a new id for the new file name - $baseUnique = $this->_getUniqueID(); - $newCachePrefix = substr(md5($baseUnique),0,8).'.'; - $cacheList = $this->getCellList(); - foreach($cacheList as $cellID) { - if ($cellID != $this->_currentObjectID) { - $obj = apc_fetch($this->_cachePrefix.$cellID.'.cache'); - if ($obj === false) { - // Entry no longer exists in APC, so clear it from the cache array - parent::deleteCacheData($cellID); - throw new Exception('Cell entry '.$cellID.' no longer exists in APC'); - } - if (!apc_store($newCachePrefix.$cellID.'.cache',$obj,$this->_cacheTime)) { - $this->__destruct(); - throw new Exception('Failed to store cell '.$cellID.' in APC'); - } - } - } - $this->_cachePrefix = $newCachePrefix; - } // function copyCellCollection() + /** + * Clone the cell collection + * + * @access public + * @param PHPExcel_Worksheet $parent The new worksheet + * @throws PHPExcel_Exception + * @return void + */ + public function copyCellCollection(PHPExcel_Worksheet $parent) { + parent::copyCellCollection($parent); + // Get a new id for the new file name + $baseUnique = $this->_getUniqueID(); + $newCachePrefix = substr(md5($baseUnique),0,8).'.'; + $cacheList = $this->getCellList(); + foreach($cacheList as $cellID) { + if ($cellID != $this->_currentObjectID) { + $obj = apc_fetch($this->_cachePrefix.$cellID.'.cache'); + if ($obj === FALSE) { + // Entry no longer exists in APC, so clear it from the cache array + parent::deleteCacheData($cellID); + throw new PHPExcel_Exception('Cell entry '.$cellID.' no longer exists in APC'); + } + if (!apc_store($newCachePrefix.$cellID.'.cache',$obj,$this->_cacheTime)) { + $this->__destruct(); + throw new PHPExcel_Exception('Failed to store cell '.$cellID.' in APC'); + } + } + } + $this->_cachePrefix = $newCachePrefix; + } // function copyCellCollection() - /** - * Clear the cell collection and disconnect from our parent - * - * @return void - */ - public function unsetWorksheetCells() { - if ($this->_currentObject !== NULL) { - $this->_currentObject->detach(); - $this->_currentObject = $this->_currentObjectID = null; - } + /** + * Clear the cell collection and disconnect from our parent + * + * @return void + */ + public function unsetWorksheetCells() { + if ($this->_currentObject !== NULL) { + $this->_currentObject->detach(); + $this->_currentObject = $this->_currentObjectID = null; + } - // Flush the APC cache - $this->__destruct(); + // Flush the APC cache + $this->__destruct(); - $this->_cellCache = array(); + $this->_cellCache = array(); - // detach ourself from the worksheet, so that it can then delete this object successfully - $this->_parent = null; - } // function unsetWorksheetCells() + // detach ourself from the worksheet, so that it can then delete this object successfully + $this->_parent = null; + } // function unsetWorksheetCells() - /** - * Initialise this new cell collection - * - * @param PHPExcel_Worksheet $parent The worksheet for this cell collection - * @param array of mixed $arguments Additional initialisation arguments - */ - public function __construct(PHPExcel_Worksheet $parent, $arguments) { - $cacheTime = (isset($arguments['cacheTime'])) ? $arguments['cacheTime'] : 600; + /** + * Initialise this new cell collection + * + * @param PHPExcel_Worksheet $parent The worksheet for this cell collection + * @param array of mixed $arguments Additional initialisation arguments + */ + public function __construct(PHPExcel_Worksheet $parent, $arguments) { + $cacheTime = (isset($arguments['cacheTime'])) ? $arguments['cacheTime'] : 600; - if ($this->_cachePrefix === NULL) { - $baseUnique = $this->_getUniqueID(); - $this->_cachePrefix = substr(md5($baseUnique),0,8).'.'; - $this->_cacheTime = $cacheTime; + if ($this->_cachePrefix === NULL) { + $baseUnique = $this->_getUniqueID(); + $this->_cachePrefix = substr(md5($baseUnique),0,8).'.'; + $this->_cacheTime = $cacheTime; - parent::__construct($parent); - } - } // function __construct() + parent::__construct($parent); + } + } // function __construct() - /** - * Destroy this cell collection - */ - public function __destruct() { - $cacheList = $this->getCellList(); - foreach($cacheList as $cellID) { - apc_delete($this->_cachePrefix.$cellID.'.cache'); - } - } // function __destruct() + /** + * Destroy this cell collection + */ + public function __destruct() { + $cacheList = $this->getCellList(); + foreach($cacheList as $cellID) { + apc_delete($this->_cachePrefix.$cellID.'.cache'); + } + } // function __destruct() - /** - * Identify whether the caching method is currently available - * Some methods are dependent on the availability of certain extensions being enabled in the PHP build - * - * @return boolean - */ - public static function cacheMethodIsAvailable() { - if (!function_exists('apc_store')) { - return false; - } - if (apc_sma_info() === false) { - return false; - } + /** + * Identify whether the caching method is currently available + * Some methods are dependent on the availability of certain extensions being enabled in the PHP build + * + * @return boolean + */ + public static function cacheMethodIsAvailable() { + if (!function_exists('apc_store')) { + return FALSE; + } + if (apc_sma_info() === FALSE) { + return FALSE; + } - return true; - } + return TRUE; + } } diff --git a/htdocs/includes/phpexcel/PHPExcel/CachedObjectStorage/CacheBase.php b/htdocs/includes/phpexcel/PHPExcel/CachedObjectStorage/CacheBase.php index d2eea08bb97..84a0416c3b6 100644 --- a/htdocs/includes/phpexcel/PHPExcel/CachedObjectStorage/CacheBase.php +++ b/htdocs/includes/phpexcel/PHPExcel/CachedObjectStorage/CacheBase.php @@ -2,7 +2,7 @@ /** * PHPExcel * - * Copyright (c) 2006 - 2012 PHPExcel + * Copyright (c) 2006 - 2014 PHPExcel * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,9 +20,9 @@ * * @category PHPExcel * @package PHPExcel_CachedObjectStorage - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version 1.7.8, 2012-10-12 + * @version 1.8.0, 2014-03-02 */ @@ -31,7 +31,7 @@ * * @category PHPExcel * @package PHPExcel_CachedObjectStorage - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) */ abstract class PHPExcel_CachedObjectStorage_CacheBase { @@ -86,6 +86,16 @@ abstract class PHPExcel_CachedObjectStorage_CacheBase { } // function __construct() + /** + * Return the parent worksheet for this cell collection + * + * @return PHPExcel_Worksheet + */ + public function getParent() + { + return $this->_parent; + } + /** * Is a value set in the current PHPExcel_CachedObjectStorage_ICache for an indexed cell? * @@ -101,12 +111,33 @@ abstract class PHPExcel_CachedObjectStorage_CacheBase { } // function isDataSet() + /** + * Move a cell object from one address to another + * + * @param string $fromAddress Current address of the cell to move + * @param string $toAddress Destination address of the cell to move + * @return boolean + */ + public function moveCell($fromAddress, $toAddress) { + if ($fromAddress === $this->_currentObjectID) { + $this->_currentObjectID = $toAddress; + } + $this->_currentCellIsDirty = true; + if (isset($this->_cellCache[$fromAddress])) { + $this->_cellCache[$toAddress] = &$this->_cellCache[$fromAddress]; + unset($this->_cellCache[$fromAddress]); + } + + return TRUE; + } // function moveCell() + + /** * Add or Update a cell in cache * * @param PHPExcel_Cell $cell Cell to update * @return void - * @throws Exception + * @throws PHPExcel_Exception */ public function updateCacheData(PHPExcel_Cell $cell) { return $this->addCacheData($cell->getCoordinate(),$cell); @@ -117,7 +148,7 @@ abstract class PHPExcel_CachedObjectStorage_CacheBase { * Delete a cell in cache identified by coordinate address * * @param string $pCoord Coordinate address of the cell to delete - * @throws Exception + * @throws PHPExcel_Exception */ public function deleteCacheData($pCoord) { if ($pCoord === $this->_currentObjectID) { @@ -151,7 +182,7 @@ abstract class PHPExcel_CachedObjectStorage_CacheBase { public function getSortedCellList() { $sortKeys = array(); foreach ($this->getCellList() as $coord) { - list($column,$row) = sscanf($coord,'%[A-Z]%d'); + sscanf($coord,'%[A-Z]%d', $column, $row); $sortKeys[sprintf('%09d%3s',$row,$column)] = $coord; } ksort($sortKeys); @@ -172,7 +203,7 @@ abstract class PHPExcel_CachedObjectStorage_CacheBase { $col = array('A' => '1A'); $row = array(1); foreach ($this->getCellList() as $coord) { - list($c,$r) = sscanf($coord,'%[A-Z]%d'); + sscanf($coord,'%[A-Z]%d', $c, $r); $row[$r] = $r; $col[$c] = strlen($c).$c; } @@ -188,26 +219,87 @@ abstract class PHPExcel_CachedObjectStorage_CacheBase { } + /** + * Return the cell address of the currently active cell object + * + * @return string + */ + public function getCurrentAddress() + { + return $this->_currentObjectID; + } + + /** + * Return the column address of the currently active cell object + * + * @return string + */ + public function getCurrentColumn() + { + sscanf($this->_currentObjectID, '%[A-Z]%d', $column, $row); + return $column; + } + + /** + * Return the row address of the currently active cell object + * + * @return string + */ + public function getCurrentRow() + { + sscanf($this->_currentObjectID, '%[A-Z]%d', $column, $row); + return $row; + } + /** * Get highest worksheet column * - * @return string Highest column name + * @param string $row Return the highest column for the specified row, + * or the highest column of any row if no row number is passed + * @return string Highest column name */ - public function getHighestColumn() + public function getHighestColumn($row = null) { - $colRow = $this->getHighestRowAndColumn(); - return $colRow['column']; - } + if ($row == null) { + $colRow = $this->getHighestRowAndColumn(); + return $colRow['column']; + } + + $columnList = array(1); + foreach ($this->getCellList() as $coord) { + sscanf($coord,'%[A-Z]%d', $c, $r); + if ($r != $row) { + continue; + } + $columnList[] = PHPExcel_Cell::columnIndexFromString($c); + } + return PHPExcel_Cell::stringFromColumnIndex(max($columnList) - 1); + } /** * Get highest worksheet row * - * @return int Highest row number + * @param string $column Return the highest row for the specified column, + * or the highest row of any column if no column letter is passed + * @return int Highest row number */ - public function getHighestRow() + public function getHighestRow($column = null) { - $colRow = $this->getHighestRowAndColumn(); - return $colRow['row']; + if ($column == null) { + $colRow = $this->getHighestRowAndColumn(); + return $colRow['row']; + } + + $rowList = array(0); + foreach ($this->getCellList() as $coord) { + sscanf($coord,'%[A-Z]%d', $c, $r); + if ($c != $column) { + continue; + } + $rowList[] = $r; + } + + return max($rowList); } @@ -232,9 +324,12 @@ abstract class PHPExcel_CachedObjectStorage_CacheBase { * @return void */ public function copyCellCollection(PHPExcel_Worksheet $parent) { + $this->_currentCellIsDirty; + $this->_storeData(); + $this->_parent = $parent; if (($this->_currentObject !== NULL) && (is_object($this->_currentObject))) { - $this->_currentObject->attach($parent); + $this->_currentObject->attach($this); } } // function copyCellCollection() diff --git a/htdocs/includes/phpexcel/PHPExcel/CachedObjectStorage/DiscISAM.php b/htdocs/includes/phpexcel/PHPExcel/CachedObjectStorage/DiscISAM.php index 805dc063ace..492abea8526 100644 --- a/htdocs/includes/phpexcel/PHPExcel/CachedObjectStorage/DiscISAM.php +++ b/htdocs/includes/phpexcel/PHPExcel/CachedObjectStorage/DiscISAM.php @@ -2,7 +2,7 @@ /** * PHPExcel * - * Copyright (c) 2006 - 2012 PHPExcel + * Copyright (c) 2006 - 2014 PHPExcel * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,9 +20,9 @@ * * @category PHPExcel * @package PHPExcel_CachedObjectStorage - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version 1.7.8, 2012-10-12 + * @version 1.8.0, 2014-03-02 */ @@ -31,7 +31,7 @@ * * @category PHPExcel * @package PHPExcel_CachedObjectStorage - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) */ class PHPExcel_CachedObjectStorage_DiscISAM extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache { @@ -40,14 +40,14 @@ class PHPExcel_CachedObjectStorage_DiscISAM extends PHPExcel_CachedObjectStorage * * @var string */ - private $_fileName = null; + private $_fileName = NULL; /** * File handle for this cache file * * @var resource */ - private $_fileHandle = null; + private $_fileHandle = NULL; /** * Directory/Folder where the cache file is located @@ -62,10 +62,10 @@ class PHPExcel_CachedObjectStorage_DiscISAM extends PHPExcel_CachedObjectStorage * and the 'nullify' the current cell object * * @return void - * @throws Exception + * @throws PHPExcel_Exception */ - private function _storeData() { - if ($this->_currentCellIsDirty) { + protected function _storeData() { + if ($this->_currentCellIsDirty && !empty($this->_currentObjectID)) { $this->_currentObject->detach(); fseek($this->_fileHandle,0,SEEK_END); @@ -86,7 +86,7 @@ class PHPExcel_CachedObjectStorage_DiscISAM extends PHPExcel_CachedObjectStorage * @param string $pCoord Coordinate address of the cell to update * @param PHPExcel_Cell $cell Cell to update * @return void - * @throws Exception + * @throws PHPExcel_Exception */ public function addCacheData($pCoord, PHPExcel_Cell $cell) { if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) { @@ -105,7 +105,7 @@ class PHPExcel_CachedObjectStorage_DiscISAM extends PHPExcel_CachedObjectStorage * Get cell at a specific coordinate * * @param string $pCoord Coordinate of the cell - * @throws Exception + * @throws PHPExcel_Exception * @return PHPExcel_Cell Cell that was found, or null if not found */ public function getCacheData($pCoord) { @@ -124,14 +124,28 @@ class PHPExcel_CachedObjectStorage_DiscISAM extends PHPExcel_CachedObjectStorage $this->_currentObjectID = $pCoord; fseek($this->_fileHandle,$this->_cellCache[$pCoord]['ptr']); $this->_currentObject = unserialize(fread($this->_fileHandle,$this->_cellCache[$pCoord]['sz'])); - // Re-attach the parent worksheet - $this->_currentObject->attach($this->_parent); + // Re-attach this as the cell's parent + $this->_currentObject->attach($this); // Return requested entry return $this->_currentObject; } // function getCacheData() + /** + * Get a list of all cell addresses currently held in cache + * + * @return array of string + */ + public function getCellList() { + if ($this->_currentObjectID !== null) { + $this->_storeData(); + } + + return parent::getCellList(); + } + + /** * Clone the cell collection * diff --git a/htdocs/includes/phpexcel/PHPExcel/CachedObjectStorage/ICache.php b/htdocs/includes/phpexcel/PHPExcel/CachedObjectStorage/ICache.php index 56f621a597b..c3f2c14d74b 100644 --- a/htdocs/includes/phpexcel/PHPExcel/CachedObjectStorage/ICache.php +++ b/htdocs/includes/phpexcel/PHPExcel/CachedObjectStorage/ICache.php @@ -2,7 +2,7 @@ /** * PHPExcel * - * Copyright (c) 2006 - 2012 PHPExcel + * Copyright (c) 2006 - 2014 PHPExcel * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,9 +20,9 @@ * * @category PHPExcel * @package PHPExcel_CachedObjectStorage - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version 1.7.8, 2012-10-12 + * @version 1.8.0, 2014-03-02 */ @@ -31,7 +31,7 @@ * * @category PHPExcel * @package PHPExcel_CachedObjectStorage - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) */ interface PHPExcel_CachedObjectStorage_ICache { @@ -41,7 +41,7 @@ interface PHPExcel_CachedObjectStorage_ICache * @param string $pCoord Coordinate address of the cell to update * @param PHPExcel_Cell $cell Cell to update * @return void - * @throws Exception + * @throws PHPExcel_Exception */ public function addCacheData($pCoord, PHPExcel_Cell $cell); @@ -50,7 +50,7 @@ interface PHPExcel_CachedObjectStorage_ICache * * @param PHPExcel_Cell $cell Cell to update * @return void - * @throws Exception + * @throws PHPExcel_Exception */ public function updateCacheData(PHPExcel_Cell $cell); @@ -59,7 +59,7 @@ interface PHPExcel_CachedObjectStorage_ICache * * @param string $pCoord Coordinate address of the cell to retrieve * @return PHPExcel_Cell Cell that was found, or null if not found - * @throws Exception + * @throws PHPExcel_Exception */ public function getCacheData($pCoord); @@ -67,7 +67,7 @@ interface PHPExcel_CachedObjectStorage_ICache * Delete a cell in cache identified by coordinate address * * @param string $pCoord Coordinate address of the cell to delete - * @throws Exception + * @throws PHPExcel_Exception */ public function deleteCacheData($pCoord); diff --git a/htdocs/includes/phpexcel/PHPExcel/CachedObjectStorage/Igbinary.php b/htdocs/includes/phpexcel/PHPExcel/CachedObjectStorage/Igbinary.php index fc2f1129917..c3056de1fb6 100644 --- a/htdocs/includes/phpexcel/PHPExcel/CachedObjectStorage/Igbinary.php +++ b/htdocs/includes/phpexcel/PHPExcel/CachedObjectStorage/Igbinary.php @@ -2,7 +2,7 @@ /** * PHPExcel * - * Copyright (c) 2006 - 2012 PHPExcel + * Copyright (c) 2006 - 2014 PHPExcel * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,9 +20,9 @@ * * @category PHPExcel * @package PHPExcel_CachedObjectStorage - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version 1.7.8, 2012-10-12 + * @version 1.8.0, 2014-03-02 */ @@ -31,7 +31,7 @@ * * @category PHPExcel * @package PHPExcel_CachedObjectStorage - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) */ class PHPExcel_CachedObjectStorage_Igbinary extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache { @@ -40,10 +40,10 @@ class PHPExcel_CachedObjectStorage_Igbinary extends PHPExcel_CachedObjectStorage * and the 'nullify' the current cell object * * @return void - * @throws Exception + * @throws PHPExcel_Exception */ - private function _storeData() { - if ($this->_currentCellIsDirty) { + protected function _storeData() { + if ($this->_currentCellIsDirty && !empty($this->_currentObjectID)) { $this->_currentObject->detach(); $this->_cellCache[$this->_currentObjectID] = igbinary_serialize($this->_currentObject); @@ -59,7 +59,7 @@ class PHPExcel_CachedObjectStorage_Igbinary extends PHPExcel_CachedObjectStorage * @param string $pCoord Coordinate address of the cell to update * @param PHPExcel_Cell $cell Cell to update * @return void - * @throws Exception + * @throws PHPExcel_Exception */ public function addCacheData($pCoord, PHPExcel_Cell $cell) { if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) { @@ -78,7 +78,7 @@ class PHPExcel_CachedObjectStorage_Igbinary extends PHPExcel_CachedObjectStorage * Get cell at a specific coordinate * * @param string $pCoord Coordinate of the cell - * @throws Exception + * @throws PHPExcel_Exception * @return PHPExcel_Cell Cell that was found, or null if not found */ public function getCacheData($pCoord) { @@ -96,14 +96,28 @@ class PHPExcel_CachedObjectStorage_Igbinary extends PHPExcel_CachedObjectStorage // Set current entry to the requested entry $this->_currentObjectID = $pCoord; $this->_currentObject = igbinary_unserialize($this->_cellCache[$pCoord]); - // Re-attach the parent worksheet - $this->_currentObject->attach($this->_parent); + // Re-attach this as the cell's parent + $this->_currentObject->attach($this); // Return requested entry return $this->_currentObject; } // function getCacheData() + /** + * Get a list of all cell addresses currently held in cache + * + * @return array of string + */ + public function getCellList() { + if ($this->_currentObjectID !== null) { + $this->_storeData(); + } + + return parent::getCellList(); + } + + /** * Clear the cell collection and disconnect from our parent * diff --git a/htdocs/includes/phpexcel/PHPExcel/CachedObjectStorage/Memcache.php b/htdocs/includes/phpexcel/PHPExcel/CachedObjectStorage/Memcache.php index 23d6957281f..9061a31a1d1 100644 --- a/htdocs/includes/phpexcel/PHPExcel/CachedObjectStorage/Memcache.php +++ b/htdocs/includes/phpexcel/PHPExcel/CachedObjectStorage/Memcache.php @@ -2,7 +2,7 @@ /** * PHPExcel * - * Copyright (c) 2006 - 2012 PHPExcel + * Copyright (c) 2006 - 2014 PHPExcel * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,9 +20,9 @@ * * @category PHPExcel * @package PHPExcel_CachedObjectStorage - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version 1.7.8, 2012-10-12 + * @version 1.8.0, 2014-03-02 */ @@ -31,7 +31,7 @@ * * @category PHPExcel * @package PHPExcel_CachedObjectStorage - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) */ class PHPExcel_CachedObjectStorage_Memcache extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache { @@ -62,17 +62,17 @@ class PHPExcel_CachedObjectStorage_Memcache extends PHPExcel_CachedObjectStorage * and the 'nullify' the current cell object * * @return void - * @throws Exception + * @throws PHPExcel_Exception */ - private function _storeData() { - if ($this->_currentCellIsDirty) { + protected function _storeData() { + if ($this->_currentCellIsDirty && !empty($this->_currentObjectID)) { $this->_currentObject->detach(); $obj = serialize($this->_currentObject); if (!$this->_memcache->replace($this->_cachePrefix.$this->_currentObjectID.'.cache',$obj,NULL,$this->_cacheTime)) { if (!$this->_memcache->add($this->_cachePrefix.$this->_currentObjectID.'.cache',$obj,NULL,$this->_cacheTime)) { $this->__destruct(); - throw new Exception('Failed to store cell '.$this->_currentObjectID.' in MemCache'); + throw new PHPExcel_Exception('Failed to store cell '.$this->_currentObjectID.' in MemCache'); } } $this->_currentCellIsDirty = false; @@ -87,7 +87,7 @@ class PHPExcel_CachedObjectStorage_Memcache extends PHPExcel_CachedObjectStorage * @param string $pCoord Coordinate address of the cell to update * @param PHPExcel_Cell $cell Cell to update * @return void - * @throws Exception + * @throws PHPExcel_Exception */ public function addCacheData($pCoord, PHPExcel_Cell $cell) { if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) { @@ -121,7 +121,7 @@ class PHPExcel_CachedObjectStorage_Memcache extends PHPExcel_CachedObjectStorage if ($success === false) { // Entry no longer exists in Memcache, so clear it from the cache array parent::deleteCacheData($pCoord); - throw new Exception('Cell entry '.$pCoord.' no longer exists in MemCache'); + throw new PHPExcel_Exception('Cell entry '.$pCoord.' no longer exists in MemCache'); } return true; } @@ -133,7 +133,7 @@ class PHPExcel_CachedObjectStorage_Memcache extends PHPExcel_CachedObjectStorage * Get cell at a specific coordinate * * @param string $pCoord Coordinate of the cell - * @throws Exception + * @throws PHPExcel_Exception * @return PHPExcel_Cell Cell that was found, or null if not found */ public function getCacheData($pCoord) { @@ -148,7 +148,7 @@ class PHPExcel_CachedObjectStorage_Memcache extends PHPExcel_CachedObjectStorage if ($obj === false) { // Entry no longer exists in Memcache, so clear it from the cache array parent::deleteCacheData($pCoord); - throw new Exception('Cell entry '.$pCoord.' no longer exists in MemCache'); + throw new PHPExcel_Exception('Cell entry '.$pCoord.' no longer exists in MemCache'); } } else { // Return null if requested entry doesn't exist in cache @@ -158,19 +158,33 @@ class PHPExcel_CachedObjectStorage_Memcache extends PHPExcel_CachedObjectStorage // Set current entry to the requested entry $this->_currentObjectID = $pCoord; $this->_currentObject = unserialize($obj); - // Re-attach the parent worksheet - $this->_currentObject->attach($this->_parent); + // Re-attach this as the cell's parent + $this->_currentObject->attach($this); // Return requested entry return $this->_currentObject; } // function getCacheData() + /** + * Get a list of all cell addresses currently held in cache + * + * @return array of string + */ + public function getCellList() { + if ($this->_currentObjectID !== null) { + $this->_storeData(); + } + + return parent::getCellList(); + } + + /** * Delete a cell in cache identified by coordinate address * * @param string $pCoord Coordinate address of the cell to delete - * @throws Exception + * @throws PHPExcel_Exception */ public function deleteCacheData($pCoord) { // Delete the entry from Memcache @@ -199,11 +213,11 @@ class PHPExcel_CachedObjectStorage_Memcache extends PHPExcel_CachedObjectStorage if ($obj === false) { // Entry no longer exists in Memcache, so clear it from the cache array parent::deleteCacheData($cellID); - throw new Exception('Cell entry '.$cellID.' no longer exists in MemCache'); + throw new PHPExcel_Exception('Cell entry '.$cellID.' no longer exists in MemCache'); } if (!$this->_memcache->add($newCachePrefix.$cellID.'.cache',$obj,NULL,$this->_cacheTime)) { $this->__destruct(); - throw new Exception('Failed to store cell '.$cellID.' in MemCache'); + throw new PHPExcel_Exception('Failed to store cell '.$cellID.' in MemCache'); } } } @@ -250,7 +264,7 @@ class PHPExcel_CachedObjectStorage_Memcache extends PHPExcel_CachedObjectStorage // Set a new Memcache object and connect to the Memcache server $this->_memcache = new Memcache(); if (!$this->_memcache->addServer($memcacheServer, $memcachePort, false, 50, 5, 5, true, array($this, 'failureCallback'))) { - throw new Exception('Could not connect to MemCache server at '.$memcacheServer.':'.$memcachePort); + throw new PHPExcel_Exception('Could not connect to MemCache server at '.$memcacheServer.':'.$memcachePort); } $this->_cacheTime = $cacheTime; @@ -264,10 +278,10 @@ class PHPExcel_CachedObjectStorage_Memcache extends PHPExcel_CachedObjectStorage * * @param string $host Memcache server * @param integer $port Memcache port - * @throws Exception + * @throws PHPExcel_Exception */ public function failureCallback($host, $port) { - throw new Exception('memcache '.$host.':'.$port.' failed'); + throw new PHPExcel_Exception('memcache '.$host.':'.$port.' failed'); } diff --git a/htdocs/includes/phpexcel/PHPExcel/CachedObjectStorage/Memory.php b/htdocs/includes/phpexcel/PHPExcel/CachedObjectStorage/Memory.php index 36f42fb6ccf..20cd59f64a3 100644 --- a/htdocs/includes/phpexcel/PHPExcel/CachedObjectStorage/Memory.php +++ b/htdocs/includes/phpexcel/PHPExcel/CachedObjectStorage/Memory.php @@ -2,7 +2,7 @@ /** * PHPExcel * - * Copyright (c) 2006 - 2012 PHPExcel + * Copyright (c) 2006 - 2014 PHPExcel * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,9 +20,9 @@ * * @category PHPExcel * @package PHPExcel_CachedObjectStorage - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version 1.7.8, 2012-10-12 + * @version 1.8.0, 2014-03-02 */ @@ -31,20 +31,32 @@ * * @category PHPExcel * @package PHPExcel_CachedObjectStorage - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) */ class PHPExcel_CachedObjectStorage_Memory extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache { + /** + * Dummy method callable from CacheBase, but unused by Memory cache + * + * @return void + */ + protected function _storeData() { + } // function _storeData() + /** * Add or Update a cell in cache identified by coordinate address * * @param string $pCoord Coordinate address of the cell to update * @param PHPExcel_Cell $cell Cell to update - * @return void - * @throws Exception + * @return PHPExcel_Cell + * @throws PHPExcel_Exception */ public function addCacheData($pCoord, PHPExcel_Cell $cell) { $this->_cellCache[$pCoord] = $cell; + + // Set current entry to the new/updated entry + $this->_currentObjectID = $pCoord; + return $cell; } // function addCacheData() @@ -53,16 +65,20 @@ class PHPExcel_CachedObjectStorage_Memory extends PHPExcel_CachedObjectStorage_C * Get cell at a specific coordinate * * @param string $pCoord Coordinate of the cell - * @throws Exception + * @throws PHPExcel_Exception * @return PHPExcel_Cell Cell that was found, or null if not found */ public function getCacheData($pCoord) { // Check if the entry that has been requested actually exists if (!isset($this->_cellCache[$pCoord])) { + $this->_currentObjectID = NULL; // Return null if requested entry doesn't exist in cache return null; } + // Set current entry to the requested entry + $this->_currentObjectID = $pCoord; + // Return requested entry return $this->_cellCache[$pCoord]; } // function getCacheData() @@ -80,7 +96,7 @@ class PHPExcel_CachedObjectStorage_Memory extends PHPExcel_CachedObjectStorage_C $newCollection = array(); foreach($this->_cellCache as $k => &$cell) { $newCollection[$k] = clone $cell; - $newCollection[$k]->attach($parent); + $newCollection[$k]->attach($this); } $this->_cellCache = $newCollection; diff --git a/htdocs/includes/phpexcel/PHPExcel/CachedObjectStorage/MemoryGZip.php b/htdocs/includes/phpexcel/PHPExcel/CachedObjectStorage/MemoryGZip.php index ee8e95eb2b5..692c1bfcb6a 100644 --- a/htdocs/includes/phpexcel/PHPExcel/CachedObjectStorage/MemoryGZip.php +++ b/htdocs/includes/phpexcel/PHPExcel/CachedObjectStorage/MemoryGZip.php @@ -2,7 +2,7 @@ /** * PHPExcel * - * Copyright (c) 2006 - 2012 PHPExcel + * Copyright (c) 2006 - 2014 PHPExcel * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,9 +20,9 @@ * * @category PHPExcel * @package PHPExcel_CachedObjectStorage - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version 1.7.8, 2012-10-12 + * @version 1.8.0, 2014-03-02 */ @@ -31,7 +31,7 @@ * * @category PHPExcel * @package PHPExcel_CachedObjectStorage - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) */ class PHPExcel_CachedObjectStorage_MemoryGZip extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache { @@ -40,10 +40,10 @@ class PHPExcel_CachedObjectStorage_MemoryGZip extends PHPExcel_CachedObjectStora * and the 'nullify' the current cell object * * @return void - * @throws Exception + * @throws PHPExcel_Exception */ - private function _storeData() { - if ($this->_currentCellIsDirty) { + protected function _storeData() { + if ($this->_currentCellIsDirty && !empty($this->_currentObjectID)) { $this->_currentObject->detach(); $this->_cellCache[$this->_currentObjectID] = gzdeflate(serialize($this->_currentObject)); @@ -59,7 +59,7 @@ class PHPExcel_CachedObjectStorage_MemoryGZip extends PHPExcel_CachedObjectStora * @param string $pCoord Coordinate address of the cell to update * @param PHPExcel_Cell $cell Cell to update * @return void - * @throws Exception + * @throws PHPExcel_Exception */ public function addCacheData($pCoord, PHPExcel_Cell $cell) { if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) { @@ -78,7 +78,7 @@ class PHPExcel_CachedObjectStorage_MemoryGZip extends PHPExcel_CachedObjectStora * Get cell at a specific coordinate * * @param string $pCoord Coordinate of the cell - * @throws Exception + * @throws PHPExcel_Exception * @return PHPExcel_Cell Cell that was found, or null if not found */ public function getCacheData($pCoord) { @@ -96,14 +96,28 @@ class PHPExcel_CachedObjectStorage_MemoryGZip extends PHPExcel_CachedObjectStora // Set current entry to the requested entry $this->_currentObjectID = $pCoord; $this->_currentObject = unserialize(gzinflate($this->_cellCache[$pCoord])); - // Re-attach the parent worksheet - $this->_currentObject->attach($this->_parent); + // Re-attach this as the cell's parent + $this->_currentObject->attach($this); // Return requested entry return $this->_currentObject; } // function getCacheData() + /** + * Get a list of all cell addresses currently held in cache + * + * @return array of string + */ + public function getCellList() { + if ($this->_currentObjectID !== null) { + $this->_storeData(); + } + + return parent::getCellList(); + } + + /** * Clear the cell collection and disconnect from our parent * diff --git a/htdocs/includes/phpexcel/PHPExcel/CachedObjectStorage/MemorySerialized.php b/htdocs/includes/phpexcel/PHPExcel/CachedObjectStorage/MemorySerialized.php index d6b09b530e8..fdd021a8dd2 100644 --- a/htdocs/includes/phpexcel/PHPExcel/CachedObjectStorage/MemorySerialized.php +++ b/htdocs/includes/phpexcel/PHPExcel/CachedObjectStorage/MemorySerialized.php @@ -2,7 +2,7 @@ /** * PHPExcel * - * Copyright (c) 2006 - 2012 PHPExcel + * Copyright (c) 2006 - 2014 PHPExcel * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,9 +20,9 @@ * * @category PHPExcel * @package PHPExcel_CachedObjectStorage - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version 1.7.8, 2012-10-12 + * @version 1.8.0, 2014-03-02 */ @@ -31,7 +31,7 @@ * * @category PHPExcel * @package PHPExcel_CachedObjectStorage - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) */ class PHPExcel_CachedObjectStorage_MemorySerialized extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache { @@ -40,10 +40,10 @@ class PHPExcel_CachedObjectStorage_MemorySerialized extends PHPExcel_CachedObjec * and the 'nullify' the current cell object * * @return void - * @throws Exception + * @throws PHPExcel_Exception */ - private function _storeData() { - if ($this->_currentCellIsDirty) { + protected function _storeData() { + if ($this->_currentCellIsDirty && !empty($this->_currentObjectID)) { $this->_currentObject->detach(); $this->_cellCache[$this->_currentObjectID] = serialize($this->_currentObject); @@ -59,7 +59,7 @@ class PHPExcel_CachedObjectStorage_MemorySerialized extends PHPExcel_CachedObjec * @param string $pCoord Coordinate address of the cell to update * @param PHPExcel_Cell $cell Cell to update * @return void - * @throws Exception + * @throws PHPExcel_Exception */ public function addCacheData($pCoord, PHPExcel_Cell $cell) { if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) { @@ -78,7 +78,7 @@ class PHPExcel_CachedObjectStorage_MemorySerialized extends PHPExcel_CachedObjec * Get cell at a specific coordinate * * @param string $pCoord Coordinate of the cell - * @throws Exception + * @throws PHPExcel_Exception * @return PHPExcel_Cell Cell that was found, or null if not found */ public function getCacheData($pCoord) { @@ -96,14 +96,28 @@ class PHPExcel_CachedObjectStorage_MemorySerialized extends PHPExcel_CachedObjec // Set current entry to the requested entry $this->_currentObjectID = $pCoord; $this->_currentObject = unserialize($this->_cellCache[$pCoord]); - // Re-attach the parent worksheet - $this->_currentObject->attach($this->_parent); + // Re-attach this as the cell's parent + $this->_currentObject->attach($this); // Return requested entry return $this->_currentObject; } // function getCacheData() + /** + * Get a list of all cell addresses currently held in cache + * + * @return array of string + */ + public function getCellList() { + if ($this->_currentObjectID !== null) { + $this->_storeData(); + } + + return parent::getCellList(); + } + + /** * Clear the cell collection and disconnect from our parent * diff --git a/htdocs/includes/phpexcel/PHPExcel/CachedObjectStorage/PHPTemp.php b/htdocs/includes/phpexcel/PHPExcel/CachedObjectStorage/PHPTemp.php index 8dbbe92e8c2..b00c19bbb4a 100644 --- a/htdocs/includes/phpexcel/PHPExcel/CachedObjectStorage/PHPTemp.php +++ b/htdocs/includes/phpexcel/PHPExcel/CachedObjectStorage/PHPTemp.php @@ -2,7 +2,7 @@ /** * PHPExcel * - * Copyright (c) 2006 - 2012 PHPExcel + * Copyright (c) 2006 - 2014 PHPExcel * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,9 +20,9 @@ * * @category PHPExcel * @package PHPExcel_CachedObjectStorage - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version 1.7.8, 2012-10-12 + * @version 1.8.0, 2014-03-02 */ @@ -31,7 +31,7 @@ * * @category PHPExcel * @package PHPExcel_CachedObjectStorage - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) */ class PHPExcel_CachedObjectStorage_PHPTemp extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache { @@ -54,10 +54,10 @@ class PHPExcel_CachedObjectStorage_PHPTemp extends PHPExcel_CachedObjectStorage_ * and the 'nullify' the current cell object * * @return void - * @throws Exception + * @throws PHPExcel_Exception */ - private function _storeData() { - if ($this->_currentCellIsDirty) { + protected function _storeData() { + if ($this->_currentCellIsDirty && !empty($this->_currentObjectID)) { $this->_currentObject->detach(); fseek($this->_fileHandle,0,SEEK_END); @@ -78,7 +78,7 @@ class PHPExcel_CachedObjectStorage_PHPTemp extends PHPExcel_CachedObjectStorage_ * @param string $pCoord Coordinate address of the cell to update * @param PHPExcel_Cell $cell Cell to update * @return void - * @throws Exception + * @throws PHPExcel_Exception */ public function addCacheData($pCoord, PHPExcel_Cell $cell) { if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) { @@ -97,7 +97,7 @@ class PHPExcel_CachedObjectStorage_PHPTemp extends PHPExcel_CachedObjectStorage_ * Get cell at a specific coordinate * * @param string $pCoord Coordinate of the cell - * @throws Exception + * @throws PHPExcel_Exception * @return PHPExcel_Cell Cell that was found, or null if not found */ public function getCacheData($pCoord) { @@ -116,14 +116,28 @@ class PHPExcel_CachedObjectStorage_PHPTemp extends PHPExcel_CachedObjectStorage_ $this->_currentObjectID = $pCoord; fseek($this->_fileHandle,$this->_cellCache[$pCoord]['ptr']); $this->_currentObject = unserialize(fread($this->_fileHandle,$this->_cellCache[$pCoord]['sz'])); - // Re-attach the parent worksheet - $this->_currentObject->attach($this->_parent); + // Re-attach this as the cell's parent + $this->_currentObject->attach($this); // Return requested entry return $this->_currentObject; } // function getCacheData() + /** + * Get a list of all cell addresses currently held in cache + * + * @return array of string + */ + public function getCellList() { + if ($this->_currentObjectID !== null) { + $this->_storeData(); + } + + return parent::getCellList(); + } + + /** * Clone the cell collection * diff --git a/htdocs/includes/phpexcel/PHPExcel/CachedObjectStorage/SQLite.php b/htdocs/includes/phpexcel/PHPExcel/CachedObjectStorage/SQLite.php index e4bf469e0fc..75b99c68a66 100644 --- a/htdocs/includes/phpexcel/PHPExcel/CachedObjectStorage/SQLite.php +++ b/htdocs/includes/phpexcel/PHPExcel/CachedObjectStorage/SQLite.php @@ -2,7 +2,7 @@ /** * PHPExcel * - * Copyright (c) 2006 - 2012 PHPExcel + * Copyright (c) 2006 - 2014 PHPExcel * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,9 +20,9 @@ * * @category PHPExcel * @package PHPExcel_CachedObjectStorage - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version 1.7.8, 2012-10-12 + * @version 1.8.0, 2014-03-02 */ @@ -31,7 +31,7 @@ * * @category PHPExcel * @package PHPExcel_CachedObjectStorage - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) */ class PHPExcel_CachedObjectStorage_SQLite extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache { @@ -54,14 +54,14 @@ class PHPExcel_CachedObjectStorage_SQLite extends PHPExcel_CachedObjectStorage_C * and the 'nullify' the current cell object * * @return void - * @throws Exception + * @throws PHPExcel_Exception */ - private function _storeData() { - if ($this->_currentCellIsDirty) { + protected function _storeData() { + if ($this->_currentCellIsDirty && !empty($this->_currentObjectID)) { $this->_currentObject->detach(); if (!$this->_DBHandle->queryExec("INSERT OR REPLACE INTO kvp_".$this->_TableName." VALUES('".$this->_currentObjectID."','".sqlite_escape_string(serialize($this->_currentObject))."')")) - throw new Exception(sqlite_error_string($this->_DBHandle->lastError())); + throw new PHPExcel_Exception(sqlite_error_string($this->_DBHandle->lastError())); $this->_currentCellIsDirty = false; } $this->_currentObjectID = $this->_currentObject = null; @@ -74,7 +74,7 @@ class PHPExcel_CachedObjectStorage_SQLite extends PHPExcel_CachedObjectStorage_C * @param string $pCoord Coordinate address of the cell to update * @param PHPExcel_Cell $cell Cell to update * @return void - * @throws Exception + * @throws PHPExcel_Exception */ public function addCacheData($pCoord, PHPExcel_Cell $cell) { if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) { @@ -93,7 +93,7 @@ class PHPExcel_CachedObjectStorage_SQLite extends PHPExcel_CachedObjectStorage_C * Get cell at a specific coordinate * * @param string $pCoord Coordinate of the cell - * @throws Exception + * @throws PHPExcel_Exception * @return PHPExcel_Cell Cell that was found, or null if not found */ public function getCacheData($pCoord) { @@ -105,7 +105,7 @@ class PHPExcel_CachedObjectStorage_SQLite extends PHPExcel_CachedObjectStorage_C $query = "SELECT value FROM kvp_".$this->_TableName." WHERE id='".$pCoord."'"; $cellResultSet = $this->_DBHandle->query($query,SQLITE_ASSOC); if ($cellResultSet === false) { - throw new Exception(sqlite_error_string($this->_DBHandle->lastError())); + throw new PHPExcel_Exception(sqlite_error_string($this->_DBHandle->lastError())); } elseif ($cellResultSet->numRows() == 0) { // Return null if requested entry doesn't exist in cache return null; @@ -116,8 +116,8 @@ class PHPExcel_CachedObjectStorage_SQLite extends PHPExcel_CachedObjectStorage_C $cellResult = $cellResultSet->fetchSingle(); $this->_currentObject = unserialize($cellResult); - // Re-attach the parent worksheet - $this->_currentObject->attach($this->_parent); + // Re-attach this as the cell's parent + $this->_currentObject->attach($this); // Return requested entry return $this->_currentObject; @@ -139,7 +139,7 @@ class PHPExcel_CachedObjectStorage_SQLite extends PHPExcel_CachedObjectStorage_C $query = "SELECT id FROM kvp_".$this->_TableName." WHERE id='".$pCoord."'"; $cellResultSet = $this->_DBHandle->query($query,SQLITE_ASSOC); if ($cellResultSet === false) { - throw new Exception(sqlite_error_string($this->_DBHandle->lastError())); + throw new PHPExcel_Exception(sqlite_error_string($this->_DBHandle->lastError())); } elseif ($cellResultSet->numRows() == 0) { // Return null if requested entry doesn't exist in cache return false; @@ -152,7 +152,7 @@ class PHPExcel_CachedObjectStorage_SQLite extends PHPExcel_CachedObjectStorage_C * Delete a cell in cache identified by coordinate address * * @param string $pCoord Coordinate address of the cell to delete - * @throws Exception + * @throws PHPExcel_Exception */ public function deleteCacheData($pCoord) { if ($pCoord === $this->_currentObjectID) { @@ -163,22 +163,52 @@ class PHPExcel_CachedObjectStorage_SQLite extends PHPExcel_CachedObjectStorage_C // Check if the requested entry exists in the cache $query = "DELETE FROM kvp_".$this->_TableName." WHERE id='".$pCoord."'"; if (!$this->_DBHandle->queryExec($query)) - throw new Exception(sqlite_error_string($this->_DBHandle->lastError())); + throw new PHPExcel_Exception(sqlite_error_string($this->_DBHandle->lastError())); $this->_currentCellIsDirty = false; } // function deleteCacheData() + /** + * Move a cell object from one address to another + * + * @param string $fromAddress Current address of the cell to move + * @param string $toAddress Destination address of the cell to move + * @return boolean + */ + public function moveCell($fromAddress, $toAddress) { + if ($fromAddress === $this->_currentObjectID) { + $this->_currentObjectID = $toAddress; + } + + $query = "DELETE FROM kvp_".$this->_TableName." WHERE id='".$toAddress."'"; + $result = $this->_DBHandle->exec($query); + if ($result === false) + throw new PHPExcel_Exception($this->_DBHandle->lastErrorMsg()); + + $query = "UPDATE kvp_".$this->_TableName." SET id='".$toAddress."' WHERE id='".$fromAddress."'"; + $result = $this->_DBHandle->exec($query); + if ($result === false) + throw new PHPExcel_Exception($this->_DBHandle->lastErrorMsg()); + + return TRUE; + } // function moveCell() + + /** * Get a list of all cell addresses currently held in cache * * @return array of string */ public function getCellList() { + if ($this->_currentObjectID !== null) { + $this->_storeData(); + } + $query = "SELECT id FROM kvp_".$this->_TableName; $cellIdsResult = $this->_DBHandle->unbufferedQuery($query,SQLITE_ASSOC); if ($cellIdsResult === false) - throw new Exception(sqlite_error_string($this->_DBHandle->lastError())); + throw new PHPExcel_Exception(sqlite_error_string($this->_DBHandle->lastError())); $cellKeys = array(); foreach($cellIdsResult as $row) { @@ -196,11 +226,14 @@ class PHPExcel_CachedObjectStorage_SQLite extends PHPExcel_CachedObjectStorage_C * @return void */ public function copyCellCollection(PHPExcel_Worksheet $parent) { + $this->_currentCellIsDirty; + $this->_storeData(); + // Get a new id for the new table name $tableName = str_replace('.','_',$this->_getUniqueID()); if (!$this->_DBHandle->queryExec('CREATE TABLE kvp_'.$tableName.' (id VARCHAR(12) PRIMARY KEY, value BLOB) AS SELECT * FROM kvp_'.$this->_TableName)) - throw new Exception(sqlite_error_string($this->_DBHandle->lastError())); + throw new PHPExcel_Exception(sqlite_error_string($this->_DBHandle->lastError())); // Copy the existing cell cache file $this->_TableName = $tableName; @@ -238,9 +271,9 @@ class PHPExcel_CachedObjectStorage_SQLite extends PHPExcel_CachedObjectStorage_C $this->_DBHandle = new SQLiteDatabase($_DBName); if ($this->_DBHandle === false) - throw new Exception(sqlite_error_string($this->_DBHandle->lastError())); + throw new PHPExcel_Exception(sqlite_error_string($this->_DBHandle->lastError())); if (!$this->_DBHandle->queryExec('CREATE TABLE kvp_'.$this->_TableName.' (id VARCHAR(12) PRIMARY KEY, value BLOB)')) - throw new Exception(sqlite_error_string($this->_DBHandle->lastError())); + throw new PHPExcel_Exception(sqlite_error_string($this->_DBHandle->lastError())); } } // function __construct() @@ -249,6 +282,9 @@ class PHPExcel_CachedObjectStorage_SQLite extends PHPExcel_CachedObjectStorage_C * Destroy this cell collection */ public function __destruct() { + if (!is_null($this->_DBHandle)) { + $this->_DBHandle->queryExec('DROP TABLE kvp_'.$this->_TableName); + } $this->_DBHandle = null; } // function __destruct() diff --git a/htdocs/includes/phpexcel/PHPExcel/CachedObjectStorage/SQLite3.php b/htdocs/includes/phpexcel/PHPExcel/CachedObjectStorage/SQLite3.php index ead6e91f87f..bcfe159bda9 100644 --- a/htdocs/includes/phpexcel/PHPExcel/CachedObjectStorage/SQLite3.php +++ b/htdocs/includes/phpexcel/PHPExcel/CachedObjectStorage/SQLite3.php @@ -2,7 +2,7 @@ /** * PHPExcel * - * Copyright (c) 2006 - 2012 PHPExcel + * Copyright (c) 2006 - 2014 PHPExcel * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,9 +20,9 @@ * * @category PHPExcel * @package PHPExcel_CachedObjectStorage - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version 1.7.8, 2012-10-12 + * @version 1.8.0, 2014-03-02 */ @@ -31,7 +31,7 @@ * * @category PHPExcel * @package PHPExcel_CachedObjectStorage - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) */ class PHPExcel_CachedObjectStorage_SQLite3 extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache { @@ -49,23 +49,50 @@ class PHPExcel_CachedObjectStorage_SQLite3 extends PHPExcel_CachedObjectStorage_ */ private $_DBHandle = null; + /** + * Prepared statement for a SQLite3 select query + * + * @var SQLite3Stmt + */ + private $_selectQuery; + + /** + * Prepared statement for a SQLite3 insert query + * + * @var SQLite3Stmt + */ + private $_insertQuery; + + /** + * Prepared statement for a SQLite3 update query + * + * @var SQLite3Stmt + */ + private $_updateQuery; + + /** + * Prepared statement for a SQLite3 delete query + * + * @var SQLite3Stmt + */ + private $_deleteQuery; + /** * Store cell data in cache for the current cell object if it's "dirty", * and the 'nullify' the current cell object * * @return void - * @throws Exception + * @throws PHPExcel_Exception */ - private function _storeData() { - if ($this->_currentCellIsDirty) { + protected function _storeData() { + if ($this->_currentCellIsDirty && !empty($this->_currentObjectID)) { $this->_currentObject->detach(); - $query = $this->_DBHandle->prepare("INSERT OR REPLACE INTO kvp_".$this->_TableName." VALUES(:id,:data)"); - $query->bindValue('id',$this->_currentObjectID,SQLITE3_TEXT); - $query->bindValue('data',serialize($this->_currentObject),SQLITE3_BLOB); - $result = $query->execute(); + $this->_insertQuery->bindValue('id',$this->_currentObjectID,SQLITE3_TEXT); + $this->_insertQuery->bindValue('data',serialize($this->_currentObject),SQLITE3_BLOB); + $result = $this->_insertQuery->execute(); if ($result === false) - throw new Exception($this->_DBHandle->lastErrorMsg()); + throw new PHPExcel_Exception($this->_DBHandle->lastErrorMsg()); $this->_currentCellIsDirty = false; } $this->_currentObjectID = $this->_currentObject = null; @@ -78,7 +105,7 @@ class PHPExcel_CachedObjectStorage_SQLite3 extends PHPExcel_CachedObjectStorage_ * @param string $pCoord Coordinate address of the cell to update * @param PHPExcel_Cell $cell Cell to update * @return void - * @throws Exception + * @throws PHPExcel_Exception */ public function addCacheData($pCoord, PHPExcel_Cell $cell) { if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) { @@ -97,7 +124,7 @@ class PHPExcel_CachedObjectStorage_SQLite3 extends PHPExcel_CachedObjectStorage_ * Get cell at a specific coordinate * * @param string $pCoord Coordinate of the cell - * @throws Exception + * @throws PHPExcel_Exception * @return PHPExcel_Cell Cell that was found, or null if not found */ public function getCacheData($pCoord) { @@ -106,21 +133,23 @@ class PHPExcel_CachedObjectStorage_SQLite3 extends PHPExcel_CachedObjectStorage_ } $this->_storeData(); - $query = "SELECT value FROM kvp_".$this->_TableName." WHERE id='".$pCoord."'"; - $cellResult = $this->_DBHandle->querySingle($query); - if ($cellResult === false) { - throw new Exception($this->_DBHandle->lastErrorMsg()); - } elseif (is_null($cellResult)) { + $this->_selectQuery->bindValue('id',$pCoord,SQLITE3_TEXT); + $cellResult = $this->_selectQuery->execute(); + if ($cellResult === FALSE) { + throw new PHPExcel_Exception($this->_DBHandle->lastErrorMsg()); + } + $cellData = $cellResult->fetchArray(SQLITE3_ASSOC); + if ($cellData === FALSE) { // Return null if requested entry doesn't exist in cache - return null; + return NULL; } // Set current entry to the requested entry $this->_currentObjectID = $pCoord; - $this->_currentObject = unserialize($cellResult); - // Re-attach the parent worksheet - $this->_currentObject->attach($this->_parent); + $this->_currentObject = unserialize($cellData['value']); + // Re-attach this as the cell's parent + $this->_currentObject->attach($this); // Return requested entry return $this->_currentObject; @@ -135,19 +164,18 @@ class PHPExcel_CachedObjectStorage_SQLite3 extends PHPExcel_CachedObjectStorage_ */ public function isDataSet($pCoord) { if ($pCoord === $this->_currentObjectID) { - return true; + return TRUE; } // Check if the requested entry exists in the cache - $query = "SELECT id FROM kvp_".$this->_TableName." WHERE id='".$pCoord."'"; - $cellResult = $this->_DBHandle->querySingle($query); - if ($cellResult === false) { - throw new Exception($this->_DBHandle->lastErrorMsg()); - } elseif (is_null($cellResult)) { - // Return null if requested entry doesn't exist in cache - return false; + $this->_selectQuery->bindValue('id',$pCoord,SQLITE3_TEXT); + $cellResult = $this->_selectQuery->execute(); + if ($cellResult === FALSE) { + throw new PHPExcel_Exception($this->_DBHandle->lastErrorMsg()); } - return true; + $cellData = $cellResult->fetchArray(SQLITE3_ASSOC); + + return ($cellData === FALSE) ? FALSE : TRUE; } // function isDataSet() @@ -155,34 +183,65 @@ class PHPExcel_CachedObjectStorage_SQLite3 extends PHPExcel_CachedObjectStorage_ * Delete a cell in cache identified by coordinate address * * @param string $pCoord Coordinate address of the cell to delete - * @throws Exception + * @throws PHPExcel_Exception */ public function deleteCacheData($pCoord) { if ($pCoord === $this->_currentObjectID) { $this->_currentObject->detach(); - $this->_currentObjectID = $this->_currentObject = null; + $this->_currentObjectID = $this->_currentObject = NULL; } // Check if the requested entry exists in the cache - $query = "DELETE FROM kvp_".$this->_TableName." WHERE id='".$pCoord."'"; - $result = $this->_DBHandle->exec($query); - if ($result === false) - throw new Exception($this->_DBHandle->lastErrorMsg()); + $this->_deleteQuery->bindValue('id',$pCoord,SQLITE3_TEXT); + $result = $this->_deleteQuery->execute(); + if ($result === FALSE) + throw new PHPExcel_Exception($this->_DBHandle->lastErrorMsg()); - $this->_currentCellIsDirty = false; + $this->_currentCellIsDirty = FALSE; } // function deleteCacheData() + /** + * Move a cell object from one address to another + * + * @param string $fromAddress Current address of the cell to move + * @param string $toAddress Destination address of the cell to move + * @return boolean + */ + public function moveCell($fromAddress, $toAddress) { + if ($fromAddress === $this->_currentObjectID) { + $this->_currentObjectID = $toAddress; + } + + $this->_deleteQuery->bindValue('id',$toAddress,SQLITE3_TEXT); + $result = $this->_deleteQuery->execute(); + if ($result === false) + throw new PHPExcel_Exception($this->_DBHandle->lastErrorMsg()); + + $this->_updateQuery->bindValue('toid',$toAddress,SQLITE3_TEXT); + $this->_updateQuery->bindValue('fromid',$fromAddress,SQLITE3_TEXT); + $result = $this->_updateQuery->execute(); + if ($result === false) + throw new PHPExcel_Exception($this->_DBHandle->lastErrorMsg()); + + return TRUE; + } // function moveCell() + + /** * Get a list of all cell addresses currently held in cache * * @return array of string */ public function getCellList() { + if ($this->_currentObjectID !== null) { + $this->_storeData(); + } + $query = "SELECT id FROM kvp_".$this->_TableName; $cellIdsResult = $this->_DBHandle->query($query); if ($cellIdsResult === false) - throw new Exception($this->_DBHandle->lastErrorMsg()); + throw new PHPExcel_Exception($this->_DBHandle->lastErrorMsg()); $cellKeys = array(); while ($row = $cellIdsResult->fetchArray(SQLITE3_ASSOC)) { @@ -200,11 +259,14 @@ class PHPExcel_CachedObjectStorage_SQLite3 extends PHPExcel_CachedObjectStorage_ * @return void */ public function copyCellCollection(PHPExcel_Worksheet $parent) { + $this->_currentCellIsDirty; + $this->_storeData(); + // Get a new id for the new table name $tableName = str_replace('.','_',$this->_getUniqueID()); if (!$this->_DBHandle->exec('CREATE TABLE kvp_'.$tableName.' (id VARCHAR(12) PRIMARY KEY, value BLOB) AS SELECT * FROM kvp_'.$this->_TableName)) - throw new Exception($this->_DBHandle->lastErrorMsg()); + throw new PHPExcel_Exception($this->_DBHandle->lastErrorMsg()); // Copy the existing cell cache file $this->_TableName = $tableName; @@ -242,10 +304,15 @@ class PHPExcel_CachedObjectStorage_SQLite3 extends PHPExcel_CachedObjectStorage_ $this->_DBHandle = new SQLite3($_DBName); if ($this->_DBHandle === false) - throw new Exception($this->_DBHandle->lastErrorMsg()); + throw new PHPExcel_Exception($this->_DBHandle->lastErrorMsg()); if (!$this->_DBHandle->exec('CREATE TABLE kvp_'.$this->_TableName.' (id VARCHAR(12) PRIMARY KEY, value BLOB)')) - throw new Exception($this->_DBHandle->lastErrorMsg()); + throw new PHPExcel_Exception($this->_DBHandle->lastErrorMsg()); } + + $this->_selectQuery = $this->_DBHandle->prepare("SELECT value FROM kvp_".$this->_TableName." WHERE id = :id"); + $this->_insertQuery = $this->_DBHandle->prepare("INSERT OR REPLACE INTO kvp_".$this->_TableName." VALUES(:id,:data)"); + $this->_updateQuery = $this->_DBHandle->prepare("UPDATE kvp_".$this->_TableName." SET id=:toId WHERE id=:fromId"); + $this->_deleteQuery = $this->_DBHandle->prepare("DELETE FROM kvp_".$this->_TableName." WHERE id = :id"); } // function __construct() @@ -254,6 +321,7 @@ class PHPExcel_CachedObjectStorage_SQLite3 extends PHPExcel_CachedObjectStorage_ */ public function __destruct() { if (!is_null($this->_DBHandle)) { + $this->_DBHandle->exec('DROP TABLE kvp_'.$this->_TableName); $this->_DBHandle->close(); } $this->_DBHandle = null; diff --git a/htdocs/includes/phpexcel/PHPExcel/CachedObjectStorage/Wincache.php b/htdocs/includes/phpexcel/PHPExcel/CachedObjectStorage/Wincache.php index ba8b0458062..96dca6627fb 100644 --- a/htdocs/includes/phpexcel/PHPExcel/CachedObjectStorage/Wincache.php +++ b/htdocs/includes/phpexcel/PHPExcel/CachedObjectStorage/Wincache.php @@ -2,7 +2,7 @@ /** * PHPExcel * - * Copyright (c) 2006 - 2012 PHPExcel + * Copyright (c) 2006 - 2014 PHPExcel * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,9 +20,9 @@ * * @category PHPExcel * @package PHPExcel_CachedObjectStorage - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version 1.7.8, 2012-10-12 + * @version 1.8.0, 2014-03-02 */ @@ -31,7 +31,7 @@ * * @category PHPExcel * @package PHPExcel_CachedObjectStorage - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) */ class PHPExcel_CachedObjectStorage_Wincache extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache { @@ -55,22 +55,22 @@ class PHPExcel_CachedObjectStorage_Wincache extends PHPExcel_CachedObjectStorage * and the 'nullify' the current cell object * * @return void - * @throws Exception + * @throws PHPExcel_Exception */ - private function _storeData() { - if ($this->_currentCellIsDirty) { + protected function _storeData() { + if ($this->_currentCellIsDirty && !empty($this->_currentObjectID)) { $this->_currentObject->detach(); $obj = serialize($this->_currentObject); if (wincache_ucache_exists($this->_cachePrefix.$this->_currentObjectID.'.cache')) { if (!wincache_ucache_set($this->_cachePrefix.$this->_currentObjectID.'.cache', $obj, $this->_cacheTime)) { $this->__destruct(); - throw new Exception('Failed to store cell '.$this->_currentObjectID.' in WinCache'); + throw new PHPExcel_Exception('Failed to store cell '.$this->_currentObjectID.' in WinCache'); } } else { if (!wincache_ucache_add($this->_cachePrefix.$this->_currentObjectID.'.cache', $obj, $this->_cacheTime)) { $this->__destruct(); - throw new Exception('Failed to store cell '.$this->_currentObjectID.' in WinCache'); + throw new PHPExcel_Exception('Failed to store cell '.$this->_currentObjectID.' in WinCache'); } } $this->_currentCellIsDirty = false; @@ -86,7 +86,7 @@ class PHPExcel_CachedObjectStorage_Wincache extends PHPExcel_CachedObjectStorage * @param string $pCoord Coordinate address of the cell to update * @param PHPExcel_Cell $cell Cell to update * @return void - * @throws Exception + * @throws PHPExcel_Exception */ public function addCacheData($pCoord, PHPExcel_Cell $cell) { if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) { @@ -119,7 +119,7 @@ class PHPExcel_CachedObjectStorage_Wincache extends PHPExcel_CachedObjectStorage if ($success === false) { // Entry no longer exists in Wincache, so clear it from the cache array parent::deleteCacheData($pCoord); - throw new Exception('Cell entry '.$pCoord.' no longer exists in WinCache'); + throw new PHPExcel_Exception('Cell entry '.$pCoord.' no longer exists in WinCache'); } return true; } @@ -131,7 +131,7 @@ class PHPExcel_CachedObjectStorage_Wincache extends PHPExcel_CachedObjectStorage * Get cell at a specific coordinate * * @param string $pCoord Coordinate of the cell - * @throws Exception + * @throws PHPExcel_Exception * @return PHPExcel_Cell Cell that was found, or null if not found */ public function getCacheData($pCoord) { @@ -148,7 +148,7 @@ class PHPExcel_CachedObjectStorage_Wincache extends PHPExcel_CachedObjectStorage if ($success === false) { // Entry no longer exists in WinCache, so clear it from the cache array parent::deleteCacheData($pCoord); - throw new Exception('Cell entry '.$pCoord.' no longer exists in WinCache'); + throw new PHPExcel_Exception('Cell entry '.$pCoord.' no longer exists in WinCache'); } } else { // Return null if requested entry doesn't exist in cache @@ -158,19 +158,33 @@ class PHPExcel_CachedObjectStorage_Wincache extends PHPExcel_CachedObjectStorage // Set current entry to the requested entry $this->_currentObjectID = $pCoord; $this->_currentObject = unserialize($obj); - // Re-attach the parent worksheet - $this->_currentObject->attach($this->_parent); + // Re-attach this as the cell's parent + $this->_currentObject->attach($this); // Return requested entry return $this->_currentObject; } // function getCacheData() + /** + * Get a list of all cell addresses currently held in cache + * + * @return array of string + */ + public function getCellList() { + if ($this->_currentObjectID !== null) { + $this->_storeData(); + } + + return parent::getCellList(); + } + + /** * Delete a cell in cache identified by coordinate address * * @param string $pCoord Coordinate address of the cell to delete - * @throws Exception + * @throws PHPExcel_Exception */ public function deleteCacheData($pCoord) { // Delete the entry from Wincache @@ -200,11 +214,11 @@ class PHPExcel_CachedObjectStorage_Wincache extends PHPExcel_CachedObjectStorage if ($success === false) { // Entry no longer exists in WinCache, so clear it from the cache array parent::deleteCacheData($cellID); - throw new Exception('Cell entry '.$cellID.' no longer exists in Wincache'); + throw new PHPExcel_Exception('Cell entry '.$cellID.' no longer exists in Wincache'); } if (!wincache_ucache_add($newCachePrefix.$cellID.'.cache', $obj, $this->_cacheTime)) { $this->__destruct(); - throw new Exception('Failed to store cell '.$cellID.' in Wincache'); + throw new PHPExcel_Exception('Failed to store cell '.$cellID.' in Wincache'); } } } diff --git a/htdocs/includes/phpexcel/PHPExcel/CachedObjectStorageFactory.php b/htdocs/includes/phpexcel/PHPExcel/CachedObjectStorageFactory.php index 51019f7bdc5..6c3ec15cf2f 100644 --- a/htdocs/includes/phpexcel/PHPExcel/CachedObjectStorageFactory.php +++ b/htdocs/includes/phpexcel/PHPExcel/CachedObjectStorageFactory.php @@ -3,7 +3,7 @@ /** * PHPExcel * - * Copyright (c) 2006 - 2012 PHPExcel + * Copyright (c) 2006 - 2014 PHPExcel * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,220 +20,232 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * @category PHPExcel - * @package PHPExcel - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version 1.7.8, 2012-10-12 + * @package PHPExcel_CachedObjectStorage + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) + * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @version 1.8.0, 2014-03-02 */ /** * PHPExcel_CachedObjectStorageFactory * - * @category PHPExcel - * @package PHPExcel_CachedObjectStorage - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @category PHPExcel + * @package PHPExcel_CachedObjectStorage + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) */ class PHPExcel_CachedObjectStorageFactory { - const cache_in_memory = 'Memory'; - const cache_in_memory_gzip = 'MemoryGZip'; - const cache_in_memory_serialized = 'MemorySerialized'; - const cache_igbinary = 'Igbinary'; - const cache_to_discISAM = 'DiscISAM'; - const cache_to_apc = 'APC'; - const cache_to_memcache = 'Memcache'; - const cache_to_phpTemp = 'PHPTemp'; - const cache_to_wincache = 'Wincache'; - const cache_to_sqlite = 'SQLite'; - const cache_to_sqlite3 = 'SQLite3'; + const cache_in_memory = 'Memory'; + const cache_in_memory_gzip = 'MemoryGZip'; + const cache_in_memory_serialized = 'MemorySerialized'; + const cache_igbinary = 'Igbinary'; + const cache_to_discISAM = 'DiscISAM'; + const cache_to_apc = 'APC'; + const cache_to_memcache = 'Memcache'; + const cache_to_phpTemp = 'PHPTemp'; + const cache_to_wincache = 'Wincache'; + const cache_to_sqlite = 'SQLite'; + const cache_to_sqlite3 = 'SQLite3'; - /** - * Name of the method used for cell cacheing - * - * @var string - */ - private static $_cacheStorageMethod = NULL; + /** + * Name of the method used for cell cacheing + * + * @var string + */ + private static $_cacheStorageMethod = NULL; - /** - * Name of the class used for cell cacheing - * - * @var string - */ - private static $_cacheStorageClass = NULL; + /** + * Name of the class used for cell cacheing + * + * @var string + */ + private static $_cacheStorageClass = NULL; - /** - * List of all possible cache storage methods - * - * @var string[] - */ - private static $_storageMethods = array( - self::cache_in_memory, - self::cache_in_memory_gzip, - self::cache_in_memory_serialized, - self::cache_igbinary, - self::cache_to_phpTemp, - self::cache_to_discISAM, - self::cache_to_apc, - self::cache_to_memcache, - self::cache_to_wincache, - self::cache_to_sqlite, - self::cache_to_sqlite3, - ); + /** + * List of all possible cache storage methods + * + * @var string[] + */ + private static $_storageMethods = array( + self::cache_in_memory, + self::cache_in_memory_gzip, + self::cache_in_memory_serialized, + self::cache_igbinary, + self::cache_to_phpTemp, + self::cache_to_discISAM, + self::cache_to_apc, + self::cache_to_memcache, + self::cache_to_wincache, + self::cache_to_sqlite, + self::cache_to_sqlite3, + ); - /** - * Default arguments for each cache storage method - * - * @var array of mixed array - */ - private static $_storageMethodDefaultParameters = array( - self::cache_in_memory => array( - ), - self::cache_in_memory_gzip => array( - ), - self::cache_in_memory_serialized => array( - ), - self::cache_igbinary => array( - ), - self::cache_to_phpTemp => array( 'memoryCacheSize' => '1MB' - ), - self::cache_to_discISAM => array( 'dir' => NULL - ), - self::cache_to_apc => array( 'cacheTime' => 600 - ), - self::cache_to_memcache => array( 'memcacheServer' => 'localhost', - 'memcachePort' => 11211, - 'cacheTime' => 600 - ), - self::cache_to_wincache => array( 'cacheTime' => 600 - ), - self::cache_to_sqlite => array( - ), - self::cache_to_sqlite3 => array( - ), - ); + /** + * Default arguments for each cache storage method + * + * @var array of mixed array + */ + private static $_storageMethodDefaultParameters = array( + self::cache_in_memory => array( + ), + self::cache_in_memory_gzip => array( + ), + self::cache_in_memory_serialized => array( + ), + self::cache_igbinary => array( + ), + self::cache_to_phpTemp => array( 'memoryCacheSize' => '1MB' + ), + self::cache_to_discISAM => array( 'dir' => NULL + ), + self::cache_to_apc => array( 'cacheTime' => 600 + ), + self::cache_to_memcache => array( 'memcacheServer' => 'localhost', + 'memcachePort' => 11211, + 'cacheTime' => 600 + ), + self::cache_to_wincache => array( 'cacheTime' => 600 + ), + self::cache_to_sqlite => array( + ), + self::cache_to_sqlite3 => array( + ), + ); - /** - * Arguments for the active cache storage method - * - * @var array of mixed array - */ - private static $_storageMethodParameters = array(); + /** + * Arguments for the active cache storage method + * + * @var array of mixed array + */ + private static $_storageMethodParameters = array(); - /** - * Return the current cache storage method - * - * @return string|NULL - **/ - public static function getCacheStorageMethod() + /** + * Return the current cache storage method + * + * @return string|NULL + **/ + public static function getCacheStorageMethod() + { + return self::$_cacheStorageMethod; + } // function getCacheStorageMethod() + + + /** + * Return the current cache storage class + * + * @return PHPExcel_CachedObjectStorage_ICache|NULL + **/ + public static function getCacheStorageClass() + { + return self::$_cacheStorageClass; + } // function getCacheStorageClass() + + + /** + * Return the list of all possible cache storage methods + * + * @return string[] + **/ + public static function getAllCacheStorageMethods() + { + return self::$_storageMethods; + } // function getCacheStorageMethods() + + + /** + * Return the list of all available cache storage methods + * + * @return string[] + **/ + public static function getCacheStorageMethods() + { + $activeMethods = array(); + foreach(self::$_storageMethods as $storageMethod) { + $cacheStorageClass = 'PHPExcel_CachedObjectStorage_' . $storageMethod; + if (call_user_func(array($cacheStorageClass, 'cacheMethodIsAvailable'))) { + $activeMethods[] = $storageMethod; + } + } + return $activeMethods; + } // function getCacheStorageMethods() + + + /** + * Identify the cache storage method to use + * + * @param string $method Name of the method to use for cell cacheing + * @param array of mixed $arguments Additional arguments to pass to the cell caching class + * when instantiating + * @return boolean + **/ + public static function initialize($method = self::cache_in_memory, $arguments = array()) + { + if (!in_array($method,self::$_storageMethods)) { + return FALSE; + } + + $cacheStorageClass = 'PHPExcel_CachedObjectStorage_'.$method; + if (!call_user_func(array( $cacheStorageClass, + 'cacheMethodIsAvailable'))) { + return FALSE; + } + + self::$_storageMethodParameters[$method] = self::$_storageMethodDefaultParameters[$method]; + foreach($arguments as $k => $v) { + if (array_key_exists($k, self::$_storageMethodParameters[$method])) { + self::$_storageMethodParameters[$method][$k] = $v; + } + } + + if (self::$_cacheStorageMethod === NULL) { + self::$_cacheStorageClass = 'PHPExcel_CachedObjectStorage_' . $method; + self::$_cacheStorageMethod = $method; + } + return TRUE; + } // function initialize() + + + /** + * Initialise the cache storage + * + * @param PHPExcel_Worksheet $parent Enable cell caching for this worksheet + * @return PHPExcel_CachedObjectStorage_ICache + **/ + public static function getInstance(PHPExcel_Worksheet $parent) + { + $cacheMethodIsAvailable = TRUE; + if (self::$_cacheStorageMethod === NULL) { + $cacheMethodIsAvailable = self::initialize(); + } + + if ($cacheMethodIsAvailable) { + $instance = new self::$_cacheStorageClass( $parent, + self::$_storageMethodParameters[self::$_cacheStorageMethod] + ); + if ($instance !== NULL) { + return $instance; + } + } + + return FALSE; + } // function getInstance() + + + /** + * Clear the cache storage + * + **/ + public static function finalize() { - return self::$_cacheStorageMethod; - } // function getCacheStorageMethod() + self::$_cacheStorageMethod = NULL; + self::$_cacheStorageClass = NULL; + self::$_storageMethodParameters = array(); + } - - /** - * Return the current cache storage class - * - * @return PHPExcel_CachedObjectStorage_ICache|NULL - **/ - public static function getCacheStorageClass() - { - return self::$_cacheStorageClass; - } // function getCacheStorageClass() - - - /** - * Return the list of all possible cache storage methods - * - * @return string[] - **/ - public static function getAllCacheStorageMethods() - { - return self::$_storageMethods; - } // function getCacheStorageMethods() - - - /** - * Return the list of all available cache storage methods - * - * @return string[] - **/ - public static function getCacheStorageMethods() - { - $activeMethods = array(); - foreach(self::$_storageMethods as $storageMethod) { - $cacheStorageClass = 'PHPExcel_CachedObjectStorage_' . $storageMethod; - if (call_user_func(array($cacheStorageClass, 'cacheMethodIsAvailable'))) { - $activeMethods[] = $storageMethod; - } - } - return $activeMethods; - } // function getCacheStorageMethods() - - - /** - * Identify the cache storage method to use - * - * @param string $method Name of the method to use for cell cacheing - * @param array of mixed $arguments Additional arguments to pass to the cell caching class - * when instantiating - * @return boolean - **/ - public static function initialize($method = self::cache_in_memory, $arguments = array()) - { - if (!in_array($method,self::$_storageMethods)) { - return FALSE; - } - - $cacheStorageClass = 'PHPExcel_CachedObjectStorage_'.$method; - if (!call_user_func(array( $cacheStorageClass, - 'cacheMethodIsAvailable'))) { - return FALSE; - } - - self::$_storageMethodParameters[$method] = self::$_storageMethodDefaultParameters[$method]; - foreach($arguments as $k => $v) { - if (isset(self::$_storageMethodParameters[$method][$k])) { - self::$_storageMethodParameters[$method][$k] = $v; - } - } - - if (self::$_cacheStorageMethod === NULL) { - self::$_cacheStorageClass = 'PHPExcel_CachedObjectStorage_' . $method; - self::$_cacheStorageMethod = $method; - } - return TRUE; - } // function initialize() - - - /** - * Initialise the cache storage - * - * @param PHPExcel_Worksheet $parent Enable cell caching for this worksheet - * @return PHPExcel_CachedObjectStorage_ICache - **/ - public static function getInstance(PHPExcel_Worksheet $parent) - { - $cacheMethodIsAvailable = TRUE; - if (self::$_cacheStorageMethod === NULL) { - $cacheMethodIsAvailable = self::initialize(); - } - - if ($cacheMethodIsAvailable) { - $instance = new self::$_cacheStorageClass( $parent, - self::$_storageMethodParameters[self::$_cacheStorageMethod] - ); - if ($instance !== NULL) { - return $instance; - } - } - - return FALSE; - } // function getInstance() - -} \ No newline at end of file +} diff --git a/htdocs/includes/phpexcel/PHPExcel/CalcEngine/CyclicReferenceStack.php b/htdocs/includes/phpexcel/PHPExcel/CalcEngine/CyclicReferenceStack.php new file mode 100644 index 00000000000..02591935a4b --- /dev/null +++ b/htdocs/includes/phpexcel/PHPExcel/CalcEngine/CyclicReferenceStack.php @@ -0,0 +1,98 @@ +_stack); + } + + /** + * Push a new entry onto the stack + * + * @param mixed $value + */ + public function push($value) { + $this->_stack[] = $value; + } // function push() + + /** + * Pop the last entry from the stack + * + * @return mixed + */ + public function pop() { + return array_pop($this->_stack); + } // function pop() + + /** + * Test to see if a specified entry exists on the stack + * + * @param mixed $value The value to test + */ + public function onStack($value) { + return in_array($value, $this->_stack); + } + + /** + * Clear the stack + */ + public function clear() { + $this->_stack = array(); + } // function push() + + /** + * Return an array of all entries on the stack + * + * @return mixed[] + */ + public function showStack() { + return $this->_stack; + } + +} // class PHPExcel_CalcEngine_CyclicReferenceStack diff --git a/htdocs/includes/phpexcel/PHPExcel/CalcEngine/Logger.php b/htdocs/includes/phpexcel/PHPExcel/CalcEngine/Logger.php new file mode 100644 index 00000000000..2048df3e515 --- /dev/null +++ b/htdocs/includes/phpexcel/PHPExcel/CalcEngine/Logger.php @@ -0,0 +1,153 @@ +_cellStack = $stack; + } + + /** + * Enable/Disable Calculation engine logging + * + * @param boolean $pValue + */ + public function setWriteDebugLog($pValue = FALSE) { + $this->_writeDebugLog = $pValue; + } + + /** + * Return whether calculation engine logging is enabled or disabled + * + * @return boolean + */ + public function getWriteDebugLog() { + return $this->_writeDebugLog; + } + + /** + * Enable/Disable echoing of debug log information + * + * @param boolean $pValue + */ + public function setEchoDebugLog($pValue = FALSE) { + $this->_echoDebugLog = $pValue; + } + + /** + * Return whether echoing of debug log information is enabled or disabled + * + * @return boolean + */ + public function getEchoDebugLog() { + return $this->_echoDebugLog; + } + + /** + * Write an entry to the calculation engine debug log + */ + public function writeDebugLog() { + // Only write the debug log if logging is enabled + if ($this->_writeDebugLog) { + $message = implode(func_get_args()); + $cellReference = implode(' -> ', $this->_cellStack->showStack()); + if ($this->_echoDebugLog) { + echo $cellReference, + ($this->_cellStack->count() > 0 ? ' => ' : ''), + $message, + PHP_EOL; + } + $this->_debugLog[] = $cellReference . + ($this->_cellStack->count() > 0 ? ' => ' : '') . + $message; + } + } // function _writeDebug() + + /** + * Clear the calculation engine debug log + */ + public function clearLog() { + $this->_debugLog = array(); + } // function flushLogger() + + /** + * Return the calculation engine debug log + * + * @return string[] + */ + public function getLog() { + return $this->_debugLog; + } // function flushLogger() + +} // class PHPExcel_CalcEngine_Logger + diff --git a/htdocs/includes/phpexcel/PHPExcel/Calculation.php b/htdocs/includes/phpexcel/PHPExcel/Calculation.php index 65d4f3d1027..b609b0d8921 100644 --- a/htdocs/includes/phpexcel/PHPExcel/Calculation.php +++ b/htdocs/includes/phpexcel/PHPExcel/Calculation.php @@ -2,7 +2,7 @@ /** * PHPExcel * - * Copyright (c) 2006 - 2012 PHPExcel + * Copyright (c) 2006 - 2014 PHPExcel * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,9 +20,9 @@ * * @category PHPExcel * @package PHPExcel_Calculation - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version 1.7.8, 2012-10-12 + * @version 1.8.0, 2014-03-02 */ @@ -53,11 +53,11 @@ if (!defined('CALCULATION_REGEXP_CELLREF')) { /** - * PHPExcel_Calculation (Singleton) + * PHPExcel_Calculation (Multiton) * * @category PHPExcel * @package PHPExcel_Calculation - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) */ class PHPExcel_Calculation { @@ -96,13 +96,29 @@ class PHPExcel_Calculation { private static $_instance; + /** + * Instance of the workbook this Calculation Engine is using + * + * @access private + * @var PHPExcel + */ + private $_workbook; + + /** + * List of instances of the calculation engine that we've instantiated for individual workbooks + * + * @access private + * @var PHPExcel_Calculation[] + */ + private static $_workbookSets; + /** * Calculation cache * * @access private * @var array */ - private static $_calculationCache = array (); + private $_calculationCache = array (); /** @@ -111,16 +127,7 @@ class PHPExcel_Calculation { * @access private * @var boolean */ - private static $_calculationCacheEnabled = true; - - - /** - * Calculation cache expiration time - * - * @access private - * @var float - */ - private static $_calculationCacheExpirationTime = 15; + private $_calculationCacheEnabled = TRUE; /** @@ -130,10 +137,10 @@ class PHPExcel_Calculation { * @access private * @var array */ - private static $_operators = array('+' => true, '-' => true, '*' => true, '/' => true, - '^' => true, '&' => true, '%' => false, '~' => false, - '>' => true, '<' => true, '=' => true, '>=' => true, - '<=' => true, '<>' => true, '|' => true, ':' => true + private static $_operators = array('+' => TRUE, '-' => TRUE, '*' => TRUE, '/' => TRUE, + '^' => TRUE, '&' => TRUE, '%' => FALSE, '~' => FALSE, + '>' => TRUE, '<' => TRUE, '=' => TRUE, '>=' => TRUE, + '<=' => TRUE, '<>' => TRUE, '|' => TRUE, ':' => TRUE ); @@ -143,12 +150,21 @@ class PHPExcel_Calculation { * @access private * @var array */ - private static $_binaryOperators = array('+' => true, '-' => true, '*' => true, '/' => true, - '^' => true, '&' => true, '>' => true, '<' => true, - '=' => true, '>=' => true, '<=' => true, '<>' => true, - '|' => true, ':' => true + private static $_binaryOperators = array('+' => TRUE, '-' => TRUE, '*' => TRUE, '/' => TRUE, + '^' => TRUE, '&' => TRUE, '>' => TRUE, '<' => TRUE, + '=' => TRUE, '>=' => TRUE, '<=' => TRUE, '<>' => TRUE, + '|' => TRUE, ':' => TRUE ); + /** + * The debug log generated by the calculation engine + * + * @access private + * @var PHPExcel_CalcEngine_Logger + * + */ + private $debugLog; + /** * Flag to determine how formula errors should be handled * If true, then a user error will be triggered @@ -158,7 +174,7 @@ class PHPExcel_Calculation { * @var boolean * */ - public $suppressFormulaErrors = false; + public $suppressFormulaErrors = FALSE; /** * Error message for any error that was raised/thrown by the calculation engine @@ -167,31 +183,7 @@ class PHPExcel_Calculation { * @var string * */ - public $formulaError = null; - - /** - * Flag to determine whether a debug log should be generated by the calculation engine - * If true, then a debug log will be generated - * If false, then a debug log will not be generated - * - * @access public - * @var boolean - * - */ - public $writeDebugLog = false; - - /** - * Flag to determine whether a debug log should be echoed by the calculation engine - * If true, then a debug log will be echoed - * If false, then a debug log will not be echoed - * A debug log can only be echoed if it is generated - * - * @access public - * @var boolean - * - */ - public $echoDebugLog = false; - + public $formulaError = NULL; /** * An array of the nested cell references accessed by the calculation engine, used for the debug log @@ -200,39 +192,85 @@ class PHPExcel_Calculation { * @var array of string * */ - private $debugLogStack = array(); + private $_cyclicReferenceStack; /** - * The debug log generated by the calculation engine + * Current iteration counter for cyclic formulae + * If the value is 0 (or less) then cyclic formulae will throw an exception, + * otherwise they will iterate to the limit defined here before returning a result * - * @access public - * @var array of string + * @var integer * */ - public $debugLog = array(); private $_cyclicFormulaCount = 0; + private $_cyclicFormulaCell = ''; + + /** + * Number of iterations for cyclic formulae + * + * @var integer + * + */ public $cyclicFormulaCount = 0; - - private $_savedPrecision = 12; + /** + * Precision used for calculations + * + * @var integer + * + */ + private $_savedPrecision = 14; + /** + * The current locale setting + * + * @var string + * + */ private static $_localeLanguage = 'en_us'; // US English (default locale) + + /** + * List of available locale settings + * Note that this is read for the locale subdirectory only when requested + * + * @var string[] + * + */ private static $_validLocaleLanguages = array( 'en' // English (default language) ); + /** + * Locale-specific argument separator for function arguments + * + * @var string + * + */ private static $_localeArgumentSeparator = ','; private static $_localeFunctions = array(); + + /** + * Locale-specific translations for Excel constants (True, False and Null) + * + * @var string[] + * + */ public static $_localeBoolean = array( 'TRUE' => 'TRUE', 'FALSE' => 'FALSE', 'NULL' => 'NULL' ); - // Constant conversion from text name/value to actual (datatyped) value - private static $_ExcelConstants = array('TRUE' => true, - 'FALSE' => false, - 'NULL' => null + /** + * Excel constant string translations to their PHP equivalents + * Constant conversion from text name/value to actual (datatyped) value + * + * @var string[] + * + */ + private static $_ExcelConstants = array('TRUE' => TRUE, + 'FALSE' => FALSE, + 'NULL' => NULL ); // PHPExcel functions @@ -404,7 +442,7 @@ class PHPExcel_Calculation { 'COLUMN' => array('category' => PHPExcel_Calculation_Function::CATEGORY_LOOKUP_AND_REFERENCE, 'functionCall' => 'PHPExcel_Calculation_LookupRef::COLUMN', 'argumentCount' => '-1', - 'passByReference' => array(true) + 'passByReference' => array(TRUE) ), 'COLUMNS' => array('category' => PHPExcel_Calculation_Function::CATEGORY_LOOKUP_AND_REFERENCE, 'functionCall' => 'PHPExcel_Calculation_LookupRef::COLUMNS', @@ -803,7 +841,7 @@ class PHPExcel_Calculation { 'argumentCount' => '1,2' ), 'HLOOKUP' => array('category' => PHPExcel_Calculation_Function::CATEGORY_LOOKUP_AND_REFERENCE, - 'functionCall' => 'PHPExcel_Calculation_Functions::DUMMY', + 'functionCall' => 'PHPExcel_Calculation_LookupRef::HLOOKUP', 'argumentCount' => '3,4' ), 'HOUR' => array('category' => PHPExcel_Calculation_Function::CATEGORY_DATE_AND_TIME, @@ -813,7 +851,7 @@ class PHPExcel_Calculation { 'HYPERLINK' => array('category' => PHPExcel_Calculation_Function::CATEGORY_LOOKUP_AND_REFERENCE, 'functionCall' => 'PHPExcel_Calculation_LookupRef::HYPERLINK', 'argumentCount' => '1,2', - 'passCellReference'=> true + 'passCellReference'=> TRUE ), 'HYPGEOMDIST' => array('category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL, 'functionCall' => 'PHPExcel_Calculation_Statistical::HYPGEOMDIST', @@ -902,7 +940,7 @@ class PHPExcel_Calculation { 'INDIRECT' => array('category' => PHPExcel_Calculation_Function::CATEGORY_LOOKUP_AND_REFERENCE, 'functionCall' => 'PHPExcel_Calculation_LookupRef::INDIRECT', 'argumentCount' => '1,2', - 'passCellReference'=> true + 'passCellReference'=> TRUE ), 'INFO' => array('category' => PHPExcel_Calculation_Function::CATEGORY_INFORMATION, 'functionCall' => 'PHPExcel_Calculation_Functions::DUMMY', @@ -1219,8 +1257,8 @@ class PHPExcel_Calculation { 'OFFSET' => array('category' => PHPExcel_Calculation_Function::CATEGORY_LOOKUP_AND_REFERENCE, 'functionCall' => 'PHPExcel_Calculation_LookupRef::OFFSET', 'argumentCount' => '3,5', - 'passCellReference'=> true, - 'passByReference' => array(true) + 'passCellReference'=> TRUE, + 'passByReference' => array(TRUE) ), 'OR' => array('category' => PHPExcel_Calculation_Function::CATEGORY_LOGICAL, 'functionCall' => 'PHPExcel_Calculation_Logical::LOGICAL_OR', @@ -1365,7 +1403,7 @@ class PHPExcel_Calculation { 'ROW' => array('category' => PHPExcel_Calculation_Function::CATEGORY_LOOKUP_AND_REFERENCE, 'functionCall' => 'PHPExcel_Calculation_LookupRef::ROW', 'argumentCount' => '-1', - 'passByReference' => array(true) + 'passByReference' => array(TRUE) ), 'ROWS' => array('category' => PHPExcel_Calculation_Function::CATEGORY_LOOKUP_AND_REFERENCE, 'functionCall' => 'PHPExcel_Calculation_LookupRef::ROWS', @@ -1680,20 +1718,20 @@ class PHPExcel_Calculation { - private function __construct() { - $localeFileDirectory = PHPEXCEL_ROOT.'PHPExcel/locale/'; - foreach (glob($localeFileDirectory.'/*',GLOB_ONLYDIR) as $filename) { - $filename = substr($filename,strlen($localeFileDirectory)+1); - if ($filename != 'en') { - self::$_validLocaleLanguages[] = $filename; - } - } - - $setPrecision = (PHP_INT_SIZE == 4) ? 12 : 16; + private function __construct(PHPExcel $workbook = NULL) { + $setPrecision = (PHP_INT_SIZE == 4) ? 14 : 16; $this->_savedPrecision = ini_get('precision'); if ($this->_savedPrecision < $setPrecision) { ini_set('precision',$setPrecision); } + + if ($workbook !== NULL) { + self::$_workbookSets[$workbook->getID()] = $this; + } + + $this->_workbook = $workbook; + $this->_cyclicReferenceStack = new PHPExcel_CalcEngine_CyclicReferenceStack(); + $this->_debugLog = new PHPExcel_CalcEngine_Logger($this->_cyclicReferenceStack); } // function __construct() @@ -1703,13 +1741,32 @@ class PHPExcel_Calculation { } } + private static function _loadLocales() { + $localeFileDirectory = PHPEXCEL_ROOT.'PHPExcel/locale/'; + foreach (glob($localeFileDirectory.'/*',GLOB_ONLYDIR) as $filename) { + $filename = substr($filename,strlen($localeFileDirectory)+1); + if ($filename != 'en') { + self::$_validLocaleLanguages[] = $filename; + } + } + } + /** * Get an instance of this class * * @access public + * @param PHPExcel $workbook Injected workbook for working with a PHPExcel object, + * or NULL to create a standalone claculation engine * @return PHPExcel_Calculation */ - public static function getInstance() { + public static function getInstance(PHPExcel $workbook = NULL) { + if ($workbook !== NULL) { + if (isset(self::$_workbookSets[$workbook->getID()])) { + return self::$_workbookSets[$workbook->getID()]; + } + return new PHPExcel_Calculation($workbook); + } + if (!isset(self::$_instance) || (self::$_instance === NULL)) { self::$_instance = new PHPExcel_Calculation(); } @@ -1717,6 +1774,19 @@ class PHPExcel_Calculation { return self::$_instance; } // function getInstance() + /** + * Unset an instance of this class + * + * @access public + * @param PHPExcel $workbook Injected workbook identifying the instance to unset + */ + public static function unsetInstance(PHPExcel $workbook = NULL) { + if ($workbook !== NULL) { + if (isset(self::$_workbookSets[$workbook->getID()])) { + unset(self::$_workbookSets[$workbook->getID()]); + } + } + } /** * Flush the calculation cache for any existing instance of this class @@ -1725,21 +1795,29 @@ class PHPExcel_Calculation { * @access public * @return null */ - public static function flushInstance() { - if (isset(self::$_instance) && (self::$_instance !== NULL)) { - self::$_instance->clearCalculationCache(); - } + public function flushInstance() { + $this->clearCalculationCache(); } // function flushInstance() + /** + * Get the debuglog for this claculation engine instance + * + * @access public + * @return PHPExcel_CalcEngine_Logger + */ + public function getDebugLog() { + return $this->_debugLog; + } + /** * __clone implementation. Cloning should not be allowed in a Singleton! * * @access public - * @throws Exception + * @throws PHPExcel_Calculation_Exception */ public final function __clone() { - throw new Exception ('Cloning a Singleton is not allowed!'); + throw new PHPExcel_Calculation_Exception ('Cloning the calculation engine is not allowed!'); } // function __clone() @@ -1775,10 +1853,10 @@ class PHPExcel_Calculation { ($returnType == self::RETURN_ARRAY_AS_ERROR) || ($returnType == self::RETURN_ARRAY_AS_ARRAY)) { self::$returnArrayAsType = $returnType; - return true; + return TRUE; } - return false; - } // function setExcelCalendar() + return FALSE; + } // function setArrayReturnType() /** @@ -1789,7 +1867,7 @@ class PHPExcel_Calculation { */ public static function getArrayReturnType() { return self::$returnArrayAsType; - } // function getExcelCalendar() + } // function getArrayReturnType() /** @@ -1799,18 +1877,17 @@ class PHPExcel_Calculation { * @return boolean */ public function getCalculationCacheEnabled() { - return self::$_calculationCacheEnabled; + return $this->_calculationCacheEnabled; } // function getCalculationCacheEnabled() - /** * Enable/disable calculation cache * * @access public * @param boolean $pValue */ - public function setCalculationCacheEnabled($pValue = true) { - self::$_calculationCacheEnabled = $pValue; + public function setCalculationCacheEnabled($pValue = TRUE) { + $this->_calculationCacheEnabled = $pValue; $this->clearCalculationCache(); } // function setCalculationCacheEnabled() @@ -1819,7 +1896,7 @@ class PHPExcel_Calculation { * Enable calculation cache */ public function enableCalculationCache() { - $this->setCalculationCacheEnabled(true); + $this->setCalculationCacheEnabled(TRUE); } // function enableCalculationCache() @@ -1827,7 +1904,7 @@ class PHPExcel_Calculation { * Disable calculation cache */ public function disableCalculationCache() { - $this->setCalculationCacheEnabled(false); + $this->setCalculationCacheEnabled(FALSE); } // function disableCalculationCache() @@ -1835,30 +1912,32 @@ class PHPExcel_Calculation { * Clear calculation cache */ public function clearCalculationCache() { - self::$_calculationCache = array(); + $this->_calculationCache = array(); } // function clearCalculationCache() + /** + * Clear calculation cache for a specified worksheet + * + * @param string $worksheetName + */ + public function clearCalculationCacheForWorksheet($worksheetName) { + if (isset($this->_calculationCache[$worksheetName])) { + unset($this->_calculationCache[$worksheetName]); + } + } // function clearCalculationCacheForWorksheet() /** - * Get calculation cache expiration time + * Rename calculation cache for a specified worksheet * - * @return float + * @param string $fromWorksheetName + * @param string $toWorksheetName */ - public function getCalculationCacheExpirationTime() { - return self::$_calculationCacheExpirationTime; - } // getCalculationCacheExpirationTime() - - - /** - * Set calculation cache expiration time - * - * @param float $pValue - */ - public function setCalculationCacheExpirationTime($pValue = 15) { - self::$_calculationCacheExpirationTime = $pValue; - } // function setCalculationCacheExpirationTime() - - + public function renameCalculationCacheForWorksheet($fromWorksheetName, $toWorksheetName) { + if (isset($this->_calculationCache[$fromWorksheetName])) { + $this->_calculationCache[$toWorksheetName] = &$this->_calculationCache[$fromWorksheetName]; + unset($this->_calculationCache[$fromWorksheetName]); + } + } // function renameCalculationCacheForWorksheet() /** @@ -1874,15 +1953,19 @@ class PHPExcel_Calculation { /** * Set the locale code * + * @param string $locale The locale to use for formula translation * @return boolean */ - public function setLocale($locale='en_us') { + public function setLocale($locale = 'en_us') { // Identify our locale and language $language = $locale = strtolower($locale); - if (strpos($locale,'_') !== false) { + if (strpos($locale,'_') !== FALSE) { list($language) = explode('_',$locale); } + if (count(self::$_validLocaleLanguages) == 1) + self::_loadLocales(); + // Test whether we have any language data for this language (any locale) if (in_array($language,self::$_validLocaleLanguages)) { // initialise language/locale settings @@ -1897,14 +1980,14 @@ class PHPExcel_Calculation { // If there isn't a locale specific function file, look for a language specific function file $functionNamesFile = PHPEXCEL_ROOT . 'PHPExcel'.DIRECTORY_SEPARATOR.'locale'.DIRECTORY_SEPARATOR.$language.DIRECTORY_SEPARATOR.'functions'; if (!file_exists($functionNamesFile)) { - return false; + return FALSE; } } // Retrieve the list of locale or language specific function names $localeFunctions = file($functionNamesFile,FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); foreach ($localeFunctions as $localeFunction) { list($localeFunction) = explode('##',$localeFunction); // Strip out comments - if (strpos($localeFunction,'=') !== false) { + if (strpos($localeFunction,'=') !== FALSE) { list($fName,$lfName) = explode('=',$localeFunction); $fName = trim($fName); $lfName = trim($lfName); @@ -1925,7 +2008,7 @@ class PHPExcel_Calculation { $localeSettings = file($configFile,FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); foreach ($localeSettings as $localeSetting) { list($localeSetting) = explode('##',$localeSetting); // Strip out comments - if (strpos($localeSetting,'=') !== false) { + if (strpos($localeSetting,'=') !== FALSE) { list($settingName,$settingValue) = explode('=',$localeSetting); $settingName = strtoupper(trim($settingName)); switch ($settingName) { @@ -1939,11 +2022,11 @@ class PHPExcel_Calculation { } self::$functionReplaceFromExcel = self::$functionReplaceToExcel = - self::$functionReplaceFromLocale = self::$functionReplaceToLocale = null; + self::$functionReplaceFromLocale = self::$functionReplaceToLocale = NULL; self::$_localeLanguage = $locale; - return true; + return TRUE; } - return false; + return FALSE; } // function setLocale() @@ -1953,9 +2036,9 @@ class PHPExcel_Calculation { for ($i = 0; $i < $strlen; ++$i) { $chr = mb_substr($formula,$i,1); switch ($chr) { - case '{' : $inBraces = true; + case '{' : $inBraces = TRUE; break; - case '}' : $inBraces = false; + case '}' : $inBraces = FALSE; break; case $fromSeparator : if (!$inBraces) { @@ -1969,13 +2052,13 @@ class PHPExcel_Calculation { private static function _translateFormula($from,$to,$formula,$fromSeparator,$toSeparator) { // Convert any Excel function names to the required language if (self::$_localeLanguage !== 'en_us') { - $inBraces = false; + $inBraces = FALSE; // If there is the possibility of braces within a quoted string, then we don't treat those as matrix indicators - if (strpos($formula,'"') !== false) { + if (strpos($formula,'"') !== FALSE) { // So instead we skip replacing in any quoted strings by only replacing in every other array element after we've exploded // the formula $temp = explode('"',$formula); - $i = false; + $i = FALSE; foreach($temp as &$value) { // Only count/replace in alternating array entries if ($i = !$i) { @@ -1996,8 +2079,8 @@ class PHPExcel_Calculation { return $formula; } - private static $functionReplaceFromExcel = null; - private static $functionReplaceToLocale = null; + private static $functionReplaceFromExcel = NULL; + private static $functionReplaceToLocale = NULL; public function _translateFormulaToLocale($formula) { if (self::$functionReplaceFromExcel === NULL) { @@ -2025,8 +2108,8 @@ class PHPExcel_Calculation { } // function _translateFormulaToLocale() - private static $functionReplaceFromLocale = null; - private static $functionReplaceToExcel = null; + private static $functionReplaceFromLocale = NULL; + private static $functionReplaceToExcel = NULL; public function _translateFormulaToEnglish($formula) { if (self::$functionReplaceFromLocale === NULL) { @@ -2120,13 +2203,13 @@ class PHPExcel_Calculation { * @access public * @param PHPExcel_Cell $pCell Cell to calculate * @return mixed - * @throws Exception + * @throws PHPExcel_Calculation_Exception */ - public function calculate(PHPExcel_Cell $pCell = null) { + public function calculate(PHPExcel_Cell $pCell = NULL) { try { return $this->calculateCellValue($pCell); - } catch (Exception $e) { - throw(new Exception($e->getMessage())); + } catch (PHPExcel_Exception $e) { + throw new PHPExcel_Calculation_Exception($e->getMessage()); } } // function calculate() @@ -2138,35 +2221,33 @@ class PHPExcel_Calculation { * @param PHPExcel_Cell $pCell Cell to calculate * @param Boolean $resetLog Flag indicating whether the debug log should be reset or not * @return mixed - * @throws Exception + * @throws PHPExcel_Calculation_Exception */ - public function calculateCellValue(PHPExcel_Cell $pCell = null, $resetLog = true) { - if ($resetLog) { - // Initialise the logging settings if requested - $this->formulaError = null; - $this->debugLog = $this->debugLogStack = array(); - $this->_cyclicFormulaCount = 1; - - $returnArrayAsType = self::$returnArrayAsType; - self::$returnArrayAsType = self::RETURN_ARRAY_AS_ARRAY; - } - - // Read the formula from the cell + public function calculateCellValue(PHPExcel_Cell $pCell = NULL, $resetLog = TRUE) { if ($pCell === NULL) { return NULL; } + $returnArrayAsType = self::$returnArrayAsType; if ($resetLog) { - self::$returnArrayAsType = $returnArrayAsType; + // Initialise the logging settings if requested + $this->formulaError = null; + $this->_debugLog->clearLog(); + $this->_cyclicReferenceStack->clear(); + $this->_cyclicFormulaCount = 1; + + self::$returnArrayAsType = self::RETURN_ARRAY_AS_ARRAY; } + // Execute the calculation for the cell formula try { $result = self::_unwrapResult($this->_calculateFormulaValue($pCell->getValue(), $pCell->getCoordinate(), $pCell)); - } catch (Exception $e) { - throw(new Exception($e->getMessage())); + } catch (PHPExcel_Exception $e) { + throw new PHPExcel_Calculation_Exception($e->getMessage()); } if ((is_array($result)) && (self::$returnArrayAsType != self::RETURN_ARRAY_AS_ARRAY)) { + self::$returnArrayAsType = $returnArrayAsType; $testResult = PHPExcel_Calculation_Functions::flattenArray($result); if (self::$returnArrayAsType == self::RETURN_ARRAY_AS_ERROR) { return PHPExcel_Calculation_Functions::VALUE(); @@ -2187,6 +2268,8 @@ class PHPExcel_Calculation { } $result = array_shift($testResult); } + self::$returnArrayAsType = $returnArrayAsType; + if ($result === NULL) { return 0; @@ -2202,7 +2285,7 @@ class PHPExcel_Calculation { * * @param string $formula Formula to parse * @return array - * @throws Exception + * @throws PHPExcel_Calculation_Exception */ public function parseFormula($formula) { // Basic validation that this is indeed a formula @@ -2220,33 +2303,57 @@ class PHPExcel_Calculation { /** * Calculate the value of a formula * - * @param string $formula Formula to parse + * @param string $formula Formula to parse + * @param string $cellID Address of the cell to calculate + * @param PHPExcel_Cell $pCell Cell to calculate * @return mixed - * @throws Exception + * @throws PHPExcel_Calculation_Exception */ - public function calculateFormula($formula, $cellID=null, PHPExcel_Cell $pCell = null) { + public function calculateFormula($formula, $cellID=NULL, PHPExcel_Cell $pCell = NULL) { // Initialise the logging settings $this->formulaError = null; - $this->debugLog = $this->debugLogStack = array(); + $this->_debugLog->clearLog(); + $this->_cyclicReferenceStack->clear(); // Disable calculation cacheing because it only applies to cell calculations, not straight formulae // But don't actually flush any cache $resetCache = $this->getCalculationCacheEnabled(); - self::$_calculationCacheEnabled = false; + $this->_calculationCacheEnabled = FALSE; // Execute the calculation try { $result = self::_unwrapResult($this->_calculateFormulaValue($formula, $cellID, $pCell)); - } catch (Exception $e) { - throw(new Exception($e->getMessage())); + } catch (PHPExcel_Exception $e) { + throw new PHPExcel_Calculation_Exception($e->getMessage()); } // Reset calculation cacheing to its previous state - self::$_calculationCacheEnabled = $resetCache; + $this->_calculationCacheEnabled = $resetCache; return $result; } // function calculateFormula() + public function getValueFromCache($worksheetName, $cellID, &$cellValue) { + // Is calculation cacheing enabled? + // Is the value present in calculation cache? +//echo 'Test cache for ',$worksheetName,'!',$cellID,PHP_EOL; + $this->_debugLog->writeDebugLog('Testing cache value for cell ', $worksheetName, '!', $cellID); + if (($this->_calculationCacheEnabled) && (isset($this->_calculationCache[$worksheetName][$cellID]))) { +//echo 'Retrieve from cache',PHP_EOL; + $this->_debugLog->writeDebugLog('Retrieving value for cell ', $worksheetName, '!', $cellID, ' from cache'); + // Return the cached result + $cellValue = $this->_calculationCache[$worksheetName][$cellID]; + return TRUE; + } + return FALSE; + } + + public function saveValueToCache($worksheetName, $cellID, $cellValue) { + if ($this->_calculationCacheEnabled) { + $this->_calculationCache[$worksheetName][$cellID] = $cellValue; + } + } + /** * Parse a cell formula and calculate its value * @@ -2254,57 +2361,26 @@ class PHPExcel_Calculation { * @param string $cellID The ID (e.g. A3) of the cell that we are calculating * @param PHPExcel_Cell $pCell Cell to calculate * @return mixed - * @throws Exception + * @throws PHPExcel_Calculation_Exception */ public function _calculateFormulaValue($formula, $cellID=null, PHPExcel_Cell $pCell = null) { -// echo ''.$cellID.'
'; $cellValue = ''; // Basic validation that this is indeed a formula - // We simply return the "cell value" (formula) if not + // We simply return the cell value if not $formula = trim($formula); if ($formula{0} != '=') return self::_wrapResult($formula); $formula = ltrim(substr($formula,1)); if (!isset($formula{0})) return self::_wrapResult($formula); - $wsTitle = "\x00Wrk"; - if ($pCell !== NULL) { - $pCellParent = $pCell->getParent(); - if ($pCellParent !== NULL) { - $wsTitle = $pCellParent->getTitle(); - } - } - // Is calculation cacheing enabled? - if ($cellID !== NULL) { - if (self::$_calculationCacheEnabled) { - // Is the value present in calculation cache? -// echo 'Testing cache value
'; - if (isset(self::$_calculationCache[$wsTitle][$cellID])) { -// echo 'Value is in cache
'; - $this->_writeDebug('Testing cache value for cell '.$cellID); - // Is cache still valid? - if ((microtime(true) - self::$_calculationCache[$wsTitle][$cellID]['time']) < self::$_calculationCacheExpirationTime) { -// echo 'Cache time is still valid
'; - $this->_writeDebug('Retrieving value for '.$cellID.' from cache'); - // Return the cached result - $returnValue = self::$_calculationCache[$wsTitle][$cellID]['data']; -// echo 'Retrieving data value of '.$returnValue.' for '.$cellID.' from cache
'; - if (is_array($returnValue)) { - $returnValue = PHPExcel_Calculation_Functions::flattenArray($returnValue); - return array_shift($returnValue); - } - return $returnValue; - } else { -// echo 'Cache has expired
'; - $this->_writeDebug('Cache value for '.$cellID.' has expired'); - // Clear the cache if it's no longer valid - unset(self::$_calculationCache[$wsTitle][$cellID]); - } - } - } + $pCellParent = ($pCell !== NULL) ? $pCell->getWorksheet() : NULL; + $wsTitle = ($pCellParent !== NULL) ? $pCellParent->getTitle() : "\x00Wrk"; + + if (($cellID !== NULL) && ($this->getValueFromCache($wsTitle, $cellID, $cellValue))) { + return $cellValue; } - if ((in_array($wsTitle.'!'.$cellID,$this->debugLogStack)) && ($wsTitle != "\x00Wrk")) { + if (($wsTitle{0} !== "\x00") && ($this->_cyclicReferenceStack->onStack($wsTitle.'!'.$cellID))) { if ($this->cyclicFormulaCount <= 0) { return $this->_raiseFormulaError('Cyclic Reference in Formula'); } elseif (($this->_cyclicFormulaCount >= $this->cyclicFormulaCount) && @@ -2322,17 +2398,15 @@ class PHPExcel_Calculation { } } } - $this->debugLogStack[] = $wsTitle.'!'.$cellID; + // Parse the formula onto the token stack and calculate the value + $this->_cyclicReferenceStack->push($wsTitle.'!'.$cellID); $cellValue = $this->_processTokenStack($this->_parseFormula($formula, $pCell), $cellID, $pCell); - array_pop($this->debugLogStack); + $this->_cyclicReferenceStack->pop(); // Save to calculation cache if ($cellID !== NULL) { - if (self::$_calculationCacheEnabled) { - self::$_calculationCache[$wsTitle][$cellID]['time'] = microtime(true); - self::$_calculationCache[$wsTitle][$cellID]['data'] = $cellValue; - } + $this->saveValueToCache($wsTitle, $cellID, $cellValue); } // Return the calculated value @@ -2407,11 +2481,20 @@ class PHPExcel_Calculation { /** * Ensure that paired matrix operands are both matrices of the same size * - * @param mixed &$matrix1 First matrix operand - * @param mixed &$matrix2 Second matrix operand + * @param mixed &$matrix1 First matrix operand + * @param mixed &$matrix2 Second matrix operand + * @param integer $matrix1Rows Row size of first matrix operand + * @param integer $matrix1Columns Column size of first matrix operand + * @param integer $matrix2Rows Row size of second matrix operand + * @param integer $matrix2Columns Column size of second matrix operand */ private static function _resizeMatricesShrink(&$matrix1,&$matrix2,$matrix1Rows,$matrix1Columns,$matrix2Rows,$matrix2Columns) { if (($matrix2Columns < $matrix1Columns) || ($matrix2Rows < $matrix1Rows)) { + if ($matrix2Rows < $matrix1Rows) { + for ($i = $matrix2Rows; $i < $matrix1Rows; ++$i) { + unset($matrix1[$i]); + } + } if ($matrix2Columns < $matrix1Columns) { for ($i = 0; $i < $matrix1Rows; ++$i) { for ($j = $matrix2Columns; $j < $matrix1Columns; ++$j) { @@ -2419,14 +2502,14 @@ class PHPExcel_Calculation { } } } - if ($matrix2Rows < $matrix1Rows) { - for ($i = $matrix2Rows; $i < $matrix1Rows; ++$i) { - unset($matrix1[$i]); - } - } } if (($matrix1Columns < $matrix2Columns) || ($matrix1Rows < $matrix2Rows)) { + if ($matrix1Rows < $matrix2Rows) { + for ($i = $matrix1Rows; $i < $matrix2Rows; ++$i) { + unset($matrix2[$i]); + } + } if ($matrix1Columns < $matrix2Columns) { for ($i = 0; $i < $matrix2Rows; ++$i) { for ($j = $matrix1Columns; $j < $matrix2Columns; ++$j) { @@ -2434,11 +2517,6 @@ class PHPExcel_Calculation { } } } - if ($matrix1Rows < $matrix2Rows) { - for ($i = $matrix1Rows; $i < $matrix2Rows; ++$i) { - unset($matrix2[$i]); - } - } } } // function _resizeMatricesShrink() @@ -2448,6 +2526,10 @@ class PHPExcel_Calculation { * * @param mixed &$matrix1 First matrix operand * @param mixed &$matrix2 Second matrix operand + * @param integer $matrix1Rows Row size of first matrix operand + * @param integer $matrix1Columns Column size of first matrix operand + * @param integer $matrix2Rows Row size of second matrix operand + * @param integer $matrix2Columns Column size of second matrix operand */ private static function _resizeMatricesExtend(&$matrix1,&$matrix2,$matrix1Rows,$matrix1Columns,$matrix2Rows,$matrix2Columns) { if (($matrix2Columns < $matrix1Columns) || ($matrix2Rows < $matrix1Rows)) { @@ -2493,7 +2575,7 @@ class PHPExcel_Calculation { * @return mixed */ private function _showValue($value) { - if ($this->writeDebugLog) { + if ($this->_debugLog->getWriteDebugLog()) { $testArray = PHPExcel_Calculation_Functions::flattenArray($value); if (count($testArray) == 1) { $value = array_pop($testArray); @@ -2528,7 +2610,7 @@ class PHPExcel_Calculation { * @return mixed */ private function _showTypeDetails($value) { - if ($this->writeDebugLog) { + if ($this->_debugLog->getWriteDebugLog()) { $testArray = PHPExcel_Calculation_Functions::flattenArray($value); if (count($testArray) == 1) { $value = array_pop($testArray); @@ -2563,15 +2645,15 @@ class PHPExcel_Calculation { static $matrixReplaceTo = array('MKMATRIX(MKMATRIX(','),MKMATRIX(','))'); // Convert any Excel matrix references to the MKMATRIX() function - if (strpos($formula,'{') !== false) { + if (strpos($formula,'{') !== FALSE) { // If there is the possibility of braces within a quoted string, then we don't treat those as matrix indicators - if (strpos($formula,'"') !== false) { + if (strpos($formula,'"') !== FALSE) { // So instead we skip replacing in any quoted strings by only replacing in every other array element after we've exploded // the formula $temp = explode('"',$formula); // Open and Closed counts used for trapping mismatched braces in the formula $openCount = $closeCount = 0; - $i = false; + $i = FALSE; foreach($temp as &$value) { // Only count/replace in alternating array entries if ($i = !$i) { @@ -2614,49 +2696,52 @@ class PHPExcel_Calculation { } // function _mkMatrix() + // Binary Operators + // These operators always work on two values + // Array key is the operator, the value indicates whether this is a left or right associative operator + private static $_operatorAssociativity = array( + '^' => 0, // Exponentiation + '*' => 0, '/' => 0, // Multiplication and Division + '+' => 0, '-' => 0, // Addition and Subtraction + '&' => 0, // Concatenation + '|' => 0, ':' => 0, // Intersect and Range + '>' => 0, '<' => 0, '=' => 0, '>=' => 0, '<=' => 0, '<>' => 0 // Comparison + ); + + // Comparison (Boolean) Operators + // These operators work on two values, but always return a boolean result + private static $_comparisonOperators = array('>' => TRUE, '<' => TRUE, '=' => TRUE, '>=' => TRUE, '<=' => TRUE, '<>' => TRUE); + + // Operator Precedence + // This list includes all valid operators, whether binary (including boolean) or unary (such as %) + // Array key is the operator, the value is its precedence + private static $_operatorPrecedence = array( + ':' => 8, // Range + '|' => 7, // Intersect + '~' => 6, // Negation + '%' => 5, // Percentage + '^' => 4, // Exponentiation + '*' => 3, '/' => 3, // Multiplication and Division + '+' => 2, '-' => 2, // Addition and Subtraction + '&' => 1, // Concatenation + '>' => 0, '<' => 0, '=' => 0, '>=' => 0, '<=' => 0, '<>' => 0 // Comparison + ); + // Convert infix to postfix notation - private function _parseFormula($formula, PHPExcel_Cell $pCell = null) { - if (($formula = self::_convertMatrixReferences(trim($formula))) === false) { + private function _parseFormula($formula, PHPExcel_Cell $pCell = NULL) { + if (($formula = self::_convertMatrixReferences(trim($formula))) === FALSE) { return FALSE; } // If we're using cell caching, then $pCell may well be flushed back to the cache (which detaches the parent worksheet), // so we store the parent worksheet so that we can re-attach it when necessary - $pCellParent = ($pCell !== NULL) ? $pCell->getParent() : NULL; - - // Binary Operators - // These operators always work on two values - // Array key is the operator, the value indicates whether this is a left or right associative operator - $operatorAssociativity = array('^' => 0, // Exponentiation - '*' => 0, '/' => 0, // Multiplication and Division - '+' => 0, '-' => 0, // Addition and Subtraction - '&' => 0, // Concatenation - '|' => 0, ':' => 0, // Intersect and Range - '>' => 0, '<' => 0, '=' => 0, '>=' => 0, '<=' => 0, '<>' => 0 // Comparison - ); - // Comparison (Boolean) Operators - // These operators work on two values, but always return a boolean result - $comparisonOperators = array('>' => true, '<' => true, '=' => true, '>=' => true, '<=' => true, '<>' => true); - - // Operator Precedence - // This list includes all valid operators, whether binary (including boolean) or unary (such as %) - // Array key is the operator, the value is its precedence - $operatorPrecedence = array(':' => 8, // Range - '|' => 7, // Intersect - '~' => 6, // Negation - '%' => 5, // Percentage - '^' => 4, // Exponentiation - '*' => 3, '/' => 3, // Multiplication and Division - '+' => 2, '-' => 2, // Addition and Subtraction - '&' => 1, // Concatenation - '>' => 0, '<' => 0, '=' => 0, '>=' => 0, '<=' => 0, '<>' => 0 // Comparison - ); + $pCellParent = ($pCell !== NULL) ? $pCell->getWorksheet() : NULL; $regexpMatchString = '/^('.self::CALCULATION_REGEXP_FUNCTION. + '|'.self::CALCULATION_REGEXP_CELLREF. '|'.self::CALCULATION_REGEXP_NUMBER. '|'.self::CALCULATION_REGEXP_STRING. '|'.self::CALCULATION_REGEXP_OPENBRACE. - '|'.self::CALCULATION_REGEXP_CELLREF. '|'.self::CALCULATION_REGEXP_NAMEDRANGE. '|'.self::CALCULATION_REGEXP_ERROR. ')/si'; @@ -2665,55 +2750,55 @@ class PHPExcel_Calculation { $index = 0; $stack = new PHPExcel_Calculation_Token_Stack; $output = array(); - $expectingOperator = false; // We use this test in syntax-checking the expression to determine when a + $expectingOperator = FALSE; // We use this test in syntax-checking the expression to determine when a // - is a negation or + is a positive operator rather than an operation - $expectingOperand = false; // We use this test in syntax-checking the expression to determine whether an operand + $expectingOperand = FALSE; // We use this test in syntax-checking the expression to determine whether an operand // should be null in a function call // The guts of the lexical parser // Loop through the formula extracting each operator and operand in turn - while(true) { -// echo 'Assessing Expression '.substr($formula, $index).'
'; + while(TRUE) { +//echo 'Assessing Expression '.substr($formula, $index),PHP_EOL; $opCharacter = $formula{$index}; // Get the first character of the value at the current index position -// echo 'Initial character of expression block is '.$opCharacter.'
'; - if ((isset($comparisonOperators[$opCharacter])) && (strlen($formula) > $index) && (isset($comparisonOperators[$formula{$index+1}]))) { +//echo 'Initial character of expression block is '.$opCharacter,PHP_EOL; + if ((isset(self::$_comparisonOperators[$opCharacter])) && (strlen($formula) > $index) && (isset(self::$_comparisonOperators[$formula{$index+1}]))) { $opCharacter .= $formula{++$index}; -// echo 'Initial character of expression block is comparison operator '.$opCharacter.'
'; +//echo 'Initial character of expression block is comparison operator '.$opCharacter.PHP_EOL; } // Find out if we're currently at the beginning of a number, variable, cell reference, function, parenthesis or operand $isOperandOrFunction = preg_match($regexpMatchString, substr($formula, $index), $match); -// echo '$isOperandOrFunction is '.(($isOperandOrFunction) ? 'True' : 'False').'
'; -// var_dump($match); +//echo '$isOperandOrFunction is '.(($isOperandOrFunction) ? 'True' : 'False').PHP_EOL; +//var_dump($match); if ($opCharacter == '-' && !$expectingOperator) { // Is it a negation instead of a minus? -// echo 'Element is a Negation operator
'; +//echo 'Element is a Negation operator',PHP_EOL; $stack->push('Unary Operator','~'); // Put a negation on the stack ++$index; // and drop the negation symbol } elseif ($opCharacter == '%' && $expectingOperator) { -// echo 'Element is a Percentage operator
'; +//echo 'Element is a Percentage operator',PHP_EOL; $stack->push('Unary Operator','%'); // Put a percentage on the stack ++$index; } elseif ($opCharacter == '+' && !$expectingOperator) { // Positive (unary plus rather than binary operator plus) can be discarded? -// echo 'Element is a Positive number, not Plus operator
'; +//echo 'Element is a Positive number, not Plus operator',PHP_EOL; ++$index; // Drop the redundant plus symbol } elseif ((($opCharacter == '~') || ($opCharacter == '|')) && (!$isOperandOrFunction)) { // We have to explicitly deny a tilde or pipe, because they are legal return $this->_raiseFormulaError("Formula Error: Illegal character '~'"); // on the stack but not in the input expression } elseif ((isset(self::$_operators[$opCharacter]) or $isOperandOrFunction) && $expectingOperator) { // Are we putting an operator on the stack? -// echo 'Element with value '.$opCharacter.' is an Operator
'; +//echo 'Element with value '.$opCharacter.' is an Operator',PHP_EOL; while($stack->count() > 0 && ($o2 = $stack->last()) && isset(self::$_operators[$o2['value']]) && - @($operatorAssociativity[$opCharacter] ? $operatorPrecedence[$opCharacter] < $operatorPrecedence[$o2['value']] : $operatorPrecedence[$opCharacter] <= $operatorPrecedence[$o2['value']])) { + @(self::$_operatorAssociativity[$opCharacter] ? self::$_operatorPrecedence[$opCharacter] < self::$_operatorPrecedence[$o2['value']] : self::$_operatorPrecedence[$opCharacter] <= self::$_operatorPrecedence[$o2['value']])) { $output[] = $stack->pop(); // Swap operands and higher precedence operators from the stack to the output } $stack->push('Binary Operator',$opCharacter); // Finally put our current operator onto the stack ++$index; - $expectingOperator = false; + $expectingOperator = FALSE; } elseif ($opCharacter == ')' && $expectingOperator) { // Are we expecting to close a parenthesis? -// echo 'Element is a Closing bracket
'; - $expectingOperand = false; +//echo 'Element is a Closing bracket',PHP_EOL; + $expectingOperand = FALSE; while (($o2 = $stack->pop()) && $o2['value'] != '(') { // Pop off the stack back to the last ( if ($o2 === NULL) return $this->_raiseFormulaError('Formula Error: Unexpected closing brace ")"'); else $output[] = $o2; @@ -2721,65 +2806,65 @@ class PHPExcel_Calculation { $d = $stack->last(2); if (preg_match('/^'.self::CALCULATION_REGEXP_FUNCTION.'$/i', $d['value'], $matches)) { // Did this parenthesis just close a function? $functionName = $matches[1]; // Get the function name -// echo 'Closed Function is '.$functionName.'
'; +//echo 'Closed Function is '.$functionName,PHP_EOL; $d = $stack->pop(); $argumentCount = $d['value']; // See how many arguments there were (argument count is the next value stored on the stack) -// if ($argumentCount == 0) { -// echo 'With no arguments
'; -// } elseif ($argumentCount == 1) { -// echo 'With 1 argument
'; -// } else { -// echo 'With '.$argumentCount.' arguments
'; -// } +//if ($argumentCount == 0) { +// echo 'With no arguments',PHP_EOL; +//} elseif ($argumentCount == 1) { +// echo 'With 1 argument',PHP_EOL; +//} else { +// echo 'With '.$argumentCount.' arguments',PHP_EOL; +//} $output[] = $d; // Dump the argument count on the output $output[] = $stack->pop(); // Pop the function and push onto the output if (isset(self::$_controlFunctions[$functionName])) { -// echo 'Built-in function '.$functionName.'
'; +//echo 'Built-in function '.$functionName,PHP_EOL; $expectedArgumentCount = self::$_controlFunctions[$functionName]['argumentCount']; $functionCall = self::$_controlFunctions[$functionName]['functionCall']; } elseif (isset(self::$_PHPExcelFunctions[$functionName])) { -// echo 'PHPExcel function '.$functionName.'
'; +//echo 'PHPExcel function '.$functionName,PHP_EOL; $expectedArgumentCount = self::$_PHPExcelFunctions[$functionName]['argumentCount']; $functionCall = self::$_PHPExcelFunctions[$functionName]['functionCall']; } else { // did we somehow push a non-function on the stack? this should never happen return $this->_raiseFormulaError("Formula Error: Internal error, non-function on stack"); } // Check the argument count - $argumentCountError = false; + $argumentCountError = FALSE; if (is_numeric($expectedArgumentCount)) { if ($expectedArgumentCount < 0) { -// echo '$expectedArgumentCount is between 0 and '.abs($expectedArgumentCount).'
'; +//echo '$expectedArgumentCount is between 0 and '.abs($expectedArgumentCount),PHP_EOL; if ($argumentCount > abs($expectedArgumentCount)) { - $argumentCountError = true; + $argumentCountError = TRUE; $expectedArgumentCountString = 'no more than '.abs($expectedArgumentCount); } } else { -// echo '$expectedArgumentCount is numeric '.$expectedArgumentCount.'
'; +//echo '$expectedArgumentCount is numeric '.$expectedArgumentCount,PHP_EOL; if ($argumentCount != $expectedArgumentCount) { - $argumentCountError = true; + $argumentCountError = TRUE; $expectedArgumentCountString = $expectedArgumentCount; } } } elseif ($expectedArgumentCount != '*') { $isOperandOrFunction = preg_match('/(\d*)([-+,])(\d*)/',$expectedArgumentCount,$argMatch); -// print_r($argMatch); -// echo '
'; +//print_r($argMatch); +//echo PHP_EOL; switch ($argMatch[2]) { case '+' : if ($argumentCount < $argMatch[1]) { - $argumentCountError = true; + $argumentCountError = TRUE; $expectedArgumentCountString = $argMatch[1].' or more '; } break; case '-' : if (($argumentCount < $argMatch[1]) || ($argumentCount > $argMatch[3])) { - $argumentCountError = true; + $argumentCountError = TRUE; $expectedArgumentCountString = 'between '.$argMatch[1].' and '.$argMatch[3]; } break; case ',' : if (($argumentCount != $argMatch[1]) && ($argumentCount != $argMatch[3])) { - $argumentCountError = true; + $argumentCountError = TRUE; $expectedArgumentCountString = 'either '.$argMatch[1].' or '.$argMatch[3]; } break; @@ -2792,7 +2877,7 @@ class PHPExcel_Calculation { ++$index; } elseif ($opCharacter == ',') { // Is this the separator for function arguments? -// echo 'Element is a Function argument separator
'; +//echo 'Element is a Function argument separator',PHP_EOL; while (($o2 = $stack->pop()) && $o2['value'] != '(') { // Pop off the stack back to the last ( if ($o2 === NULL) return $this->_raiseFormulaError("Formula Error: Unexpected ,"); else $output[] = $o2; // pop the argument expression stuff and push onto the output @@ -2800,7 +2885,7 @@ class PHPExcel_Calculation { // If we've a comma when we're expecting an operand, then what we actually have is a null operand; // so push a null onto the stack if (($expectingOperand) || (!$expectingOperator)) { - $output[] = array('type' => 'NULL Value', 'value' => self::$_ExcelConstants['NULL'], 'reference' => null); + $output[] = array('type' => 'NULL Value', 'value' => self::$_ExcelConstants['NULL'], 'reference' => NULL); } // make sure there was a function $d = $stack->last(2); @@ -2809,8 +2894,8 @@ class PHPExcel_Calculation { $d = $stack->pop(); $stack->push($d['type'],++$d['value'],$d['reference']); // increment the argument count $stack->push('Brace', '('); // put the ( back on, we'll need to pop back to it again - $expectingOperator = false; - $expectingOperand = true; + $expectingOperator = FALSE; + $expectingOperand = TRUE; ++$index; } elseif ($opCharacter == '(' && !$expectingOperator) { @@ -2819,8 +2904,8 @@ class PHPExcel_Calculation { ++$index; } elseif ($isOperandOrFunction && !$expectingOperator) { // do we now have a function/variable/number? - $expectingOperator = true; - $expectingOperand = false; + $expectingOperator = TRUE; + $expectingOperand = FALSE; $val = $match[1]; $length = strlen($val); // echo 'Element with value '.$val.' is an Operand, Variable, Constant, String, Number, Cell Reference or Function
'; @@ -2833,14 +2918,14 @@ class PHPExcel_Calculation { $ax = preg_match('/^\s*(\s*\))/i', substr($formula, $index+$length), $amatch); if ($ax) { $stack->push('Operand Count for Function '.strtoupper($val).')', 0); - $expectingOperator = true; + $expectingOperator = TRUE; } else { $stack->push('Operand Count for Function '.strtoupper($val).')', 1); - $expectingOperator = false; + $expectingOperator = FALSE; } $stack->push('Brace', '('); } else { // it's a var w/ implicit multiplication - $output[] = array('type' => 'Value', 'value' => $matches[1], 'reference' => null); + $output[] = array('type' => 'Value', 'value' => $matches[1], 'reference' => NULL); } } elseif (preg_match('/^'.self::CALCULATION_REGEXP_CELLREF.'$/i', $val, $matches)) { // echo 'Element '.$val.' is a Cell reference
'; @@ -2865,7 +2950,7 @@ class PHPExcel_Calculation { } $output[] = array('type' => 'Cell Reference', 'value' => $val, 'reference' => $val); -// $expectingOperator = false; +// $expectingOperator = FALSE; } else { // it's a variable, constant, string, number or boolean // echo 'Element is a Variable, Constant, String, Number or Boolean
'; // If the last entry on the stack was a : operator, then we may have a row or column range reference @@ -2873,12 +2958,12 @@ class PHPExcel_Calculation { if ($testPrevOp['value'] == ':') { $startRowColRef = $output[count($output)-1]['value']; $rangeWS1 = ''; - if (strpos('!',$startRowColRef) !== false) { + if (strpos('!',$startRowColRef) !== FALSE) { list($rangeWS1,$startRowColRef) = explode('!',$startRowColRef); } if ($rangeWS1 != '') $rangeWS1 .= '!'; $rangeWS2 = $rangeWS1; - if (strpos('!',$val) !== false) { + if (strpos('!',$val) !== FALSE) { list($rangeWS2,$val) = explode('!',$val); } if ($rangeWS2 != '') $rangeWS2 .= '!'; @@ -2897,14 +2982,14 @@ class PHPExcel_Calculation { } } - $localeConstant = false; + $localeConstant = FALSE; if ($opCharacter == '"') { // echo 'Element is a String
'; // UnEscape any quotes within the string $val = self::_wrapResult(str_replace('""','"',self::_unwrapResult($val))); } elseif (is_numeric($val)) { // echo 'Element is a Number
'; - if ((strpos($val,'.') !== false) || (stripos($val,'e') !== false) || ($val > PHP_INT_MAX) || ($val < -PHP_INT_MAX)) { + if ((strpos($val,'.') !== FALSE) || (stripos($val,'e') !== FALSE) || ($val > PHP_INT_MAX) || ($val < -PHP_INT_MAX)) { // echo 'Casting '.$val.' to float
'; $val = (float) $val; } else { @@ -2915,11 +3000,11 @@ class PHPExcel_Calculation { $excelConstant = trim(strtoupper($val)); // echo 'Element '.$excelConstant.' is an Excel Constant
'; $val = self::$_ExcelConstants[$excelConstant]; - } elseif (($localeConstant = array_search(trim(strtoupper($val)), self::$_localeBoolean)) !== false) { + } elseif (($localeConstant = array_search(trim(strtoupper($val)), self::$_localeBoolean)) !== FALSE) { // echo 'Element '.$localeConstant.' is an Excel Constant
'; $val = self::$_ExcelConstants[$localeConstant]; } - $details = array('type' => 'Value', 'value' => $val, 'reference' => null); + $details = array('type' => 'Value', 'value' => $val, 'reference' => NULL); if ($localeConstant) { $details['localeValue'] = $localeConstant; } $output[] = $details; } @@ -2929,9 +3014,9 @@ class PHPExcel_Calculation { ++$index; } elseif ($opCharacter == ')') { // miscellaneous error checking if ($expectingOperand) { - $output[] = array('type' => 'NULL Value', 'value' => self::$_ExcelConstants['NULL'], 'reference' => null); - $expectingOperand = false; - $expectingOperator = true; + $output[] = array('type' => 'NULL Value', 'value' => self::$_ExcelConstants['NULL'], 'reference' => NULL); + $expectingOperand = FALSE; + $expectingOperator = TRUE; } else { return $this->_raiseFormulaError("Formula Error: Unexpected ')'"); } @@ -2967,17 +3052,17 @@ class PHPExcel_Calculation { while($stack->count() > 0 && ($o2 = $stack->last()) && isset(self::$_operators[$o2['value']]) && - @($operatorAssociativity[$opCharacter] ? $operatorPrecedence[$opCharacter] < $operatorPrecedence[$o2['value']] : $operatorPrecedence[$opCharacter] <= $operatorPrecedence[$o2['value']])) { + @(self::$_operatorAssociativity[$opCharacter] ? self::$_operatorPrecedence[$opCharacter] < self::$_operatorPrecedence[$o2['value']] : self::$_operatorPrecedence[$opCharacter] <= self::$_operatorPrecedence[$o2['value']])) { $output[] = $stack->pop(); // Swap operands and higher precedence operators from the stack to the output } $stack->push('Binary Operator','|'); // Put an Intersect Operator on the stack - $expectingOperator = false; + $expectingOperator = FALSE; } } } while (($op = $stack->pop()) !== NULL) { // pop everything off the stack and push onto output - if ((is_array($opCharacter) && $opCharacter['value'] == '(') || ($opCharacter === '(')) + if ((is_array($op) && $op['value'] == '(') || ($op === '(')) return $this->_raiseFormulaError("Formula Error: Expecting ')'"); // if there are any opening braces on the stack, then braces were unbalanced $output[] = $op; } @@ -3001,11 +3086,12 @@ class PHPExcel_Calculation { } // evaluate postfix notation - private function _processTokenStack($tokens, $cellID = null, PHPExcel_Cell $pCell = null) { - if ($tokens == false) return false; + private function _processTokenStack($tokens, $cellID = NULL, PHPExcel_Cell $pCell = NULL) { + if ($tokens == FALSE) return FALSE; - // If we're using cell caching, then $pCell may well be flushed back to the cache (which detaches the parent worksheet), - // so we store the parent worksheet so that we can re-attach it when necessary + // If we're using cell caching, then $pCell may well be flushed back to the cache (which detaches the parent cell collection), + // so we store the parent cell collection so that we can re-attach it when necessary + $pCellWorksheet = ($pCell !== NULL) ? $pCell->getWorksheet() : NULL; $pCellParent = ($pCell !== NULL) ? $pCell->getParent() : null; $stack = new PHPExcel_Calculation_Token_Stack; @@ -3027,9 +3113,9 @@ class PHPExcel_Calculation { // Log what we're doing if ($token == ':') { - $this->_writeDebug('Evaluating Range '.$this->_showValue($operand1Data['reference']).$token.$this->_showValue($operand2Data['reference'])); + $this->_debugLog->writeDebugLog('Evaluating Range ', $this->_showValue($operand1Data['reference']), ' ', $token, ' ', $this->_showValue($operand2Data['reference'])); } else { - $this->_writeDebug('Evaluating '.$this->_showValue($operand1).' '.$token.' '.$this->_showValue($operand2)); + $this->_debugLog->writeDebugLog('Evaluating ', $this->_showValue($operand1), ' ', $token, ' ', $this->_showValue($operand2)); } // Process the operation in the appropriate manner @@ -3046,12 +3132,12 @@ class PHPExcel_Calculation { // Binary Operators case ':' : // Range $sheet1 = $sheet2 = ''; - if (strpos($operand1Data['reference'],'!') !== false) { + if (strpos($operand1Data['reference'],'!') !== FALSE) { list($sheet1,$operand1Data['reference']) = explode('!',$operand1Data['reference']); } else { - $sheet1 = ($pCellParent !== NULL) ? $pCellParent->getTitle() : ''; + $sheet1 = ($pCellParent !== NULL) ? $pCellWorksheet->getTitle() : ''; } - if (strpos($operand2Data['reference'],'!') !== false) { + if (strpos($operand2Data['reference'],'!') !== FALSE) { list($sheet2,$operand2Data['reference']) = explode('!',$operand2Data['reference']); } else { $sheet2 = $sheet1; @@ -3085,13 +3171,13 @@ class PHPExcel_Calculation { } $cellRef = PHPExcel_Cell::stringFromColumnIndex(min($oCol)).min($oRow).':'.PHPExcel_Cell::stringFromColumnIndex(max($oCol)).max($oRow); if ($pCellParent !== NULL) { - $cellValue = $this->extractCellRange($cellRef, $pCellParent->getParent()->getSheetByName($sheet1), false); + $cellValue = $this->extractCellRange($cellRef, $this->_workbook->getSheetByName($sheet1), FALSE); } else { return $this->_raiseFormulaError('Unable to access Cell Reference'); } $stack->push('Cell Reference',$cellValue,$cellRef); } else { - $stack->push('Error',PHPExcel_Calculation_Functions::REF(),null); + $stack->push('Error',PHPExcel_Calculation_Functions::REF(),NULL); } break; @@ -3129,14 +3215,14 @@ class PHPExcel_Calculation { // Perform the required operation against the operand 1 matrix, passing in operand 2 $matrixResult = $matrix->concat($operand2); $result = $matrixResult->getArray(); - } catch (Exception $ex) { - $this->_writeDebug('JAMA Matrix Exception: '.$ex->getMessage()); + } catch (PHPExcel_Exception $ex) { + $this->_debugLog->writeDebugLog('JAMA Matrix Exception: ', $ex->getMessage()); $result = '#VALUE!'; } } else { $result = '"'.str_replace('""','"',self::_unwrapResult($operand1,'"').self::_unwrapResult($operand2,'"')).'"'; } - $this->_writeDebug('Evaluation Result is '.$this->_showTypeDetails($result)); + $this->_debugLog->writeDebugLog('Evaluation Result is ', $this->_showTypeDetails($result)); $stack->push('Value',$result); break; case '|' : // Intersect @@ -3150,7 +3236,7 @@ class PHPExcel_Calculation { } } $cellRef = PHPExcel_Cell::stringFromColumnIndex(min($oCol)).min($oRow).':'.PHPExcel_Cell::stringFromColumnIndex(max($oCol)).max($oRow); - $this->_writeDebug('Evaluation Result is '.$this->_showTypeDetails($cellIntersect)); + $this->_debugLog->writeDebugLog('Evaluation Result is ', $this->_showTypeDetails($cellIntersect)); $stack->push('Value',$cellIntersect,$cellRef); break; } @@ -3162,11 +3248,11 @@ class PHPExcel_Calculation { $arg = $arg['value']; if ($token === '~') { // echo 'Token is a negation operator
'; - $this->_writeDebug('Evaluating Negation of '.$this->_showValue($arg)); + $this->_debugLog->writeDebugLog('Evaluating Negation of ', $this->_showValue($arg)); $multiplier = -1; } else { // echo 'Token is a percentile operator
'; - $this->_writeDebug('Evaluating Percentile of '.$this->_showValue($arg)); + $this->_debugLog->writeDebugLog('Evaluating Percentile of ', $this->_showValue($arg)); $multiplier = 0.01; } if (is_array($arg)) { @@ -3175,18 +3261,18 @@ class PHPExcel_Calculation { $matrix1 = new PHPExcel_Shared_JAMA_Matrix($arg); $matrixResult = $matrix1->arrayTimesEquals($multiplier); $result = $matrixResult->getArray(); - } catch (Exception $ex) { - $this->_writeDebug('JAMA Matrix Exception: '.$ex->getMessage()); + } catch (PHPExcel_Exception $ex) { + $this->_debugLog->writeDebugLog('JAMA Matrix Exception: ', $ex->getMessage()); $result = '#VALUE!'; } - $this->_writeDebug('Evaluation Result is '.$this->_showTypeDetails($result)); + $this->_debugLog->writeDebugLog('Evaluation Result is ', $this->_showTypeDetails($result)); $stack->push('Value',$result); } else { $this->_executeNumericBinaryOperation($cellID,$multiplier,$arg,'*','arrayTimesEquals',$stack); } } elseif (preg_match('/^'.self::CALCULATION_REGEXP_CELLREF.'$/i', $token, $matches)) { - $cellRef = null; + $cellRef = NULL; // echo 'Element '.$token.' is a Cell reference
'; if (isset($matches[8])) { // echo 'Reference is a Range of cells
'; @@ -3197,29 +3283,29 @@ class PHPExcel_Calculation { $cellRef = $matches[6].$matches[7].':'.$matches[9].$matches[10]; if ($matches[2] > '') { $matches[2] = trim($matches[2],"\"'"); - if ((strpos($matches[2],'[') !== false) || (strpos($matches[2],']') !== false)) { + if ((strpos($matches[2],'[') !== FALSE) || (strpos($matches[2],']') !== FALSE)) { // It's a Reference to an external workbook (not currently supported) return $this->_raiseFormulaError('Unable to access External Workbook'); } $matches[2] = trim($matches[2],"\"'"); // echo '$cellRef='.$cellRef.' in worksheet '.$matches[2].'
'; - $this->_writeDebug('Evaluating Cell Range '.$cellRef.' in worksheet '.$matches[2]); + $this->_debugLog->writeDebugLog('Evaluating Cell Range ', $cellRef, ' in worksheet ', $matches[2]); if ($pCellParent !== NULL) { - $cellValue = $this->extractCellRange($cellRef, $pCellParent->getParent()->getSheetByName($matches[2]), false); + $cellValue = $this->extractCellRange($cellRef, $this->_workbook->getSheetByName($matches[2]), FALSE); } else { return $this->_raiseFormulaError('Unable to access Cell Reference'); } - $this->_writeDebug('Evaluation Result for cells '.$cellRef.' in worksheet '.$matches[2].' is '.$this->_showTypeDetails($cellValue)); + $this->_debugLog->writeDebugLog('Evaluation Result for cells ', $cellRef, ' in worksheet ', $matches[2], ' is ', $this->_showTypeDetails($cellValue)); // $cellRef = $matches[2].'!'.$cellRef; } else { // echo '$cellRef='.$cellRef.' in current worksheet
'; - $this->_writeDebug('Evaluating Cell Range '.$cellRef.' in current worksheet'); + $this->_debugLog->writeDebugLog('Evaluating Cell Range ', $cellRef, ' in current worksheet'); if ($pCellParent !== NULL) { - $cellValue = $this->extractCellRange($cellRef, $pCellParent, false); + $cellValue = $this->extractCellRange($cellRef, $pCellWorksheet, FALSE); } else { return $this->_raiseFormulaError('Unable to access Cell Reference'); } - $this->_writeDebug('Evaluation Result for cells '.$cellRef.' is '.$this->_showTypeDetails($cellValue)); + $this->_debugLog->writeDebugLog('Evaluation Result for cells ', $cellRef, ' is ', $this->_showTypeDetails($cellValue)); } } } else { @@ -3231,34 +3317,35 @@ class PHPExcel_Calculation { $cellRef = $matches[6].$matches[7]; if ($matches[2] > '') { $matches[2] = trim($matches[2],"\"'"); - if ((strpos($matches[2],'[') !== false) || (strpos($matches[2],']') !== false)) { + if ((strpos($matches[2],'[') !== FALSE) || (strpos($matches[2],']') !== FALSE)) { // It's a Reference to an external workbook (not currently supported) return $this->_raiseFormulaError('Unable to access External Workbook'); } // echo '$cellRef='.$cellRef.' in worksheet '.$matches[2].'
'; - $this->_writeDebug('Evaluating Cell '.$cellRef.' in worksheet '.$matches[2]); + $this->_debugLog->writeDebugLog('Evaluating Cell ', $cellRef, ' in worksheet ', $matches[2]); if ($pCellParent !== NULL) { - if ($pCellParent->getParent()->getSheetByName($matches[2])->cellExists($cellRef)) { - $cellValue = $this->extractCellRange($cellRef, $pCellParent->getParent()->getSheetByName($matches[2]), false); + $cellSheet = $this->_workbook->getSheetByName($matches[2]); + if ($cellSheet && $cellSheet->cellExists($cellRef)) { + $cellValue = $this->extractCellRange($cellRef, $this->_workbook->getSheetByName($matches[2]), FALSE); $pCell->attach($pCellParent); } else { - $cellValue = null; + $cellValue = NULL; } } else { return $this->_raiseFormulaError('Unable to access Cell Reference'); } - $this->_writeDebug('Evaluation Result for cell '.$cellRef.' in worksheet '.$matches[2].' is '.$this->_showTypeDetails($cellValue)); + $this->_debugLog->writeDebugLog('Evaluation Result for cell ', $cellRef, ' in worksheet ', $matches[2], ' is ', $this->_showTypeDetails($cellValue)); // $cellRef = $matches[2].'!'.$cellRef; } else { // echo '$cellRef='.$cellRef.' in current worksheet
'; - $this->_writeDebug('Evaluating Cell '.$cellRef.' in current worksheet'); - if ($pCellParent->cellExists($cellRef)) { - $cellValue = $this->extractCellRange($cellRef, $pCellParent, false); + $this->_debugLog->writeDebugLog('Evaluating Cell ', $cellRef, ' in current worksheet'); + if ($pCellParent->isDataSet($cellRef)) { + $cellValue = $this->extractCellRange($cellRef, $pCellWorksheet, FALSE); $pCell->attach($pCellParent); } else { - $cellValue = null; + $cellValue = NULL; } - $this->_writeDebug('Evaluation Result for cell '.$cellRef.' is '.$this->_showTypeDetails($cellValue)); + $this->_debugLog->writeDebugLog('Evaluation Result for cell ', $cellRef, ' is ', $this->_showTypeDetails($cellValue)); } } } @@ -3271,7 +3358,7 @@ class PHPExcel_Calculation { $argCount = $stack->pop(); $argCount = $argCount['value']; if ($functionName != 'MKMATRIX') { - $this->_writeDebug('Evaluating Function '.self::_localeFunc($functionName).'() with '.(($argCount == 0) ? 'no' : $argCount).' argument'.(($argCount == 1) ? '' : 's')); + $this->_debugLog->writeDebugLog('Evaluating Function ', self::_localeFunc($functionName), '() with ', (($argCount == 0) ? 'no' : $argCount), ' argument', (($argCount == 1) ? '' : 's')); } if ((isset(self::$_PHPExcelFunctions[$functionName])) || (isset(self::$_controlFunctions[$functionName]))) { // function if (isset(self::$_PHPExcelFunctions[$functionName])) { @@ -3314,30 +3401,30 @@ class PHPExcel_Calculation { // print_r($args); // echo '
'; if ($functionName != 'MKMATRIX') { - if ($this->writeDebugLog) { + if ($this->_debugLog->getWriteDebugLog()) { krsort($argArrayVals); - $this->_writeDebug('Evaluating '. self::_localeFunc($functionName).'( '.implode(self::$_localeArgumentSeparator.' ',PHPExcel_Calculation_Functions::flattenArray($argArrayVals)).' )'); + $this->_debugLog->writeDebugLog('Evaluating ', self::_localeFunc($functionName), '( ', implode(self::$_localeArgumentSeparator.' ',PHPExcel_Calculation_Functions::flattenArray($argArrayVals)), ' )'); } } // Process each argument in turn, building the return value as an array // if (($argCount == 1) && (is_array($args[1])) && ($functionName != 'MKMATRIX')) { // $operand1 = $args[1]; -// $this->_writeDebug('Argument is a matrix: '.$this->_showValue($operand1)); +// $this->_debugLog->writeDebugLog('Argument is a matrix: ', $this->_showValue($operand1)); // $result = array(); // $row = 0; // foreach($operand1 as $args) { // if (is_array($args)) { // foreach($args as $arg) { -// $this->_writeDebug('Evaluating '.self::_localeFunc($functionName).'( '.$this->_showValue($arg).' )'); +// $this->_debugLog->writeDebugLog('Evaluating ', self::_localeFunc($functionName), '( ', $this->_showValue($arg), ' )'); // $r = call_user_func_array($functionCall,$arg); -// $this->_writeDebug('Evaluation Result for '.self::_localeFunc($functionName).'() function call is '.$this->_showTypeDetails($r)); +// $this->_debugLog->writeDebugLog('Evaluation Result for ', self::_localeFunc($functionName), '() function call is ', $this->_showTypeDetails($r)); // $result[$row][] = $r; // } // ++$row; // } else { -// $this->_writeDebug('Evaluating '.self::_localeFunc($functionName).'( '.$this->_showValue($args).' )'); +// $this->_debugLog->writeDebugLog('Evaluating ', self::_localeFunc($functionName), '( ', $this->_showValue($args), ' )'); // $r = call_user_func_array($functionCall,$args); -// $this->_writeDebug('Evaluation Result for '.self::_localeFunc($functionName).'() function call is '.$this->_showTypeDetails($r)); +// $this->_debugLog->writeDebugLog('Evaluation Result for ', self::_localeFunc($functionName), '() function call is ', $this->_showTypeDetails($r)); // $result[] = $r; // } // } @@ -3346,7 +3433,7 @@ class PHPExcel_Calculation { if ($passCellReference) { $args[] = $pCell; } - if (strpos($functionCall,'::') !== false) { + if (strpos($functionCall,'::') !== FALSE) { $result = call_user_func_array(explode('::',$functionCall),$args); } else { foreach($args as &$arg) { @@ -3357,7 +3444,7 @@ class PHPExcel_Calculation { } // } if ($functionName != 'MKMATRIX') { - $this->_writeDebug('Evaluation Result for '.self::_localeFunc($functionName).'() function call is '.$this->_showTypeDetails($result)); + $this->_debugLog->writeDebugLog('Evaluation Result for ', self::_localeFunc($functionName), '() function call is ', $this->_showTypeDetails($result)); } $stack->push('Value',self::_wrapResult($result)); } @@ -3368,7 +3455,7 @@ class PHPExcel_Calculation { $excelConstant = strtoupper($token); // echo 'Token is a PHPExcel constant: '.$excelConstant.'
'; $stack->push('Constant Value',self::$_ExcelConstants[$excelConstant]); - $this->_writeDebug('Evaluating Constant '.$excelConstant.' as '.$this->_showTypeDetails(self::$_ExcelConstants[$excelConstant])); + $this->_debugLog->writeDebugLog('Evaluating Constant ', $excelConstant, ' as ', $this->_showTypeDetails(self::$_ExcelConstants[$excelConstant])); } elseif ((is_numeric($token)) || ($token === NULL) || (is_bool($token)) || ($token == '') || ($token{0} == '"') || ($token{0} == '#')) { // echo 'Token is a number, boolean, string, null or an Excel error
'; $stack->push('Value',$token); @@ -3377,10 +3464,10 @@ class PHPExcel_Calculation { // echo 'Token is a named range
'; $namedRange = $matches[6]; // echo 'Named Range is '.$namedRange.'
'; - $this->_writeDebug('Evaluating Named Range '.$namedRange); - $cellValue = $this->extractNamedRange($namedRange, ((null !== $pCell) ? $pCellParent : null), false); + $this->_debugLog->writeDebugLog('Evaluating Named Range ', $namedRange); + $cellValue = $this->extractNamedRange($namedRange, ((NULL !== $pCell) ? $pCellWorksheet : NULL), FALSE); $pCell->attach($pCellParent); - $this->_writeDebug('Evaluation Result for named range '.$namedRange.' is '.$this->_showTypeDetails($cellValue)); + $this->_debugLog->writeDebugLog('Evaluation Result for named range ', $namedRange, ' is ', $this->_showTypeDetails($cellValue)); $stack->push('Named Range',$cellValue,$namedRange); } else { return $this->_raiseFormulaError("undefined variable '$token'"); @@ -3399,7 +3486,14 @@ class PHPExcel_Calculation { } // function _processTokenStack() - private function _validateBinaryOperand($cellID,&$operand,&$stack) { + private function _validateBinaryOperand($cellID, &$operand, &$stack) { + if (is_array($operand)) { + if ((count($operand, COUNT_RECURSIVE) - count($operand)) == 1) { + do { + $operand = array_pop($operand); + } while (is_array($operand)); + } + } // Numbers, matrices and booleans can pass straight through, as they're already valid if (is_string($operand)) { // We only need special validations for the operand if it is a string @@ -3410,36 +3504,36 @@ class PHPExcel_Calculation { // If not a numeric, test to see if the value is an Excel error, and so can't be used in normal binary operations if ($operand > '' && $operand{0} == '#') { $stack->push('Value', $operand); - $this->_writeDebug('Evaluation Result is '.$this->_showTypeDetails($operand)); - return false; + $this->_debugLog->writeDebugLog('Evaluation Result is ', $this->_showTypeDetails($operand)); + return FALSE; } elseif (!PHPExcel_Shared_String::convertToNumberIfFraction($operand)) { // If not a numeric or a fraction, then it's a text string, and so can't be used in mathematical binary operations $stack->push('Value', '#VALUE!'); - $this->_writeDebug('Evaluation Result is a '.$this->_showTypeDetails('#VALUE!')); - return false; + $this->_debugLog->writeDebugLog('Evaluation Result is a ', $this->_showTypeDetails('#VALUE!')); + return FALSE; } } } // return a true if the value of the operand is one that we can use in normal binary operations - return true; + return TRUE; } // function _validateBinaryOperand() - private function _executeBinaryComparisonOperation($cellID,$operand1,$operand2,$operation,&$stack,$recursingArrays=false) { + private function _executeBinaryComparisonOperation($cellID, $operand1, $operand2, $operation, &$stack, $recursingArrays=FALSE) { // If we're dealing with matrix operations, we want a matrix result if ((is_array($operand1)) || (is_array($operand2))) { $result = array(); if ((is_array($operand1)) && (!is_array($operand2))) { foreach($operand1 as $x => $operandData) { - $this->_writeDebug('Evaluating Comparison '.$this->_showValue($operandData).' '.$operation.' '.$this->_showValue($operand2)); + $this->_debugLog->writeDebugLog('Evaluating Comparison ', $this->_showValue($operandData), ' ', $operation, ' ', $this->_showValue($operand2)); $this->_executeBinaryComparisonOperation($cellID,$operandData,$operand2,$operation,$stack); $r = $stack->pop(); $result[$x] = $r['value']; } } elseif ((!is_array($operand1)) && (is_array($operand2))) { foreach($operand2 as $x => $operandData) { - $this->_writeDebug('Evaluating Comparison '.$this->_showValue($operand1).' '.$operation.' '.$this->_showValue($operandData)); + $this->_debugLog->writeDebugLog('Evaluating Comparison ', $this->_showValue($operand1), ' ', $operation, ' ', $this->_showValue($operandData)); $this->_executeBinaryComparisonOperation($cellID,$operand1,$operandData,$operation,$stack); $r = $stack->pop(); $result[$x] = $r['value']; @@ -3447,32 +3541,54 @@ class PHPExcel_Calculation { } else { if (!$recursingArrays) { self::_checkMatrixOperands($operand1,$operand2,2); } foreach($operand1 as $x => $operandData) { - $this->_writeDebug('Evaluating Comparison '.$this->_showValue($operandData).' '.$operation.' '.$this->_showValue($operand2[$x])); - $this->_executeBinaryComparisonOperation($cellID,$operandData,$operand2[$x],$operation,$stack,true); + $this->_debugLog->writeDebugLog('Evaluating Comparison ', $this->_showValue($operandData), ' ', $operation, ' ', $this->_showValue($operand2[$x])); + $this->_executeBinaryComparisonOperation($cellID,$operandData,$operand2[$x],$operation,$stack,TRUE); $r = $stack->pop(); $result[$x] = $r['value']; } } // Log the result details - $this->_writeDebug('Comparison Evaluation Result is '.$this->_showTypeDetails($result)); + $this->_debugLog->writeDebugLog('Comparison Evaluation Result is ', $this->_showTypeDetails($result)); // And push the result onto the stack $stack->push('Array',$result); - return true; + return TRUE; } // Simple validate the two operands if they are string values if (is_string($operand1) && $operand1 > '' && $operand1{0} == '"') { $operand1 = self::_unwrapResult($operand1); } if (is_string($operand2) && $operand2 > '' && $operand2{0} == '"') { $operand2 = self::_unwrapResult($operand2); } + // Use case insensitive comparaison if not OpenOffice mode + if (PHPExcel_Calculation_Functions::getCompatibilityMode() != PHPExcel_Calculation_Functions::COMPATIBILITY_OPENOFFICE) + { + if (is_string($operand1)) { + $operand1 = strtoupper($operand1); + } + + if (is_string($operand2)) { + $operand2 = strtoupper($operand2); + } + } + + $useLowercaseFirstComparison = is_string($operand1) && is_string($operand2) && PHPExcel_Calculation_Functions::getCompatibilityMode() == PHPExcel_Calculation_Functions::COMPATIBILITY_OPENOFFICE; + // execute the necessary operation switch ($operation) { // Greater than case '>': - $result = ($operand1 > $operand2); + if ($useLowercaseFirstComparison) { + $result = $this->strcmpLowercaseFirst($operand1, $operand2) > 0; + } else { + $result = ($operand1 > $operand2); + } break; // Less than case '<': - $result = ($operand1 < $operand2); + if ($useLowercaseFirstComparison) { + $result = $this->strcmpLowercaseFirst($operand1, $operand2) < 0; + } else { + $result = ($operand1 < $operand2); + } break; // Equality case '=': @@ -3480,11 +3596,19 @@ class PHPExcel_Calculation { break; // Greater than or equal case '>=': - $result = ($operand1 >= $operand2); + if ($useLowercaseFirstComparison) { + $result = $this->strcmpLowercaseFirst($operand1, $operand2) >= 0; + } else { + $result = ($operand1 >= $operand2); + } break; // Less than or equal case '<=': - $result = ($operand1 <= $operand2); + if ($useLowercaseFirstComparison) { + $result = $this->strcmpLowercaseFirst($operand1, $operand2) <= 0; + } else { + $result = ($operand1 <= $operand2); + } break; // Inequality case '<>': @@ -3493,109 +3617,102 @@ class PHPExcel_Calculation { } // Log the result details - $this->_writeDebug('Evaluation Result is '.$this->_showTypeDetails($result)); + $this->_debugLog->writeDebugLog('Evaluation Result is ', $this->_showTypeDetails($result)); // And push the result onto the stack $stack->push('Value',$result); - return true; + return TRUE; } // function _executeBinaryComparisonOperation() + /** + * Compare two strings in the same way as strcmp() except that lowercase come before uppercase letters + * @param string $str1 + * @param string $str2 + * @return integer + */ + private function strcmpLowercaseFirst($str1, $str2) + { + $from = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'; + $to = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; + $inversedStr1 = strtr($str1, $from, $to); + $inversedStr2 = strtr($str2, $from, $to); + + return strcmp($inversedStr1, $inversedStr2); + } private function _executeNumericBinaryOperation($cellID,$operand1,$operand2,$operation,$matrixFunction,&$stack) { // Validate the two operands - if (!$this->_validateBinaryOperand($cellID,$operand1,$stack)) return false; - if (!$this->_validateBinaryOperand($cellID,$operand2,$stack)) return false; + if (!$this->_validateBinaryOperand($cellID,$operand1,$stack)) return FALSE; + if (!$this->_validateBinaryOperand($cellID,$operand2,$stack)) return FALSE; - $executeMatrixOperation = false; // If either of the operands is a matrix, we need to treat them both as matrices // (converting the other operand to a matrix if need be); then perform the required // matrix operation if ((is_array($operand1)) || (is_array($operand2))) { - // Ensure that both operands are arrays/matrices - $executeMatrixOperation = true; - $mSize = array(); - list($mSize[],$mSize[],$mSize[],$mSize[]) = self::_checkMatrixOperands($operand1,$operand2,2); + // Ensure that both operands are arrays/matrices of the same size + self::_checkMatrixOperands($operand1, $operand2, 2); - // But if they're both single cell matrices, then we can treat them as simple values - if (array_sum($mSize) == 4) { - $executeMatrixOperation = false; - $operand1 = $operand1[0][0]; - $operand2 = $operand2[0][0]; - } - } - - if ($executeMatrixOperation) { try { // Convert operand 1 from a PHP array to a matrix $matrix = new PHPExcel_Shared_JAMA_Matrix($operand1); // Perform the required operation against the operand 1 matrix, passing in operand 2 $matrixResult = $matrix->$matrixFunction($operand2); $result = $matrixResult->getArray(); - } catch (Exception $ex) { - $this->_writeDebug('JAMA Matrix Exception: '.$ex->getMessage()); + } catch (PHPExcel_Exception $ex) { + $this->_debugLog->writeDebugLog('JAMA Matrix Exception: ', $ex->getMessage()); $result = '#VALUE!'; } } else { if ((PHPExcel_Calculation_Functions::getCompatibilityMode() != PHPExcel_Calculation_Functions::COMPATIBILITY_OPENOFFICE) && - ((is_string($operand1) && !is_numeric($operand1)) || (is_string($operand2) && !is_numeric($operand2)))) { + ((is_string($operand1) && !is_numeric($operand1) && strlen($operand1)>0) || + (is_string($operand2) && !is_numeric($operand2) && strlen($operand2)>0))) { $result = PHPExcel_Calculation_Functions::VALUE(); } else { // If we're dealing with non-matrix operations, execute the necessary operation switch ($operation) { // Addition case '+': - $result = $operand1+$operand2; + $result = $operand1 + $operand2; break; // Subtraction case '-': - $result = $operand1-$operand2; + $result = $operand1 - $operand2; break; // Multiplication case '*': - $result = $operand1*$operand2; + $result = $operand1 * $operand2; break; // Division case '/': if ($operand2 == 0) { // Trap for Divide by Zero error $stack->push('Value','#DIV/0!'); - $this->_writeDebug('Evaluation Result is '.$this->_showTypeDetails('#DIV/0!')); - return false; + $this->_debugLog->writeDebugLog('Evaluation Result is ', $this->_showTypeDetails('#DIV/0!')); + return FALSE; } else { - $result = $operand1/$operand2; + $result = $operand1 / $operand2; } break; // Power case '^': - $result = pow($operand1,$operand2); + $result = pow($operand1, $operand2); break; } } } // Log the result details - $this->_writeDebug('Evaluation Result is '.$this->_showTypeDetails($result)); + $this->_debugLog->writeDebugLog('Evaluation Result is ', $this->_showTypeDetails($result)); // And push the result onto the stack $stack->push('Value',$result); - return true; + return TRUE; } // function _executeNumericBinaryOperation() - private function _writeDebug($message) { - // Only write the debug log if logging is enabled - if ($this->writeDebugLog) { - if ($this->echoDebugLog) { - echo implode(' -> ',$this->debugLogStack).' -> '.$message,'
'; - } - $this->debugLog[] = implode(' -> ',$this->debugLogStack).' -> '.$message; - } - } // function _writeDebug() - - // trigger an error, but nicely, if need be protected function _raiseFormulaError($errorMessage) { $this->formulaError = $errorMessage; - $this->debugLogStack = array(); - if (!$this->suppressFormulaErrors) throw new Exception($errorMessage); + $this->_cyclicReferenceStack->clear(); + if (!$this->suppressFormulaErrors) throw new PHPExcel_Calculation_Exception($errorMessage); trigger_error($errorMessage, E_USER_ERROR); } // function _raiseFormulaError() @@ -3603,49 +3720,51 @@ class PHPExcel_Calculation { /** * Extract range values * - * @param string &$pRange String based range representation + * @param string &$pRange String based range representation * @param PHPExcel_Worksheet $pSheet Worksheet + * @param boolean $resetLog Flag indicating whether calculation log should be reset or not * @return mixed Array of values in range if range contains more than one element. Otherwise, a single value is returned. - * @throws Exception + * @throws PHPExcel_Calculation_Exception */ - public function extractCellRange(&$pRange = 'A1', PHPExcel_Worksheet $pSheet = null, $resetLog=true) { + public function extractCellRange(&$pRange = 'A1', PHPExcel_Worksheet $pSheet = NULL, $resetLog = TRUE) { // Return value $returnValue = array (); -// echo 'extractCellRange('.$pRange.')
'; +// echo 'extractCellRange('.$pRange.')',PHP_EOL; if ($pSheet !== NULL) { -// echo 'Passed sheet name is '.$pSheet->getTitle().'
'; -// echo 'Range reference is '.$pRange.'
'; + $pSheetName = $pSheet->getTitle(); +// echo 'Passed sheet name is '.$pSheetName.PHP_EOL; +// echo 'Range reference is '.$pRange.PHP_EOL; if (strpos ($pRange, '!') !== false) { -// echo '$pRange reference includes sheet reference
'; - $worksheetReference = PHPExcel_Worksheet::extractSheetTitle($pRange, true); - $pSheet = $pSheet->getParent()->getSheetByName($worksheetReference[0]); -// echo 'New sheet name is '.$pSheet->getTitle().'
'; - $pRange = $worksheetReference[1]; -// echo 'Adjusted Range reference is '.$pRange.'
'; +// echo '$pRange reference includes sheet reference',PHP_EOL; + list($pSheetName,$pRange) = PHPExcel_Worksheet::extractSheetTitle($pRange, true); +// echo 'New sheet name is '.$pSheetName,PHP_EOL; +// echo 'Adjusted Range reference is '.$pRange,PHP_EOL; + $pSheet = $this->_workbook->getSheetByName($pSheetName); } // Extract range $aReferences = PHPExcel_Cell::extractAllCellReferencesInRange($pRange); - $pRange = $pSheet->getTitle().'!'.$pRange; + $pRange = $pSheetName.'!'.$pRange; if (!isset($aReferences[1])) { // Single cell in range - list($currentCol,$currentRow) = sscanf($aReferences[0],'%[A-Z]%d'); + sscanf($aReferences[0],'%[A-Z]%d', $currentCol, $currentRow); + $cellValue = NULL; if ($pSheet->cellExists($aReferences[0])) { $returnValue[$currentRow][$currentCol] = $pSheet->getCell($aReferences[0])->getCalculatedValue($resetLog); } else { - $returnValue[$currentRow][$currentCol] = null; + $returnValue[$currentRow][$currentCol] = NULL; } } else { // Extract cell data for all cells in the range foreach ($aReferences as $reference) { // Extract range - list($currentCol,$currentRow) = sscanf($reference,'%[A-Z]%d'); - + sscanf($reference,'%[A-Z]%d', $currentCol, $currentRow); + $cellValue = NULL; if ($pSheet->cellExists($reference)) { $returnValue[$currentRow][$currentCol] = $pSheet->getCell($reference)->getCalculatedValue($resetLog); } else { - $returnValue[$currentRow][$currentCol] = null; + $returnValue[$currentRow][$currentCol] = NULL; } } } @@ -3662,23 +3781,24 @@ class PHPExcel_Calculation { * @param string &$pRange String based range representation * @param PHPExcel_Worksheet $pSheet Worksheet * @return mixed Array of values in range if range contains more than one element. Otherwise, a single value is returned. - * @throws Exception + * @param boolean $resetLog Flag indicating whether calculation log should be reset or not + * @throws PHPExcel_Calculation_Exception */ - public function extractNamedRange(&$pRange = 'A1', PHPExcel_Worksheet $pSheet = null, $resetLog=true) { + public function extractNamedRange(&$pRange = 'A1', PHPExcel_Worksheet $pSheet = NULL, $resetLog = TRUE) { // Return value $returnValue = array (); // echo 'extractNamedRange('.$pRange.')
'; if ($pSheet !== NULL) { -// echo 'Current sheet name is '.$pSheet->getTitle().'
'; + $pSheetName = $pSheet->getTitle(); +// echo 'Current sheet name is '.$pSheetName.'
'; // echo 'Range reference is '.$pRange.'
'; if (strpos ($pRange, '!') !== false) { -// echo '$pRange reference includes sheet reference
'; - $worksheetReference = PHPExcel_Worksheet::extractSheetTitle($pRange, true); - $pSheet = $pSheet->getParent()->getSheetByName($worksheetReference[0]); -// echo 'New sheet name is '.$pSheet->getTitle().'
'; - $pRange = $worksheetReference[1]; -// echo 'Adjusted Range reference is '.$pRange.'
'; +// echo '$pRange reference includes sheet reference',PHP_EOL; + list($pSheetName,$pRange) = PHPExcel_Worksheet::extractSheetTitle($pRange, true); +// echo 'New sheet name is '.$pSheetName,PHP_EOL; +// echo 'Adjusted Range reference is '.$pRange,PHP_EOL; + $pSheet = $this->_workbook->getSheetByName($pSheetName); } // Named range? @@ -3713,10 +3833,11 @@ class PHPExcel_Calculation { if (!isset($aReferences[1])) { // Single cell (or single column or row) in range list($currentCol,$currentRow) = PHPExcel_Cell::coordinateFromString($aReferences[0]); + $cellValue = NULL; if ($pSheet->cellExists($aReferences[0])) { $returnValue[$currentRow][$currentCol] = $pSheet->getCell($aReferences[0])->getCalculatedValue($resetLog); } else { - $returnValue[$currentRow][$currentCol] = null; + $returnValue[$currentRow][$currentCol] = NULL; } } else { // Extract cell data for all cells in the range @@ -3724,10 +3845,11 @@ class PHPExcel_Calculation { // Extract range list($currentCol,$currentRow) = PHPExcel_Cell::coordinateFromString($reference); // echo 'NAMED RANGE: $currentCol='.$currentCol.' $currentRow='.$currentRow.'
'; + $cellValue = NULL; if ($pSheet->cellExists($reference)) { $returnValue[$currentRow][$currentCol] = $pSheet->getCell($reference)->getCalculatedValue($resetLog); } else { - $returnValue[$currentRow][$currentCol] = null; + $returnValue[$currentRow][$currentCol] = NULL; } } } @@ -3751,7 +3873,7 @@ class PHPExcel_Calculation { if (isset(self::$_PHPExcelFunctions[$pFunction])) { return (self::$_PHPExcelFunctions[$pFunction]['functionCall'] != 'PHPExcel_Calculation_Functions::DUMMY'); } else { - return false; + return FALSE; } } // function isImplemented() diff --git a/htdocs/includes/phpexcel/PHPExcel/Calculation/Database.php b/htdocs/includes/phpexcel/PHPExcel/Calculation/Database.php index 4a6c8f72c9a..c3e86d761cb 100644 --- a/htdocs/includes/phpexcel/PHPExcel/Calculation/Database.php +++ b/htdocs/includes/phpexcel/PHPExcel/Calculation/Database.php @@ -2,7 +2,7 @@ /** * PHPExcel * - * Copyright (c) 2006 - 2012 PHPExcel + * Copyright (c) 2006 - 2014 PHPExcel * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,9 +20,9 @@ * * @category PHPExcel * @package PHPExcel_Calculation - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version 1.7.8, 2012-10-12 + * @version 1.8.0, 2014-03-02 */ @@ -41,7 +41,7 @@ if (!defined('PHPEXCEL_ROOT')) { * * @category PHPExcel * @package PHPExcel_Calculation - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) */ class PHPExcel_Calculation_Database { diff --git a/htdocs/includes/phpexcel/PHPExcel/Calculation/DateTime.php b/htdocs/includes/phpexcel/PHPExcel/Calculation/DateTime.php index 3b5dc45aaaa..debd1315073 100644 --- a/htdocs/includes/phpexcel/PHPExcel/Calculation/DateTime.php +++ b/htdocs/includes/phpexcel/PHPExcel/Calculation/DateTime.php @@ -2,7 +2,7 @@ /** * PHPExcel * - * Copyright (c) 2006 - 2012 PHPExcel + * Copyright (c) 2006 - 2014 PHPExcel * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,9 +20,9 @@ * * @category PHPExcel * @package PHPExcel_Calculation - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version 1.7.8, 2012-10-12 + * @version 1.8.0, 2014-03-02 */ @@ -41,7 +41,7 @@ if (!defined('PHPEXCEL_ROOT')) { * * @category PHPExcel * @package PHPExcel_Calculation - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) */ class PHPExcel_Calculation_DateTime { @@ -56,6 +56,18 @@ class PHPExcel_Calculation_DateTime { } // function _isLeapYear() + /** + * Return the number of days between two dates based on a 360 day calendar + * + * @param integer $startDay Day of month of the start date + * @param integer $startMonth Month of the start date + * @param integer $startYear Year of the start date + * @param integer $endDay Day of month of the start date + * @param integer $endMonth Month of the start date + * @param integer $endYear Year of the start date + * @param boolean $methodUS Whether to use the US method or the European method of calculation + * @return integer Number of days between the start date and the end date + */ private static function _dateDiff360($startDay, $startMonth, $startYear, $endDay, $endMonth, $endYear, $methodUS) { if ($startDay == 31) { --$startDay; @@ -92,7 +104,7 @@ class PHPExcel_Calculation_DateTime { (PHPExcel_Calculation_Functions::getCompatibilityMode() == PHPExcel_Calculation_Functions::COMPATIBILITY_GNUMERIC)) { return PHPExcel_Calculation_Functions::VALUE(); } - if ((is_object($dateValue)) && ($dateValue instanceof PHPExcel_Shared_Date::$dateTimeObjectType)) { + if ((is_object($dateValue)) && ($dateValue instanceof DateTime)) { $dateValue = PHPExcel_Shared_Date::PHPToExcel($dateValue); } else { $saveReturnDateType = PHPExcel_Calculation_Functions::getReturnDateType(); @@ -238,6 +250,10 @@ class PHPExcel_Calculation_DateTime { * Excel Function: * DATE(year,month,day) * + * PHPExcel is a lot more forgiving than MS Excel when passing non numeric values to this function. + * A Month name or abbreviation (English only at this point) such as 'January' or 'Jan' will still be accepted, + * as will a day value with a suffix (e.g. '21st' rather than simply 21); again only English language. + * * @access public * @category Date/Time Functions * @param integer $year The value of the year argument can include one to four digits. @@ -278,6 +294,14 @@ class PHPExcel_Calculation_DateTime { $month = PHPExcel_Calculation_Functions::flattenSingleValue($month); $day = PHPExcel_Calculation_Functions::flattenSingleValue($day); + if (($month !== NULL) && (!is_numeric($month))) { + $month = PHPExcel_Shared_Date::monthStringToNumber($month); + } + + if (($day !== NULL) && (!is_numeric($day))) { + $day = PHPExcel_Shared_Date::dayStringToNumber($day); + } + $year = ($year !== NULL) ? PHPExcel_Shared_String::testStringAsNumeric($year) : 0; $month = ($month !== NULL) ? PHPExcel_Shared_String::testStringAsNumeric($month) : 0; $day = ($day !== NULL) ? PHPExcel_Shared_String::testStringAsNumeric($day) : 0; @@ -720,6 +744,10 @@ class PHPExcel_Calculation_DateTime { return PHPExcel_Calculation_Functions::VALUE(); } + if (!is_bool($method)) { + return PHPExcel_Calculation_Functions::VALUE(); + } + // Execute function $PHPStartDateObject = PHPExcel_Shared_Date::ExcelToPHPObject($startDate); $startDay = $PHPStartDateObject->format('j'); diff --git a/htdocs/includes/phpexcel/PHPExcel/Calculation/Engineering.php b/htdocs/includes/phpexcel/PHPExcel/Calculation/Engineering.php index cfaffafbab5..7e32aa87081 100644 --- a/htdocs/includes/phpexcel/PHPExcel/Calculation/Engineering.php +++ b/htdocs/includes/phpexcel/PHPExcel/Calculation/Engineering.php @@ -2,7 +2,7 @@ /** * PHPExcel * - * Copyright (c) 2006 - 2012 PHPExcel + * Copyright (c) 2006 - 2014 PHPExcel * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,9 +20,9 @@ * * @category PHPExcel * @package PHPExcel_Calculation - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version 1.7.8, 2012-10-12 + * @version 1.8.0, 2014-03-02 */ @@ -45,7 +45,7 @@ define('EULER', 2.71828182845904523536); * * @category PHPExcel * @package PHPExcel_Calculation - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) */ class PHPExcel_Calculation_Engineering { @@ -741,8 +741,6 @@ class PHPExcel_Calculation_Engineering { /** - * _cleanComplex - * * Cleans the leading characters in a complex number string * * @param string $complexNumber The complex number to clean @@ -756,20 +754,25 @@ class PHPExcel_Calculation_Engineering { return $complexNumber; } - - private static function _nbrConversionFormat($xVal,$places) { + /** + * Formats a number base string value with leading zeroes + * + * @param string $xVal The "number" to pad + * @param integer $places The length that we want to pad this value + * @return string The padded "number" + */ + private static function _nbrConversionFormat($xVal, $places) { if (!is_null($places)) { if (strlen($xVal) <= $places) { - return substr(str_pad($xVal,$places,'0',STR_PAD_LEFT),-10); + return substr(str_pad($xVal, $places, '0', STR_PAD_LEFT), -10); } else { return PHPExcel_Calculation_Functions::NaN(); } } - return substr($xVal,-10); + return substr($xVal, -10); } // function _nbrConversionFormat() - /** * BESSELI * @@ -1932,7 +1935,7 @@ class PHPExcel_Calculation_Engineering { /** * IMLOG2 * - * Returns the common logarithm (base 10) of a complex number in x + yi or x + yj text format. + * Returns the base-2 logarithm of a complex number in x + yi or x + yj text format. * * Excel Function: * IMLOG2(complexNumber) @@ -2356,7 +2359,6 @@ class PHPExcel_Calculation_Engineering { * Returns an array of units of measure, for a specified conversion group, or for all groups * * @param string $group The group whose units of measure you want to retrieve - * * @return array */ public static function getConversionGroupUnits($group = NULL) { @@ -2373,6 +2375,7 @@ class PHPExcel_Calculation_Engineering { /** * getConversionGroupUnitDetails * + * @param string $group The group whose units of measure you want to retrieve * @return array */ public static function getConversionGroupUnitDetails($group = NULL) { diff --git a/htdocs/includes/phpexcel/PHPExcel/Calculation/Exception.php b/htdocs/includes/phpexcel/PHPExcel/Calculation/Exception.php index 31aa287a2a4..037f7884af1 100644 --- a/htdocs/includes/phpexcel/PHPExcel/Calculation/Exception.php +++ b/htdocs/includes/phpexcel/PHPExcel/Calculation/Exception.php @@ -2,7 +2,7 @@ /** * PHPExcel * - * Copyright (c) 2006 - 2012 PHPExcel + * Copyright (c) 2006 - 2014 PHPExcel * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,9 +20,9 @@ * * @category PHPExcel * @package PHPExcel_Calculation - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version 1.7.8, 2012-10-12 + * @version 1.8.0, 2014-03-02 */ @@ -31,9 +31,9 @@ * * @category PHPExcel * @package PHPExcel_Calculation - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) */ -class PHPExcel_Calculation_Exception extends Exception { +class PHPExcel_Calculation_Exception extends PHPExcel_Exception { /** * Error handler callback * diff --git a/htdocs/includes/phpexcel/PHPExcel/Calculation/ExceptionHandler.php b/htdocs/includes/phpexcel/PHPExcel/Calculation/ExceptionHandler.php index 8b89a8fd6f7..389f6477834 100644 --- a/htdocs/includes/phpexcel/PHPExcel/Calculation/ExceptionHandler.php +++ b/htdocs/includes/phpexcel/PHPExcel/Calculation/ExceptionHandler.php @@ -2,7 +2,7 @@ /** * PHPExcel * - * Copyright (c) 2006 - 2012 PHPExcel + * Copyright (c) 2006 - 2014 PHPExcel * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,9 +20,9 @@ * * @category PHPExcel * @package PHPExcel_Calculation - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version 1.7.8, 2012-10-12 + * @version 1.8.0, 2014-03-02 */ /** @@ -30,7 +30,7 @@ * * @category PHPExcel * @package PHPExcel_Calculation - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) */ class PHPExcel_Calculation_ExceptionHandler { /** diff --git a/htdocs/includes/phpexcel/PHPExcel/Calculation/Financial.php b/htdocs/includes/phpexcel/PHPExcel/Calculation/Financial.php index 8534258e863..525b172109a 100644 --- a/htdocs/includes/phpexcel/PHPExcel/Calculation/Financial.php +++ b/htdocs/includes/phpexcel/PHPExcel/Calculation/Financial.php @@ -2,7 +2,7 @@ /** * PHPExcel * - * Copyright (c) 2006 - 2012 PHPExcel + * Copyright (c) 2006 - 2014 PHPExcel * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,9 +20,9 @@ * * @category PHPExcel * @package PHPExcel_Calculation - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version 1.7.8, 2012-10-12 + * @version 1.8.0, 2014-03-02 */ @@ -48,7 +48,7 @@ define('FINANCIAL_PRECISION', 1.0e-08); * * @category PHPExcel * @package PHPExcel_Calculation - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) */ class PHPExcel_Calculation_Financial { @@ -1206,13 +1206,22 @@ class PHPExcel_Calculation_Financial { /** * FVSCHEDULE * + * Returns the future value of an initial principal after applying a series of compound interest rates. + * Use FVSCHEDULE to calculate the future value of an investment with a variable or adjustable rate. + * + * Excel Function: + * FVSCHEDULE(principal,schedule) + * + * @param float $principal The present value. + * @param float[] $schedule An array of interest rates to apply. + * @return float */ public static function FVSCHEDULE($principal, $schedule) { $principal = PHPExcel_Calculation_Functions::flattenSingleValue($principal); $schedule = PHPExcel_Calculation_Functions::flattenArray($schedule); - foreach($schedule as $n) { - $principal *= 1 + $n; + foreach($schedule as $rate) { + $principal *= 1 + $rate; } return $principal; @@ -1227,13 +1236,13 @@ class PHPExcel_Calculation_Financial { * Excel Function: * INTRATE(settlement,maturity,investment,redemption[,basis]) * - * @param mixed settlement The security's settlement date. + * @param mixed $settlement The security's settlement date. * The security settlement date is the date after the issue date when the security is traded to the buyer. - * @param mixed maturity The security's maturity date. + * @param mixed $maturity The security's maturity date. * The maturity date is the date when the security expires. - * @param integer investment The amount invested in the security. - * @param integer redemption The amount to be received at maturity. - * @param integer basis The type of day count to use. + * @param integer $investment The amount invested in the security. + * @param integer $redemption The amount to be received at maturity. + * @param integer $basis The type of day count to use. * 0 or omitted US (NASD) 30/360 * 1 Actual/actual * 2 Actual/360 @@ -1273,6 +1282,9 @@ class PHPExcel_Calculation_Financial { * * Returns the interest payment for a given period for an investment based on periodic, constant payments and a constant interest rate. * + * Excel Function: + * IPMT(rate,per,nper,pv[,fv][,type]) + * * @param float $rate Interest rate per period * @param int $per Period for which we want to find the interest * @param int $nper Number of periods @@ -1302,7 +1314,25 @@ class PHPExcel_Calculation_Financial { return $interestAndPrincipal[0]; } // function IPMT() - + /** + * IRR + * + * Returns the internal rate of return for a series of cash flows represented by the numbers in values. + * These cash flows do not have to be even, as they would be for an annuity. However, the cash flows must occur + * at regular intervals, such as monthly or annually. The internal rate of return is the interest rate received + * for an investment consisting of payments (negative values) and income (positive values) that occur at regular + * periods. + * + * Excel Function: + * IRR(values[,guess]) + * + * @param float[] $values An array or a reference to cells that contain numbers for which you want + * to calculate the internal rate of return. + * Values must contain at least one positive value and one negative value to + * calculate the internal rate of return. + * @param float $guess A number that you guess is close to the result of IRR + * @return float + */ public static function IRR($values, $guess = 0.1) { if (!is_array($values)) return PHPExcel_Calculation_Functions::VALUE(); $values = PHPExcel_Calculation_Functions::flattenArray($values); @@ -1336,28 +1366,30 @@ class PHPExcel_Calculation_Financial { $dx *= 0.5; $x_mid = $rtb + $dx; $f_mid = self::NPV($x_mid, $values); - if ($f_mid <= 0.0) $rtb = $x_mid; - if ((abs($f_mid) < FINANCIAL_PRECISION) || (abs($dx) < FINANCIAL_PRECISION)) return $x_mid; + if ($f_mid <= 0.0) + $rtb = $x_mid; + if ((abs($f_mid) < FINANCIAL_PRECISION) || (abs($dx) < FINANCIAL_PRECISION)) + return $x_mid; } return PHPExcel_Calculation_Functions::VALUE(); } // function IRR() /** - * ISPMT + * ISPMT * - * Returns the interest payment for an investment based on an interest rate and a constant payment schedule. + * Returns the interest payment for an investment based on an interest rate and a constant payment schedule. * - * Excel Function: - * =ISPMT(interest_rate, period, number_payments, PV) + * Excel Function: + * =ISPMT(interest_rate, period, number_payments, PV) * - * interest_rate is the interest rate for the investment + * interest_rate is the interest rate for the investment * - * period is the period to calculate the interest rate. It must be betweeen 1 and number_payments. + * period is the period to calculate the interest rate. It must be betweeen 1 and number_payments. * - * number_payments is the number of payments for the annuity + * number_payments is the number of payments for the annuity * - * PV is the loan amount or present value of the payments + * PV is the loan amount or present value of the payments */ public static function ISPMT() { // Return value @@ -1384,6 +1416,22 @@ class PHPExcel_Calculation_Financial { } // function ISPMT() + /** + * MIRR + * + * Returns the modified internal rate of return for a series of periodic cash flows. MIRR considers both + * the cost of the investment and the interest received on reinvestment of cash. + * + * Excel Function: + * MIRR(values,finance_rate, reinvestment_rate) + * + * @param float[] $values An array or a reference to cells that contain a series of payments and + * income occurring at regular intervals. + * Payments are negative value, income is positive values. + * @param float $finance_rate The interest rate you pay on the money used in the cash flows + * @param float $reinvestment_rate The interest rate you receive on the cash flows as you reinvest them + * @return float + */ public static function MIRR($values, $finance_rate, $reinvestment_rate) { if (!is_array($values)) return PHPExcel_Calculation_Functions::VALUE(); $values = PHPExcel_Calculation_Functions::flattenArray($values); @@ -1475,14 +1523,11 @@ class PHPExcel_Calculation_Financial { } } // function NPER() - /** * NPV * * Returns the Net Present Value of a cash flow series given a discount rate. * - * @param float Discount interest rate - * @param array Cash flow series * @return float */ public static function NPV() { @@ -1505,7 +1550,6 @@ class PHPExcel_Calculation_Financial { return $returnValue; } // function NPV() - /** * PMT * diff --git a/htdocs/includes/phpexcel/PHPExcel/Calculation/FormulaParser.php b/htdocs/includes/phpexcel/PHPExcel/Calculation/FormulaParser.php index 7318a5b74b4..754a638d4ca 100644 --- a/htdocs/includes/phpexcel/PHPExcel/Calculation/FormulaParser.php +++ b/htdocs/includes/phpexcel/PHPExcel/Calculation/FormulaParser.php @@ -2,7 +2,7 @@ /** * PHPExcel * - * Copyright (c) 2006 - 2012 PHPExcel + * Copyright (c) 2006 - 2014 PHPExcel * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,9 +20,9 @@ * * @category PHPExcel * @package PHPExcel_Calculation - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version 1.7.8, 2012-10-12 + * @version 1.8.0, 2014-03-02 */ @@ -54,7 +54,7 @@ PARTLY BASED ON: * * @category PHPExcel * @package PHPExcel_Calculation - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) */ class PHPExcel_Calculation_FormulaParser { /* Character constants */ @@ -93,13 +93,13 @@ class PHPExcel_Calculation_FormulaParser { * Create a new PHPExcel_Calculation_FormulaParser * * @param string $pFormula Formula to parse - * @throws Exception + * @throws PHPExcel_Calculation_Exception */ public function __construct($pFormula = '') { // Check parameters if (is_null($pFormula)) { - throw new Exception("Invalid parameter passed: formula"); + throw new PHPExcel_Calculation_Exception("Invalid parameter passed: formula"); } // Initialise values @@ -122,13 +122,13 @@ class PHPExcel_Calculation_FormulaParser { * * @param int $pId Token id * @return string - * @throws Exception + * @throws PHPExcel_Calculation_Exception */ public function getToken($pId = 0) { if (isset($this->_tokens[$pId])) { return $this->_tokens[$pId]; } else { - throw new Exception("Token with id $pId does not exist."); + throw new PHPExcel_Calculation_Exception("Token with id $pId does not exist."); } } diff --git a/htdocs/includes/phpexcel/PHPExcel/Calculation/FormulaToken.php b/htdocs/includes/phpexcel/PHPExcel/Calculation/FormulaToken.php index b8a2571aebf..fd5e2e530fd 100644 --- a/htdocs/includes/phpexcel/PHPExcel/Calculation/FormulaToken.php +++ b/htdocs/includes/phpexcel/PHPExcel/Calculation/FormulaToken.php @@ -2,7 +2,7 @@ /** * PHPExcel * - * Copyright (c) 2006 - 2012 PHPExcel + * Copyright (c) 2006 - 2014 PHPExcel * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,9 +20,9 @@ * * @category PHPExcel * @package PHPExcel_Calculation - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version 1.7.8, 2012-10-12 + * @version 1.8.0, 2014-03-02 */ @@ -55,7 +55,7 @@ PARTLY BASED ON: * * @category PHPExcel * @package PHPExcel_Calculation - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) */ class PHPExcel_Calculation_FormulaToken { /* Token types */ diff --git a/htdocs/includes/phpexcel/PHPExcel/Calculation/Function.php b/htdocs/includes/phpexcel/PHPExcel/Calculation/Function.php index 88f8c3b5471..7299834eb69 100644 --- a/htdocs/includes/phpexcel/PHPExcel/Calculation/Function.php +++ b/htdocs/includes/phpexcel/PHPExcel/Calculation/Function.php @@ -2,7 +2,7 @@ /** * PHPExcel * - * Copyright (c) 2006 - 2012 PHPExcel + * Copyright (c) 2006 - 2014 PHPExcel * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,9 +20,9 @@ * * @category PHPExcel * @package PHPExcel_Calculation - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version 1.7.8, 2012-10-12 + * @version 1.8.0, 2014-03-02 */ @@ -31,7 +31,7 @@ * * @category PHPExcel * @package PHPExcel_Calculation - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) */ class PHPExcel_Calculation_Function { /* Function categories */ @@ -74,7 +74,7 @@ class PHPExcel_Calculation_Function { * @param string $pCategory Category (represented by CATEGORY_*) * @param string $pExcelName Excel function name * @param string $pPHPExcelName PHPExcel function mapping - * @throws Exception + * @throws PHPExcel_Calculation_Exception */ public function __construct($pCategory = NULL, $pExcelName = NULL, $pPHPExcelName = NULL) { @@ -84,7 +84,7 @@ class PHPExcel_Calculation_Function { $this->_excelName = $pExcelName; $this->_phpExcelName = $pPHPExcelName; } else { - throw new Exception("Invalid parameters passed."); + throw new PHPExcel_Calculation_Exception("Invalid parameters passed."); } } @@ -101,13 +101,13 @@ class PHPExcel_Calculation_Function { * Set Category (represented by CATEGORY_*) * * @param string $value - * @throws Exception + * @throws PHPExcel_Calculation_Exception */ public function setCategory($value = null) { if (!is_null($value)) { $this->_category = $value; } else { - throw new Exception("Invalid parameter passed."); + throw new PHPExcel_Calculation_Exception("Invalid parameter passed."); } } diff --git a/htdocs/includes/phpexcel/PHPExcel/Calculation/Functions.php b/htdocs/includes/phpexcel/PHPExcel/Calculation/Functions.php index e0a5629559d..71bfa19b6a1 100644 --- a/htdocs/includes/phpexcel/PHPExcel/Calculation/Functions.php +++ b/htdocs/includes/phpexcel/PHPExcel/Calculation/Functions.php @@ -2,7 +2,7 @@ /** * PHPExcel * - * Copyright (c) 2006 - 2012 PHPExcel + * Copyright (c) 2006 - 2014 PHPExcel * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,9 +20,9 @@ * * @category PHPExcel * @package PHPExcel_Calculation - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version 1.7.8, 2012-10-12 + * @version 1.8.0, 2014-03-02 */ @@ -54,7 +54,7 @@ define('PRECISION', 8.88E-016); * * @category PHPExcel * @package PHPExcel_Calculation - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) */ class PHPExcel_Calculation_Functions { @@ -270,7 +270,7 @@ class PHPExcel_Calculation_Functions { * * @access public * @category Error Returns - * @return string #REF! + * @return string #NULL! */ public static function NULL() { return self::$_errorCodes['null']; @@ -308,13 +308,20 @@ class PHPExcel_Calculation_Functions { public static function _ifCondition($condition) { $condition = PHPExcel_Calculation_Functions::flattenSingleValue($condition); + if (!isset($condition{0})) + $condition = '=""'; if (!in_array($condition{0},array('>', '<', '='))) { if (!is_numeric($condition)) { $condition = PHPExcel_Calculation::_wrapResult(strtoupper($condition)); } return '='.$condition; } else { preg_match('/([<>=]+)(.*)/',$condition,$matches); list(,$operator,$operand) = $matches; - if (!is_numeric($operand)) { $operand = PHPExcel_Calculation::_wrapResult(strtoupper($operand)); } + + if (!is_numeric($operand)) { + $operand = str_replace('"', '""', $operand); + $operand = PHPExcel_Calculation::_wrapResult(strtoupper($operand)); + } + return $operator.$operand; } } // function _ifCondition() @@ -489,7 +496,7 @@ class PHPExcel_Calculation_Functions { * @return string Version information */ public static function VERSION() { - return 'PHPExcel 1.7.8, 2012-10-12'; + return 'PHPExcel 1.8.0, 2014-03-02'; } // function VERSION() @@ -687,100 +694,6 @@ if (!function_exists('atanh')) { } // function atanh() } -if (!function_exists('money_format')) { - function money_format($format, $number) { - $regex = array( '/%((?:[\^!\-]|\+|\(|\=.)*)([0-9]+)?(?:#([0-9]+))?', - '(?:\.([0-9]+))?([in%])/' - ); - $regex = implode('', $regex); - if (setlocale(LC_MONETARY, null) == '') { - setlocale(LC_MONETARY, ''); - } - $locale = localeconv(); - $number = floatval($number); - if (!preg_match($regex, $format, $fmatch)) { - trigger_error("No format specified or invalid format", E_USER_WARNING); - return $number; - } - $flags = array( 'fillchar' => preg_match('/\=(.)/', $fmatch[1], $match) ? $match[1] : ' ', - 'nogroup' => preg_match('/\^/', $fmatch[1]) > 0, - 'usesignal' => preg_match('/\+|\(/', $fmatch[1], $match) ? $match[0] : '+', - 'nosimbol' => preg_match('/\!/', $fmatch[1]) > 0, - 'isleft' => preg_match('/\-/', $fmatch[1]) > 0 - ); - $width = trim($fmatch[2]) ? (int)$fmatch[2] : 0; - $left = trim($fmatch[3]) ? (int)$fmatch[3] : 0; - $right = trim($fmatch[4]) ? (int)$fmatch[4] : $locale['int_frac_digits']; - $conversion = $fmatch[5]; - $positive = true; - if ($number < 0) { - $positive = false; - $number *= -1; - } - $letter = $positive ? 'p' : 'n'; - $prefix = $suffix = $cprefix = $csuffix = $signal = ''; - if (!$positive) { - $signal = $locale['negative_sign']; - switch (true) { - case $locale['n_sign_posn'] == 0 || $flags['usesignal'] == '(': - $prefix = '('; - $suffix = ')'; - break; - case $locale['n_sign_posn'] == 1: - $prefix = $signal; - break; - case $locale['n_sign_posn'] == 2: - $suffix = $signal; - break; - case $locale['n_sign_posn'] == 3: - $cprefix = $signal; - break; - case $locale['n_sign_posn'] == 4: - $csuffix = $signal; - break; - } - } - if (!$flags['nosimbol']) { - $currency = $cprefix; - $currency .= ($conversion == 'i' ? $locale['int_curr_symbol'] : $locale['currency_symbol']); - $currency .= $csuffix; - $currency = iconv('ISO-8859-1','UTF-8',$currency); - } else { - $currency = ''; - } - $space = $locale["{$letter}_sep_by_space"] ? ' ' : ''; - - if (!isset($locale['mon_decimal_point']) || empty($locale['mon_decimal_point'])) { - $locale['mon_decimal_point'] = (!isset($locale['decimal_point']) || empty($locale['decimal_point'])) ? - $locale['decimal_point'] : - '.'; - } - - $number = number_format($number, $right, $locale['mon_decimal_point'], $flags['nogroup'] ? '' : $locale['mon_thousands_sep'] ); - $number = explode($locale['mon_decimal_point'], $number); - - $n = strlen($prefix) + strlen($currency); - if ($left > 0 && $left > $n) { - if ($flags['isleft']) { - $number[0] .= str_repeat($flags['fillchar'], $left - $n); - } else { - $number[0] = str_repeat($flags['fillchar'], $left - $n) . $number[0]; - } - } - $number = implode($locale['mon_decimal_point'], $number); - if ($locale["{$letter}_cs_precedes"]) { - $number = $prefix . $currency . $space . $number . $suffix; - } else { - $number = $prefix . $number . $space . $currency . $suffix; - } - if ($width > 0) { - $number = str_pad($number, $width, $flags['fillchar'], $flags['isleft'] ? STR_PAD_RIGHT : STR_PAD_LEFT); - } - $format = str_replace($fmatch[0], $number, $format); - return $format; - } // function money_format() -} - // // Strangely, PHP doesn't have a mb_str_replace multibyte function diff --git a/htdocs/includes/phpexcel/PHPExcel/Calculation/Logical.php b/htdocs/includes/phpexcel/PHPExcel/Calculation/Logical.php index 80f2a2650d9..bb206a14257 100644 --- a/htdocs/includes/phpexcel/PHPExcel/Calculation/Logical.php +++ b/htdocs/includes/phpexcel/PHPExcel/Calculation/Logical.php @@ -2,7 +2,7 @@ /** * PHPExcel * - * Copyright (c) 2006 - 2012 PHPExcel + * Copyright (c) 2006 - 2014 PHPExcel * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,9 +20,9 @@ * * @category PHPExcel * @package PHPExcel_Calculation - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version 1.7.8, 2012-10-12 + * @version 1.8.0, 2014-03-02 */ @@ -41,7 +41,7 @@ if (!defined('PHPEXCEL_ROOT')) { * * @category PHPExcel * @package PHPExcel_Calculation - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) */ class PHPExcel_Calculation_Logical { diff --git a/htdocs/includes/phpexcel/PHPExcel/Calculation/LookupRef.php b/htdocs/includes/phpexcel/PHPExcel/Calculation/LookupRef.php index c8246903f2e..e1285d90409 100644 --- a/htdocs/includes/phpexcel/PHPExcel/Calculation/LookupRef.php +++ b/htdocs/includes/phpexcel/PHPExcel/Calculation/LookupRef.php @@ -2,7 +2,7 @@ /** * PHPExcel * - * Copyright (c) 2006 - 2012 PHPExcel + * Copyright (c) 2006 - 2014 PHPExcel * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,9 +20,9 @@ * * @category PHPExcel * @package PHPExcel_Calculation - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version 1.7.8, 2012-10-12 + * @version 1.8.0, 2014-03-02 */ @@ -41,7 +41,7 @@ if (!defined('PHPEXCEL_ROOT')) { * * @category PHPExcel * @package PHPExcel_Calculation - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) */ class PHPExcel_Calculation_LookupRef { @@ -251,8 +251,9 @@ class PHPExcel_Calculation_LookupRef { * * @access public * @category Logical Functions - * @param string $linkURL Value to check, is also the value returned when no error - * @param string $displayName Value to return when testValue is an error condition + * @param string $linkURL Value to check, is also the value returned when no error + * @param string $displayName Value to return when testValue is an error condition + * @param PHPExcel_Cell $pCell The cell to set the hyperlink in * @return mixed The value of $displayName (or $linkURL if $displayName was blank) */ public static function HYPERLINK($linkURL = '', $displayName = null, PHPExcel_Cell $pCell = null) { @@ -287,13 +288,14 @@ class PHPExcel_Calculation_LookupRef { * * NOTE - INDIRECT() does not yet support the optional a1 parameter introduced in Excel 2010 * - * @param cellAddress An array or array formula, or a reference to a range of cells for which you want the number of rows + * @param cellAddress $cellAddress The cell address of the current cell (containing this formula) + * @param PHPExcel_Cell $pCell The current cell (containing this formula) * @return mixed The cells referenced by cellAddress * * @todo Support for the optional a1 parameter introduced in Excel 2010 * */ - public static function INDIRECT($cellAddress=Null, PHPExcel_Cell $pCell = null) { + public static function INDIRECT($cellAddress = NULL, PHPExcel_Cell $pCell = NULL) { $cellAddress = PHPExcel_Calculation_Functions::flattenSingleValue($cellAddress); if (is_null($cellAddress) || $cellAddress === '') { return PHPExcel_Calculation_Functions::REF(); @@ -307,29 +309,30 @@ class PHPExcel_Calculation_LookupRef { if ((!preg_match('/^'.PHPExcel_Calculation::CALCULATION_REGEXP_CELLREF.'$/i', $cellAddress1, $matches)) || ((!is_null($cellAddress2)) && (!preg_match('/^'.PHPExcel_Calculation::CALCULATION_REGEXP_CELLREF.'$/i', $cellAddress2, $matches)))) { - if (!preg_match('/^'.PHPExcel_Calculation::CALCULATION_REGEXP_NAMEDRANGE.'$/i', $cellAddress1, $matches)) { return PHPExcel_Calculation_Functions::REF(); } - if (strpos($cellAddress,'!') !== false) { - list($sheetName,$cellAddress) = explode('!',$cellAddress); - $pSheet = $pCell->getParent()->getParent()->getSheetByName($sheetName); + if (strpos($cellAddress,'!') !== FALSE) { + list($sheetName, $cellAddress) = explode('!',$cellAddress); + $sheetName = trim($sheetName, "'"); + $pSheet = $pCell->getWorksheet()->getParent()->getSheetByName($sheetName); } else { - $pSheet = $pCell->getParent(); + $pSheet = $pCell->getWorksheet(); } - return PHPExcel_Calculation::getInstance()->extractNamedRange($cellAddress, $pSheet, False); + return PHPExcel_Calculation::getInstance()->extractNamedRange($cellAddress, $pSheet, FALSE); } - if (strpos($cellAddress,'!') !== false) { + if (strpos($cellAddress,'!') !== FALSE) { list($sheetName,$cellAddress) = explode('!',$cellAddress); - $pSheet = $pCell->getParent()->getParent()->getSheetByName($sheetName); + $sheetName = trim($sheetName, "'"); + $pSheet = $pCell->getWorksheet()->getParent()->getSheetByName($sheetName); } else { - $pSheet = $pCell->getParent(); + $pSheet = $pCell->getWorksheet(); } - return PHPExcel_Calculation::getInstance()->extractCellRange($cellAddress, $pSheet, False); + return PHPExcel_Calculation::getInstance()->extractCellRange($cellAddress, $pSheet, FALSE); } // function INDIRECT() @@ -373,9 +376,10 @@ class PHPExcel_Calculation_LookupRef { return PHPExcel_Calculation_Functions::REF(); } - $sheetName = null; + $sheetName = NULL; if (strpos($cellAddress,"!")) { list($sheetName,$cellAddress) = explode("!",$cellAddress); + $sheetName = trim($sheetName, "'"); } if (strpos($cellAddress,":")) { list($startCell,$endCell) = explode(":",$cellAddress); @@ -416,10 +420,10 @@ class PHPExcel_Calculation_LookupRef { $cellAddress .= ':'.$endCellColumn.$endCellRow; } - if ($sheetName !== null) { - $pSheet = $pCell->getParent()->getParent()->getSheetByName($sheetName); + if ($sheetName !== NULL) { + $pSheet = $pCell->getWorksheet()->getParent()->getSheetByName($sheetName); } else { - $pSheet = $pCell->getParent(); + $pSheet = $pCell->getWorksheet(); } return PHPExcel_Calculation::getInstance()->extractCellRange($cellAddress, $pSheet, False); @@ -458,7 +462,7 @@ class PHPExcel_Calculation_LookupRef { return PHPExcel_Calculation_Functions::VALUE(); } $chosenEntry = floor($chosenEntry); - if (($chosenEntry <= 0) || ($chosenEntry > $entryCount)) { + if (($chosenEntry < 0) || ($chosenEntry > $entryCount)) { return PHPExcel_Calculation_Functions::VALUE(); } @@ -717,7 +721,8 @@ class PHPExcel_Calculation_LookupRef { $rowNumber = $rowValue = False; foreach($lookup_array as $rowKey => $rowData) { - if (strtolower($rowData[$firstColumn]) > strtolower($lookup_value)) { + if ((is_numeric($lookup_value) && is_numeric($rowData[$firstColumn]) && ($rowData[$firstColumn] > $lookup_value)) || + (!is_numeric($lookup_value) && !is_numeric($rowData[$firstColumn]) && (strtolower($rowData[$firstColumn]) > strtolower($lookup_value)))) { break; } $rowNumber = $rowKey; @@ -730,7 +735,11 @@ class PHPExcel_Calculation_LookupRef { return PHPExcel_Calculation_Functions::NA(); } else { // otherwise return the appropriate value - return $lookup_array[$rowNumber][$returnColumn]; + $result = $lookup_array[$rowNumber][$returnColumn]; + if ((is_numeric($lookup_value) && is_numeric($result)) || + (!is_numeric($lookup_value) && !is_numeric($result))) { + return $result; + } } } @@ -738,6 +747,70 @@ class PHPExcel_Calculation_LookupRef { } // function VLOOKUP() +/** + * HLOOKUP + * The HLOOKUP function searches for value in the top-most row of lookup_array and returns the value in the same column based on the index_number. + * @param lookup_value The value that you want to match in lookup_array + * @param lookup_array The range of cells being searched + * @param index_number The row number in table_array from which the matching value must be returned. The first row is 1. + * @param not_exact_match Determines if you are looking for an exact match based on lookup_value. + * @return mixed The value of the found cell + */ + public static function HLOOKUP($lookup_value, $lookup_array, $index_number, $not_exact_match=true) { + $lookup_value = PHPExcel_Calculation_Functions::flattenSingleValue($lookup_value); + $index_number = PHPExcel_Calculation_Functions::flattenSingleValue($index_number); + $not_exact_match = PHPExcel_Calculation_Functions::flattenSingleValue($not_exact_match); + + // index_number must be greater than or equal to 1 + if ($index_number < 1) { + return PHPExcel_Calculation_Functions::VALUE(); + } + + // index_number must be less than or equal to the number of columns in lookup_array + if ((!is_array($lookup_array)) || (empty($lookup_array))) { + return PHPExcel_Calculation_Functions::REF(); + } else { + $f = array_keys($lookup_array); + $firstRow = array_pop($f); + if ((!is_array($lookup_array[$firstRow])) || ($index_number > count($lookup_array[$firstRow]))) { + return PHPExcel_Calculation_Functions::REF(); + } else { + $columnKeys = array_keys($lookup_array[$firstRow]); + $firstkey = $f[0] - 1; + $returnColumn = $firstkey + $index_number; + $firstColumn = array_shift($f); + } + } + + if (!$not_exact_match) { + $firstRowH = asort($lookup_array[$firstColumn]); + } + + $rowNumber = $rowValue = False; + foreach($lookup_array[$firstColumn] as $rowKey => $rowData) { + if ((is_numeric($lookup_value) && is_numeric($rowData) && ($rowData > $lookup_value)) || + (!is_numeric($lookup_value) && !is_numeric($rowData) && (strtolower($rowData) > strtolower($lookup_value)))) { + break; + } + $rowNumber = $rowKey; + $rowValue = $rowData; + } + + if ($rowNumber !== false) { + if ((!$not_exact_match) && ($rowValue != $lookup_value)) { + // if an exact match is required, we have what we need to return an appropriate response + return PHPExcel_Calculation_Functions::NA(); + } else { + // otherwise return the appropriate value + $result = $lookup_array[$returnColumn][$rowNumber]; + return $result; + } + } + + return PHPExcel_Calculation_Functions::NA(); + } // function HLOOKUP() + + /** * LOOKUP * The LOOKUP function searches for value either from a one-row or one-column range or from an array. diff --git a/htdocs/includes/phpexcel/PHPExcel/Calculation/MathTrig.php b/htdocs/includes/phpexcel/PHPExcel/Calculation/MathTrig.php index 79c573b2774..10930552b35 100644 --- a/htdocs/includes/phpexcel/PHPExcel/Calculation/MathTrig.php +++ b/htdocs/includes/phpexcel/PHPExcel/Calculation/MathTrig.php @@ -2,7 +2,7 @@ /** * PHPExcel * - * Copyright (c) 2006 - 2012 PHPExcel + * Copyright (c) 2006 - 2014 PHPExcel * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,9 +20,9 @@ * * @category PHPExcel * @package PHPExcel_Calculation - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version 1.7.8, 2012-10-12 + * @version 1.8.0, 2014-03-02 */ @@ -41,7 +41,7 @@ if (!defined('PHPEXCEL_ROOT')) { * * @category PHPExcel * @package PHPExcel_Calculation - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) */ class PHPExcel_Calculation_MathTrig { @@ -79,7 +79,7 @@ class PHPExcel_Calculation_MathTrig { * ATAN2 * * This function calculates the arc tangent of the two variables x and y. It is similar to - * calculating the arc tangent of y x, except that the signs of both arguments are used + * calculating the arc tangent of y ÷ x, except that the signs of both arguments are used * to determine the quadrant of the result. * The arctangent is the angle from the x-axis to a line containing the origin (0, 0) and a * point with coordinates (xCoordinate, yCoordinate). The angle is given in radians between @@ -495,13 +495,13 @@ class PHPExcel_Calculation_MathTrig { * * @access public * @category Mathematical and Trigonometric Functions - * @param float $value The positive real number for which you want the logarithm + * @param float $number The positive real number for which you want the logarithm * @param float $base The base of the logarithm. If base is omitted, it is assumed to be 10. * @return float */ public static function LOG_BASE($number = NULL, $base = 10) { $number = PHPExcel_Calculation_Functions::flattenSingleValue($number); - $base = (is_null($base)) ? 10 : (float) PHPExcel_Calculation_Functions::flattenSingleValue($base); + $base = (is_null($base)) ? 10 : (float) PHPExcel_Calculation_Functions::flattenSingleValue($base); if ((!is_numeric($base)) || (!is_numeric($number))) return PHPExcel_Calculation_Functions::VALUE(); @@ -547,7 +547,7 @@ class PHPExcel_Calculation_MathTrig { try { $matrix = new PHPExcel_Shared_JAMA_Matrix($matrixData); return $matrix->det(); - } catch (Exception $ex) { + } catch (PHPExcel_Exception $ex) { return PHPExcel_Calculation_Functions::VALUE(); } } // function MDETERM() @@ -589,7 +589,7 @@ class PHPExcel_Calculation_MathTrig { try { $matrix = new PHPExcel_Shared_JAMA_Matrix($matrixData); return $matrix->inverse()->getArray(); - } catch (Exception $ex) { + } catch (PHPExcel_Exception $ex) { return PHPExcel_Calculation_Functions::VALUE(); } } // function MINVERSE() @@ -642,7 +642,7 @@ class PHPExcel_Calculation_MathTrig { } return $matrixA->times($matrixB)->getArray(); - } catch (Exception $ex) { + } catch (PHPExcel_Exception $ex) { return PHPExcel_Calculation_Functions::VALUE(); } } // function MMULT() @@ -1164,7 +1164,11 @@ class PHPExcel_Calculation_MathTrig { $condition = PHPExcel_Calculation_Functions::_ifCondition($condition); // Loop through arguments foreach ($aArgs as $key => $arg) { - if (!is_numeric($arg)) { $arg = PHPExcel_Calculation::_wrapResult(strtoupper($arg)); } + if (!is_numeric($arg)) { + $arg = str_replace('"', '""', $arg); + $arg = PHPExcel_Calculation::_wrapResult(strtoupper($arg)); + } + $testCondition = '='.$arg.$condition; if (PHPExcel_Calculation::getInstance()->_calculateFormulaValue($testCondition)) { // Is it a value within our criteria @@ -1252,7 +1256,8 @@ class PHPExcel_Calculation_MathTrig { /** * SUMX2MY2 * - * @param mixed $value Value to check + * @param mixed[] $matrixData1 Matrix #1 + * @param mixed[] $matrixData2 Matrix #2 * @return float */ public static function SUMX2MY2($matrixData1,$matrixData2) { @@ -1281,7 +1286,8 @@ class PHPExcel_Calculation_MathTrig { /** * SUMX2PY2 * - * @param mixed $value Value to check + * @param mixed[] $matrixData1 Matrix #1 + * @param mixed[] $matrixData2 Matrix #2 * @return float */ public static function SUMX2PY2($matrixData1,$matrixData2) { @@ -1310,7 +1316,8 @@ class PHPExcel_Calculation_MathTrig { /** * SUMXMY2 * - * @param mixed $value Value to check + * @param mixed[] $matrixData1 Matrix #1 + * @param mixed[] $matrixData2 Matrix #2 * @return float */ public static function SUMXMY2($matrixData1,$matrixData2) { diff --git a/htdocs/includes/phpexcel/PHPExcel/Calculation/Statistical.php b/htdocs/includes/phpexcel/PHPExcel/Calculation/Statistical.php index 2fbb163ef7b..32b9c781d9c 100644 --- a/htdocs/includes/phpexcel/PHPExcel/Calculation/Statistical.php +++ b/htdocs/includes/phpexcel/PHPExcel/Calculation/Statistical.php @@ -2,7 +2,7 @@ /** * PHPExcel * - * Copyright (c) 2006 - 2012 PHPExcel + * Copyright (c) 2006 - 2014 PHPExcel * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,9 +20,9 @@ * * @category PHPExcel * @package PHPExcel_Calculation - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version 1.7.8, 2012-10-12 + * @version 1.8.0, 2014-03-02 */ @@ -57,7 +57,7 @@ define('SQRT2PI', 2.5066282746310005024157652848110452530069867406099); * * @category PHPExcel * @package PHPExcel_Calculation - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) */ class PHPExcel_Calculation_Statistical { @@ -834,6 +834,7 @@ class PHPExcel_Calculation_Statistical { * @category Mathematical and Trigonometric Functions * @param mixed $arg,... Data values * @param string $condition The criteria that defines which cells will be checked. + * @param mixed[] $averageArgs Data values * @return float */ public static function AVERAGEIF($aArgs,$condition,$averageArgs = array()) { @@ -912,6 +913,8 @@ class PHPExcel_Calculation_Statistical { * @param float $probability Probability at which you want to evaluate the distribution * @param float $alpha Parameter to the distribution * @param float $beta Parameter to the distribution + * @param float $rMin Minimum value + * @param float $rMax Maximum value * @param boolean $cumulative * @return float * @@ -1954,9 +1957,9 @@ class PHPExcel_Calculation_Statistical { * @param boolean A logical value specifying whether to return additional regression statistics. * @return array */ - public static function LINEST($yValues,$xValues=null,$const=True,$stats=False) { - $const = (is_null($const)) ? True : (boolean) PHPExcel_Calculation_Functions::flattenSingleValue($const); - $stats = (is_null($stats)) ? False : (boolean) PHPExcel_Calculation_Functions::flattenSingleValue($stats); + public static function LINEST($yValues, $xValues = NULL, $const = TRUE, $stats = FALSE) { + $const = (is_null($const)) ? TRUE : (boolean) PHPExcel_Calculation_Functions::flattenSingleValue($const); + $stats = (is_null($stats)) ? FALSE : (boolean) PHPExcel_Calculation_Functions::flattenSingleValue($stats); if (is_null($xValues)) $xValues = range(1,count(PHPExcel_Calculation_Functions::flattenArray($yValues))); if (!self::_checkTrendArrays($yValues,$xValues)) { @@ -2059,7 +2062,9 @@ class PHPExcel_Calculation_Statistical { * * Returns the inverse of the normal cumulative distribution * - * @param float $value + * @param float $probability + * @param float $mean + * @param float $stdDev * @return float * * @todo Try implementing P J Acklam's refinement algorithm for greater @@ -2088,6 +2093,8 @@ class PHPExcel_Calculation_Statistical { * with parameters mean and standard_dev. * * @param float $value + * @param float $mean + * @param float $stdDev * @return float */ public static function LOGNORMDIST($value, $mean, $stdDev) { @@ -3621,14 +3628,14 @@ class PHPExcel_Calculation_Statistical { * Returns the Weibull distribution. Use this distribution in reliability * analysis, such as calculating a device's mean time to failure. * - * @param float $value - * @param float $alpha Alpha Parameter - * @param float $beta Beta Parameter + * @param float $dataSet + * @param float $m0 Alpha Parameter + * @param float $sigma Beta Parameter * @param boolean $cumulative * @return float * */ - public static function ZTEST($dataSet, $m0, $sigma=null) { + public static function ZTEST($dataSet, $m0, $sigma = NULL) { $dataSet = PHPExcel_Calculation_Functions::flattenArrayIndexed($dataSet); $m0 = PHPExcel_Calculation_Functions::flattenSingleValue($m0); $sigma = PHPExcel_Calculation_Functions::flattenSingleValue($sigma); diff --git a/htdocs/includes/phpexcel/PHPExcel/Calculation/TextData.php b/htdocs/includes/phpexcel/PHPExcel/Calculation/TextData.php index 3289645f519..d1ba2728e0f 100644 --- a/htdocs/includes/phpexcel/PHPExcel/Calculation/TextData.php +++ b/htdocs/includes/phpexcel/PHPExcel/Calculation/TextData.php @@ -2,7 +2,7 @@ /** * PHPExcel * - * Copyright (c) 2006 - 2012 PHPExcel + * Copyright (c) 2006 - 2014 PHPExcel * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,9 +20,9 @@ * * @category PHPExcel * @package PHPExcel_Calculation - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version 1.7.8, 2012-10-12 + * @version 1.8.0, 2014-03-02 */ @@ -41,7 +41,7 @@ if (!defined('PHPEXCEL_ROOT')) { * * @category PHPExcel * @package PHPExcel_Calculation - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) */ class PHPExcel_Calculation_TextData { @@ -89,7 +89,7 @@ class PHPExcel_Calculation_TextData { /** * TRIMNONPRINTABLE * - * @param mixed $value Value to check + * @param mixed $stringValue Value to check * @return string */ public static function TRIMNONPRINTABLE($stringValue = '') { @@ -113,7 +113,7 @@ class PHPExcel_Calculation_TextData { /** * TRIMSPACES * - * @param mixed $value Value to check + * @param mixed $stringValue Value to check * @return string */ public static function TRIMSPACES($stringValue = '') { @@ -133,7 +133,7 @@ class PHPExcel_Calculation_TextData { /** * ASCIICODE * - * @param string $character Value + * @param string $characters Value * @return int */ public static function ASCIICODE($characters) { @@ -208,16 +208,17 @@ class PHPExcel_Calculation_TextData { } $decimals = floor($decimals); + $mask = '$#,##0'; if ($decimals > 0) { - return money_format('%.'.$decimals.'n',$value); + $mask .= '.' . str_repeat('0',$decimals); } else { $round = pow(10,abs($decimals)); if ($value < 0) { $round = 0-$round; } - $value = PHPExcel_Calculation_MathTrig::MROUND($value,$round); - // The implementation of money_format used if the standard PHP function is not available can't handle decimal places of 0, - // so we display to 1 dp and chop off that character and the decimal separator using substr - return substr(money_format('%.1n',$value),0,-2); + $value = PHPExcel_Calculation_MathTrig::MROUND($value, $round); } + + return PHPExcel_Style_NumberFormat::toFormattedString($value, $mask); + } // function DOLLAR() @@ -296,7 +297,9 @@ class PHPExcel_Calculation_TextData { /** * FIXEDFORMAT * - * @param mixed $value Value to check + * @param mixed $value Value to check + * @param integer $decimals + * @param boolean $no_commas * @return boolean */ public static function FIXEDFORMAT($value, $decimals = 2, $no_commas = FALSE) { @@ -407,7 +410,6 @@ class PHPExcel_Calculation_TextData { * STRINGLENGTH * * @param string $value Value - * @param int $chars Number of characters * @return string */ public static function STRINGLENGTH($value = '') { @@ -440,11 +442,7 @@ class PHPExcel_Calculation_TextData { $mixedCaseString = ($mixedCaseString) ? PHPExcel_Calculation::getTRUE() : PHPExcel_Calculation::getFALSE(); } - if (function_exists('mb_convert_case')) { - return mb_convert_case($mixedCaseString, MB_CASE_LOWER, 'UTF-8'); - } else { - return strtoupper($mixedCaseString); - } + return PHPExcel_Shared_String::StrToLower($mixedCaseString); } // function LOWERCASE() @@ -463,11 +461,7 @@ class PHPExcel_Calculation_TextData { $mixedCaseString = ($mixedCaseString) ? PHPExcel_Calculation::getTRUE() : PHPExcel_Calculation::getFALSE(); } - if (function_exists('mb_convert_case')) { - return mb_convert_case($mixedCaseString, MB_CASE_UPPER, 'UTF-8'); - } else { - return strtoupper($mixedCaseString); - } + return PHPExcel_Shared_String::StrToUpper($mixedCaseString); } // function UPPERCASE() @@ -486,20 +480,17 @@ class PHPExcel_Calculation_TextData { $mixedCaseString = ($mixedCaseString) ? PHPExcel_Calculation::getTRUE() : PHPExcel_Calculation::getFALSE(); } - if (function_exists('mb_convert_case')) { - return mb_convert_case($mixedCaseString, MB_CASE_TITLE, 'UTF-8'); - } else { - return ucwords($mixedCaseString); - } + return PHPExcel_Shared_String::StrToTitle($mixedCaseString); } // function PROPERCASE() /** * REPLACE * - * @param string $value Value - * @param int $start Start character - * @param int $chars Number of characters + * @param string $oldText String to modify + * @param int $start Start character + * @param int $chars Number of characters + * @param string $newText String to replace in defined position * @return string */ public static function REPLACE($oldText = '', $start = 1, $chars = null, $newText) { @@ -565,7 +556,7 @@ class PHPExcel_Calculation_TextData { /** * RETURNSTRING * - * @param mixed $value Value to check + * @param mixed $testValue Value to check * @return boolean */ public static function RETURNSTRING($testValue = '') { @@ -582,6 +573,7 @@ class PHPExcel_Calculation_TextData { * TEXTFORMAT * * @param mixed $value Value to check + * @param string $format Format mask to use * @return boolean */ public static function TEXTFORMAT($value,$format) { diff --git a/htdocs/includes/phpexcel/PHPExcel/Calculation/Token/Stack.php b/htdocs/includes/phpexcel/PHPExcel/Calculation/Token/Stack.php index ea7efa0c923..821f3bd280e 100644 --- a/htdocs/includes/phpexcel/PHPExcel/Calculation/Token/Stack.php +++ b/htdocs/includes/phpexcel/PHPExcel/Calculation/Token/Stack.php @@ -2,7 +2,7 @@ /** * PHPExcel * - * Copyright (c) 2006 - 2012 PHPExcel + * Copyright (c) 2006 - 2014 PHPExcel * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,24 +20,53 @@ * * @category PHPExcel * @package PHPExcel_Calculation - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version 1.7.8, 2012-10-12 + * @version 1.8.0, 2014-03-02 */ +/** + * PHPExcel_Calculation_Token_Stack + * + * @category PHPExcel_Calculation_Token_Stack + * @package PHPExcel_Calculation + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) + */ class PHPExcel_Calculation_Token_Stack { + /** + * The parser stack for formulae + * + * @var mixed[] + */ private $_stack = array(); + + /** + * Count of entries in the parser stack + * + * @var integer + */ private $_count = 0; + /** + * Return the number of entries on the stack + * + * @return integer + */ public function count() { return $this->_count; } // function count() - - public function push($type,$value,$reference=null) { + /** + * Push a new entry onto the stack + * + * @param mixed $type + * @param mixed $value + * @param mixed $reference + */ + public function push($type, $value, $reference = NULL) { $this->_stack[$this->_count++] = array('type' => $type, 'value' => $value, 'reference' => $reference @@ -50,24 +79,37 @@ class PHPExcel_Calculation_Token_Stack { } } // function push() - + /** + * Pop the last entry from the stack + * + * @return mixed + */ public function pop() { if ($this->_count > 0) { return $this->_stack[--$this->_count]; } - return null; + return NULL; } // function pop() - - public function last($n=1) { - if ($this->_count-$n < 0) { - return null; + /** + * Return an entry from the stack without removing it + * + * @param integer $n number indicating how far back in the stack we want to look + * @return mixed + */ + public function last($n = 1) { + if ($this->_count - $n < 0) { + return NULL; } - return $this->_stack[$this->_count-$n]; + return $this->_stack[$this->_count - $n]; } // function last() - - function __construct() { + /** + * Clear the stack + */ + function clear() { + $this->_stack = array(); + $this->_count = 0; } } // class PHPExcel_Calculation_Token_Stack diff --git a/htdocs/includes/phpexcel/PHPExcel/Cell.php b/htdocs/includes/phpexcel/PHPExcel/Cell.php index 75996f2942f..1788559fd30 100644 --- a/htdocs/includes/phpexcel/PHPExcel/Cell.php +++ b/htdocs/includes/phpexcel/PHPExcel/Cell.php @@ -2,7 +2,7 @@ /** * PHPExcel * - * Copyright (c) 2006 - 2012 PHPExcel + * Copyright (c) 2006 - 2014 PHPExcel * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,9 +20,9 @@ * * @category PHPExcel * @package PHPExcel_Cell - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version 1.7.8, 2012-10-12 + * @version 1.8.0, 2014-03-02 */ @@ -31,7 +31,7 @@ * * @category PHPExcel * @package PHPExcel_Cell - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) */ class PHPExcel_Cell { @@ -50,20 +50,6 @@ class PHPExcel_Cell */ private static $_valueBinder = NULL; - /** - * Column of the cell - * - * @var string - */ - private $_column; - - /** - * Row of the cell - * - * @var int - */ - private $_row; - /** * Value of the cell * @@ -93,7 +79,7 @@ class PHPExcel_Cell /** * Parent worksheet * - * @var PHPExcel_Worksheet + * @var PHPExcel_CachedObjectStorage_CacheBase */ private $_parent; @@ -117,7 +103,8 @@ class PHPExcel_Cell * @return void **/ public function notifyCacheController() { - $this->_parent->getCellCacheController()->updateCacheData($this); + $this->_parent->updateCacheData($this); + return $this; } @@ -125,7 +112,9 @@ class PHPExcel_Cell $this->_parent = NULL; } - public function attach($parent) { + public function attach(PHPExcel_CachedObjectStorage_CacheBase $parent) { + + $this->_parent = $parent; } @@ -133,24 +122,18 @@ class PHPExcel_Cell /** * Create a new Cell * - * @param string $pColumn - * @param int $pRow * @param mixed $pValue * @param string $pDataType * @param PHPExcel_Worksheet $pSheet * @throws PHPExcel_Exception */ - public function __construct($pColumn = 'A', $pRow = 1, $pValue = NULL, $pDataType = NULL, PHPExcel_Worksheet $pSheet = NULL) + public function __construct($pValue = NULL, $pDataType = NULL, PHPExcel_Worksheet $pSheet = NULL) { - // Initialise cell coordinate - $this->_column = strtoupper($pColumn); - $this->_row = $pRow; - // Initialise cell value $this->_value = $pValue; - // Set worksheet - $this->_parent = $pSheet; + // Set worksheet cache + $this->_parent = $pSheet->getCellCacheController(); // Set datatype? if ($pDataType !== NULL) { @@ -174,7 +157,7 @@ class PHPExcel_Cell */ public function getColumn() { - return $this->_column; + return $this->_parent->getCurrentColumn(); } /** @@ -184,7 +167,7 @@ class PHPExcel_Cell */ public function getRow() { - return $this->_row; + return $this->_parent->getCurrentRow(); } /** @@ -194,7 +177,7 @@ class PHPExcel_Cell */ public function getCoordinate() { - return $this->_column . $this->_row; + return $this->_parent->getCurrentAddress(); } /** @@ -216,7 +199,7 @@ class PHPExcel_Cell { return (string) PHPExcel_Style_NumberFormat::toFormattedString( $this->getCalculatedValue(), - $this->_parent->getParent()->getCellXfByIndex($this->getXfIndex()) + $this->getWorksheet()->getParent()->getCellXfByIndex($this->getXfIndex()) ->getNumberFormat()->getFormatCode() ); } @@ -250,10 +233,12 @@ class PHPExcel_Cell { // set the value according to data type switch ($pDataType) { + case PHPExcel_Cell_DataType::TYPE_NULL: + $this->_value = $pValue; + break; case PHPExcel_Cell_DataType::TYPE_STRING2: $pDataType = PHPExcel_Cell_DataType::TYPE_STRING; case PHPExcel_Cell_DataType::TYPE_STRING: - case PHPExcel_Cell_DataType::TYPE_NULL: case PHPExcel_Cell_DataType::TYPE_INLINE: $this->_value = PHPExcel_Cell_DataType::checkString($pValue); break; @@ -285,43 +270,48 @@ class PHPExcel_Cell * * @deprecated Since version 1.7.8 for planned changes to cell for array formula handling * + * @param boolean $resetLog Whether the calculation engine logger should be reset or not * @return mixed * @throws PHPExcel_Exception */ public function getCalculatedValue($resetLog = TRUE) { -// echo 'Cell '.$this->getCoordinate().' value is a '.$this->_dataType.' with a value of '.$this->getValue().'
'; +//echo 'Cell '.$this->getCoordinate().' value is a '.$this->_dataType.' with a value of '.$this->getValue().PHP_EOL; if ($this->_dataType == PHPExcel_Cell_DataType::TYPE_FORMULA) { try { -// echo 'Cell value for '.$this->getCoordinate().' is a formula: Calculating value
'; - $result = PHPExcel_Calculation::getInstance()->calculateCellValue($this,$resetLog); -// echo $this->getCoordinate().' calculation result is '.$result.'
'; - } catch ( Exception $ex ) { +//echo 'Cell value for '.$this->getCoordinate().' is a formula: Calculating value'.PHP_EOL; + $result = PHPExcel_Calculation::getInstance( + $this->getWorksheet()->getParent() + )->calculateCellValue($this,$resetLog); +//echo $this->getCoordinate().' calculation result is '.$result.PHP_EOL; + // We don't yet handle array returns + if (is_array($result)) { + while (is_array($result)) { + $result = array_pop($result); + } + } + } catch ( PHPExcel_Exception $ex ) { if (($ex->getMessage() === 'Unable to access External Workbook') && ($this->_calculatedValue !== NULL)) { -// echo 'Returning fallback value of '.$this->_calculatedValue.' for cell '.$this->getCoordinate().'
'; +//echo 'Returning fallback value of '.$this->_calculatedValue.' for cell '.$this->getCoordinate().PHP_EOL; return $this->_calculatedValue; // Fallback for calculations referencing external files. } -// echo 'Calculation Exception: '.$ex->getMessage().'
'; +//echo 'Calculation Exception: '.$ex->getMessage().PHP_EOL; $result = '#N/A'; - throw( - new PHPExcel_Exception( - $this->getParent()->getTitle().'!'.$this->getCoordinate().' -> '.$ex->getMessage() - ) + throw new PHPExcel_Calculation_Exception( + $this->getWorksheet()->getTitle().'!'.$this->getCoordinate().' -> '.$ex->getMessage() ); } if ($result === '#Not Yet Implemented') { -// echo 'Returning fallback value of '.$this->_calculatedValue.' for cell '.$this->getCoordinate().'
'; +//echo 'Returning fallback value of '.$this->_calculatedValue.' for cell '.$this->getCoordinate().PHP_EOL; return $this->_calculatedValue; // Fallback if calculation engine does not support the formula. } -// echo 'Returning calculated value of '.$result.' for cell '.$this->getCoordinate().'
'; +//echo 'Returning calculated value of '.$result.' for cell '.$this->getCoordinate().PHP_EOL; return $result; + } elseif($this->_value instanceof PHPExcel_RichText) { +// echo 'Cell value for '.$this->getCoordinate().' is rich text: Returning data value of '.$this->_value.'
'; + return $this->_value->getPlainText(); } - -// if ($this->_value === NULL) { -// echo 'Cell '.$this->getCoordinate().' has no value, formula or otherwise
'; -// return NULL; -// } // echo 'Cell value for '.$this->getCoordinate().' is not a formula: Returning data value of '.$this->_value.'
'; return $this->_value; } @@ -382,6 +372,16 @@ class PHPExcel_Cell return $this->notifyCacheController(); } + /** + * Identify if the cell contains a formula + * + * @return boolean + */ + public function isFormula() + { + return $this->_dataType == PHPExcel_Cell_DataType::TYPE_FORMULA; + } + /** * Does this cell contain Data validation rules? * @@ -394,7 +394,7 @@ class PHPExcel_Cell throw new PHPExcel_Exception('Cannot check for data validation when cell is not bound to a worksheet'); } - return $this->_parent->dataValidationExists($this->getCoordinate()); + return $this->getWorksheet()->dataValidationExists($this->getCoordinate()); } /** @@ -409,7 +409,7 @@ class PHPExcel_Cell throw new PHPExcel_Exception('Cannot get data validation for cell that is not bound to a worksheet'); } - return $this->_parent->getDataValidation($this->getCoordinate()); + return $this->getWorksheet()->getDataValidation($this->getCoordinate()); } /** @@ -425,7 +425,7 @@ class PHPExcel_Cell throw new PHPExcel_Exception('Cannot set data validation for cell that is not bound to a worksheet'); } - $this->_parent->setDataValidation($this->getCoordinate(), $pDataValidation); + $this->getWorksheet()->setDataValidation($this->getCoordinate(), $pDataValidation); return $this->notifyCacheController(); } @@ -442,7 +442,7 @@ class PHPExcel_Cell throw new PHPExcel_Exception('Cannot check for hyperlink when cell is not bound to a worksheet'); } - return $this->_parent->hyperlinkExists($this->getCoordinate()); + return $this->getWorksheet()->hyperlinkExists($this->getCoordinate()); } /** @@ -457,7 +457,7 @@ class PHPExcel_Cell throw new PHPExcel_Exception('Cannot get hyperlink for cell that is not bound to a worksheet'); } - return $this->_parent->getHyperlink($this->getCoordinate()); + return $this->getWorksheet()->getHyperlink($this->getCoordinate()); } /** @@ -473,7 +473,7 @@ class PHPExcel_Cell throw new PHPExcel_Exception('Cannot set hyperlink for cell that is not bound to a worksheet'); } - $this->_parent->setHyperlink($this->getCoordinate(), $pHyperlink); + $this->getWorksheet()->setHyperlink($this->getCoordinate(), $pHyperlink); return $this->notifyCacheController(); } @@ -481,12 +481,31 @@ class PHPExcel_Cell /** * Get parent worksheet * - * @return PHPExcel_Worksheet + * @return PHPExcel_CachedObjectStorage_CacheBase */ public function getParent() { return $this->_parent; } + /** + * Get parent worksheet + * + * @return PHPExcel_Worksheet + */ + public function getWorksheet() { + return $this->_parent->getParent(); + } + + /** + * Get cell style + * + * @return PHPExcel_Style + */ + public function getStyle() + { + return $this->getWorksheet()->getParent()->getCellXfByIndex($this->getXfIndex()); + } + /** * Re-bind parent * @@ -494,7 +513,7 @@ class PHPExcel_Cell * @return PHPExcel_Cell */ public function rebindParent(PHPExcel_Worksheet $parent) { - $this->_parent = $parent; + $this->_parent = $parent->getCellCacheController(); return $this->notifyCacheController(); } @@ -727,7 +746,6 @@ class PHPExcel_Cell * * @param string $pString * @return int Column index (base 1 !!!) - * @throws Exception */ public static function columnIndexFromString($pString = 'A') { @@ -825,8 +843,8 @@ class PHPExcel_Cell // Range... list($rangeStart, $rangeEnd) = $range; - list($startCol, $startRow) = sscanf($rangeStart,'%[A-Z]%d'); - list($endCol, $endRow) = sscanf($rangeEnd,'%[A-Z]%d'); + sscanf($rangeStart,'%[A-Z]%d', $startCol, $startRow); + sscanf($rangeEnd,'%[A-Z]%d', $endCol, $endRow); $endCol++; // Current data @@ -848,7 +866,7 @@ class PHPExcel_Cell // Sort the result by column and row $sortKeys = array(); foreach (array_unique($returnValue) as $coord) { - list($column,$row) = sscanf($coord,'%[A-Z]%d'); + sscanf($coord,'%[A-Z]%d', $column, $row); $sortKeys[sprintf('%3s%09d',$column,$row)] = $coord; } ksort($sortKeys); @@ -861,16 +879,16 @@ class PHPExcel_Cell * Compare 2 cells * * @param PHPExcel_Cell $a Cell a - * @param PHPExcel_Cell $a Cell b + * @param PHPExcel_Cell $b Cell b * @return int Result of comparison (always -1 or 1, never zero!) */ public static function compareCells(PHPExcel_Cell $a, PHPExcel_Cell $b) { - if ($a->_row < $b->_row) { + if ($a->getRow() < $b->getRow()) { return -1; - } elseif ($a->_row > $b->_row) { + } elseif ($a->getRow() > $b->getRow()) { return 1; - } elseif (self::columnIndexFromString($a->_column) < self::columnIndexFromString($b->_column)) { + } elseif (self::columnIndexFromString($a->getColumn()) < self::columnIndexFromString($b->getColumn())) { return -1; } else { return 1; @@ -894,11 +912,11 @@ class PHPExcel_Cell * Set value binder to use * * @param PHPExcel_Cell_IValueBinder $binder - * @throws Exception + * @throws PHPExcel_Exception */ public static function setValueBinder(PHPExcel_Cell_IValueBinder $binder = NULL) { if ($binder === NULL) { - throw new Exception("A PHPExcel_Cell_IValueBinder is required for PHPExcel to function correctly."); + throw new PHPExcel_Exception("A PHPExcel_Cell_IValueBinder is required for PHPExcel to function correctly."); } self::$_valueBinder = $binder; diff --git a/htdocs/includes/phpexcel/PHPExcel/Cell/AdvancedValueBinder.php b/htdocs/includes/phpexcel/PHPExcel/Cell/AdvancedValueBinder.php index 3603f5ee61d..00a2b57fa12 100644 --- a/htdocs/includes/phpexcel/PHPExcel/Cell/AdvancedValueBinder.php +++ b/htdocs/includes/phpexcel/PHPExcel/Cell/AdvancedValueBinder.php @@ -2,7 +2,7 @@ /** * PHPExcel * - * Copyright (c) 2006 - 2012 PHPExcel + * Copyright (c) 2006 - 2014 PHPExcel * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,19 +20,19 @@ * * @category PHPExcel * @package PHPExcel_Cell - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version 1.7.8, 2012-10-12 + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) + * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @version 1.8.0, 2014-03-02 */ /** PHPExcel root directory */ if (!defined('PHPEXCEL_ROOT')) { - /** - * @ignore - */ - define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../'); - require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php'); + /** + * @ignore + */ + define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../'); + require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php'); } @@ -41,150 +41,152 @@ if (!defined('PHPEXCEL_ROOT')) { * * @category PHPExcel * @package PHPExcel_Cell - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) */ class PHPExcel_Cell_AdvancedValueBinder extends PHPExcel_Cell_DefaultValueBinder implements PHPExcel_Cell_IValueBinder { - /** - * Bind value to a cell - * - * @param PHPExcel_Cell $cell Cell to bind value to - * @param mixed $value Value to bind in cell - * @return boolean - */ - public function bindValue(PHPExcel_Cell $cell, $value = null) - { - // sanitize UTF-8 strings - if (is_string($value)) { - $value = PHPExcel_Shared_String::SanitizeUTF8($value); - } + /** + * Bind value to a cell + * + * @param PHPExcel_Cell $cell Cell to bind value to + * @param mixed $value Value to bind in cell + * @return boolean + */ + public function bindValue(PHPExcel_Cell $cell, $value = null) + { + // sanitize UTF-8 strings + if (is_string($value)) { + $value = PHPExcel_Shared_String::SanitizeUTF8($value); + } - // Find out data type - $dataType = parent::dataTypeForValue($value); + // Find out data type + $dataType = parent::dataTypeForValue($value); - // Style logic - strings - if ($dataType === PHPExcel_Cell_DataType::TYPE_STRING && !$value instanceof PHPExcel_RichText) { - // Test for booleans using locale-setting - if ($value == PHPExcel_Calculation::getTRUE()) { - $cell->setValueExplicit( TRUE, PHPExcel_Cell_DataType::TYPE_BOOL); - return true; - } elseif($value == PHPExcel_Calculation::getFALSE()) { - $cell->setValueExplicit( FALSE, PHPExcel_Cell_DataType::TYPE_BOOL); - return true; - } + // Style logic - strings + if ($dataType === PHPExcel_Cell_DataType::TYPE_STRING && !$value instanceof PHPExcel_RichText) { + // Test for booleans using locale-setting + if ($value == PHPExcel_Calculation::getTRUE()) { + $cell->setValueExplicit( TRUE, PHPExcel_Cell_DataType::TYPE_BOOL); + return true; + } elseif($value == PHPExcel_Calculation::getFALSE()) { + $cell->setValueExplicit( FALSE, PHPExcel_Cell_DataType::TYPE_BOOL); + return true; + } - // Check for number in scientific format - if (preg_match('/^'.PHPExcel_Calculation::CALCULATION_REGEXP_NUMBER.'$/', $value)) { - $cell->setValueExplicit( (float) $value, PHPExcel_Cell_DataType::TYPE_NUMERIC); - return true; - } + // Check for number in scientific format + if (preg_match('/^'.PHPExcel_Calculation::CALCULATION_REGEXP_NUMBER.'$/', $value)) { + $cell->setValueExplicit( (float) $value, PHPExcel_Cell_DataType::TYPE_NUMERIC); + return true; + } - // Check for fraction - if (preg_match('/^([+-]?) *([0-9]*)\s?\/\s*([0-9]*)$/', $value, $matches)) { - // Convert value to number - $value = $matches[2] / $matches[3]; - if ($matches[1] == '-') $value = 0 - $value; - $cell->setValueExplicit( (float) $value, PHPExcel_Cell_DataType::TYPE_NUMERIC); - // Set style - $cell->getParent()->getStyle( $cell->getCoordinate() ) - ->getNumberFormat()->setFormatCode( '??/??' ); - return true; - } elseif (preg_match('/^([+-]?)([0-9]*) +([0-9]*)\s?\/\s*([0-9]*)$/', $value, $matches)) { - // Convert value to number - $value = $matches[2] + ($matches[3] / $matches[4]); - if ($matches[1] == '-') $value = 0 - $value; - $cell->setValueExplicit( (float) $value, PHPExcel_Cell_DataType::TYPE_NUMERIC); - // Set style - $cell->getParent()->getStyle( $cell->getCoordinate() ) - ->getNumberFormat()->setFormatCode( '# ??/??' ); - return true; - } + // Check for fraction + if (preg_match('/^([+-]?)\s*([0-9]+)\s?\/\s*([0-9]+)$/', $value, $matches)) { + // Convert value to number + $value = $matches[2] / $matches[3]; + if ($matches[1] == '-') $value = 0 - $value; + $cell->setValueExplicit( (float) $value, PHPExcel_Cell_DataType::TYPE_NUMERIC); + // Set style + $cell->getWorksheet()->getStyle( $cell->getCoordinate() ) + ->getNumberFormat()->setFormatCode( '??/??' ); + return true; + } elseif (preg_match('/^([+-]?)([0-9]*) +([0-9]*)\s?\/\s*([0-9]*)$/', $value, $matches)) { + // Convert value to number + $value = $matches[2] + ($matches[3] / $matches[4]); + if ($matches[1] == '-') $value = 0 - $value; + $cell->setValueExplicit( (float) $value, PHPExcel_Cell_DataType::TYPE_NUMERIC); + // Set style + $cell->getWorksheet()->getStyle( $cell->getCoordinate() ) + ->getNumberFormat()->setFormatCode( '# ??/??' ); + return true; + } - // Check for percentage - if (preg_match('/^\-?[0-9]*\.?[0-9]*\s?\%$/', $value)) { - // Convert value to number - $value = (float) str_replace('%', '', $value) / 100; - $cell->setValueExplicit( $value, PHPExcel_Cell_DataType::TYPE_NUMERIC); - // Set style - $cell->getParent()->getStyle( $cell->getCoordinate() ) - ->getNumberFormat()->setFormatCode( PHPExcel_Style_NumberFormat::FORMAT_PERCENTAGE_00 ); - return true; - } + // Check for percentage + if (preg_match('/^\-?[0-9]*\.?[0-9]*\s?\%$/', $value)) { + // Convert value to number + $value = (float) str_replace('%', '', $value) / 100; + $cell->setValueExplicit( $value, PHPExcel_Cell_DataType::TYPE_NUMERIC); + // Set style + $cell->getWorksheet()->getStyle( $cell->getCoordinate() ) + ->getNumberFormat()->setFormatCode( PHPExcel_Style_NumberFormat::FORMAT_PERCENTAGE_00 ); + return true; + } - // Check for currency - $currencyCode = PHPExcel_Shared_String::getCurrencyCode(); - if (preg_match('/^'.preg_quote($currencyCode).' *(\d{1,3}(\,\d{3})*|(\d+))(\.\d{2})?$/', $value)) { - // Convert value to number - $value = (float) trim(str_replace(array($currencyCode,','), '', $value)); - $cell->setValueExplicit( $value, PHPExcel_Cell_DataType::TYPE_NUMERIC); - // Set style - $cell->getParent()->getStyle( $cell->getCoordinate() ) - ->getNumberFormat()->setFormatCode( - str_replace('$', $currencyCode, PHPExcel_Style_NumberFormat::FORMAT_CURRENCY_USD_SIMPLE ) - ); - return true; - } elseif (preg_match('/^\$ *(\d{1,3}(\,\d{3})*|(\d+))(\.\d{2})?$/', $value)) { - // Convert value to number - $value = (float) trim(str_replace(array('$',','), '', $value)); - $cell->setValueExplicit( $value, PHPExcel_Cell_DataType::TYPE_NUMERIC); - // Set style - $cell->getParent()->getStyle( $cell->getCoordinate() ) - ->getNumberFormat()->setFormatCode( PHPExcel_Style_NumberFormat::FORMAT_CURRENCY_USD_SIMPLE ); - return true; - } + // Check for currency + $currencyCode = PHPExcel_Shared_String::getCurrencyCode(); + $decimalSeparator = PHPExcel_Shared_String::getDecimalSeparator(); + $thousandsSeparator = PHPExcel_Shared_String::getThousandsSeparator(); + if (preg_match('/^'.preg_quote($currencyCode).' *(\d{1,3}('.preg_quote($thousandsSeparator).'\d{3})*|(\d+))('.preg_quote($decimalSeparator).'\d{2})?$/', $value)) { + // Convert value to number + $value = (float) trim(str_replace(array($currencyCode, $thousandsSeparator, $decimalSeparator), array('', '', '.'), $value)); + $cell->setValueExplicit( $value, PHPExcel_Cell_DataType::TYPE_NUMERIC); + // Set style + $cell->getWorksheet()->getStyle( $cell->getCoordinate() ) + ->getNumberFormat()->setFormatCode( + str_replace('$', $currencyCode, PHPExcel_Style_NumberFormat::FORMAT_CURRENCY_USD_SIMPLE ) + ); + return true; + } elseif (preg_match('/^\$ *(\d{1,3}(\,\d{3})*|(\d+))(\.\d{2})?$/', $value)) { + // Convert value to number + $value = (float) trim(str_replace(array('$',','), '', $value)); + $cell->setValueExplicit( $value, PHPExcel_Cell_DataType::TYPE_NUMERIC); + // Set style + $cell->getWorksheet()->getStyle( $cell->getCoordinate() ) + ->getNumberFormat()->setFormatCode( PHPExcel_Style_NumberFormat::FORMAT_CURRENCY_USD_SIMPLE ); + return true; + } - // Check for time without seconds e.g. '9:45', '09:45' - if (preg_match('/^(\d|[0-1]\d|2[0-3]):[0-5]\d$/', $value)) { - // Convert value to number - list($h, $m) = explode(':', $value); - $days = $h / 24 + $m / 1440; - $cell->setValueExplicit($days, PHPExcel_Cell_DataType::TYPE_NUMERIC); - // Set style - $cell->getParent()->getStyle( $cell->getCoordinate() ) - ->getNumberFormat()->setFormatCode( PHPExcel_Style_NumberFormat::FORMAT_DATE_TIME3 ); - return true; - } + // Check for time without seconds e.g. '9:45', '09:45' + if (preg_match('/^(\d|[0-1]\d|2[0-3]):[0-5]\d$/', $value)) { + // Convert value to number + list($h, $m) = explode(':', $value); + $days = $h / 24 + $m / 1440; + $cell->setValueExplicit($days, PHPExcel_Cell_DataType::TYPE_NUMERIC); + // Set style + $cell->getWorksheet()->getStyle( $cell->getCoordinate() ) + ->getNumberFormat()->setFormatCode( PHPExcel_Style_NumberFormat::FORMAT_DATE_TIME3 ); + return true; + } - // Check for time with seconds '9:45:59', '09:45:59' - if (preg_match('/^(\d|[0-1]\d|2[0-3]):[0-5]\d:[0-5]\d$/', $value)) { - // Convert value to number - list($h, $m, $s) = explode(':', $value); - $days = $h / 24 + $m / 1440 + $s / 86400; - // Convert value to number - $cell->setValueExplicit($days, PHPExcel_Cell_DataType::TYPE_NUMERIC); - // Set style - $cell->getParent()->getStyle( $cell->getCoordinate() ) - ->getNumberFormat()->setFormatCode( PHPExcel_Style_NumberFormat::FORMAT_DATE_TIME4 ); - return true; - } + // Check for time with seconds '9:45:59', '09:45:59' + if (preg_match('/^(\d|[0-1]\d|2[0-3]):[0-5]\d:[0-5]\d$/', $value)) { + // Convert value to number + list($h, $m, $s) = explode(':', $value); + $days = $h / 24 + $m / 1440 + $s / 86400; + // Convert value to number + $cell->setValueExplicit($days, PHPExcel_Cell_DataType::TYPE_NUMERIC); + // Set style + $cell->getWorksheet()->getStyle( $cell->getCoordinate() ) + ->getNumberFormat()->setFormatCode( PHPExcel_Style_NumberFormat::FORMAT_DATE_TIME4 ); + return true; + } - // Check for datetime, e.g. '2008-12-31', '2008-12-31 15:59', '2008-12-31 15:59:10' - if (($d = PHPExcel_Shared_Date::stringToExcel($value)) !== false) { - // Convert value to number - $cell->setValueExplicit($d, PHPExcel_Cell_DataType::TYPE_NUMERIC); - // Determine style. Either there is a time part or not. Look for ':' - if (strpos($value, ':') !== false) { - $formatCode = 'yyyy-mm-dd h:mm'; - } else { - $formatCode = 'yyyy-mm-dd'; - } - $cell->getParent()->getStyle( $cell->getCoordinate() ) - ->getNumberFormat()->setFormatCode($formatCode); - return true; - } + // Check for datetime, e.g. '2008-12-31', '2008-12-31 15:59', '2008-12-31 15:59:10' + if (($d = PHPExcel_Shared_Date::stringToExcel($value)) !== false) { + // Convert value to number + $cell->setValueExplicit($d, PHPExcel_Cell_DataType::TYPE_NUMERIC); + // Determine style. Either there is a time part or not. Look for ':' + if (strpos($value, ':') !== false) { + $formatCode = 'yyyy-mm-dd h:mm'; + } else { + $formatCode = 'yyyy-mm-dd'; + } + $cell->getWorksheet()->getStyle( $cell->getCoordinate() ) + ->getNumberFormat()->setFormatCode($formatCode); + return true; + } - // Check for newline character "\n" - if (strpos($value, "\n") !== FALSE) { - $value = PHPExcel_Shared_String::SanitizeUTF8($value); - $cell->setValueExplicit($value, PHPExcel_Cell_DataType::TYPE_STRING); - // Set style - $cell->getParent()->getStyle( $cell->getCoordinate() ) - ->getAlignment()->setWrapText(TRUE); - return true; - } - } + // Check for newline character "\n" + if (strpos($value, "\n") !== FALSE) { + $value = PHPExcel_Shared_String::SanitizeUTF8($value); + $cell->setValueExplicit($value, PHPExcel_Cell_DataType::TYPE_STRING); + // Set style + $cell->getWorksheet()->getStyle( $cell->getCoordinate() ) + ->getAlignment()->setWrapText(TRUE); + return true; + } + } - // Not bound yet? Use parent... - return parent::bindValue($cell, $value); - } + // Not bound yet? Use parent... + return parent::bindValue($cell, $value); + } } diff --git a/htdocs/includes/phpexcel/PHPExcel/Cell/DataType.php b/htdocs/includes/phpexcel/PHPExcel/Cell/DataType.php index a833a5a44e3..85765426b89 100644 --- a/htdocs/includes/phpexcel/PHPExcel/Cell/DataType.php +++ b/htdocs/includes/phpexcel/PHPExcel/Cell/DataType.php @@ -2,7 +2,7 @@ /** * PHPExcel * - * Copyright (c) 2006 - 2012 PHPExcel + * Copyright (c) 2006 - 2014 PHPExcel * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,9 +20,9 @@ * * @category PHPExcel * @package PHPExcel_Cell - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version 1.7.8, 2012-10-12 + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) + * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @version 1.8.0, 2014-03-02 */ @@ -31,84 +31,92 @@ * * @category PHPExcel * @package PHPExcel_Cell - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) */ class PHPExcel_Cell_DataType { - /* Data types */ - const TYPE_STRING2 = 'str'; - const TYPE_STRING = 's'; - const TYPE_FORMULA = 'f'; - const TYPE_NUMERIC = 'n'; - const TYPE_BOOL = 'b'; - const TYPE_NULL = 'null'; - const TYPE_INLINE = 'inlineStr'; - const TYPE_ERROR = 'e'; + /* Data types */ + const TYPE_STRING2 = 'str'; + const TYPE_STRING = 's'; + const TYPE_FORMULA = 'f'; + const TYPE_NUMERIC = 'n'; + const TYPE_BOOL = 'b'; + const TYPE_NULL = 'null'; + const TYPE_INLINE = 'inlineStr'; + const TYPE_ERROR = 'e'; - /** - * List of error codes - * - * @var array - */ - private static $_errorCodes = array('#NULL!' => 0, '#DIV/0!' => 1, '#VALUE!' => 2, '#REF!' => 3, '#NAME?' => 4, '#NUM!' => 5, '#N/A' => 6); + /** + * List of error codes + * + * @var array + */ + private static $_errorCodes = array( + '#NULL!' => 0, + '#DIV/0!' => 1, + '#VALUE!' => 2, + '#REF!' => 3, + '#NAME?' => 4, + '#NUM!' => 5, + '#N/A' => 6 + ); - /** - * Get list of error codes - * - * @return array - */ - public static function getErrorCodes() { - return self::$_errorCodes; - } + /** + * Get list of error codes + * + * @return array + */ + public static function getErrorCodes() { + return self::$_errorCodes; + } - /** - * DataType for value - * - * @deprecated Replaced by PHPExcel_Cell_IValueBinder infrastructure - * @param mixed $pValue - * @return int - */ - public static function dataTypeForValue($pValue = null) { - return PHPExcel_Cell_DefaultValueBinder::dataTypeForValue($pValue); - } + /** + * DataType for value + * + * @deprecated Replaced by PHPExcel_Cell_IValueBinder infrastructure, will be removed in version 1.8.0 + * @param mixed $pValue + * @return string + */ + public static function dataTypeForValue($pValue = null) { + return PHPExcel_Cell_DefaultValueBinder::dataTypeForValue($pValue); + } - /** - * Check a string that it satisfies Excel requirements - * - * @param mixed Value to sanitize to an Excel string - * @return mixed Sanitized value - */ - public static function checkString($pValue = null) - { - if ($pValue instanceof PHPExcel_RichText) { - // TODO: Sanitize Rich-Text string (max. character count is 32,767) - return $pValue; - } + /** + * Check a string that it satisfies Excel requirements + * + * @param mixed Value to sanitize to an Excel string + * @return mixed Sanitized value + */ + public static function checkString($pValue = null) + { + if ($pValue instanceof PHPExcel_RichText) { + // TODO: Sanitize Rich-Text string (max. character count is 32,767) + return $pValue; + } - // string must never be longer than 32,767 characters, truncate if necessary - $pValue = PHPExcel_Shared_String::Substring($pValue, 0, 32767); + // string must never be longer than 32,767 characters, truncate if necessary + $pValue = PHPExcel_Shared_String::Substring($pValue, 0, 32767); - // we require that newline is represented as "\n" in core, not as "\r\n" or "\r" - $pValue = str_replace(array("\r\n", "\r"), "\n", $pValue); + // we require that newline is represented as "\n" in core, not as "\r\n" or "\r" + $pValue = str_replace(array("\r\n", "\r"), "\n", $pValue); - return $pValue; - } + return $pValue; + } - /** - * Check a value that it is a valid error code - * - * @param mixed Value to sanitize to an Excel error code - * @return string Sanitized value - */ - public static function checkErrorCode($pValue = null) - { - $pValue = (string)$pValue; + /** + * Check a value that it is a valid error code + * + * @param mixed Value to sanitize to an Excel error code + * @return string Sanitized value + */ + public static function checkErrorCode($pValue = null) + { + $pValue = (string) $pValue; - if ( !array_key_exists($pValue, self::$_errorCodes) ) { - $pValue = '#NULL!'; - } + if ( !array_key_exists($pValue, self::$_errorCodes) ) { + $pValue = '#NULL!'; + } - return $pValue; - } + return $pValue; + } } diff --git a/htdocs/includes/phpexcel/PHPExcel/Cell/DataValidation.php b/htdocs/includes/phpexcel/PHPExcel/Cell/DataValidation.php index 01b1edb7e52..3174a3fe44a 100644 --- a/htdocs/includes/phpexcel/PHPExcel/Cell/DataValidation.php +++ b/htdocs/includes/phpexcel/PHPExcel/Cell/DataValidation.php @@ -2,7 +2,7 @@ /** * PHPExcel * - * Copyright (c) 2006 - 2012 PHPExcel + * Copyright (c) 2006 - 2014 PHPExcel * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,9 +20,9 @@ * * @category PHPExcel * @package PHPExcel_Cell - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version 1.7.8, 2012-10-12 + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) + * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @version 1.8.0, 2014-03-02 */ @@ -31,34 +31,34 @@ * * @category PHPExcel * @package PHPExcel_Cell - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) */ class PHPExcel_Cell_DataValidation { - /* Data validation types */ - const TYPE_NONE = 'none'; - const TYPE_CUSTOM = 'custom'; - const TYPE_DATE = 'date'; - const TYPE_DECIMAL = 'decimal'; - const TYPE_LIST = 'list'; - const TYPE_TEXTLENGTH = 'textLength'; - const TYPE_TIME = 'time'; - const TYPE_WHOLE = 'whole'; + /* Data validation types */ + const TYPE_NONE = 'none'; + const TYPE_CUSTOM = 'custom'; + const TYPE_DATE = 'date'; + const TYPE_DECIMAL = 'decimal'; + const TYPE_LIST = 'list'; + const TYPE_TEXTLENGTH = 'textLength'; + const TYPE_TIME = 'time'; + const TYPE_WHOLE = 'whole'; - /* Data validation error styles */ - const STYLE_STOP = 'stop'; - const STYLE_WARNING = 'warning'; - const STYLE_INFORMATION = 'information'; + /* Data validation error styles */ + const STYLE_STOP = 'stop'; + const STYLE_WARNING = 'warning'; + const STYLE_INFORMATION = 'information'; - /* Data validation operators */ - const OPERATOR_BETWEEN = 'between'; - const OPERATOR_EQUAL = 'equal'; - const OPERATOR_GREATERTHAN = 'greaterThan'; - const OPERATOR_GREATERTHANOREQUAL = 'greaterThanOrEqual'; - const OPERATOR_LESSTHAN = 'lessThan'; - const OPERATOR_LESSTHANOREQUAL = 'lessThanOrEqual'; - const OPERATOR_NOTBETWEEN = 'notBetween'; - const OPERATOR_NOTEQUAL = 'notEqual'; + /* Data validation operators */ + const OPERATOR_BETWEEN = 'between'; + const OPERATOR_EQUAL = 'equal'; + const OPERATOR_GREATERTHAN = 'greaterThan'; + const OPERATOR_GREATERTHANOREQUAL = 'greaterThanOrEqual'; + const OPERATOR_LESSTHAN = 'lessThan'; + const OPERATOR_LESSTHANOREQUAL = 'lessThanOrEqual'; + const OPERATOR_NOTBETWEEN = 'notBetween'; + const OPERATOR_NOTEQUAL = 'notEqual'; /** * Formula 1 @@ -153,322 +153,320 @@ class PHPExcel_Cell_DataValidation /** * Create a new PHPExcel_Cell_DataValidation - * - * @throws Exception */ public function __construct() { - // Initialise member variables - $this->_formula1 = ''; - $this->_formula2 = ''; - $this->_type = PHPExcel_Cell_DataValidation::TYPE_NONE; - $this->_errorStyle = PHPExcel_Cell_DataValidation::STYLE_STOP; - $this->_operator = ''; - $this->_allowBlank = false; - $this->_showDropDown = false; - $this->_showInputMessage = false; - $this->_showErrorMessage = false; - $this->_errorTitle = ''; - $this->_error = ''; - $this->_promptTitle = ''; - $this->_prompt = ''; + // Initialise member variables + $this->_formula1 = ''; + $this->_formula2 = ''; + $this->_type = PHPExcel_Cell_DataValidation::TYPE_NONE; + $this->_errorStyle = PHPExcel_Cell_DataValidation::STYLE_STOP; + $this->_operator = ''; + $this->_allowBlank = FALSE; + $this->_showDropDown = FALSE; + $this->_showInputMessage = FALSE; + $this->_showErrorMessage = FALSE; + $this->_errorTitle = ''; + $this->_error = ''; + $this->_promptTitle = ''; + $this->_prompt = ''; } - /** - * Get Formula 1 - * - * @return string - */ - public function getFormula1() { - return $this->_formula1; - } - - /** - * Set Formula 1 - * - * @param string $value - * @return PHPExcel_Cell_DataValidation - */ - public function setFormula1($value = '') { - $this->_formula1 = $value; - return $this; - } - - /** - * Get Formula 2 - * - * @return string - */ - public function getFormula2() { - return $this->_formula2; - } - - /** - * Set Formula 2 - * - * @param string $value - * @return PHPExcel_Cell_DataValidation - */ - public function setFormula2($value = '') { - $this->_formula2 = $value; - return $this; - } - - /** - * Get Type - * - * @return string - */ - public function getType() { - return $this->_type; - } - - /** - * Set Type - * - * @param string $value - * @return PHPExcel_Cell_DataValidation - */ - public function setType($value = PHPExcel_Cell_DataValidation::TYPE_NONE) { - $this->_type = $value; - return $this; - } - - /** - * Get Error style - * - * @return string - */ - public function getErrorStyle() { - return $this->_errorStyle; - } - - /** - * Set Error style - * - * @param string $value - * @return PHPExcel_Cell_DataValidation - */ - public function setErrorStyle($value = PHPExcel_Cell_DataValidation::STYLE_STOP) { - $this->_errorStyle = $value; - return $this; - } - - /** - * Get Operator - * - * @return string - */ - public function getOperator() { - return $this->_operator; - } - - /** - * Set Operator - * - * @param string $value - * @return PHPExcel_Cell_DataValidation - */ - public function setOperator($value = '') { - $this->_operator = $value; - return $this; - } - - /** - * Get Allow Blank - * - * @return boolean - */ - public function getAllowBlank() { - return $this->_allowBlank; - } - - /** - * Set Allow Blank - * - * @param boolean $value - * @return PHPExcel_Cell_DataValidation - */ - public function setAllowBlank($value = false) { - $this->_allowBlank = $value; - return $this; - } - - /** - * Get Show DropDown - * - * @return boolean - */ - public function getShowDropDown() { - return $this->_showDropDown; - } - - /** - * Set Show DropDown - * - * @param boolean $value - * @return PHPExcel_Cell_DataValidation - */ - public function setShowDropDown($value = false) { - $this->_showDropDown = $value; - return $this; - } - - /** - * Get Show InputMessage - * - * @return boolean - */ - public function getShowInputMessage() { - return $this->_showInputMessage; - } - - /** - * Set Show InputMessage - * - * @param boolean $value - * @return PHPExcel_Cell_DataValidation - */ - public function setShowInputMessage($value = false) { - $this->_showInputMessage = $value; - return $this; - } - - /** - * Get Show ErrorMessage - * - * @return boolean - */ - public function getShowErrorMessage() { - return $this->_showErrorMessage; - } - - /** - * Set Show ErrorMessage - * - * @param boolean $value - * @return PHPExcel_Cell_DataValidation - */ - public function setShowErrorMessage($value = false) { - $this->_showErrorMessage = $value; - return $this; - } - - /** - * Get Error title - * - * @return string - */ - public function getErrorTitle() { - return $this->_errorTitle; - } - - /** - * Set Error title - * - * @param string $value - * @return PHPExcel_Cell_DataValidation - */ - public function setErrorTitle($value = '') { - $this->_errorTitle = $value; - return $this; - } - - /** - * Get Error - * - * @return string - */ - public function getError() { - return $this->_error; - } - - /** - * Set Error - * - * @param string $value - * @return PHPExcel_Cell_DataValidation - */ - public function setError($value = '') { - $this->_error = $value; - return $this; - } - - /** - * Get Prompt title - * - * @return string - */ - public function getPromptTitle() { - return $this->_promptTitle; - } - - /** - * Set Prompt title - * - * @param string $value - * @return PHPExcel_Cell_DataValidation - */ - public function setPromptTitle($value = '') { - $this->_promptTitle = $value; - return $this; - } - - /** - * Get Prompt - * - * @return string - */ - public function getPrompt() { - return $this->_prompt; - } - - /** - * Set Prompt - * - * @param string $value - * @return PHPExcel_Cell_DataValidation - */ - public function setPrompt($value = '') { - $this->_prompt = $value; - return $this; - } - - /** - * Get hash code - * - * @return string Hash code - */ - public function getHashCode() { - return md5( - $this->_formula1 - . $this->_formula2 - . $this->_type = PHPExcel_Cell_DataValidation::TYPE_NONE - . $this->_errorStyle = PHPExcel_Cell_DataValidation::STYLE_STOP - . $this->_operator - . ($this->_allowBlank ? 't' : 'f') - . ($this->_showDropDown ? 't' : 'f') - . ($this->_showInputMessage ? 't' : 'f') - . ($this->_showErrorMessage ? 't' : 'f') - . $this->_errorTitle - . $this->_error - . $this->_promptTitle - . $this->_prompt - . __CLASS__ - ); + /** + * Get Formula 1 + * + * @return string + */ + public function getFormula1() { + return $this->_formula1; } - /** - * Implement PHP __clone to create a deep clone, not just a shallow copy. - */ - public function __clone() { - $vars = get_object_vars($this); - foreach ($vars as $key => $value) { - if (is_object($value)) { - $this->$key = clone $value; - } else { - $this->$key = $value; - } - } - } + /** + * Set Formula 1 + * + * @param string $value + * @return PHPExcel_Cell_DataValidation + */ + public function setFormula1($value = '') { + $this->_formula1 = $value; + return $this; + } + + /** + * Get Formula 2 + * + * @return string + */ + public function getFormula2() { + return $this->_formula2; + } + + /** + * Set Formula 2 + * + * @param string $value + * @return PHPExcel_Cell_DataValidation + */ + public function setFormula2($value = '') { + $this->_formula2 = $value; + return $this; + } + + /** + * Get Type + * + * @return string + */ + public function getType() { + return $this->_type; + } + + /** + * Set Type + * + * @param string $value + * @return PHPExcel_Cell_DataValidation + */ + public function setType($value = PHPExcel_Cell_DataValidation::TYPE_NONE) { + $this->_type = $value; + return $this; + } + + /** + * Get Error style + * + * @return string + */ + public function getErrorStyle() { + return $this->_errorStyle; + } + + /** + * Set Error style + * + * @param string $value + * @return PHPExcel_Cell_DataValidation + */ + public function setErrorStyle($value = PHPExcel_Cell_DataValidation::STYLE_STOP) { + $this->_errorStyle = $value; + return $this; + } + + /** + * Get Operator + * + * @return string + */ + public function getOperator() { + return $this->_operator; + } + + /** + * Set Operator + * + * @param string $value + * @return PHPExcel_Cell_DataValidation + */ + public function setOperator($value = '') { + $this->_operator = $value; + return $this; + } + + /** + * Get Allow Blank + * + * @return boolean + */ + public function getAllowBlank() { + return $this->_allowBlank; + } + + /** + * Set Allow Blank + * + * @param boolean $value + * @return PHPExcel_Cell_DataValidation + */ + public function setAllowBlank($value = false) { + $this->_allowBlank = $value; + return $this; + } + + /** + * Get Show DropDown + * + * @return boolean + */ + public function getShowDropDown() { + return $this->_showDropDown; + } + + /** + * Set Show DropDown + * + * @param boolean $value + * @return PHPExcel_Cell_DataValidation + */ + public function setShowDropDown($value = false) { + $this->_showDropDown = $value; + return $this; + } + + /** + * Get Show InputMessage + * + * @return boolean + */ + public function getShowInputMessage() { + return $this->_showInputMessage; + } + + /** + * Set Show InputMessage + * + * @param boolean $value + * @return PHPExcel_Cell_DataValidation + */ + public function setShowInputMessage($value = false) { + $this->_showInputMessage = $value; + return $this; + } + + /** + * Get Show ErrorMessage + * + * @return boolean + */ + public function getShowErrorMessage() { + return $this->_showErrorMessage; + } + + /** + * Set Show ErrorMessage + * + * @param boolean $value + * @return PHPExcel_Cell_DataValidation + */ + public function setShowErrorMessage($value = false) { + $this->_showErrorMessage = $value; + return $this; + } + + /** + * Get Error title + * + * @return string + */ + public function getErrorTitle() { + return $this->_errorTitle; + } + + /** + * Set Error title + * + * @param string $value + * @return PHPExcel_Cell_DataValidation + */ + public function setErrorTitle($value = '') { + $this->_errorTitle = $value; + return $this; + } + + /** + * Get Error + * + * @return string + */ + public function getError() { + return $this->_error; + } + + /** + * Set Error + * + * @param string $value + * @return PHPExcel_Cell_DataValidation + */ + public function setError($value = '') { + $this->_error = $value; + return $this; + } + + /** + * Get Prompt title + * + * @return string + */ + public function getPromptTitle() { + return $this->_promptTitle; + } + + /** + * Set Prompt title + * + * @param string $value + * @return PHPExcel_Cell_DataValidation + */ + public function setPromptTitle($value = '') { + $this->_promptTitle = $value; + return $this; + } + + /** + * Get Prompt + * + * @return string + */ + public function getPrompt() { + return $this->_prompt; + } + + /** + * Set Prompt + * + * @param string $value + * @return PHPExcel_Cell_DataValidation + */ + public function setPrompt($value = '') { + $this->_prompt = $value; + return $this; + } + + /** + * Get hash code + * + * @return string Hash code + */ + public function getHashCode() { + return md5( + $this->_formula1 + . $this->_formula2 + . $this->_type = PHPExcel_Cell_DataValidation::TYPE_NONE + . $this->_errorStyle = PHPExcel_Cell_DataValidation::STYLE_STOP + . $this->_operator + . ($this->_allowBlank ? 't' : 'f') + . ($this->_showDropDown ? 't' : 'f') + . ($this->_showInputMessage ? 't' : 'f') + . ($this->_showErrorMessage ? 't' : 'f') + . $this->_errorTitle + . $this->_error + . $this->_promptTitle + . $this->_prompt + . __CLASS__ + ); + } + + /** + * Implement PHP __clone to create a deep clone, not just a shallow copy. + */ + public function __clone() { + $vars = get_object_vars($this); + foreach ($vars as $key => $value) { + if (is_object($value)) { + $this->$key = clone $value; + } else { + $this->$key = $value; + } + } + } } diff --git a/htdocs/includes/phpexcel/PHPExcel/Cell/DefaultValueBinder.php b/htdocs/includes/phpexcel/PHPExcel/Cell/DefaultValueBinder.php index f520cc5ed7a..f1880faa790 100644 --- a/htdocs/includes/phpexcel/PHPExcel/Cell/DefaultValueBinder.php +++ b/htdocs/includes/phpexcel/PHPExcel/Cell/DefaultValueBinder.php @@ -2,7 +2,7 @@ /** * PHPExcel * - * Copyright (c) 2006 - 2012 PHPExcel + * Copyright (c) 2006 - 2014 PHPExcel * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,19 +20,19 @@ * * @category PHPExcel * @package PHPExcel_Cell - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version 1.7.8, 2012-10-12 + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) + * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @version 1.8.0, 2014-03-02 */ /** PHPExcel root directory */ if (!defined('PHPEXCEL_ROOT')) { - /** - * @ignore - */ - define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../'); - require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php'); + /** + * @ignore + */ + define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../'); + require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php'); } @@ -41,66 +41,66 @@ if (!defined('PHPEXCEL_ROOT')) { * * @category PHPExcel * @package PHPExcel_Cell - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) */ class PHPExcel_Cell_DefaultValueBinder implements PHPExcel_Cell_IValueBinder { - /** - * Bind value to a cell - * - * @param PHPExcel_Cell $cell Cell to bind value to - * @param mixed $value Value to bind in cell - * @return boolean - */ - public function bindValue(PHPExcel_Cell $cell, $value = null) - { - // sanitize UTF-8 strings - if (is_string($value)) { - $value = PHPExcel_Shared_String::SanitizeUTF8($value); - } + /** + * Bind value to a cell + * + * @param PHPExcel_Cell $cell Cell to bind value to + * @param mixed $value Value to bind in cell + * @return boolean + */ + public function bindValue(PHPExcel_Cell $cell, $value = null) + { + // sanitize UTF-8 strings + if (is_string($value)) { + $value = PHPExcel_Shared_String::SanitizeUTF8($value); + } - // Set value explicit - $cell->setValueExplicit( $value, self::dataTypeForValue($value) ); + // Set value explicit + $cell->setValueExplicit( $value, self::dataTypeForValue($value) ); - // Done! - return true; - } + // Done! + return TRUE; + } - /** - * DataType for value - * - * @param mixed $pValue - * @return int - */ - public static function dataTypeForValue($pValue = null) { - // Match the value against a few data types - if (is_null($pValue)) { - return PHPExcel_Cell_DataType::TYPE_NULL; + /** + * DataType for value + * + * @param mixed $pValue + * @return string + */ + public static function dataTypeForValue($pValue = null) { + // Match the value against a few data types + if (is_null($pValue)) { + return PHPExcel_Cell_DataType::TYPE_NULL; - } elseif ($pValue === '') { - return PHPExcel_Cell_DataType::TYPE_STRING; + } elseif ($pValue === '') { + return PHPExcel_Cell_DataType::TYPE_STRING; - } elseif ($pValue instanceof PHPExcel_RichText) { - return PHPExcel_Cell_DataType::TYPE_INLINE; + } elseif ($pValue instanceof PHPExcel_RichText) { + return PHPExcel_Cell_DataType::TYPE_INLINE; - } elseif ($pValue{0} === '=' && strlen($pValue) > 1) { - return PHPExcel_Cell_DataType::TYPE_FORMULA; + } elseif ($pValue{0} === '=' && strlen($pValue) > 1) { + return PHPExcel_Cell_DataType::TYPE_FORMULA; - } elseif (is_bool($pValue)) { - return PHPExcel_Cell_DataType::TYPE_BOOL; + } elseif (is_bool($pValue)) { + return PHPExcel_Cell_DataType::TYPE_BOOL; - } elseif (is_float($pValue) || is_int($pValue)) { - return PHPExcel_Cell_DataType::TYPE_NUMERIC; + } elseif (is_float($pValue) || is_int($pValue)) { + return PHPExcel_Cell_DataType::TYPE_NUMERIC; - } elseif (preg_match('/^\-?([0-9]+\\.?[0-9]*|[0-9]*\\.?[0-9]+)$/', $pValue)) { - return PHPExcel_Cell_DataType::TYPE_NUMERIC; + } elseif (preg_match('/^\-?([0-9]+\\.?[0-9]*|[0-9]*\\.?[0-9]+)$/', $pValue)) { + return PHPExcel_Cell_DataType::TYPE_NUMERIC; - } elseif (is_string($pValue) && array_key_exists($pValue, PHPExcel_Cell_DataType::getErrorCodes())) { - return PHPExcel_Cell_DataType::TYPE_ERROR; + } elseif (is_string($pValue) && array_key_exists($pValue, PHPExcel_Cell_DataType::getErrorCodes())) { + return PHPExcel_Cell_DataType::TYPE_ERROR; - } else { - return PHPExcel_Cell_DataType::TYPE_STRING; + } else { + return PHPExcel_Cell_DataType::TYPE_STRING; - } - } + } + } } diff --git a/htdocs/includes/phpexcel/PHPExcel/Cell/Hyperlink.php b/htdocs/includes/phpexcel/PHPExcel/Cell/Hyperlink.php index 9dc13042aa5..06edfad0b69 100644 --- a/htdocs/includes/phpexcel/PHPExcel/Cell/Hyperlink.php +++ b/htdocs/includes/phpexcel/PHPExcel/Cell/Hyperlink.php @@ -2,7 +2,7 @@ /** * PHPExcel * - * Copyright (c) 2006 - 2012 PHPExcel + * Copyright (c) 2006 - 2014 PHPExcel * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,9 +20,9 @@ * * @category PHPExcel * @package PHPExcel_Cell - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version 1.7.8, 2012-10-12 + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) + * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @version 1.8.0, 2014-03-02 */ @@ -31,97 +31,96 @@ * * @category PHPExcel * @package PHPExcel_Cell - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) */ class PHPExcel_Cell_Hyperlink { - /** - * URL to link the cell to - * - * @var string - */ - private $_url; + /** + * URL to link the cell to + * + * @var string + */ + private $_url; - /** - * Tooltip to display on the hyperlink - * - * @var string - */ - private $_tooltip; + /** + * Tooltip to display on the hyperlink + * + * @var string + */ + private $_tooltip; /** * Create a new PHPExcel_Cell_Hyperlink * - * @param string $pUrl Url to link the cell to - * @param string $pTooltip Tooltip to display on the hyperlink - * @throws Exception + * @param string $pUrl Url to link the cell to + * @param string $pTooltip Tooltip to display on the hyperlink */ public function __construct($pUrl = '', $pTooltip = '') { - // Initialise member variables - $this->_url = $pUrl; - $this->_tooltip = $pTooltip; + // Initialise member variables + $this->_url = $pUrl; + $this->_tooltip = $pTooltip; } - /** - * Get URL - * - * @return string - */ - public function getUrl() { - return $this->_url; - } + /** + * Get URL + * + * @return string + */ + public function getUrl() { + return $this->_url; + } - /** - * Set URL - * - * @param string $value - * @return PHPExcel_Cell_Hyperlink - */ - public function setUrl($value = '') { - $this->_url = $value; - return $this; - } + /** + * Set URL + * + * @param string $value + * @return PHPExcel_Cell_Hyperlink + */ + public function setUrl($value = '') { + $this->_url = $value; + return $this; + } - /** - * Get tooltip - * - * @return string - */ - public function getTooltip() { - return $this->_tooltip; - } + /** + * Get tooltip + * + * @return string + */ + public function getTooltip() { + return $this->_tooltip; + } - /** - * Set tooltip - * - * @param string $value - * @return PHPExcel_Cell_Hyperlink - */ - public function setTooltip($value = '') { - $this->_tooltip = $value; - return $this; - } + /** + * Set tooltip + * + * @param string $value + * @return PHPExcel_Cell_Hyperlink + */ + public function setTooltip($value = '') { + $this->_tooltip = $value; + return $this; + } - /** - * Is this hyperlink internal? (to another sheet) - * - * @return boolean - */ - public function isInternal() { - return strpos($this->_url, 'sheet://') !== false; - } + /** + * Is this hyperlink internal? (to another worksheet) + * + * @return boolean + */ + public function isInternal() { + return strpos($this->_url, 'sheet://') !== false; + } - /** - * Get hash code - * - * @return string Hash code - */ - public function getHashCode() { - return md5( - $this->_url - . $this->_tooltip - . __CLASS__ - ); + /** + * Get hash code + * + * @return string Hash code + */ + public function getHashCode() { + return md5( + $this->_url + . $this->_tooltip + . __CLASS__ + ); } } diff --git a/htdocs/includes/phpexcel/PHPExcel/Cell/IValueBinder.php b/htdocs/includes/phpexcel/PHPExcel/Cell/IValueBinder.php index 4070b674c77..bc7b468b9cd 100644 --- a/htdocs/includes/phpexcel/PHPExcel/Cell/IValueBinder.php +++ b/htdocs/includes/phpexcel/PHPExcel/Cell/IValueBinder.php @@ -2,7 +2,7 @@ /** * PHPExcel * - * Copyright (c) 2006 - 2012 PHPExcel + * Copyright (c) 2006 - 2014 PHPExcel * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,9 +20,9 @@ * * @category PHPExcel * @package PHPExcel_Cell - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version 1.7.8, 2012-10-12 + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) + * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @version 1.8.0, 2014-03-02 */ @@ -31,16 +31,16 @@ * * @category PHPExcel * @package PHPExcel_Cell - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) */ interface PHPExcel_Cell_IValueBinder { - /** - * Bind value to a cell - * - * @param PHPExcel_Cell $cell Cell to bind value to - * @param mixed $value Value to bind in cell - * @return boolean - */ - public function bindValue(PHPExcel_Cell $cell, $value = null); + /** + * Bind value to a cell + * + * @param PHPExcel_Cell $cell Cell to bind value to + * @param mixed $value Value to bind in cell + * @return boolean + */ + public function bindValue(PHPExcel_Cell $cell, $value = NULL); } diff --git a/htdocs/includes/phpexcel/PHPExcel/Chart.php b/htdocs/includes/phpexcel/PHPExcel/Chart.php index 4fa4cddb2df..9d251b8fd49 100644 --- a/htdocs/includes/phpexcel/PHPExcel/Chart.php +++ b/htdocs/includes/phpexcel/PHPExcel/Chart.php @@ -2,7 +2,7 @@ /** * PHPExcel * - * Copyright (c) 2006 - 2012 PHPExcel + * Copyright (c) 2006 - 2014 PHPExcel * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,9 +20,9 @@ * * @category PHPExcel * @package PHPExcel_Chart - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version 1.7.8, 2012-10-12 + * @version 1.8.0, 2014-03-02 */ @@ -31,7 +31,7 @@ * * @category PHPExcel * @package PHPExcel_Chart - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) */ class PHPExcel_Chart { @@ -184,7 +184,7 @@ class PHPExcel_Chart * Set Worksheet * * @param PHPExcel_Worksheet $pValue - * @throws Exception + * @throws PHPExcel_Chart_Exception * @return PHPExcel_Chart */ public function setWorksheet(PHPExcel_Worksheet $pValue = null) { @@ -378,6 +378,13 @@ class PHPExcel_Chart return $this; } + /** + * Set the offset position within the Top Left cell for the chart + * + * @param integer $xOffset + * @param integer $yOffset + * @return PHPExcel_Chart + */ public function setTopLeftOffset($xOffset=null,$yOffset=null) { if (!is_null($xOffset)) $this->setTopLeftXOffset($xOffset); @@ -387,6 +394,11 @@ class PHPExcel_Chart return $this; } + /** + * Get the offset position within the Top Left cell for the chart + * + * @return integer[] + */ public function getTopLeftOffset() { return array( 'X' => $this->_topLeftXOffset, 'Y' => $this->_topLeftYOffset @@ -458,6 +470,13 @@ class PHPExcel_Chart return $this->_bottomRightCellRef; } + /** + * Set the offset position within the Bottom Right cell for the chart + * + * @param integer $xOffset + * @param integer $yOffset + * @return PHPExcel_Chart + */ public function setBottomRightOffset($xOffset=null,$yOffset=null) { if (!is_null($xOffset)) $this->setBottomRightXOffset($xOffset); @@ -467,6 +486,11 @@ class PHPExcel_Chart return $this; } + /** + * Get the offset position within the Bottom Right cell for the chart + * + * @return integer[] + */ public function getBottomRightOffset() { return array( 'X' => $this->_bottomRightXOffset, 'Y' => $this->_bottomRightYOffset diff --git a/htdocs/includes/phpexcel/PHPExcel/Chart/DataSeries.php b/htdocs/includes/phpexcel/PHPExcel/Chart/DataSeries.php index 16e5e23194f..f5391aae995 100644 --- a/htdocs/includes/phpexcel/PHPExcel/Chart/DataSeries.php +++ b/htdocs/includes/phpexcel/PHPExcel/Chart/DataSeries.php @@ -2,7 +2,7 @@ /** * PHPExcel * - * Copyright (c) 2006 - 2012 PHPExcel + * Copyright (c) 2006 - 2014 PHPExcel * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,9 +20,9 @@ * * @category PHPExcel * @package PHPExcel_Chart - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version 1.7.8, 2012-10-12 + * @version 1.8.0, 2014-03-02 */ @@ -31,7 +31,7 @@ * * @category PHPExcel * @package PHPExcel_Chart - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) */ class PHPExcel_Chart_DataSeries { @@ -52,6 +52,7 @@ class PHPExcel_Chart_DataSeries const TYPE_RADARCHART = 'radarChart'; const TYPE_BUBBLECHART = 'bubbleChart'; const TYPE_STOCKCHART = 'stockChart'; + const TYPE_CANDLECHART = self::TYPE_STOCKCHART; // Synonym const GROUPING_CLUSTERED = 'clustered'; const GROUPING_STACKED = 'stacked'; @@ -169,9 +170,11 @@ class PHPExcel_Chart_DataSeries * Set Plot Type * * @param string $plotType + * @return PHPExcel_Chart_DataSeries */ public function setPlotType($plotType = '') { $this->_plotType = $plotType; + return $this; } /** @@ -187,9 +190,11 @@ class PHPExcel_Chart_DataSeries * Set Plot Grouping Type * * @param string $groupingType + * @return PHPExcel_Chart_DataSeries */ public function setPlotGrouping($groupingType = null) { $this->_plotGrouping = $groupingType; + return $this; } /** @@ -205,9 +210,11 @@ class PHPExcel_Chart_DataSeries * Set Plot Direction * * @param string $plotDirection + * @return PHPExcel_Chart_DataSeries */ public function setPlotDirection($plotDirection = null) { $this->_plotDirection = $plotDirection; + return $this; } /** @@ -280,9 +287,11 @@ class PHPExcel_Chart_DataSeries * Set Plot Style * * @param string $plotStyle + * @return PHPExcel_Chart_DataSeries */ public function setPlotStyle($plotStyle = null) { $this->_plotStyle = $plotStyle; + return $this; } /** @@ -331,9 +340,11 @@ class PHPExcel_Chart_DataSeries * Set Smooth Line * * @param boolean $smoothLine + * @return PHPExcel_Chart_DataSeries */ public function setSmoothLine($smoothLine = TRUE) { $this->_smoothLine = $smoothLine; + return $this; } public function refresh(PHPExcel_Worksheet $worksheet) { diff --git a/htdocs/includes/phpexcel/PHPExcel/Chart/DataSeriesValues.php b/htdocs/includes/phpexcel/PHPExcel/Chart/DataSeriesValues.php index e49d0c79a84..930542b5601 100644 --- a/htdocs/includes/phpexcel/PHPExcel/Chart/DataSeriesValues.php +++ b/htdocs/includes/phpexcel/PHPExcel/Chart/DataSeriesValues.php @@ -2,7 +2,7 @@ /** * PHPExcel * - * Copyright (c) 2006 - 2012 PHPExcel + * Copyright (c) 2006 - 2014 PHPExcel * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,9 +20,9 @@ * * @category PHPExcel * @package PHPExcel_Chart - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version 1.7.8, 2012-10-12 + * @version 1.8.0, 2014-03-02 */ @@ -31,7 +31,7 @@ * * @category PHPExcel * @package PHPExcel_Chart - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) */ class PHPExcel_Chart_DataSeriesValues { @@ -279,7 +279,7 @@ class PHPExcel_Chart_DataSeriesValues public function refresh(PHPExcel_Worksheet $worksheet, $flatten = TRUE) { if ($this->_dataSource !== NULL) { - $calcEngine = PHPExcel_Calculation::getInstance(); + $calcEngine = PHPExcel_Calculation::getInstance($worksheet->getParent()); $newDataValues = PHPExcel_Calculation::_unwrapResult( $calcEngine->_calculateFormulaValue( '='.$this->_dataSource, @@ -289,6 +289,12 @@ class PHPExcel_Chart_DataSeriesValues ); if ($flatten) { $this->_dataValues = PHPExcel_Calculation_Functions::flattenArray($newDataValues); + foreach($this->_dataValues as &$dataValue) { + if ((!empty($dataValue)) && ($dataValue[0] == '#')) { + $dataValue = 0.0; + } + } + unset($dataValue); } else { $cellRange = explode('!',$this->_dataSource); if (count($cellRange) > 1) { diff --git a/htdocs/includes/phpexcel/PHPExcel/Chart/Exception.php b/htdocs/includes/phpexcel/PHPExcel/Chart/Exception.php index 984d5f91ddb..ecf3c43824e 100644 --- a/htdocs/includes/phpexcel/PHPExcel/Chart/Exception.php +++ b/htdocs/includes/phpexcel/PHPExcel/Chart/Exception.php @@ -2,7 +2,7 @@ /** * PHPExcel * - * Copyright (c) 2006 - 2012 PHPExcel + * Copyright (c) 2006 - 2014 PHPExcel * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,9 +20,9 @@ * * @category PHPExcel * @package PHPExcel_Chart - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version 1.7.8, 2012-10-12 + * @version 1.8.0, 2014-03-02 */ @@ -31,9 +31,9 @@ * * @category PHPExcel * @package PHPExcel_Chart - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) */ -class PHPExcel_Chart_Exception extends Exception { +class PHPExcel_Chart_Exception extends PHPExcel_Exception { /** * Error handler callback * diff --git a/htdocs/includes/phpexcel/PHPExcel/Chart/Layout.php b/htdocs/includes/phpexcel/PHPExcel/Chart/Layout.php index d128382c16f..d749dfedce2 100644 --- a/htdocs/includes/phpexcel/PHPExcel/Chart/Layout.php +++ b/htdocs/includes/phpexcel/PHPExcel/Chart/Layout.php @@ -2,7 +2,7 @@ /** * PHPExcel * - * Copyright (c) 2006 - 2012 PHPExcel + * Copyright (c) 2006 - 2014 PHPExcel * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,9 +20,9 @@ * * @category PHPExcel * @package PHPExcel_Chart - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version 1.7.8, 2012-10-12 + * @version 1.8.0, 2014-03-02 */ @@ -31,7 +31,7 @@ * * @category PHPExcel * @package PHPExcel_Chart - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) */ class PHPExcel_Chart_Layout { @@ -167,9 +167,11 @@ class PHPExcel_Chart_Layout * Set Layout Target * * @param Layout Target $value + * @return PHPExcel_Chart_Layout */ public function setLayoutTarget($value) { $this->_layoutTarget = $value; + return $this; } /** @@ -185,9 +187,11 @@ class PHPExcel_Chart_Layout * Set X-Mode * * @param X-Mode $value + * @return PHPExcel_Chart_Layout */ public function setXMode($value) { $this->_xMode = $value; + return $this; } /** @@ -196,16 +200,18 @@ class PHPExcel_Chart_Layout * @return string */ public function getYMode() { - return $this->_xMode; + return $this->_yMode; } /** * Set Y-Mode * * @param Y-Mode $value + * @return PHPExcel_Chart_Layout */ public function setYMode($value) { - $this->_xMode = $value; + $this->_yMode = $value; + return $this; } /** @@ -221,9 +227,11 @@ class PHPExcel_Chart_Layout * Set X-Position * * @param X-Position $value + * @return PHPExcel_Chart_Layout */ public function setXPosition($value) { $this->_xPos = $value; + return $this; } /** @@ -239,9 +247,11 @@ class PHPExcel_Chart_Layout * Set Y-Position * * @param Y-Position $value + * @return PHPExcel_Chart_Layout */ public function setYPosition($value) { $this->_yPos = $value; + return $this; } /** @@ -257,9 +267,11 @@ class PHPExcel_Chart_Layout * Set Width * * @param Width $value + * @return PHPExcel_Chart_Layout */ public function setWidth($value) { $this->_width = $value; + return $this; } /** @@ -275,9 +287,11 @@ class PHPExcel_Chart_Layout * Set Height * * @param Height $value + * @return PHPExcel_Chart_Layout */ public function setHeight($value) { $this->_height = $value; + return $this; } @@ -295,9 +309,11 @@ class PHPExcel_Chart_Layout * Specifies that legend keys should be shown in data labels. * * @param boolean $value Show legend key + * @return PHPExcel_Chart_Layout */ public function setShowLegendKey($value) { $this->_showLegendKey = $value; + return $this; } /** @@ -314,9 +330,11 @@ class PHPExcel_Chart_Layout * Specifies that the value should be shown in data labels. * * @param boolean $value Show val + * @return PHPExcel_Chart_Layout */ public function setShowVal($value) { $this->_showVal = $value; + return $this; } /** @@ -333,9 +351,11 @@ class PHPExcel_Chart_Layout * Specifies that the category name should be shown in data labels. * * @param boolean $value Show cat name + * @return PHPExcel_Chart_Layout */ public function setShowCatName($value) { $this->_showCatName = $value; + return $this; } /** @@ -351,10 +371,12 @@ class PHPExcel_Chart_Layout * Set show ser name * Specifies that the series name should be shown in data labels. * - * @param boolean $value Show ser name + * @param boolean $value Show series name + * @return PHPExcel_Chart_Layout */ public function setShowSerName($value) { $this->_showSerName = $value; + return $this; } /** @@ -371,9 +393,11 @@ class PHPExcel_Chart_Layout * Specifies that the percentage should be shown in data labels. * * @param boolean $value Show percentage + * @return PHPExcel_Chart_Layout */ public function setShowPercent($value) { $this->_showPercent = $value; + return $this; } /** @@ -390,9 +414,11 @@ class PHPExcel_Chart_Layout * Specifies that the bubble size should be shown in data labels. * * @param boolean $value Show bubble size + * @return PHPExcel_Chart_Layout */ public function setShowBubbleSize($value) { $this->_showBubbleSize = $value; + return $this; } /** @@ -409,9 +435,11 @@ class PHPExcel_Chart_Layout * Specifies that leader lines should be shown in data labels. * * @param boolean $value Show leader lines + * @return PHPExcel_Chart_Layout */ public function setShowLeaderLines($value) { $this->_showLeaderLines = $value; + return $this; } } diff --git a/htdocs/includes/phpexcel/PHPExcel/Chart/Legend.php b/htdocs/includes/phpexcel/PHPExcel/Chart/Legend.php index 0ccd77e958d..4b7c6449aab 100644 --- a/htdocs/includes/phpexcel/PHPExcel/Chart/Legend.php +++ b/htdocs/includes/phpexcel/PHPExcel/Chart/Legend.php @@ -2,7 +2,7 @@ /** * PHPExcel * - * Copyright (c) 2006 - 2012 PHPExcel + * Copyright (c) 2006 - 2014 PHPExcel * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,9 +20,9 @@ * * @category PHPExcel * @package PHPExcel_Chart - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version 1.7.8, 2012-10-12 + * @version 1.8.0, 2014-03-02 */ @@ -31,7 +31,7 @@ * * @category PHPExcel * @package PHPExcel_Chart - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) */ class PHPExcel_Chart_Legend { diff --git a/htdocs/includes/phpexcel/PHPExcel/Chart/PlotArea.php b/htdocs/includes/phpexcel/PHPExcel/Chart/PlotArea.php index 134ee59550a..237d29b0e25 100644 --- a/htdocs/includes/phpexcel/PHPExcel/Chart/PlotArea.php +++ b/htdocs/includes/phpexcel/PHPExcel/Chart/PlotArea.php @@ -2,7 +2,7 @@ /** * PHPExcel * - * Copyright (c) 2006 - 2012 PHPExcel + * Copyright (c) 2006 - 2014 PHPExcel * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,9 +20,9 @@ * * @category PHPExcel * @package PHPExcel_Chart - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version 1.7.8, 2012-10-12 + * @version 1.8.0, 2014-03-02 */ @@ -31,7 +31,7 @@ * * @category PHPExcel * @package PHPExcel_Chart - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) */ class PHPExcel_Chart_PlotArea { @@ -110,10 +110,13 @@ class PHPExcel_Chart_PlotArea /** * Set Plot Series * - * @param array of PHPExcel_Chart_DataSeries + * @param [PHPExcel_Chart_DataSeries] + * @return PHPExcel_Chart_PlotArea */ public function setPlotSeries($plotSeries = array()) { $this->_plotSeries = $plotSeries; + + return $this; } public function refresh(PHPExcel_Worksheet $worksheet) { diff --git a/htdocs/includes/phpexcel/PHPExcel/Chart/Renderer/jpgraph.php b/htdocs/includes/phpexcel/PHPExcel/Chart/Renderer/jpgraph.php index 889fd9fce08..14ba2a04152 100644 --- a/htdocs/includes/phpexcel/PHPExcel/Chart/Renderer/jpgraph.php +++ b/htdocs/includes/phpexcel/PHPExcel/Chart/Renderer/jpgraph.php @@ -3,7 +3,7 @@ /** * PHPExcel * - * Copyright (c) 2006 - 2012 PHPExcel + * Copyright (c) 2006 - 2014 PHPExcel * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,10 +20,10 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * @category PHPExcel - * @package PHPExcel_Chart - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @package PHPExcel_Chart_Renderer + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version 1.7.8, 2012-10-12 + * @version 1.8.0, 2014-03-02 */ @@ -35,7 +35,7 @@ require_once(PHPExcel_Settings::getChartRendererPath().'/jpgraph.php'); * * @category PHPExcel * @package PHPExcel_Chart_Renderer - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) */ class PHPExcel_Chart_Renderer_jpgraph { @@ -107,13 +107,11 @@ class PHPExcel_Chart_Renderer_jpgraph $testCurrentIndex = 0; foreach($datasetLabels as $i => $datasetLabel) { - array_reverse($datasetLabel); - if (is_array($datasetLabel)) { if ($rotation == 'bar') { - $datasetLabel = array_reverse($datasetLabel); $datasetLabels[$i] = implode(" ",$datasetLabel); } else { + $datasetLabel = array_reverse($datasetLabel); $datasetLabels[$i] = implode("\n",$datasetLabel); } } else { @@ -519,19 +517,37 @@ class PHPExcel_Chart_Renderer_jpgraph private function _renderPlotStock($groupID) { $seriesCount = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotSeriesCount(); $plotOrder = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotOrder(); - $seriesPlots = array(); $dataValues = array(); - // Loop through each data series in turn - for($i = 0; $i < $seriesCount; ++$i) { - $dataValuesY = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotCategoryByIndex($i)->getDataValues(); - $dataValuesX = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotValuesByIndex($i)->getDataValues(); - - foreach($dataValuesX as $j => $dataValueX) - $dataValues[$j][$plotOrder[$i]] = $dataValueX; + // Loop through each data series in turn and build the plot arrays + foreach($plotOrder as $i => $v) { + $dataValuesX = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotValuesByIndex($v)->getDataValues(); + foreach($dataValuesX as $j => $dataValueX) { + $dataValues[$plotOrder[$i]][$j] = $dataValueX; + } + } + if(empty($dataValues)) { + return; } - $seriesPlot = new StockPlot($dataValues); + $dataValuesPlot = array(); + // Flatten the plot arrays to a single dimensional array to work with jpgraph + for($j = 0; $j < count($dataValues[0]); $j++) { + for($i = 0; $i < $seriesCount; $i++) { + $dataValuesPlot[] = $dataValues[$i][$j]; + } + } + + // Set the x-axis labels + $labelCount = count($this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotValuesByIndex(0)->getPointCount()); + if ($labelCount > 0) { + $datasetLabels = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotCategoryByIndex(0)->getDataValues(); + $datasetLabels = $this->_formatDataSetLabels($groupID, $datasetLabels, $labelCount); + $this->_graph->xaxis->SetTickLabels($datasetLabels); + } + + $seriesPlot = new StockPlot($dataValuesPlot); + $seriesPlot->SetWidth(20); $this->_graph->Add($seriesPlot); } // function _renderPlotStock() @@ -683,9 +699,9 @@ class PHPExcel_Chart_Renderer_jpgraph private function _renderStockChart($groupCount) { require_once('jpgraph_stock.php'); - $this->_renderCartesianPlotArea(); + $this->_renderCartesianPlotArea('intint'); - for($groupID = 0; $groupID < $groupCount; ++$i) { + for($groupID = 0; $groupID < $groupCount; ++$groupID) { $this->_renderPlotStock($groupID); } } // function _renderStockChart() diff --git a/htdocs/includes/phpexcel/PHPExcel/Chart/Title.php b/htdocs/includes/phpexcel/PHPExcel/Chart/Title.php index ef26f465825..415551b3f0f 100644 --- a/htdocs/includes/phpexcel/PHPExcel/Chart/Title.php +++ b/htdocs/includes/phpexcel/PHPExcel/Chart/Title.php @@ -2,7 +2,7 @@ /** * PHPExcel * - * Copyright (c) 2006 - 2012 PHPExcel + * Copyright (c) 2006 - 2014 PHPExcel * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,9 +20,9 @@ * * @category PHPExcel * @package PHPExcel_Chart - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version 1.7.8, 2012-10-12 + * @version 1.8.0, 2014-03-02 */ @@ -31,7 +31,7 @@ * * @category PHPExcel * @package PHPExcel_Chart - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) */ class PHPExcel_Chart_Title { @@ -72,9 +72,12 @@ class PHPExcel_Chart_Title * Set caption * * @param string $caption + * @return PHPExcel_Chart_Title */ public function setCaption($caption = null) { $this->_caption = $caption; + + return $this; } /** diff --git a/htdocs/includes/phpexcel/PHPExcel/Comment.php b/htdocs/includes/phpexcel/PHPExcel/Comment.php index 4ba239f4b7c..a2422c60e9e 100644 --- a/htdocs/includes/phpexcel/PHPExcel/Comment.php +++ b/htdocs/includes/phpexcel/PHPExcel/Comment.php @@ -2,7 +2,7 @@ /** * PHPExcel * - * Copyright (c) 2006 - 2012 PHPExcel + * Copyright (c) 2006 - 2014 PHPExcel * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,9 +20,9 @@ * * @category PHPExcel * @package PHPExcel - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version 1.7.8, 2012-10-12 + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) + * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @version 1.8.0, 2014-03-02 */ @@ -31,85 +31,85 @@ * * @category PHPExcel * @package PHPExcel - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) */ class PHPExcel_Comment implements PHPExcel_IComparable { - /** - * Author - * - * @var string - */ - private $_author; + /** + * Author + * + * @var string + */ + private $_author; - /** - * Rich text comment - * - * @var PHPExcel_RichText - */ - private $_text; + /** + * Rich text comment + * + * @var PHPExcel_RichText + */ + private $_text; - /** - * Comment width (CSS style, i.e. XXpx or YYpt) - * - * @var string - */ - private $_width = '96pt'; + /** + * Comment width (CSS style, i.e. XXpx or YYpt) + * + * @var string + */ + private $_width = '96pt'; - /** - * Left margin (CSS style, i.e. XXpx or YYpt) - * - * @var string - */ - private $_marginLeft = '59.25pt'; + /** + * Left margin (CSS style, i.e. XXpx or YYpt) + * + * @var string + */ + private $_marginLeft = '59.25pt'; - /** - * Top margin (CSS style, i.e. XXpx or YYpt) - * - * @var string - */ - private $_marginTop = '1.5pt'; + /** + * Top margin (CSS style, i.e. XXpx or YYpt) + * + * @var string + */ + private $_marginTop = '1.5pt'; - /** - * Visible - * - * @var boolean - */ - private $_visible = false; + /** + * Visible + * + * @var boolean + */ + private $_visible = false; - /** - * Comment height (CSS style, i.e. XXpx or YYpt) - * - * @var string - */ - private $_height = '55.5pt'; + /** + * Comment height (CSS style, i.e. XXpx or YYpt) + * + * @var string + */ + private $_height = '55.5pt'; - /** - * Comment fill color - * - * @var PHPExcel_Style_Color - */ - private $_fillColor; + /** + * Comment fill color + * + * @var PHPExcel_Style_Color + */ + private $_fillColor; - /** - * Alignment - * - * @var string - */ - private $_alignment; + /** + * Alignment + * + * @var string + */ + private $_alignment; /** * Create a new PHPExcel_Comment * - * @throws Exception + * @throws PHPExcel_Exception */ public function __construct() { - // Initialise variables - $this->_author = 'Author'; - $this->_text = new PHPExcel_RichText(); - $this->_fillColor = new PHPExcel_Style_Color('FFFFFFE1'); - $this->_alignment = PHPExcel_Style_Alignment::HORIZONTAL_GENERAL; + // Initialise variables + $this->_author = 'Author'; + $this->_text = new PHPExcel_RichText(); + $this->_fillColor = new PHPExcel_Style_Color('FFFFFFE1'); + $this->_alignment = PHPExcel_Style_Alignment::HORIZONTAL_GENERAL; } /** @@ -118,7 +118,7 @@ class PHPExcel_Comment implements PHPExcel_IComparable * @return string */ public function getAuthor() { - return $this->_author; + return $this->_author; } /** @@ -127,10 +127,10 @@ class PHPExcel_Comment implements PHPExcel_IComparable * @param string $pValue * @return PHPExcel_Comment */ - public function setAuthor($pValue = '') { - $this->_author = $pValue; - return $this; - } + public function setAuthor($pValue = '') { + $this->_author = $pValue; + return $this; + } /** * Get Rich text comment @@ -138,7 +138,7 @@ class PHPExcel_Comment implements PHPExcel_IComparable * @return PHPExcel_RichText */ public function getText() { - return $this->_text; + return $this->_text; } /** @@ -148,8 +148,8 @@ class PHPExcel_Comment implements PHPExcel_IComparable * @return PHPExcel_Comment */ public function setText(PHPExcel_RichText $pValue) { - $this->_text = $pValue; - return $this; + $this->_text = $pValue; + return $this; } /** @@ -268,8 +268,8 @@ class PHPExcel_Comment implements PHPExcel_IComparable * @return PHPExcel_Comment */ public function setAlignment($pValue = PHPExcel_Style_Alignment::HORIZONTAL_GENERAL) { - $this->_alignment = $pValue; - return $this; + $this->_alignment = $pValue; + return $this; } /** @@ -278,40 +278,50 @@ class PHPExcel_Comment implements PHPExcel_IComparable * @return string */ public function getAlignment() { - return $this->_alignment; + return $this->_alignment; } - /** - * Get hash code - * - * @return string Hash code - */ - public function getHashCode() { - return md5( - $this->_author - . $this->_text->getHashCode() - . $this->_width - . $this->_height - . $this->_marginLeft - . $this->_marginTop - . ($this->_visible ? 1 : 0) - . $this->_fillColor->getHashCode() - . $this->_alignment - . __CLASS__ - ); + /** + * Get hash code + * + * @return string Hash code + */ + public function getHashCode() { + return md5( + $this->_author + . $this->_text->getHashCode() + . $this->_width + . $this->_height + . $this->_marginLeft + . $this->_marginTop + . ($this->_visible ? 1 : 0) + . $this->_fillColor->getHashCode() + . $this->_alignment + . __CLASS__ + ); + } + + /** + * Implement PHP __clone to create a deep clone, not just a shallow copy. + */ + public function __clone() { + $vars = get_object_vars($this); + foreach ($vars as $key => $value) { + if (is_object($value)) { + $this->$key = clone $value; + } else { + $this->$key = $value; + } + } + } + + /** + * Convert to string + * + * @return string + */ + public function __toString() { + return $this->_text->getPlainText(); } - /** - * Implement PHP __clone to create a deep clone, not just a shallow copy. - */ - public function __clone() { - $vars = get_object_vars($this); - foreach ($vars as $key => $value) { - if (is_object($value)) { - $this->$key = clone $value; - } else { - $this->$key = $value; - } - } - } } diff --git a/htdocs/includes/phpexcel/PHPExcel/DocumentProperties.php b/htdocs/includes/phpexcel/PHPExcel/DocumentProperties.php index 1f4cad247ca..2f1fa1ede7d 100644 --- a/htdocs/includes/phpexcel/PHPExcel/DocumentProperties.php +++ b/htdocs/includes/phpexcel/PHPExcel/DocumentProperties.php @@ -2,7 +2,7 @@ /** * PHPExcel * - * Copyright (c) 2006 - 2012 PHPExcel + * Copyright (c) 2006 - 2014 PHPExcel * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -18,571 +18,570 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - * @category PHPExcel - * @package PHPExcel - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version 1.7.8, 2012-10-12 + * @category PHPExcel + * @package PHPExcel + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) + * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @version 1.8.0, 2014-03-02 */ /** * PHPExcel_DocumentProperties * - * @category PHPExcel - * @package PHPExcel - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @category PHPExcel + * @package PHPExcel + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) */ class PHPExcel_DocumentProperties { - /** constants */ - const PROPERTY_TYPE_BOOLEAN = 'b'; - const PROPERTY_TYPE_INTEGER = 'i'; - const PROPERTY_TYPE_FLOAT = 'f'; - const PROPERTY_TYPE_DATE = 'd'; - const PROPERTY_TYPE_STRING = 's'; - const PROPERTY_TYPE_UNKNOWN = 'u'; + /** constants */ + const PROPERTY_TYPE_BOOLEAN = 'b'; + const PROPERTY_TYPE_INTEGER = 'i'; + const PROPERTY_TYPE_FLOAT = 'f'; + const PROPERTY_TYPE_DATE = 'd'; + const PROPERTY_TYPE_STRING = 's'; + const PROPERTY_TYPE_UNKNOWN = 'u'; + + /** + * Creator + * + * @var string + */ + private $_creator = 'Unknown Creator'; + + /** + * LastModifiedBy + * + * @var string + */ + private $_lastModifiedBy; + + /** + * Created + * + * @var datetime + */ + private $_created; + + /** + * Modified + * + * @var datetime + */ + private $_modified; + + /** + * Title + * + * @var string + */ + private $_title = 'Untitled Spreadsheet'; + + /** + * Description + * + * @var string + */ + private $_description = ''; + + /** + * Subject + * + * @var string + */ + private $_subject = ''; + + /** + * Keywords + * + * @var string + */ + private $_keywords = ''; + + /** + * Category + * + * @var string + */ + private $_category = ''; + + /** + * Manager + * + * @var string + */ + private $_manager = ''; + + /** + * Company + * + * @var string + */ + private $_company = 'Microsoft Corporation'; + + /** + * Custom Properties + * + * @var string + */ + private $_customProperties = array(); - /** - * Creator - * - * @var string - */ - private $_creator = 'Unknown Creator'; + /** + * Create a new PHPExcel_DocumentProperties + */ + public function __construct() + { + // Initialise values + $this->_lastModifiedBy = $this->_creator; + $this->_created = time(); + $this->_modified = time(); + } - /** - * LastModifiedBy - * - * @var string - */ - private $_lastModifiedBy; + /** + * Get Creator + * + * @return string + */ + public function getCreator() { + return $this->_creator; + } - /** - * Created - * - * @var datetime - */ - private $_created; + /** + * Set Creator + * + * @param string $pValue + * @return PHPExcel_DocumentProperties + */ + public function setCreator($pValue = '') { + $this->_creator = $pValue; + return $this; + } - /** - * Modified - * - * @var datetime - */ - private $_modified; + /** + * Get Last Modified By + * + * @return string + */ + public function getLastModifiedBy() { + return $this->_lastModifiedBy; + } - /** - * Title - * - * @var string - */ - private $_title = 'Untitled Spreadsheet'; + /** + * Set Last Modified By + * + * @param string $pValue + * @return PHPExcel_DocumentProperties + */ + public function setLastModifiedBy($pValue = '') { + $this->_lastModifiedBy = $pValue; + return $this; + } - /** - * Description - * - * @var string - */ - private $_description = ''; + /** + * Get Created + * + * @return datetime + */ + public function getCreated() { + return $this->_created; + } - /** - * Subject - * - * @var string - */ - private $_subject = ''; + /** + * Set Created + * + * @param datetime $pValue + * @return PHPExcel_DocumentProperties + */ + public function setCreated($pValue = null) { + if ($pValue === NULL) { + $pValue = time(); + } elseif (is_string($pValue)) { + if (is_numeric($pValue)) { + $pValue = intval($pValue); + } else { + $pValue = strtotime($pValue); + } + } - /** - * Keywords - * - * @var string - */ - private $_keywords = ''; + $this->_created = $pValue; + return $this; + } - /** - * Category - * - * @var string - */ - private $_category = ''; + /** + * Get Modified + * + * @return datetime + */ + public function getModified() { + return $this->_modified; + } - /** - * Manager - * - * @var string - */ - private $_manager = ''; + /** + * Set Modified + * + * @param datetime $pValue + * @return PHPExcel_DocumentProperties + */ + public function setModified($pValue = null) { + if ($pValue === NULL) { + $pValue = time(); + } elseif (is_string($pValue)) { + if (is_numeric($pValue)) { + $pValue = intval($pValue); + } else { + $pValue = strtotime($pValue); + } + } - /** - * Company - * - * @var string - */ - private $_company = 'Microsoft Corporation'; + $this->_modified = $pValue; + return $this; + } - /** - * Custom Properties - * - * @var string - */ - private $_customProperties = array(); + /** + * Get Title + * + * @return string + */ + public function getTitle() { + return $this->_title; + } + /** + * Set Title + * + * @param string $pValue + * @return PHPExcel_DocumentProperties + */ + public function setTitle($pValue = '') { + $this->_title = $pValue; + return $this; + } - /** - * Create a new PHPExcel_DocumentProperties - */ - public function __construct() - { - // Initialise values - $this->_lastModifiedBy = $this->_creator; - $this->_created = time(); - $this->_modified = time(); - } + /** + * Get Description + * + * @return string + */ + public function getDescription() { + return $this->_description; + } - /** - * Get Creator - * - * @return string - */ - public function getCreator() { - return $this->_creator; - } + /** + * Set Description + * + * @param string $pValue + * @return PHPExcel_DocumentProperties + */ + public function setDescription($pValue = '') { + $this->_description = $pValue; + return $this; + } - /** - * Set Creator - * - * @param string $pValue - * @return PHPExcel_DocumentProperties - */ - public function setCreator($pValue = '') { - $this->_creator = $pValue; - return $this; - } + /** + * Get Subject + * + * @return string + */ + public function getSubject() { + return $this->_subject; + } - /** - * Get Last Modified By - * - * @return string - */ - public function getLastModifiedBy() { - return $this->_lastModifiedBy; - } + /** + * Set Subject + * + * @param string $pValue + * @return PHPExcel_DocumentProperties + */ + public function setSubject($pValue = '') { + $this->_subject = $pValue; + return $this; + } - /** - * Set Last Modified By - * - * @param string $pValue - * @return PHPExcel_DocumentProperties - */ - public function setLastModifiedBy($pValue = '') { - $this->_lastModifiedBy = $pValue; - return $this; - } + /** + * Get Keywords + * + * @return string + */ + public function getKeywords() { + return $this->_keywords; + } - /** - * Get Created - * - * @return datetime - */ - public function getCreated() { - return $this->_created; - } + /** + * Set Keywords + * + * @param string $pValue + * @return PHPExcel_DocumentProperties + */ + public function setKeywords($pValue = '') { + $this->_keywords = $pValue; + return $this; + } - /** - * Set Created - * - * @param datetime $pValue - * @return PHPExcel_DocumentProperties - */ - public function setCreated($pValue = null) { - if ($pValue === NULL) { - $pValue = time(); - } elseif (is_string($pValue)) { - if (is_numeric($pValue)) { - $pValue = intval($pValue); - } else { - $pValue = strtotime($pValue); - } - } + /** + * Get Category + * + * @return string + */ + public function getCategory() { + return $this->_category; + } - $this->_created = $pValue; - return $this; - } + /** + * Set Category + * + * @param string $pValue + * @return PHPExcel_DocumentProperties + */ + public function setCategory($pValue = '') { + $this->_category = $pValue; + return $this; + } - /** - * Get Modified - * - * @return datetime - */ - public function getModified() { - return $this->_modified; - } + /** + * Get Company + * + * @return string + */ + public function getCompany() { + return $this->_company; + } - /** - * Set Modified - * - * @param datetime $pValue - * @return PHPExcel_DocumentProperties - */ - public function setModified($pValue = null) { - if ($pValue === NULL) { - $pValue = time(); - } elseif (is_string($pValue)) { - if (is_numeric($pValue)) { - $pValue = intval($pValue); - } else { - $pValue = strtotime($pValue); - } - } + /** + * Set Company + * + * @param string $pValue + * @return PHPExcel_DocumentProperties + */ + public function setCompany($pValue = '') { + $this->_company = $pValue; + return $this; + } - $this->_modified = $pValue; - return $this; - } + /** + * Get Manager + * + * @return string + */ + public function getManager() { + return $this->_manager; + } - /** - * Get Title - * - * @return string - */ - public function getTitle() { - return $this->_title; - } + /** + * Set Manager + * + * @param string $pValue + * @return PHPExcel_DocumentProperties + */ + public function setManager($pValue = '') { + $this->_manager = $pValue; + return $this; + } - /** - * Set Title - * - * @param string $pValue - * @return PHPExcel_DocumentProperties - */ - public function setTitle($pValue = '') { - $this->_title = $pValue; - return $this; - } + /** + * Get a List of Custom Property Names + * + * @return array of string + */ + public function getCustomProperties() { + return array_keys($this->_customProperties); + } - /** - * Get Description - * - * @return string - */ - public function getDescription() { - return $this->_description; - } + /** + * Check if a Custom Property is defined + * + * @param string $propertyName + * @return boolean + */ + public function isCustomPropertySet($propertyName) { + return isset($this->_customProperties[$propertyName]); + } - /** - * Set Description - * - * @param string $pValue - * @return PHPExcel_DocumentProperties - */ - public function setDescription($pValue = '') { - $this->_description = $pValue; - return $this; - } + /** + * Get a Custom Property Value + * + * @param string $propertyName + * @return string + */ + public function getCustomPropertyValue($propertyName) { + if (isset($this->_customProperties[$propertyName])) { + return $this->_customProperties[$propertyName]['value']; + } - /** - * Get Subject - * - * @return string - */ - public function getSubject() { - return $this->_subject; - } + } - /** - * Set Subject - * - * @param string $pValue - * @return PHPExcel_DocumentProperties - */ - public function setSubject($pValue = '') { - $this->_subject = $pValue; - return $this; - } + /** + * Get a Custom Property Type + * + * @param string $propertyName + * @return string + */ + public function getCustomPropertyType($propertyName) { + if (isset($this->_customProperties[$propertyName])) { + return $this->_customProperties[$propertyName]['type']; + } - /** - * Get Keywords - * - * @return string - */ - public function getKeywords() { - return $this->_keywords; - } + } - /** - * Set Keywords - * - * @param string $pValue - * @return PHPExcel_DocumentProperties - */ - public function setKeywords($pValue = '') { - $this->_keywords = $pValue; - return $this; - } + /** + * Set a Custom Property + * + * @param string $propertyName + * @param mixed $propertyValue + * @param string $propertyType + * 'i' : Integer + * 'f' : Floating Point + * 's' : String + * 'd' : Date/Time + * 'b' : Boolean + * @return PHPExcel_DocumentProperties + */ + public function setCustomProperty($propertyName,$propertyValue='',$propertyType=NULL) { + if (($propertyType === NULL) || (!in_array($propertyType,array(self::PROPERTY_TYPE_INTEGER, + self::PROPERTY_TYPE_FLOAT, + self::PROPERTY_TYPE_STRING, + self::PROPERTY_TYPE_DATE, + self::PROPERTY_TYPE_BOOLEAN)))) { + if ($propertyValue === NULL) { + $propertyType = self::PROPERTY_TYPE_STRING; + } elseif (is_float($propertyValue)) { + $propertyType = self::PROPERTY_TYPE_FLOAT; + } elseif(is_int($propertyValue)) { + $propertyType = self::PROPERTY_TYPE_INTEGER; + } elseif (is_bool($propertyValue)) { + $propertyType = self::PROPERTY_TYPE_BOOLEAN; + } else { + $propertyType = self::PROPERTY_TYPE_STRING; + } + } - /** - * Get Category - * - * @return string - */ - public function getCategory() { - return $this->_category; - } + $this->_customProperties[$propertyName] = array('value' => $propertyValue, 'type' => $propertyType); + return $this; + } - /** - * Set Category - * - * @param string $pValue - * @return PHPExcel_DocumentProperties - */ - public function setCategory($pValue = '') { - $this->_category = $pValue; - return $this; - } + /** + * Implement PHP __clone to create a deep clone, not just a shallow copy. + */ + public function __clone() { + $vars = get_object_vars($this); + foreach ($vars as $key => $value) { + if (is_object($value)) { + $this->$key = clone $value; + } else { + $this->$key = $value; + } + } + } - /** - * Get Company - * - * @return string - */ - public function getCompany() { - return $this->_company; - } + public static function convertProperty($propertyValue,$propertyType) { + switch ($propertyType) { + case 'empty' : // Empty + return ''; + break; + case 'null' : // Null + return NULL; + break; + case 'i1' : // 1-Byte Signed Integer + case 'i2' : // 2-Byte Signed Integer + case 'i4' : // 4-Byte Signed Integer + case 'i8' : // 8-Byte Signed Integer + case 'int' : // Integer + return (int) $propertyValue; + break; + case 'ui1' : // 1-Byte Unsigned Integer + case 'ui2' : // 2-Byte Unsigned Integer + case 'ui4' : // 4-Byte Unsigned Integer + case 'ui8' : // 8-Byte Unsigned Integer + case 'uint' : // Unsigned Integer + return abs((int) $propertyValue); + break; + case 'r4' : // 4-Byte Real Number + case 'r8' : // 8-Byte Real Number + case 'decimal' : // Decimal + return (float) $propertyValue; + break; + case 'lpstr' : // LPSTR + case 'lpwstr' : // LPWSTR + case 'bstr' : // Basic String + return $propertyValue; + break; + case 'date' : // Date and Time + case 'filetime' : // File Time + return strtotime($propertyValue); + break; + case 'bool' : // Boolean + return ($propertyValue == 'true') ? True : False; + break; + case 'cy' : // Currency + case 'error' : // Error Status Code + case 'vector' : // Vector + case 'array' : // Array + case 'blob' : // Binary Blob + case 'oblob' : // Binary Blob Object + case 'stream' : // Binary Stream + case 'ostream' : // Binary Stream Object + case 'storage' : // Binary Storage + case 'ostorage' : // Binary Storage Object + case 'vstream' : // Binary Versioned Stream + case 'clsid' : // Class ID + case 'cf' : // Clipboard Data + return $propertyValue; + break; + } + return $propertyValue; + } - /** - * Set Company - * - * @param string $pValue - * @return PHPExcel_DocumentProperties - */ - public function setCompany($pValue = '') { - $this->_company = $pValue; - return $this; - } - - /** - * Get Manager - * - * @return string - */ - public function getManager() { - return $this->_manager; - } - - /** - * Set Manager - * - * @param string $pValue - * @return PHPExcel_DocumentProperties - */ - public function setManager($pValue = '') { - $this->_manager = $pValue; - return $this; - } - - /** - * Get a List of Custom Property Names - * - * @return array of string - */ - public function getCustomProperties() { - return array_keys($this->_customProperties); - } - - /** - * Check if a Custom Property is defined - * - * @param string $propertyName - * @return boolean - */ - public function isCustomPropertySet($propertyName) { - return isset($this->_customProperties[$propertyName]); - } - - /** - * Get a Custom Property Value - * - * @param string $propertyName - * @return string - */ - public function getCustomPropertyValue($propertyName) { - if (isset($this->_customProperties[$propertyName])) { - return $this->_customProperties[$propertyName]['value']; - } - - } - - /** - * Get a Custom Property Type - * - * @param string $propertyName - * @return string - */ - public function getCustomPropertyType($propertyName) { - if (isset($this->_customProperties[$propertyName])) { - return $this->_customProperties[$propertyName]['type']; - } - - } - - /** - * Set a Custom Property - * - * @param string $propertyName - * @param mixed $propertyValue - * @param string $propertyType - * 'i' : Integer - * 'f' : Floating Point - * 's' : String - * 'd' : Date/Time - * 'b' : Boolean - * @return PHPExcel_DocumentProperties - */ - public function setCustomProperty($propertyName,$propertyValue='',$propertyType=NULL) { - if (($propertyType === NULL) || (!in_array($propertyType,array(self::PROPERTY_TYPE_INTEGER, - self::PROPERTY_TYPE_FLOAT, - self::PROPERTY_TYPE_STRING, - self::PROPERTY_TYPE_DATE, - self::PROPERTY_TYPE_BOOLEAN)))) { - if ($propertyValue === NULL) { - $propertyType = self::PROPERTY_TYPE_STRING; - } elseif (is_float($propertyValue)) { - $propertyType = self::PROPERTY_TYPE_FLOAT; - } elseif(is_int($propertyValue)) { - $propertyType = self::PROPERTY_TYPE_INTEGER; - } elseif (is_bool($propertyValue)) { - $propertyType = self::PROPERTY_TYPE_BOOLEAN; - } else { - $propertyType = self::PROPERTY_TYPE_STRING; - } - } - - $this->_customProperties[$propertyName] = array('value' => $propertyValue, 'type' => $propertyType); - return $this; - } - - /** - * Implement PHP __clone to create a deep clone, not just a shallow copy. - */ - public function __clone() { - $vars = get_object_vars($this); - foreach ($vars as $key => $value) { - if (is_object($value)) { - $this->$key = clone $value; - } else { - $this->$key = $value; - } - } - } - - public static function convertProperty($propertyValue,$propertyType) { - switch ($propertyType) { - case 'empty' : // Empty - return ''; - break; - case 'null' : // Null - return NULL; - break; - case 'i1' : // 1-Byte Signed Integer - case 'i2' : // 2-Byte Signed Integer - case 'i4' : // 4-Byte Signed Integer - case 'i8' : // 8-Byte Signed Integer - case 'int' : // Integer - return (int) $propertyValue; - break; - case 'ui1' : // 1-Byte Unsigned Integer - case 'ui2' : // 2-Byte Unsigned Integer - case 'ui4' : // 4-Byte Unsigned Integer - case 'ui8' : // 8-Byte Unsigned Integer - case 'uint' : // Unsigned Integer - return abs((int) $propertyValue); - break; - case 'r4' : // 4-Byte Real Number - case 'r8' : // 8-Byte Real Number - case 'decimal' : // Decimal - return (float) $propertyValue; - break; - case 'lpstr' : // LPSTR - case 'lpwstr' : // LPWSTR - case 'bstr' : // Basic String - return $propertyValue; - break; - case 'date' : // Date and Time - case 'filetime' : // File Time - return strtotime($propertyValue); - break; - case 'bool' : // Boolean - return ($propertyValue == 'true') ? True : False; - break; - case 'cy' : // Currency - case 'error' : // Error Status Code - case 'vector' : // Vector - case 'array' : // Array - case 'blob' : // Binary Blob - case 'oblob' : // Binary Blob Object - case 'stream' : // Binary Stream - case 'ostream' : // Binary Stream Object - case 'storage' : // Binary Storage - case 'ostorage' : // Binary Storage Object - case 'vstream' : // Binary Versioned Stream - case 'clsid' : // Class ID - case 'cf' : // Clipboard Data - return $propertyValue; - break; - } - return $propertyValue; - } - - public static function convertPropertyType($propertyType) { - switch ($propertyType) { - case 'i1' : // 1-Byte Signed Integer - case 'i2' : // 2-Byte Signed Integer - case 'i4' : // 4-Byte Signed Integer - case 'i8' : // 8-Byte Signed Integer - case 'int' : // Integer - case 'ui1' : // 1-Byte Unsigned Integer - case 'ui2' : // 2-Byte Unsigned Integer - case 'ui4' : // 4-Byte Unsigned Integer - case 'ui8' : // 8-Byte Unsigned Integer - case 'uint' : // Unsigned Integer - return self::PROPERTY_TYPE_INTEGER; - break; - case 'r4' : // 4-Byte Real Number - case 'r8' : // 8-Byte Real Number - case 'decimal' : // Decimal - return self::PROPERTY_TYPE_FLOAT; - break; - case 'empty' : // Empty - case 'null' : // Null - case 'lpstr' : // LPSTR - case 'lpwstr' : // LPWSTR - case 'bstr' : // Basic String - return self::PROPERTY_TYPE_STRING; - break; - case 'date' : // Date and Time - case 'filetime' : // File Time - return self::PROPERTY_TYPE_DATE; - break; - case 'bool' : // Boolean - return self::PROPERTY_TYPE_BOOLEAN; - break; - case 'cy' : // Currency - case 'error' : // Error Status Code - case 'vector' : // Vector - case 'array' : // Array - case 'blob' : // Binary Blob - case 'oblob' : // Binary Blob Object - case 'stream' : // Binary Stream - case 'ostream' : // Binary Stream Object - case 'storage' : // Binary Storage - case 'ostorage' : // Binary Storage Object - case 'vstream' : // Binary Versioned Stream - case 'clsid' : // Class ID - case 'cf' : // Clipboard Data - return self::PROPERTY_TYPE_UNKNOWN; - break; - } - return self::PROPERTY_TYPE_UNKNOWN; - } + public static function convertPropertyType($propertyType) { + switch ($propertyType) { + case 'i1' : // 1-Byte Signed Integer + case 'i2' : // 2-Byte Signed Integer + case 'i4' : // 4-Byte Signed Integer + case 'i8' : // 8-Byte Signed Integer + case 'int' : // Integer + case 'ui1' : // 1-Byte Unsigned Integer + case 'ui2' : // 2-Byte Unsigned Integer + case 'ui4' : // 4-Byte Unsigned Integer + case 'ui8' : // 8-Byte Unsigned Integer + case 'uint' : // Unsigned Integer + return self::PROPERTY_TYPE_INTEGER; + break; + case 'r4' : // 4-Byte Real Number + case 'r8' : // 8-Byte Real Number + case 'decimal' : // Decimal + return self::PROPERTY_TYPE_FLOAT; + break; + case 'empty' : // Empty + case 'null' : // Null + case 'lpstr' : // LPSTR + case 'lpwstr' : // LPWSTR + case 'bstr' : // Basic String + return self::PROPERTY_TYPE_STRING; + break; + case 'date' : // Date and Time + case 'filetime' : // File Time + return self::PROPERTY_TYPE_DATE; + break; + case 'bool' : // Boolean + return self::PROPERTY_TYPE_BOOLEAN; + break; + case 'cy' : // Currency + case 'error' : // Error Status Code + case 'vector' : // Vector + case 'array' : // Array + case 'blob' : // Binary Blob + case 'oblob' : // Binary Blob Object + case 'stream' : // Binary Stream + case 'ostream' : // Binary Stream Object + case 'storage' : // Binary Storage + case 'ostorage' : // Binary Storage Object + case 'vstream' : // Binary Versioned Stream + case 'clsid' : // Class ID + case 'cf' : // Clipboard Data + return self::PROPERTY_TYPE_UNKNOWN; + break; + } + return self::PROPERTY_TYPE_UNKNOWN; + } } diff --git a/htdocs/includes/phpexcel/PHPExcel/DocumentSecurity.php b/htdocs/includes/phpexcel/PHPExcel/DocumentSecurity.php index 32bcb93035d..340504e8f18 100644 --- a/htdocs/includes/phpexcel/PHPExcel/DocumentSecurity.php +++ b/htdocs/includes/phpexcel/PHPExcel/DocumentSecurity.php @@ -2,7 +2,7 @@ /** * PHPExcel * - * Copyright (c) 2006 - 2012 PHPExcel + * Copyright (c) 2006 - 2014 PHPExcel * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,9 +20,9 @@ * * @category PHPExcel * @package PHPExcel - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version 1.7.8, 2012-10-12 + * @version 1.8.0, 2014-03-02 */ @@ -31,7 +31,7 @@ * * @category PHPExcel * @package PHPExcel - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) */ class PHPExcel_DocumentSecurity { diff --git a/htdocs/includes/phpexcel/PHPExcel/Exception.php b/htdocs/includes/phpexcel/PHPExcel/Exception.php index 454eaaa21b1..683e9099d8c 100644 --- a/htdocs/includes/phpexcel/PHPExcel/Exception.php +++ b/htdocs/includes/phpexcel/PHPExcel/Exception.php @@ -2,7 +2,7 @@ /** * PHPExcel * - * Copyright (c) 2006 - 2012 PHPExcel + * Copyright (c) 2006 - 2014 PHPExcel * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,9 +20,9 @@ * * @category PHPExcel * @package PHPExcel - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version 1.7.8, 2012-10-12 + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) + * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @version 1.8.0, 2014-03-02 */ @@ -31,22 +31,22 @@ * * @category PHPExcel * @package PHPExcel - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) */ class PHPExcel_Exception extends Exception { - /** - * Error handler callback - * - * @param mixed $code - * @param mixed $string - * @param mixed $file - * @param mixed $line - * @param mixed $context - */ - public static function errorHandlerCallback($code, $string, $file, $line, $context) { - $e = new self($string, $code); - $e->line = $line; - $e->file = $file; - throw $e; - } + /** + * Error handler callback + * + * @param mixed $code + * @param mixed $string + * @param mixed $file + * @param mixed $line + * @param mixed $context + */ + public static function errorHandlerCallback($code, $string, $file, $line, $context) { + $e = new self($string, $code); + $e->line = $line; + $e->file = $file; + throw $e; + } } diff --git a/htdocs/includes/phpexcel/PHPExcel/HashTable.php b/htdocs/includes/phpexcel/PHPExcel/HashTable.php index ca15e6e7a79..7a9205e5b95 100644 --- a/htdocs/includes/phpexcel/PHPExcel/HashTable.php +++ b/htdocs/includes/phpexcel/PHPExcel/HashTable.php @@ -2,7 +2,7 @@ /** * PHPExcel * - * Copyright (c) 2006 - 2012 PHPExcel + * Copyright (c) 2006 - 2014 PHPExcel * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,9 +20,9 @@ * * @category PHPExcel * @package PHPExcel - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version 1.7.8, 2012-10-12 + * @version 1.8.0, 2014-03-02 */ @@ -31,7 +31,7 @@ * * @category PHPExcel * @package PHPExcel - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) */ class PHPExcel_HashTable { @@ -53,7 +53,7 @@ class PHPExcel_HashTable * Create a new PHPExcel_HashTable * * @param PHPExcel_IComparable[] $pSource Optional source array to create HashTable from - * @throws Exception + * @throws PHPExcel_Exception */ public function __construct($pSource = null) { @@ -67,14 +67,14 @@ class PHPExcel_HashTable * Add HashTable items from source * * @param PHPExcel_IComparable[] $pSource Source array to create HashTable from - * @throws Exception + * @throws PHPExcel_Exception */ public function addFromSource($pSource = null) { // Check if an array was passed if ($pSource == null) { return; } else if (!is_array($pSource)) { - throw new Exception('Invalid array parameter passed.'); + throw new PHPExcel_Exception('Invalid array parameter passed.'); } foreach ($pSource as $item) { @@ -86,7 +86,7 @@ class PHPExcel_HashTable * Add HashTable item * * @param PHPExcel_IComparable $pSource Item to add - * @throws Exception + * @throws PHPExcel_Exception */ public function add(PHPExcel_IComparable $pSource = null) { $hash = $pSource->getHashCode(); @@ -100,7 +100,7 @@ class PHPExcel_HashTable * Remove HashTable item * * @param PHPExcel_IComparable $pSource Item to remove - * @throws Exception + * @throws PHPExcel_Exception */ public function remove(PHPExcel_IComparable $pSource = null) { $hash = $pSource->getHashCode(); diff --git a/htdocs/includes/phpexcel/PHPExcel/IComparable.php b/htdocs/includes/phpexcel/PHPExcel/IComparable.php index 1c87f398cf4..6b1e18aa901 100644 --- a/htdocs/includes/phpexcel/PHPExcel/IComparable.php +++ b/htdocs/includes/phpexcel/PHPExcel/IComparable.php @@ -18,9 +18,9 @@ * * @category PHPExcel * @package PHPExcel - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version 1.7.8, 2012-10-12 + * @version 1.8.0, 2014-03-02 */ @@ -29,7 +29,7 @@ * * @category PHPExcel * @package PHPExcel - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) */ interface PHPExcel_IComparable { diff --git a/htdocs/includes/phpexcel/PHPExcel/IOFactory.php b/htdocs/includes/phpexcel/PHPExcel/IOFactory.php index eeeb2af93a1..69ec8b69531 100644 --- a/htdocs/includes/phpexcel/PHPExcel/IOFactory.php +++ b/htdocs/includes/phpexcel/PHPExcel/IOFactory.php @@ -2,7 +2,7 @@ /** * PHPExcel * - * Copyright (c) 2006 - 2012 PHPExcel + * Copyright (c) 2006 - 2014 PHPExcel * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,9 +20,9 @@ * * @category PHPExcel * @package PHPExcel - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version 1.7.8, 2012-10-12 + * @version 1.8.0, 2014-03-02 */ @@ -40,7 +40,7 @@ if (!defined('PHPEXCEL_ROOT')) { * * @category PHPExcel * @package PHPExcel - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) */ class PHPExcel_IOFactory { @@ -96,13 +96,13 @@ class PHPExcel_IOFactory * @static * @access public * @param array $value - * @throws Exception + * @throws PHPExcel_Reader_Exception */ public static function setSearchLocations($value) { if (is_array($value)) { self::$_searchLocations = $value; } else { - throw new Exception('Invalid parameter passed.'); + throw new PHPExcel_Reader_Exception('Invalid parameter passed.'); } } // function setSearchLocations() @@ -127,7 +127,7 @@ class PHPExcel_IOFactory * @param PHPExcel $phpExcel * @param string $writerType Example: Excel2007 * @return PHPExcel_Writer_IWriter - * @throws Exception + * @throws PHPExcel_Reader_Exception */ public static function createWriter(PHPExcel $phpExcel, $writerType = '') { // Search type @@ -146,7 +146,7 @@ class PHPExcel_IOFactory } // Nothing found... - throw new Exception("No $searchType found for type $writerType"); + throw new PHPExcel_Reader_Exception("No $searchType found for type $writerType"); } // function createWriter() /** @@ -156,7 +156,7 @@ class PHPExcel_IOFactory * @access public * @param string $readerType Example: Excel2007 * @return PHPExcel_Reader_IReader - * @throws Exception + * @throws PHPExcel_Reader_Exception */ public static function createReader($readerType = '') { // Search type @@ -175,7 +175,7 @@ class PHPExcel_IOFactory } // Nothing found... - throw new Exception("No $searchType found for type $readerType"); + throw new PHPExcel_Reader_Exception("No $searchType found for type $readerType"); } // function createReader() /** @@ -183,9 +183,9 @@ class PHPExcel_IOFactory * * @static * @access public - * @param string $pFileName The name of the spreadsheet file + * @param string $pFilename The name of the spreadsheet file * @return PHPExcel - * @throws Exception + * @throws PHPExcel_Reader_Exception */ public static function load($pFilename) { $reader = self::createReaderForFile($pFilename); @@ -197,9 +197,9 @@ class PHPExcel_IOFactory * * @static * @access public - * @param string $pFileName The name of the spreadsheet file to identify + * @param string $pFilename The name of the spreadsheet file to identify * @return string - * @throws Exception + * @throws PHPExcel_Reader_Exception */ public static function identify($pFilename) { $reader = self::createReaderForFile($pFilename); @@ -214,9 +214,9 @@ class PHPExcel_IOFactory * * @static * @access public - * @param string $pFileName The name of the spreadsheet file + * @param string $pFilename The name of the spreadsheet file * @return PHPExcel_Reader_IReader - * @throws Exception + * @throws PHPExcel_Reader_Exception */ public static function createReaderForFile($pFilename) { @@ -283,6 +283,6 @@ class PHPExcel_IOFactory } } - throw new Exception('Unable to identify a reader for this file'); + throw new PHPExcel_Reader_Exception('Unable to identify a reader for this file'); } // function createReaderForFile() } diff --git a/htdocs/includes/phpexcel/PHPExcel/NamedRange.php b/htdocs/includes/phpexcel/PHPExcel/NamedRange.php index 3debd41a184..3ad5caabd46 100644 --- a/htdocs/includes/phpexcel/PHPExcel/NamedRange.php +++ b/htdocs/includes/phpexcel/PHPExcel/NamedRange.php @@ -2,7 +2,7 @@ /** * PHPExcel * - * Copyright (c) 2006 - 2012 PHPExcel + * Copyright (c) 2006 - 2014 PHPExcel * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,9 +20,9 @@ * * @category PHPExcel * @package PHPExcel - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version 1.7.8, 2012-10-12 + * @version 1.8.0, 2014-03-02 */ @@ -31,7 +31,7 @@ * * @category PHPExcel * @package PHPExcel - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) */ class PHPExcel_NamedRange { @@ -78,12 +78,13 @@ class PHPExcel_NamedRange * @param string $pRange * @param bool $pLocalOnly * @param PHPExcel_Worksheet|null $pScope Scope. Only applies when $pLocalOnly = true. Null for global scope. + * @throws PHPExcel_Exception */ public function __construct($pName = null, PHPExcel_Worksheet $pWorksheet, $pRange = 'A1', $pLocalOnly = false, $pScope = null) { // Validate data if (($pName === NULL) || ($pWorksheet === NULL) || ($pRange === NULL)) { - throw new Exception('Parameters can not be null.'); + throw new PHPExcel_Exception('Parameters can not be null.'); } // Set local members diff --git a/htdocs/includes/phpexcel/PHPExcel/Reader/Abstract.php b/htdocs/includes/phpexcel/PHPExcel/Reader/Abstract.php new file mode 100644 index 00000000000..0d5180c6e3e --- /dev/null +++ b/htdocs/includes/phpexcel/PHPExcel/Reader/Abstract.php @@ -0,0 +1,227 @@ +_readDataOnly; + } + + /** + * Set read data only + * Set to true, to advise the Reader only to read data values for cells, and to ignore any formatting information. + * Set to false (the default) to advise the Reader to read both data and formatting for cells. + * + * @param boolean $pValue + * + * @return PHPExcel_Reader_IReader + */ + public function setReadDataOnly($pValue = FALSE) { + $this->_readDataOnly = $pValue; + return $this; + } + + /** + * Read charts in workbook? + * If this is true, then the Reader will include any charts that exist in the workbook. + * Note that a ReadDataOnly value of false overrides, and charts won't be read regardless of the IncludeCharts value. + * If false (the default) it will ignore any charts defined in the workbook file. + * + * @return boolean + */ + public function getIncludeCharts() { + return $this->_includeCharts; + } + + /** + * Set read charts in workbook + * Set to true, to advise the Reader to include any charts that exist in the workbook. + * Note that a ReadDataOnly value of false overrides, and charts won't be read regardless of the IncludeCharts value. + * Set to false (the default) to discard charts. + * + * @param boolean $pValue + * + * @return PHPExcel_Reader_IReader + */ + public function setIncludeCharts($pValue = FALSE) { + $this->_includeCharts = (boolean) $pValue; + return $this; + } + + /** + * Get which sheets to load + * Returns either an array of worksheet names (the list of worksheets that should be loaded), or a null + * indicating that all worksheets in the workbook should be loaded. + * + * @return mixed + */ + public function getLoadSheetsOnly() + { + return $this->_loadSheetsOnly; + } + + /** + * Set which sheets to load + * + * @param mixed $value + * This should be either an array of worksheet names to be loaded, or a string containing a single worksheet name. + * If NULL, then it tells the Reader to read all worksheets in the workbook + * + * @return PHPExcel_Reader_IReader + */ + public function setLoadSheetsOnly($value = NULL) + { + $this->_loadSheetsOnly = is_array($value) ? + $value : array($value); + return $this; + } + + /** + * Set all sheets to load + * Tells the Reader to load all worksheets from the workbook. + * + * @return PHPExcel_Reader_IReader + */ + public function setLoadAllSheets() + { + $this->_loadSheetsOnly = NULL; + return $this; + } + + /** + * Read filter + * + * @return PHPExcel_Reader_IReadFilter + */ + public function getReadFilter() { + return $this->_readFilter; + } + + /** + * Set read filter + * + * @param PHPExcel_Reader_IReadFilter $pValue + * @return PHPExcel_Reader_IReader + */ + public function setReadFilter(PHPExcel_Reader_IReadFilter $pValue) { + $this->_readFilter = $pValue; + return $this; + } + + /** + * Open file for reading + * + * @param string $pFilename + * @throws PHPExcel_Reader_Exception + * @return resource + */ + protected function _openFile($pFilename) + { + // Check if file exists + if (!file_exists($pFilename) || !is_readable($pFilename)) { + throw new PHPExcel_Reader_Exception("Could not open " . $pFilename . " for reading! File does not exist."); + } + + // Open file + $this->_fileHandle = fopen($pFilename, 'r'); + if ($this->_fileHandle === FALSE) { + throw new PHPExcel_Reader_Exception("Could not open file " . $pFilename . " for reading."); + } + } + + /** + * Can the current PHPExcel_Reader_IReader read the file? + * + * @param string $pFilename + * @return boolean + * @throws PHPExcel_Reader_Exception + */ + public function canRead($pFilename) + { + // Check if file exists + try { + $this->_openFile($pFilename); + } catch (Exception $e) { + return FALSE; + } + + $readable = $this->_isValidFormat(); + fclose ($this->_fileHandle); + return $readable; + } + +} diff --git a/htdocs/includes/phpexcel/PHPExcel/Reader/CSV.php b/htdocs/includes/phpexcel/PHPExcel/Reader/CSV.php index 2739e3c4136..8bf7b848195 100644 --- a/htdocs/includes/phpexcel/PHPExcel/Reader/CSV.php +++ b/htdocs/includes/phpexcel/PHPExcel/Reader/CSV.php @@ -2,7 +2,7 @@ /** * PHPExcel * - * Copyright (c) 2006 - 2012 PHPExcel + * Copyright (c) 2006 - 2014 PHPExcel * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,9 +20,9 @@ * * @category PHPExcel * @package PHPExcel_Reader - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version 1.7.8, 2012-10-12 + * @version 1.8.0, 2014-03-02 */ @@ -40,9 +40,9 @@ if (!defined('PHPEXCEL_ROOT')) { * * @category PHPExcel * @package PHPExcel_Reader - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) */ -class PHPExcel_Reader_CSV implements PHPExcel_Reader_IReader +class PHPExcel_Reader_CSV extends PHPExcel_Reader_Abstract implements PHPExcel_Reader_IReader { /** * Input encoding @@ -92,144 +92,104 @@ class PHPExcel_Reader_CSV implements PHPExcel_Reader_IReader */ private $_contiguous = false; - /** * Row counter for loading rows contiguously * - * @access private * @var int */ private $_contiguousRow = -1; - /** - * PHPExcel_Reader_IReadFilter instance - * - * @access private - * @var PHPExcel_Reader_IReadFilter - */ - private $_readFilter = null; - /** * Create a new PHPExcel_Reader_CSV */ public function __construct() { $this->_readFilter = new PHPExcel_Reader_DefaultReadFilter(); - } // function __construct() - + } /** - * Can the current PHPExcel_Reader_IReader read the file? + * Validate that the current file is a CSV file * - * @access public - * @param string $pFileName * @return boolean - * @throws Exception */ - public function canRead($pFilename) + protected function _isValidFormat() { - // Check if file exists - if (!file_exists($pFilename)) { - throw new Exception("Could not open " . $pFilename . " for reading! File does not exist."); - } - - return true; - } // function canRead() - - - /** - * Read filter - * - * @access public - * @return PHPExcel_Reader_IReadFilter - */ - public function getReadFilter() { - return $this->_readFilter; - } // function getReadFilter() - - - /** - * Set read filter - * - * @access public - * @param PHPExcel_Reader_IReadFilter $pValue - */ - public function setReadFilter(PHPExcel_Reader_IReadFilter $pValue) { - $this->_readFilter = $pValue; - return $this; - } // function setReadFilter() - + return TRUE; + } /** * Set input encoding * - * @access public * @param string $pValue Input encoding */ public function setInputEncoding($pValue = 'UTF-8') { $this->_inputEncoding = $pValue; return $this; - } // function setInputEncoding() - + } /** * Get input encoding * - * @access public * @return string */ public function getInputEncoding() { return $this->_inputEncoding; - } // function getInputEncoding() - + } /** - * Return worksheet info (Name, Last Column Letter, Last Column Index, Total Rows, Total Columns) + * Move filepointer past any BOM marker * - * @access public - * @param string $pFilename - * @throws Exception */ - public function listWorksheetInfo($pFilename) + protected function _skipBOM() { - // Check if file exists - if (!file_exists($pFilename)) { - throw new Exception("Could not open " . $pFilename . " for reading! File does not exist."); - } + rewind($this->_fileHandle); - // Open file - $fileHandle = fopen($pFilename, 'r'); - if ($fileHandle === false) { - throw new Exception("Could not open file " . $pFilename . " for reading."); - } - - // Skip BOM, if any switch ($this->_inputEncoding) { case 'UTF-8': - fgets($fileHandle, 4) == "\xEF\xBB\xBF" ? - fseek($fileHandle, 3) : fseek($fileHandle, 0); + fgets($this->_fileHandle, 4) == "\xEF\xBB\xBF" ? + fseek($this->_fileHandle, 3) : fseek($this->_fileHandle, 0); break; case 'UTF-16LE': - fgets($fileHandle, 3) == "\xFF\xFE" ? - fseek($fileHandle, 2) : fseek($fileHandle, 0); + fgets($this->_fileHandle, 3) == "\xFF\xFE" ? + fseek($this->_fileHandle, 2) : fseek($this->_fileHandle, 0); break; case 'UTF-16BE': - fgets($fileHandle, 3) == "\xFE\xFF" ? - fseek($fileHandle, 2) : fseek($fileHandle, 0); + fgets($this->_fileHandle, 3) == "\xFE\xFF" ? + fseek($this->_fileHandle, 2) : fseek($this->_fileHandle, 0); break; case 'UTF-32LE': - fgets($fileHandle, 5) == "\xFF\xFE\x00\x00" ? - fseek($fileHandle, 4) : fseek($fileHandle, 0); + fgets($this->_fileHandle, 5) == "\xFF\xFE\x00\x00" ? + fseek($this->_fileHandle, 4) : fseek($this->_fileHandle, 0); break; case 'UTF-32BE': - fgets($fileHandle, 5) == "\x00\x00\xFE\xFF" ? - fseek($fileHandle, 4) : fseek($fileHandle, 0); + fgets($this->_fileHandle, 5) == "\x00\x00\xFE\xFF" ? + fseek($this->_fileHandle, 4) : fseek($this->_fileHandle, 0); break; default: break; } + } + + /** + * Return worksheet info (Name, Last Column Letter, Last Column Index, Total Rows, Total Columns) + * + * @param string $pFilename + * @throws PHPExcel_Reader_Exception + */ + public function listWorksheetInfo($pFilename) + { + // Open file + $this->_openFile($pFilename); + if (!$this->_isValidFormat()) { + fclose ($this->_fileHandle); + throw new PHPExcel_Reader_Exception($pFilename . " is an Invalid Spreadsheet file."); + } + $fileHandle = $this->_fileHandle; + + // Skip BOM, if any + $this->_skipBOM(); $escapeEnclosures = array( "\\" . $this->_enclosure, $this->_enclosure . $this->_enclosure ); @@ -255,14 +215,12 @@ class PHPExcel_Reader_CSV implements PHPExcel_Reader_IReader return $worksheetInfo; } - /** * Loads PHPExcel from file * - * @access public * @param string $pFilename * @return PHPExcel - * @throws Exception + * @throws PHPExcel_Reader_Exception */ public function load($pFilename) { @@ -271,65 +229,37 @@ class PHPExcel_Reader_CSV implements PHPExcel_Reader_IReader // Load into this instance return $this->loadIntoExisting($pFilename, $objPHPExcel); - } // function load() - + } /** * Loads PHPExcel from file into PHPExcel instance * - * @access public * @param string $pFilename * @param PHPExcel $objPHPExcel * @return PHPExcel - * @throws Exception + * @throws PHPExcel_Reader_Exception */ public function loadIntoExisting($pFilename, PHPExcel $objPHPExcel) { - // Check if file exists - if (!file_exists($pFilename)) { - throw new Exception("Could not open " . $pFilename . " for reading! File does not exist."); - } - - // Create new PHPExcel - while ($objPHPExcel->getSheetCount() <= $this->_sheetIndex) { - $objPHPExcel->createSheet(); - } - $sheet = $objPHPExcel->setActiveSheetIndex( $this->_sheetIndex ); - $lineEnding = ini_get('auto_detect_line_endings'); ini_set('auto_detect_line_endings', true); // Open file - $fileHandle = fopen($pFilename, 'r'); - if ($fileHandle === false) { - throw new Exception("Could not open file $pFilename for reading."); + $this->_openFile($pFilename); + if (!$this->_isValidFormat()) { + fclose ($this->_fileHandle); + throw new PHPExcel_Reader_Exception($pFilename . " is an Invalid Spreadsheet file."); } + $fileHandle = $this->_fileHandle; // Skip BOM, if any - switch ($this->_inputEncoding) { - case 'UTF-8': - fgets($fileHandle, 4) == "\xEF\xBB\xBF" ? - fseek($fileHandle, 3) : fseek($fileHandle, 0); - break; - case 'UTF-16LE': - fgets($fileHandle, 3) == "\xFF\xFE" ? - fseek($fileHandle, 2) : fseek($fileHandle, 0); - break; - case 'UTF-16BE': - fgets($fileHandle, 3) == "\xFE\xFF" ? - fseek($fileHandle, 2) : fseek($fileHandle, 0); - break; - case 'UTF-32LE': - fgets($fileHandle, 5) == "\xFF\xFE\x00\x00" ? - fseek($fileHandle, 4) : fseek($fileHandle, 0); - break; - case 'UTF-32BE': - fgets($fileHandle, 5) == "\x00\x00\xFE\xFF" ? - fseek($fileHandle, 4) : fseek($fileHandle, 0); - break; - default: - break; + $this->_skipBOM(); + + // Create new PHPExcel object + while ($objPHPExcel->getSheetCount() <= $this->_sheetIndex) { + $objPHPExcel->createSheet(); } + $sheet = $objPHPExcel->setActiveSheetIndex($this->_sheetIndex); $escapeEnclosures = array( "\\" . $this->_enclosure, $this->_enclosure . $this->_enclosure @@ -373,48 +303,40 @@ class PHPExcel_Reader_CSV implements PHPExcel_Reader_IReader // Return return $objPHPExcel; - } // function loadIntoExisting() - + } /** * Get delimiter * - * @access public * @return string */ public function getDelimiter() { return $this->_delimiter; - } // function getDelimiter() - + } /** * Set delimiter * - * @access public * @param string $pValue Delimiter, defaults to , * @return PHPExcel_Reader_CSV */ public function setDelimiter($pValue = ',') { $this->_delimiter = $pValue; return $this; - } // function setDelimiter() - + } /** * Get enclosure * - * @access public * @return string */ public function getEnclosure() { return $this->_enclosure; - } // function getEnclosure() - + } /** * Set enclosure * - * @access public * @param string $pValue Enclosure, defaults to " * @return PHPExcel_Reader_CSV */ @@ -424,82 +346,70 @@ class PHPExcel_Reader_CSV implements PHPExcel_Reader_IReader } $this->_enclosure = $pValue; return $this; - } // function setEnclosure() - + } /** * Get line ending * - * @access public * @return string */ public function getLineEnding() { return $this->_lineEnding; - } // function getLineEnding() - + } /** * Set line ending * - * @access public * @param string $pValue Line ending, defaults to OS line ending (PHP_EOL) * @return PHPExcel_Reader_CSV */ public function setLineEnding($pValue = PHP_EOL) { $this->_lineEnding = $pValue; return $this; - } // function setLineEnding() - + } /** * Get sheet index * - * @access public - * @return int + * @return integer */ public function getSheetIndex() { return $this->_sheetIndex; - } // function getSheetIndex() - + } /** * Set sheet index * - * @access public - * @param int $pValue Sheet index + * @param integer $pValue Sheet index * @return PHPExcel_Reader_CSV */ public function setSheetIndex($pValue = 0) { $this->_sheetIndex = $pValue; return $this; - } // function setSheetIndex() - + } /** * Set Contiguous * - * @access public - * @param string $pValue Input encoding + * @param boolean $contiguous */ - public function setContiguous($contiguous = false) + public function setContiguous($contiguous = FALSE) { - $this->_contiguous = (bool)$contiguous; + $this->_contiguous = (bool) $contiguous; if (!$contiguous) { - $this->_contiguousRow = -1; + $this->_contiguousRow = -1; } return $this; - } // function setInputEncoding() - + } /** * Get Contiguous * - * @access public * @return boolean */ public function getContiguous() { return $this->_contiguous; - } // function getSheetIndex() + } } diff --git a/htdocs/includes/phpexcel/PHPExcel/Reader/DefaultReadFilter.php b/htdocs/includes/phpexcel/PHPExcel/Reader/DefaultReadFilter.php index 276b974eecc..228ed10877a 100644 --- a/htdocs/includes/phpexcel/PHPExcel/Reader/DefaultReadFilter.php +++ b/htdocs/includes/phpexcel/PHPExcel/Reader/DefaultReadFilter.php @@ -2,7 +2,7 @@ /** * PHPExcel * - * Copyright (c) 2006 - 2012 PHPExcel + * Copyright (c) 2006 - 2014 PHPExcel * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,9 +20,9 @@ * * @category PHPExcel * @package PHPExcel_Reader - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version 1.7.8, 2012-10-12 + * @version 1.8.0, 2014-03-02 */ @@ -40,7 +40,7 @@ if (!defined('PHPEXCEL_ROOT')) { * * @category PHPExcel * @package PHPExcel_Reader - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) */ class PHPExcel_Reader_DefaultReadFilter implements PHPExcel_Reader_IReadFilter { diff --git a/htdocs/includes/phpexcel/PHPExcel/Reader/Excel2003XML.php b/htdocs/includes/phpexcel/PHPExcel/Reader/Excel2003XML.php index 33ffe6dcb3f..ce1f31d6772 100644 --- a/htdocs/includes/phpexcel/PHPExcel/Reader/Excel2003XML.php +++ b/htdocs/includes/phpexcel/PHPExcel/Reader/Excel2003XML.php @@ -2,7 +2,7 @@ /** * PHPExcel * - * Copyright (c) 2006 - 2012 PHPExcel + * Copyright (c) 2006 - 2014 PHPExcel * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,9 +20,9 @@ * * @category PHPExcel * @package PHPExcel_Reader - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version 1.7.8, 2012-10-12 + * @version 1.8.0, 2014-03-02 */ @@ -40,24 +40,10 @@ if (!defined('PHPEXCEL_ROOT')) { * * @category PHPExcel * @package PHPExcel_Reader - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) */ -class PHPExcel_Reader_Excel2003XML implements PHPExcel_Reader_IReader +class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements PHPExcel_Reader_IReader { - /** - * Read data only? - * - * @var boolean - */ - private $_readDataOnly = false; - - /** - * Restict which sheets should be loaded? - * - * @var array - */ - private $_loadSheetsOnly = null; - /** * Formats * @@ -65,13 +51,6 @@ class PHPExcel_Reader_Excel2003XML implements PHPExcel_Reader_IReader */ private $_styles = array(); - /** - * PHPExcel_Reader_IReadFilter instance - * - * @var PHPExcel_Reader_IReadFilter - */ - private $_readFilter = null; - /** * Character set used in the file * @@ -88,93 +67,12 @@ class PHPExcel_Reader_Excel2003XML implements PHPExcel_Reader_IReader } - /** - * Read data only? - * - * @return boolean - */ - public function getReadDataOnly() { - return $this->_readDataOnly; - } - - - /** - * Set read data only - * - * @param boolean $pValue - * @return PHPExcel_Reader_Excel2003XML - */ - public function setReadDataOnly($pValue = false) { - $this->_readDataOnly = $pValue; - return $this; - } - - - /** - * Get which sheets to load - * - * @return mixed - */ - public function getLoadSheetsOnly() - { - return $this->_loadSheetsOnly; - } - - - /** - * Set which sheets to load - * - * @param mixed $value - * @return PHPExcel_Reader_Excel2003XML - */ - public function setLoadSheetsOnly($value = null) - { - $this->_loadSheetsOnly = is_array($value) ? - $value : array($value); - return $this; - } - - - /** - * Set all sheets to load - * - * @return PHPExcel_Reader_Excel2003XML - */ - public function setLoadAllSheets() - { - $this->_loadSheetsOnly = null; - return $this; - } - - - /** - * Read filter - * - * @return PHPExcel_Reader_IReadFilter - */ - public function getReadFilter() { - return $this->_readFilter; - } - - - /** - * Set read filter - * - * @param PHPExcel_Reader_IReadFilter $pValue - * @return PHPExcel_Reader_Excel2003XML - */ - public function setReadFilter(PHPExcel_Reader_IReadFilter $pValue) { - $this->_readFilter = $pValue; - return $this; - } - - /** * Can the current PHPExcel_Reader_IReader read the file? * - * @param string $pFileName + * @param string $pFilename * @return boolean - * @throws Exception + * @throws PHPExcel_Reader_Exception */ public function canRead($pFilename) { @@ -194,15 +92,13 @@ class PHPExcel_Reader_Excel2003XML implements PHPExcel_Reader_IReader '' ); - // Check if file exists - if (!file_exists($pFilename)) { - throw new Exception("Could not open " . $pFilename . " for reading! File does not exist."); - } - + // Open file + $this->_openFile($pFilename); + $fileHandle = $this->_fileHandle; + // Read sample data (first 2 KB will do) - $fh = fopen($pFilename, 'r'); - $data = fread($fh, 2048); - fclose($fh); + $data = fread($fileHandle, 2048); + fclose($fileHandle); $valid = true; foreach($signature as $match) { @@ -227,21 +123,21 @@ class PHPExcel_Reader_Excel2003XML implements PHPExcel_Reader_IReader * Reads names of the worksheets from a file, without parsing the whole file to a PHPExcel object * * @param string $pFilename - * @throws Exception + * @throws PHPExcel_Reader_Exception */ public function listWorksheetNames($pFilename) { // Check if file exists if (!file_exists($pFilename)) { - throw new Exception("Could not open " . $pFilename . " for reading! File does not exist."); + throw new PHPExcel_Reader_Exception("Could not open " . $pFilename . " for reading! File does not exist."); } if (!$this->canRead($pFilename)) { - throw new Exception($pFilename . " is an Invalid Spreadsheet file."); + throw new PHPExcel_Reader_Exception($pFilename . " is an Invalid Spreadsheet file."); } $worksheetNames = array(); - $xml = simplexml_load_file($pFilename); + $xml = simplexml_load_file($pFilename, 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions()); $namespaces = $xml->getNamespaces(true); $xml_ss = $xml->children($namespaces['ss']); @@ -258,18 +154,18 @@ class PHPExcel_Reader_Excel2003XML implements PHPExcel_Reader_IReader * Return worksheet info (Name, Last Column Letter, Last Column Index, Total Rows, Total Columns) * * @param string $pFilename - * @throws Exception + * @throws PHPExcel_Reader_Exception */ public function listWorksheetInfo($pFilename) { // Check if file exists if (!file_exists($pFilename)) { - throw new Exception("Could not open " . $pFilename . " for reading! File does not exist."); + throw new PHPExcel_Reader_Exception("Could not open " . $pFilename . " for reading! File does not exist."); } $worksheetInfo = array(); - $xml = simplexml_load_file($pFilename); + $xml = simplexml_load_file($pFilename, 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions()); $namespaces = $xml->getNamespaces(true); $worksheetID = 1; @@ -330,7 +226,7 @@ class PHPExcel_Reader_Excel2003XML implements PHPExcel_Reader_IReader * * @param string $pFilename * @return PHPExcel - * @throws Exception + * @throws PHPExcel_Reader_Exception */ public function load($pFilename) { @@ -392,7 +288,7 @@ class PHPExcel_Reader_Excel2003XML implements PHPExcel_Reader_IReader * @param string $pFilename * @param PHPExcel $objPHPExcel * @return PHPExcel - * @throws Exception + * @throws PHPExcel_Reader_Exception */ public function loadIntoExisting($pFilename, PHPExcel $objPHPExcel) { @@ -427,14 +323,14 @@ class PHPExcel_Reader_Excel2003XML implements PHPExcel_Reader_IReader // Check if file exists if (!file_exists($pFilename)) { - throw new Exception("Could not open " . $pFilename . " for reading! File does not exist."); + throw new PHPExcel_Reader_Exception("Could not open " . $pFilename . " for reading! File does not exist."); } if (!$this->canRead($pFilename)) { - throw new Exception($pFilename . " is an Invalid Spreadsheet file."); + throw new PHPExcel_Reader_Exception($pFilename . " is an Invalid Spreadsheet file."); } - $xml = simplexml_load_file($pFilename); + $xml = simplexml_load_file($pFilename, 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions()); $namespaces = $xml->getNamespaces(true); $docProps = $objPHPExcel->getProperties(); diff --git a/htdocs/includes/phpexcel/PHPExcel/Reader/Excel2007.php b/htdocs/includes/phpexcel/PHPExcel/Reader/Excel2007.php index fbb9158ebd3..d8344ac7a29 100644 --- a/htdocs/includes/phpexcel/PHPExcel/Reader/Excel2007.php +++ b/htdocs/includes/phpexcel/PHPExcel/Reader/Excel2007.php @@ -2,7 +2,7 @@ /** * PHPExcel * - * Copyright (c) 2006 - 2012 PHPExcel + * Copyright (c) 2006 - 2014 PHPExcel * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,9 +20,9 @@ * * @category PHPExcel * @package PHPExcel_Reader - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version 1.7.8, 2012-10-12 + * @version 1.8.0, 2014-03-02 */ @@ -40,42 +40,10 @@ if (!defined('PHPEXCEL_ROOT')) { * * @category PHPExcel * @package PHPExcel_Reader - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) */ -class PHPExcel_Reader_Excel2007 implements PHPExcel_Reader_IReader +class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPExcel_Reader_IReader { - /** - * Read data only? - * Identifies whether the Reader should only read data values for cells, and ignore any formatting information; - * or whether it should read both data and formatting - * - * @var boolean - */ - private $_readDataOnly = FALSE; - - /** - * Read charts that are defined in the workbook? - * Identifies whether the Reader should read the definitions for any charts that exist in the workbook; - * - * @var boolean - */ - private $_includeCharts = FALSE; - - /** - * Restrict which sheets should be loaded? - * This property holds an array of worksheet names to be loaded. If null, then all worksheets will be loaded. - * - * @var array of string - */ - private $_loadSheetsOnly = NULL; - - /** - * PHPExcel_Reader_IReadFilter instance - * - * @var PHPExcel_Reader_IReadFilter - */ - private $_readFilter = NULL; - /** * PHPExcel_ReferenceHelper instance * @@ -100,152 +68,33 @@ class PHPExcel_Reader_Excel2007 implements PHPExcel_Reader_IReader } - /** - * Read data only? - * If this is true, then the Reader will only read data values for cells, it will not read any formatting information. - * If false (the default) it will read data and formatting. - * - * @return boolean - */ - public function getReadDataOnly() { - return $this->_readDataOnly; - } - - - /** - * Set read data only - * Set to true, to advise the Reader only to read data values for cells, and to ignore any formatting information. - * Set to false (the default) to advise the Reader to read both data and formatting for cells. - * - * @param boolean $pValue - * - * @return PHPExcel_Reader_Excel2007 - */ - public function setReadDataOnly($pValue = FALSE) { - $this->_readDataOnly = $pValue; - return $this; - } - - - /** - * Read charts in workbook? - * If this is true, then the Reader will include any charts that exist in the workbook. - * Note that a ReadDataOnly value of false overrides, and charts won't be read regardless of the IncludeCharts value. - * If false (the default) it will ignore any charts defined in the workbook file. - * - * @return boolean - */ - public function getIncludeCharts() { - return $this->_includeCharts; - } - - - /** - * Set read charts in workbook - * Set to true, to advise the Reader to include any charts that exist in the workbook. - * Note that a ReadDataOnly value of false overrides, and charts won't be read regardless of the IncludeCharts value. - * Set to false (the default) to discard charts. - * - * @param boolean $pValue - * - * @return PHPExcel_Reader_Excel2007 - */ - public function setIncludeCharts($pValue = FALSE) { - $this->_includeCharts = (boolean) $pValue; - return $this; - } - - - /** - * Get which sheets to load - * Returns either an array of worksheet names (the list of worksheets that should be loaded), or a null - * indicating that all worksheets in the workbook should be loaded. - * - * @return mixed - */ - public function getLoadSheetsOnly() - { - return $this->_loadSheetsOnly; - } - - - /** - * Set which sheets to load - * - * @param mixed $value - * This should be either an array of worksheet names to be loaded, or a string containing a single worksheet name. - * If NULL, then it tells the Reader to read all worksheets in the workbook - * - * @return PHPExcel_Reader_Excel2007 - */ - public function setLoadSheetsOnly($value = NULL) - { - $this->_loadSheetsOnly = is_array($value) ? - $value : array($value); - return $this; - } - - - /** - * Set all sheets to load - * Tells the Reader to load all worksheets from the workbook. - * - * @return PHPExcel_Reader_Excel2007 - */ - public function setLoadAllSheets() - { - $this->_loadSheetsOnly = NULL; - return $this; - } - - - /** - * Read filter - * - * @return PHPExcel_Reader_IReadFilter - */ - public function getReadFilter() { - return $this->_readFilter; - } - - - /** - * Set read filter - * - * @param PHPExcel_Reader_IReadFilter $pValue - * @return PHPExcel_Reader_Excel2007 - */ - public function setReadFilter(PHPExcel_Reader_IReadFilter $pValue) { - $this->_readFilter = $pValue; - return $this; - } - - /** * Can the current PHPExcel_Reader_IReader read the file? * - * @param string $pFileName + * @param string $pFilename * @return boolean - * @throws Exception + * @throws PHPExcel_Reader_Exception */ public function canRead($pFilename) { // Check if file exists if (!file_exists($pFilename)) { - throw new Exception("Could not open " . $pFilename . " for reading! File does not exist."); + throw new PHPExcel_Reader_Exception("Could not open " . $pFilename . " for reading! File does not exist."); } + $zipClass = PHPExcel_Settings::getZipClass(); + // Check if zip class exists - if (!class_exists('ZipArchive',FALSE)) { - throw new Exception("ZipArchive library is not enabled"); - } +// if (!class_exists($zipClass, FALSE)) { +// throw new PHPExcel_Reader_Exception($zipClass . " library is not enabled"); +// } $xl = false; // Load file - $zip = new ZipArchive; + $zip = new $zipClass; if ($zip->open($pFilename) === true) { // check if it is an OOXML archive - $rels = simplexml_load_string($this->_getFromZipArchive($zip, "_rels/.rels")); + $rels = simplexml_load_string($this->_getFromZipArchive($zip, "_rels/.rels"), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions()); if ($rels !== false) { foreach ($rels->Relationship as $rel) { switch ($rel["Type"]) { @@ -265,29 +114,77 @@ class PHPExcel_Reader_Excel2007 implements PHPExcel_Reader_IReader } + /** + * Reads names of the worksheets from a file, without parsing the whole file to a PHPExcel object + * + * @param string $pFilename + * @throws PHPExcel_Reader_Exception + */ + public function listWorksheetNames($pFilename) + { + // Check if file exists + if (!file_exists($pFilename)) { + throw new PHPExcel_Reader_Exception("Could not open " . $pFilename . " for reading! File does not exist."); + } + + $worksheetNames = array(); + + $zipClass = PHPExcel_Settings::getZipClass(); + + $zip = new $zipClass; + $zip->open($pFilename); + + // The files we're looking at here are small enough that simpleXML is more efficient than XMLReader + $rels = simplexml_load_string( + $this->_getFromZipArchive($zip, "_rels/.rels", 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions()) + ); //~ http://schemas.openxmlformats.org/package/2006/relationships"); + foreach ($rels->Relationship as $rel) { + switch ($rel["Type"]) { + case "http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument": + $xmlWorkbook = simplexml_load_string( + $this->_getFromZipArchive($zip, "{$rel['Target']}", 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions()) + ); //~ http://schemas.openxmlformats.org/spreadsheetml/2006/main"); + + if ($xmlWorkbook->sheets) { + foreach ($xmlWorkbook->sheets->sheet as $eleSheet) { + // Check if sheet should be skipped + $worksheetNames[] = (string) $eleSheet["name"]; + } + } + } + } + + $zip->close(); + + return $worksheetNames; + } + + /** * Return worksheet info (Name, Last Column Letter, Last Column Index, Total Rows, Total Columns) * * @param string $pFilename - * @throws Exception + * @throws PHPExcel_Reader_Exception */ public function listWorksheetInfo($pFilename) { // Check if file exists if (!file_exists($pFilename)) { - throw new Exception("Could not open " . $pFilename . " for reading! File does not exist."); + throw new PHPExcel_Reader_Exception("Could not open " . $pFilename . " for reading! File does not exist."); } $worksheetInfo = array(); - $zip = new ZipArchive; + $zipClass = PHPExcel_Settings::getZipClass(); + + $zip = new $zipClass; $zip->open($pFilename); - $rels = simplexml_load_string($this->_getFromZipArchive($zip, "_rels/.rels")); //~ http://schemas.openxmlformats.org/package/2006/relationships"); + $rels = simplexml_load_string($this->_getFromZipArchive($zip, "_rels/.rels"), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions()); //~ http://schemas.openxmlformats.org/package/2006/relationships"); foreach ($rels->Relationship as $rel) { if ($rel["Type"] == "http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument") { $dir = dirname($rel["Target"]); - $relsWorkbook = simplexml_load_string($this->_getFromZipArchive($zip, "$dir/_rels/" . basename($rel["Target"]) . ".rels")); //~ http://schemas.openxmlformats.org/package/2006/relationships"); + $relsWorkbook = simplexml_load_string($this->_getFromZipArchive($zip, "$dir/_rels/" . basename($rel["Target"]) . ".rels"), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions()); //~ http://schemas.openxmlformats.org/package/2006/relationships"); $relsWorkbook->registerXPathNamespace("rel", "http://schemas.openxmlformats.org/package/2006/relationships"); $worksheets = array(); @@ -297,36 +194,40 @@ class PHPExcel_Reader_Excel2007 implements PHPExcel_Reader_IReader } } - $xmlWorkbook = simplexml_load_string($this->_getFromZipArchive($zip, "{$rel['Target']}")); //~ http://schemas.openxmlformats.org/spreadsheetml/2006/main"); + $xmlWorkbook = simplexml_load_string($this->_getFromZipArchive($zip, "{$rel['Target']}"), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions()); //~ http://schemas.openxmlformats.org/spreadsheetml/2006/main"); if ($xmlWorkbook->sheets) { $dir = dirname($rel["Target"]); foreach ($xmlWorkbook->sheets->sheet as $eleSheet) { - $tmpInfo = array(); - $tmpInfo['worksheetName'] = (string) $eleSheet["name"]; - $tmpInfo['lastColumnLetter'] = 'A'; - $tmpInfo['lastColumnIndex'] = 0; - $tmpInfo['totalRows'] = 0; - $tmpInfo['totalColumns'] = 0; + $tmpInfo = array( + 'worksheetName' => (string) $eleSheet["name"], + 'lastColumnLetter' => 'A', + 'lastColumnIndex' => 0, + 'totalRows' => 0, + 'totalColumns' => 0, + ); $fileWorksheet = $worksheets[(string) self::array_item($eleSheet->attributes("http://schemas.openxmlformats.org/officeDocument/2006/relationships"), "id")]; - $xmlSheet = simplexml_load_string($this->_getFromZipArchive($zip, "$dir/$fileWorksheet")); //~ http://schemas.openxmlformats.org/spreadsheetml/2006/main"); - if ($xmlSheet && $xmlSheet->sheetData && $xmlSheet->sheetData->row) { - foreach ($xmlSheet->sheetData->row as $row) { - foreach ($row->c as $c) { - $r = (string) $c["r"]; - $coordinates = PHPExcel_Cell::coordinateFromString($r); - $rowIndex = $coordinates[1]; - $columnIndex = PHPExcel_Cell::columnIndexFromString($coordinates[0]) - 1; + $xml = new XMLReader(); + $res = $xml->open('zip://'.PHPExcel_Shared_File::realpath($pFilename).'#'."$dir/$fileWorksheet", null, PHPExcel_Settings::getLibXmlLoaderOptions()); + $xml->setParserProperty(2,true); - $tmpInfo['totalRows'] = max($tmpInfo['totalRows'], $rowIndex); - $tmpInfo['lastColumnIndex'] = max($tmpInfo['lastColumnIndex'], $columnIndex); - } + $currCells = 0; + while ($xml->read()) { + if ($xml->name == 'row' && $xml->nodeType == XMLReader::ELEMENT) { + $row = $xml->getAttribute('r'); + $tmpInfo['totalRows'] = $row; + $tmpInfo['totalColumns'] = max($tmpInfo['totalColumns'],$currCells); + $currCells = 0; + } elseif ($xml->name == 'c' && $xml->nodeType == XMLReader::ELEMENT) { + $currCells++; } } + $tmpInfo['totalColumns'] = max($tmpInfo['totalColumns'],$currCells); + $xml->close(); + $tmpInfo['lastColumnIndex'] = $tmpInfo['totalColumns'] - 1; $tmpInfo['lastColumnLetter'] = PHPExcel_Cell::stringFromColumnIndex($tmpInfo['lastColumnIndex']); - $tmpInfo['totalColumns'] = $tmpInfo['lastColumnIndex'] + 1; $worksheetInfo[] = $tmpInfo; } @@ -341,7 +242,7 @@ class PHPExcel_Reader_Excel2007 implements PHPExcel_Reader_IReader private static function _castToBool($c) { -// echo 'Initial Cast to Boolean
'; +// echo 'Initial Cast to Boolean', PHP_EOL; $value = isset($c->v) ? (string) $c->v : NULL; if ($value == '0') { return FALSE; @@ -355,48 +256,46 @@ class PHPExcel_Reader_Excel2007 implements PHPExcel_Reader_IReader private static function _castToError($c) { -// echo 'Initial Cast to Error
'; +// echo 'Initial Cast to Error', PHP_EOL; return isset($c->v) ? (string) $c->v : NULL; } // function _castToError() private static function _castToString($c) { -// echo 'Initial Cast to String
'; +// echo 'Initial Cast to String, PHP_EOL; return isset($c->v) ? (string) $c->v : NULL; } // function _castToString() private function _castToFormula($c,$r,&$cellDataType,&$value,&$calculatedValue,&$sharedFormulas,$castBaseType) { -// echo 'Formula
'; -// echo '$c->f is '.$c->f.'
'; +// echo 'Formula', PHP_EOL; +// echo '$c->f is ', $c->f, PHP_EOL; $cellDataType = 'f'; $value = "={$c->f}"; $calculatedValue = self::$castBaseType($c); // Shared formula? if (isset($c->f['t']) && strtolower((string)$c->f['t']) == 'shared') { -// echo 'SHARED FORMULA
'; +// echo 'SHARED FORMULA', PHP_EOL; $instance = (string)$c->f['si']; -// echo 'Instance ID = '.$instance.'
'; +// echo 'Instance ID = ', $instance, PHP_EOL; // -// echo 'Shared Formula Array:
';
+//			echo 'Shared Formula Array:', PHP_EOL;
 //			print_r($sharedFormulas);
-//			echo '
'; if (!isset($sharedFormulas[(string)$c->f['si']])) { -// echo 'SETTING NEW SHARED FORMULA
'; -// echo 'Master is '.$r.'
'; -// echo 'Formula is '.$value.'
'; +// echo 'SETTING NEW SHARED FORMULA', PHP_EOL; +// echo 'Master is ', $r, PHP_EOL; +// echo 'Formula is ', $value, PHP_EOL; $sharedFormulas[$instance] = array( 'master' => $r, 'formula' => $value ); -// echo 'New Shared Formula Array:
';
+//				echo 'New Shared Formula Array:', PHP_EOL;
 //				print_r($sharedFormulas);
-//				echo '
'; } else { -// echo 'GETTING SHARED FORMULA
'; -// echo 'Master is '.$sharedFormulas[$instance]['master'].'
'; -// echo 'Formula is '.$sharedFormulas[$instance]['formula'].'
'; +// echo 'GETTING SHARED FORMULA', PHP_EOL; +// echo 'Master is ', $sharedFormulas[$instance]['master'], PHP_EOL; +// echo 'Formula is ', $sharedFormulas[$instance]['formula'], PHP_EOL; $master = PHPExcel_Cell::coordinateFromString($sharedFormulas[$instance]['master']); $current = PHPExcel_Cell::coordinateFromString($r); @@ -409,13 +308,13 @@ class PHPExcel_Reader_Excel2007 implements PHPExcel_Reader_IReader $difference[0], $difference[1] ); -// echo 'Adjusted Formula is '.$value.'
'; +// echo 'Adjusted Formula is ', $value, PHP_EOL; } } } - public function _getFromZipArchive(ZipArchive $archive, $fileName = '') + public function _getFromZipArchive($archive, $fileName = '') { // Root-relative paths if (strpos($fileName, '//') !== false) @@ -435,56 +334,17 @@ class PHPExcel_Reader_Excel2007 implements PHPExcel_Reader_IReader } - /** - * Reads names of the worksheets from a file, without parsing the whole file to a PHPExcel object - * - * @param string $pFilename - * @throws Exception - */ - public function listWorksheetNames($pFilename) - { - // Check if file exists - if (!file_exists($pFilename)) { - throw new Exception("Could not open " . $pFilename . " for reading! File does not exist."); - } - - $worksheetNames = array(); - - $zip = new ZipArchive; - $zip->open($pFilename); - - $rels = simplexml_load_string($this->_getFromZipArchive($zip, "_rels/.rels")); //~ http://schemas.openxmlformats.org/package/2006/relationships"); - foreach ($rels->Relationship as $rel) { - switch ($rel["Type"]) { - case "http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument": - $xmlWorkbook = simplexml_load_string($this->_getFromZipArchive($zip, "{$rel['Target']}")); //~ http://schemas.openxmlformats.org/spreadsheetml/2006/main"); - - if ($xmlWorkbook->sheets) { - foreach ($xmlWorkbook->sheets->sheet as $eleSheet) { - // Check if sheet should be skipped - $worksheetNames[] = (string) $eleSheet["name"]; - } - } - } - } - - $zip->close(); - - return $worksheetNames; - } - - /** * Loads PHPExcel from file * * @param string $pFilename - * @throws Exception + * @throws PHPExcel_Reader_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."); + throw new PHPExcel_Reader_Exception("Could not open " . $pFilename . " for reading! File does not exist."); } // Initialisations @@ -494,18 +354,21 @@ class PHPExcel_Reader_Excel2007 implements PHPExcel_Reader_IReader $excel->removeCellStyleXfByIndex(0); // remove the default style $excel->removeCellXfByIndex(0); // remove the default style } - $zip = new ZipArchive; + + $zipClass = PHPExcel_Settings::getZipClass(); + + $zip = new $zipClass; $zip->open($pFilename); // Read the theme first, because we need the colour scheme when reading the styles - $wbRels = simplexml_load_string($this->_getFromZipArchive($zip, "xl/_rels/workbook.xml.rels")); //~ http://schemas.openxmlformats.org/package/2006/relationships"); + $wbRels = simplexml_load_string($this->_getFromZipArchive($zip, "xl/_rels/workbook.xml.rels"), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions()); //~ http://schemas.openxmlformats.org/package/2006/relationships"); foreach ($wbRels->Relationship as $rel) { switch ($rel["Type"]) { case "http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme": $themeOrderArray = array('lt1','dk1','lt2','dk2'); $themeOrderAdditional = count($themeOrderArray); - $xmlTheme = simplexml_load_string($this->_getFromZipArchive($zip, "xl/{$rel['Target']}")); + $xmlTheme = simplexml_load_string($this->_getFromZipArchive($zip, "xl/{$rel['Target']}"), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions()); if (is_object($xmlTheme)) { $xmlThemeName = $xmlTheme->attributes(); $xmlTheme = $xmlTheme->children("http://schemas.openxmlformats.org/drawingml/2006/main"); @@ -535,11 +398,11 @@ class PHPExcel_Reader_Excel2007 implements PHPExcel_Reader_IReader } } - $rels = simplexml_load_string($this->_getFromZipArchive($zip, "_rels/.rels")); //~ http://schemas.openxmlformats.org/package/2006/relationships"); + $rels = simplexml_load_string($this->_getFromZipArchive($zip, "_rels/.rels"), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions()); //~ http://schemas.openxmlformats.org/package/2006/relationships"); foreach ($rels->Relationship as $rel) { switch ($rel["Type"]) { case "http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties": - $xmlCore = simplexml_load_string($this->_getFromZipArchive($zip, "{$rel['Target']}")); + $xmlCore = simplexml_load_string($this->_getFromZipArchive($zip, "{$rel['Target']}"), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions()); if (is_object($xmlCore)) { $xmlCore->registerXPathNamespace("dc", "http://purl.org/dc/elements/1.1/"); $xmlCore->registerXPathNamespace("dcterms", "http://purl.org/dc/terms/"); @@ -558,7 +421,7 @@ class PHPExcel_Reader_Excel2007 implements PHPExcel_Reader_IReader break; case "http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties": - $xmlCore = simplexml_load_string($this->_getFromZipArchive($zip, "{$rel['Target']}")); + $xmlCore = simplexml_load_string($this->_getFromZipArchive($zip, "{$rel['Target']}"), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions()); if (is_object($xmlCore)) { $docProps = $excel->getProperties(); if (isset($xmlCore->Company)) @@ -569,7 +432,7 @@ class PHPExcel_Reader_Excel2007 implements PHPExcel_Reader_IReader break; case "http://schemas.openxmlformats.org/officeDocument/2006/relationships/custom-properties": - $xmlCore = simplexml_load_string($this->_getFromZipArchive($zip, "{$rel['Target']}")); + $xmlCore = simplexml_load_string($this->_getFromZipArchive($zip, "{$rel['Target']}"), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions()); if (is_object($xmlCore)) { $docProps = $excel->getProperties(); foreach ($xmlCore as $xmlProperty) { @@ -586,15 +449,21 @@ class PHPExcel_Reader_Excel2007 implements PHPExcel_Reader_IReader } } break; - + //Ribbon + case "http://schemas.microsoft.com/office/2006/relationships/ui/extensibility": + $customUI = $rel['Target']; + if(!is_null($customUI)){ + $this->_readRibbon($excel, $customUI, $zip); + } + break; case "http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument": $dir = dirname($rel["Target"]); - $relsWorkbook = simplexml_load_string($this->_getFromZipArchive($zip, "$dir/_rels/" . basename($rel["Target"]) . ".rels")); //~ http://schemas.openxmlformats.org/package/2006/relationships"); + $relsWorkbook = simplexml_load_string($this->_getFromZipArchive($zip, "$dir/_rels/" . basename($rel["Target"]) . ".rels"), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions()); //~ http://schemas.openxmlformats.org/package/2006/relationships"); $relsWorkbook->registerXPathNamespace("rel", "http://schemas.openxmlformats.org/package/2006/relationships"); $sharedStrings = array(); $xpath = self::array_item($relsWorkbook->xpath("rel:Relationship[@Type='http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings']")); - $xmlStrings = simplexml_load_string($this->_getFromZipArchive($zip, "$dir/$xpath[Target]")); //~ http://schemas.openxmlformats.org/spreadsheetml/2006/main"); + $xmlStrings = simplexml_load_string($this->_getFromZipArchive($zip, "$dir/$xpath[Target]"), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions()); //~ http://schemas.openxmlformats.org/spreadsheetml/2006/main"); if (isset($xmlStrings) && isset($xmlStrings->si)) { foreach ($xmlStrings->si as $val) { if (isset($val->t)) { @@ -606,16 +475,34 @@ class PHPExcel_Reader_Excel2007 implements PHPExcel_Reader_IReader } $worksheets = array(); + $macros = $customUI = NULL; foreach ($relsWorkbook->Relationship as $ele) { - if ($ele["Type"] == "http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet") { + switch($ele['Type']){ + case "http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet": $worksheets[(string) $ele["Id"]] = $ele["Target"]; + break; + // a vbaProject ? (: some macros) + case "http://schemas.microsoft.com/office/2006/relationships/vbaProject": + $macros = $ele["Target"]; + break; } } + if(!is_null($macros)){ + $macrosCode = $this->_getFromZipArchive($zip, 'xl/vbaProject.bin');//vbaProject.bin always in 'xl' dir and always named vbaProject.bin + if($macrosCode !== false){ + $excel->setMacrosCode($macrosCode); + $excel->setHasMacros(true); + //short-circuit : not reading vbaProject.bin.rel to get Signature =>allways vbaProjectSignature.bin in 'xl' dir + $Certificate = $this->_getFromZipArchive($zip, 'xl/vbaProjectSignature.bin'); + if($Certificate !== false) + $excel->setMacrosCertificate($Certificate); + } + } $styles = array(); $cellStyles = array(); $xpath = self::array_item($relsWorkbook->xpath("rel:Relationship[@Type='http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles']")); - $xmlStyles = simplexml_load_string($this->_getFromZipArchive($zip, "$dir/$xpath[Target]")); //~ http://schemas.openxmlformats.org/spreadsheetml/2006/main"); + $xmlStyles = simplexml_load_string($this->_getFromZipArchive($zip, "$dir/$xpath[Target]"), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions()); //~ http://schemas.openxmlformats.org/spreadsheetml/2006/main"); $numFmts = null; if ($xmlStyles && $xmlStyles->numFmts[0]) { $numFmts = $xmlStyles->numFmts[0]; @@ -640,6 +527,10 @@ class PHPExcel_Reader_Excel2007 implements PHPExcel_Reader_IReader $numFmt = PHPExcel_Style_NumberFormat::builtInFormatCode((int)$xf["numFmtId"]); } } + $quotePrefix = false; + if (isset($xf["quotePrefix"])) { + $quotePrefix = (boolean) $xf["quotePrefix"]; + } //$numFmt = str_replace('mm', 'i', $numFmt); //$numFmt = str_replace('h', 'H', $numFmt); @@ -650,6 +541,7 @@ class PHPExcel_Reader_Excel2007 implements PHPExcel_Reader_IReader "border" => $xmlStyles->borders->border[intval($xf["borderId"])], "alignment" => $xf->alignment, "protection" => $xf->protection, + "quotePrefix" => $quotePrefix, ); $styles[] = $style; @@ -677,6 +569,7 @@ class PHPExcel_Reader_Excel2007 implements PHPExcel_Reader_IReader "border" => $xmlStyles->borders->border[intval($xf["borderId"])], "alignment" => $xf->alignment, "protection" => $xf->protection, + "quotePrefix" => $quotePrefix, ); $cellStyles[] = $cellStyle; @@ -713,14 +606,13 @@ class PHPExcel_Reader_Excel2007 implements PHPExcel_Reader_IReader } } - $xmlWorkbook = simplexml_load_string($this->_getFromZipArchive($zip, "{$rel['Target']}")); //~ http://schemas.openxmlformats.org/spreadsheetml/2006/main"); + $xmlWorkbook = simplexml_load_string($this->_getFromZipArchive($zip, "{$rel['Target']}"), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions()); //~ http://schemas.openxmlformats.org/spreadsheetml/2006/main"); // Set base date if ($xmlWorkbook->workbookPr) { PHPExcel_Shared_Date::setExcelCalendar(PHPExcel_Shared_Date::CALENDAR_WINDOWS_1900); if (isset($xmlWorkbook->workbookPr['date1904'])) { - $date1904 = (string)$xmlWorkbook->workbookPr['date1904']; - if ($date1904 == "true" || $date1904 == "1") { + if (self::boolean((string) $xmlWorkbook->workbookPr['date1904'])) { PHPExcel_Shared_Date::setExcelCalendar(PHPExcel_Shared_Date::CALENDAR_MAC_1904); } } @@ -757,7 +649,7 @@ class PHPExcel_Reader_Excel2007 implements PHPExcel_Reader_IReader // reverse $docSheet->setTitle((string) $eleSheet["name"],false); $fileWorksheet = $worksheets[(string) self::array_item($eleSheet->attributes("http://schemas.openxmlformats.org/officeDocument/2006/relationships"), "id")]; - $xmlSheet = simplexml_load_string($this->_getFromZipArchive($zip, "$dir/$fileWorksheet")); //~ http://schemas.openxmlformats.org/spreadsheetml/2006/main"); + $xmlSheet = simplexml_load_string($this->_getFromZipArchive($zip, "$dir/$fileWorksheet"), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions()); //~ http://schemas.openxmlformats.org/spreadsheetml/2006/main"); $sharedFormulas = array(); @@ -779,15 +671,15 @@ class PHPExcel_Reader_Excel2007 implements PHPExcel_Reader_IReader } if (isset($xmlSheet->sheetViews->sheetView['showGridLines'])) { - $docSheet->setShowGridLines((string)$xmlSheet->sheetViews->sheetView['showGridLines'] ? true : false); + $docSheet->setShowGridLines(self::boolean((string)$xmlSheet->sheetViews->sheetView['showGridLines'])); } if (isset($xmlSheet->sheetViews->sheetView['showRowColHeaders'])) { - $docSheet->setShowRowColHeaders((string)$xmlSheet->sheetViews->sheetView['showRowColHeaders'] ? true : false); + $docSheet->setShowRowColHeaders(self::boolean((string)$xmlSheet->sheetViews->sheetView['showRowColHeaders'])); } if (isset($xmlSheet->sheetViews->sheetView['rightToLeft'])) { - $docSheet->setRightToLeft((string)$xmlSheet->sheetViews->sheetView['rightToLeft'] ? true : false); + $docSheet->setRightToLeft(self::boolean((string)$xmlSheet->sheetViews->sheetView['rightToLeft'])); } if (isset($xmlSheet->sheetViews->sheetView->pane)) { @@ -825,31 +717,38 @@ class PHPExcel_Reader_Excel2007 implements PHPExcel_Reader_IReader $docSheet->getTabColor()->setARGB( (string)$xmlSheet->sheetPr->tabColor['rgb'] ); } } - + if (isset($xmlSheet->sheetPr) && isset($xmlSheet->sheetPr['codeName'])) { + $docSheet->setCodeName((string) $xmlSheet->sheetPr['codeName']); + } if (isset($xmlSheet->sheetPr) && isset($xmlSheet->sheetPr->outlinePr)) { - if (isset($xmlSheet->sheetPr->outlinePr['summaryRight']) && $xmlSheet->sheetPr->outlinePr['summaryRight'] == false) { - $docSheet->setShowSummaryRight(false); + if (isset($xmlSheet->sheetPr->outlinePr['summaryRight']) && + !self::boolean((string) $xmlSheet->sheetPr->outlinePr['summaryRight'])) { + $docSheet->setShowSummaryRight(FALSE); } else { - $docSheet->setShowSummaryRight(true); + $docSheet->setShowSummaryRight(TRUE); } - if (isset($xmlSheet->sheetPr->outlinePr['summaryBelow']) && $xmlSheet->sheetPr->outlinePr['summaryBelow'] == false) { - $docSheet->setShowSummaryBelow(false); + if (isset($xmlSheet->sheetPr->outlinePr['summaryBelow']) && + !self::boolean((string) $xmlSheet->sheetPr->outlinePr['summaryBelow'])) { + $docSheet->setShowSummaryBelow(FALSE); } else { - $docSheet->setShowSummaryBelow(true); + $docSheet->setShowSummaryBelow(TRUE); } } if (isset($xmlSheet->sheetPr) && isset($xmlSheet->sheetPr->pageSetUpPr)) { - if (isset($xmlSheet->sheetPr->pageSetUpPr['fitToPage']) && $xmlSheet->sheetPr->pageSetUpPr['fitToPage'] == false) { - $docSheet->getPageSetup()->setFitToPage(false); + if (isset($xmlSheet->sheetPr->pageSetUpPr['fitToPage']) && + !self::boolean((string) $xmlSheet->sheetPr->pageSetUpPr['fitToPage'])) { + $docSheet->getPageSetup()->setFitToPage(FALSE); } else { - $docSheet->getPageSetup()->setFitToPage(true); + $docSheet->getPageSetup()->setFitToPage(TRUE); } } if (isset($xmlSheet->sheetFormatPr)) { - if (isset($xmlSheet->sheetFormatPr['customHeight']) && ((string)$xmlSheet->sheetFormatPr['customHeight'] == '1' || strtolower((string)$xmlSheet->sheetFormatPr['customHeight']) == 'true') && isset($xmlSheet->sheetFormatPr['defaultRowHeight'])) { + if (isset($xmlSheet->sheetFormatPr['customHeight']) && + self::boolean((string) $xmlSheet->sheetFormatPr['customHeight']) && + isset($xmlSheet->sheetFormatPr['defaultRowHeight'])) { $docSheet->getDefaultRowDimension()->setRowHeight( (float)$xmlSheet->sheetFormatPr['defaultRowHeight'] ); } if (isset($xmlSheet->sheetFormatPr['defaultColWidth'])) { @@ -863,18 +762,19 @@ class PHPExcel_Reader_Excel2007 implements PHPExcel_Reader_IReader if (isset($xmlSheet->cols) && !$this->_readDataOnly) { foreach ($xmlSheet->cols->col as $col) { - for ($i = intval($col["min"]) - 1; $i < intval($col["max"]); ++$i) { + for ($i = intval($col["min"]) - 1; $i < intval($col["max"]); ++$i) { if ($col["style"] && !$this->_readDataOnly) { $docSheet->getColumnDimension(PHPExcel_Cell::stringFromColumnIndex($i))->setXfIndex(intval($col["style"])); } - if ($col["bestFit"]) { - //$docSheet->getColumnDimension(PHPExcel_Cell::stringFromColumnIndex($i))->setAutoSize(true); + if (self::boolean($col["bestFit"])) { + //$docSheet->getColumnDimension(PHPExcel_Cell::stringFromColumnIndex($i))->setAutoSize(TRUE); } - if ($col["hidden"]) { - $docSheet->getColumnDimension(PHPExcel_Cell::stringFromColumnIndex($i))->setVisible(false); + if (self::boolean($col["hidden"])) { + // echo PHPExcel_Cell::stringFromColumnIndex($i),': HIDDEN COLUMN',PHP_EOL; + $docSheet->getColumnDimension(PHPExcel_Cell::stringFromColumnIndex($i))->setVisible(FALSE); } - if ($col["collapsed"]) { - $docSheet->getColumnDimension(PHPExcel_Cell::stringFromColumnIndex($i))->setCollapsed(true); + if (self::boolean($col["collapsed"])) { + $docSheet->getColumnDimension(PHPExcel_Cell::stringFromColumnIndex($i))->setCollapsed(TRUE); } if ($col["outlineLevel"] > 0) { $docSheet->getColumnDimension(PHPExcel_Cell::stringFromColumnIndex($i))->setOutlineLevel(intval($col["outlineLevel"])); @@ -889,19 +789,19 @@ class PHPExcel_Reader_Excel2007 implements PHPExcel_Reader_IReader } if (isset($xmlSheet->printOptions) && !$this->_readDataOnly) { - if ($xmlSheet->printOptions['gridLinesSet'] == 'true' && $xmlSheet->printOptions['gridLinesSet'] == '1') { - $docSheet->setShowGridlines(true); + if (self::boolean((string) $xmlSheet->printOptions['gridLinesSet'])) { + $docSheet->setShowGridlines(TRUE); } - if ($xmlSheet->printOptions['gridLines'] == 'true' || $xmlSheet->printOptions['gridLines'] == '1') { - $docSheet->setPrintGridlines(true); + if (self::boolean((string) $xmlSheet->printOptions['gridLines'])) { + $docSheet->setPrintGridlines(TRUE); } - if ($xmlSheet->printOptions['horizontalCentered']) { - $docSheet->getPageSetup()->setHorizontalCentered(true); + if (self::boolean((string) $xmlSheet->printOptions['horizontalCentered'])) { + $docSheet->getPageSetup()->setHorizontalCentered(TRUE); } - if ($xmlSheet->printOptions['verticalCentered']) { - $docSheet->getPageSetup()->setVerticalCentered(true); + if (self::boolean((string) $xmlSheet->printOptions['verticalCentered'])) { + $docSheet->getPageSetup()->setVerticalCentered(TRUE); } } @@ -910,11 +810,11 @@ class PHPExcel_Reader_Excel2007 implements PHPExcel_Reader_IReader if ($row["ht"] && !$this->_readDataOnly) { $docSheet->getRowDimension(intval($row["r"]))->setRowHeight(floatval($row["ht"])); } - if ($row["hidden"] && !$this->_readDataOnly) { - $docSheet->getRowDimension(intval($row["r"]))->setVisible(false); + if (self::boolean($row["hidden"]) && !$this->_readDataOnly) { + $docSheet->getRowDimension(intval($row["r"]))->setVisible(FALSE); } - if ($row["collapsed"]) { - $docSheet->getRowDimension(intval($row["r"]))->setCollapsed(true); + if (self::boolean($row["collapsed"])) { + $docSheet->getRowDimension(intval($row["r"]))->setCollapsed(TRUE); } if ($row["outlineLevel"] > 0) { $docSheet->getRowDimension(intval($row["r"]))->setOutlineLevel(intval($row["outlineLevel"])); @@ -938,15 +838,15 @@ class PHPExcel_Reader_Excel2007 implements PHPExcel_Reader_IReader } } - // echo 'Reading cell '.$coordinates[0].$coordinates[1].'
'; + // echo 'Reading cell ', $coordinates[0], $coordinates[1], PHP_EOL; // print_r($c); - // echo '
'; - // echo 'Cell Data Type is '.$cellDataType.': '; + // echo PHP_EOL; + // echo 'Cell Data Type is ', $cellDataType, ': '; // // Read cell! switch ($cellDataType) { case "s": - // echo 'String
'; + // echo 'String', PHP_EOL; if ((string)$c->v != '') { $value = $sharedStrings[intval($c->v)]; @@ -959,7 +859,7 @@ class PHPExcel_Reader_Excel2007 implements PHPExcel_Reader_IReader break; case "b": - // echo 'Boolean
'; + // echo 'Boolean', PHP_EOL; if (!isset($c->f)) { $value = self::_castToBool($c); } else { @@ -970,41 +870,41 @@ class PHPExcel_Reader_Excel2007 implements PHPExcel_Reader_IReader $att = $c->f; $docSheet->getCell($r)->setFormulaAttributes($att); } - // echo '$calculatedValue = '.$calculatedValue.'
'; + // echo '$calculatedValue = ', $calculatedValue, PHP_EOL; } break; case "inlineStr": - // echo 'Inline String
'; + // echo 'Inline String', PHP_EOL; $value = $this->_parseRichText($c->is); break; case "e": - // echo 'Error
'; + // echo 'Error', PHP_EOL; if (!isset($c->f)) { $value = self::_castToError($c); } else { // Formula $this->_castToFormula($c,$r,$cellDataType,$value,$calculatedValue,$sharedFormulas,'_castToError'); - // echo '$calculatedValue = '.$calculatedValue.'
'; + // echo '$calculatedValue = ', $calculatedValue, PHP_EOL; } break; default: - // echo 'Default
'; + // echo 'Default', PHP_EOL; if (!isset($c->f)) { - // echo 'Not a Formula
'; + // echo 'Not a Formula', PHP_EOL; $value = self::_castToString($c); } else { - // echo 'Treat as Formula
'; + // echo 'Treat as Formula', PHP_EOL; // Formula $this->_castToFormula($c,$r,$cellDataType,$value,$calculatedValue,$sharedFormulas,'_castToString'); - // echo '$calculatedValue = '.$calculatedValue.'
'; + // echo '$calculatedValue = ', $calculatedValue, PHP_EOL; } break; } - // echo 'Value is '.$value.'
'; + // echo 'Value is ', $value, PHP_EOL; // Check for numeric values if (is_numeric($value) && $cellDataType != 's') { @@ -1091,12 +991,12 @@ class PHPExcel_Reader_Excel2007 implements PHPExcel_Reader_IReader if (!$this->_readDataOnly && $xmlSheet && $xmlSheet->sheetProtection) { foreach ($aKeys as $key) { $method = "set" . ucfirst($key); - $docSheet->getProtection()->$method($xmlSheet->sheetProtection[$key] == "true"); + $docSheet->getProtection()->$method(self::boolean((string) $xmlSheet->sheetProtection[$key])); } } if (!$this->_readDataOnly && $xmlSheet && $xmlSheet->sheetProtection) { - $docSheet->getProtection()->setPassword((string) $xmlSheet->sheetProtection["password"], true); + $docSheet->getProtection()->setPassword((string) $xmlSheet->sheetProtection["password"], TRUE); if ($xmlSheet->protectedRanges->protectedRange) { foreach ($xmlSheet->protectedRanges->protectedRange as $protectedRange) { $docSheet->protectCells((string) $protectedRange["sqref"], (string) $protectedRange["password"], true); @@ -1233,16 +1133,16 @@ class PHPExcel_Reader_Excel2007 implements PHPExcel_Reader_IReader $docPageSetup->setPaperSize(intval($xmlSheet->pageSetup["paperSize"])); } if (isset($xmlSheet->pageSetup["scale"])) { - $docPageSetup->setScale(intval($xmlSheet->pageSetup["scale"]), false); + $docPageSetup->setScale(intval($xmlSheet->pageSetup["scale"]), FALSE); } if (isset($xmlSheet->pageSetup["fitToHeight"]) && intval($xmlSheet->pageSetup["fitToHeight"]) >= 0) { - $docPageSetup->setFitToHeight(intval($xmlSheet->pageSetup["fitToHeight"]), false); + $docPageSetup->setFitToHeight(intval($xmlSheet->pageSetup["fitToHeight"]), FALSE); } if (isset($xmlSheet->pageSetup["fitToWidth"]) && intval($xmlSheet->pageSetup["fitToWidth"]) >= 0) { - $docPageSetup->setFitToWidth(intval($xmlSheet->pageSetup["fitToWidth"]), false); + $docPageSetup->setFitToWidth(intval($xmlSheet->pageSetup["fitToWidth"]), FALSE); } if (isset($xmlSheet->pageSetup["firstPageNumber"]) && isset($xmlSheet->pageSetup["useFirstPageNumber"]) && - ((string)$xmlSheet->pageSetup["useFirstPageNumber"] == 'true' || (string)$xmlSheet->pageSetup["useFirstPageNumber"] == '1')) { + self::boolean((string) $xmlSheet->pageSetup["useFirstPageNumber"])) { $docPageSetup->setFirstPageNumber(intval($xmlSheet->pageSetup["firstPageNumber"])); } } @@ -1251,28 +1151,28 @@ class PHPExcel_Reader_Excel2007 implements PHPExcel_Reader_IReader $docHeaderFooter = $docSheet->getHeaderFooter(); if (isset($xmlSheet->headerFooter["differentOddEven"]) && - ((string)$xmlSheet->headerFooter["differentOddEven"] == 'true' || (string)$xmlSheet->headerFooter["differentOddEven"] == '1')) { - $docHeaderFooter->setDifferentOddEven(true); + self::boolean((string)$xmlSheet->headerFooter["differentOddEven"])) { + $docHeaderFooter->setDifferentOddEven(TRUE); } else { - $docHeaderFooter->setDifferentOddEven(false); + $docHeaderFooter->setDifferentOddEven(FALSE); } if (isset($xmlSheet->headerFooter["differentFirst"]) && - ((string)$xmlSheet->headerFooter["differentFirst"] == 'true' || (string)$xmlSheet->headerFooter["differentFirst"] == '1')) { - $docHeaderFooter->setDifferentFirst(true); + self::boolean((string)$xmlSheet->headerFooter["differentFirst"])) { + $docHeaderFooter->setDifferentFirst(TRUE); } else { - $docHeaderFooter->setDifferentFirst(false); + $docHeaderFooter->setDifferentFirst(FALSE); } if (isset($xmlSheet->headerFooter["scaleWithDoc"]) && - ((string)$xmlSheet->headerFooter["scaleWithDoc"] == 'false' || (string)$xmlSheet->headerFooter["scaleWithDoc"] == '0')) { - $docHeaderFooter->setScaleWithDocument(false); + !self::boolean((string)$xmlSheet->headerFooter["scaleWithDoc"])) { + $docHeaderFooter->setScaleWithDocument(FALSE); } else { - $docHeaderFooter->setScaleWithDocument(true); + $docHeaderFooter->setScaleWithDocument(TRUE); } if (isset($xmlSheet->headerFooter["alignWithMargins"]) && - ((string)$xmlSheet->headerFooter["alignWithMargins"] == 'false' || (string)$xmlSheet->headerFooter["alignWithMargins"] == '0')) { - $docHeaderFooter->setAlignWithMargins(false); + !self::boolean((string)$xmlSheet->headerFooter["alignWithMargins"])) { + $docHeaderFooter->setAlignWithMargins(FALSE); } else { - $docHeaderFooter->setAlignWithMargins(true); + $docHeaderFooter->setAlignWithMargins(TRUE); } $docHeaderFooter->setOddHeader((string) $xmlSheet->headerFooter->oddHeader); @@ -1334,7 +1234,7 @@ class PHPExcel_Reader_Excel2007 implements PHPExcel_Reader_IReader if (!$this->_readDataOnly) { // Locate hyperlink relations if ($zip->locateName(dirname("$dir/$fileWorksheet") . "/_rels/" . basename($fileWorksheet) . ".rels")) { - $relsWorksheet = simplexml_load_string($this->_getFromZipArchive($zip, dirname("$dir/$fileWorksheet") . "/_rels/" . basename($fileWorksheet) . ".rels") ); //~ http://schemas.openxmlformats.org/package/2006/relationships"); + $relsWorksheet = simplexml_load_string($this->_getFromZipArchive($zip, dirname("$dir/$fileWorksheet") . "/_rels/" . basename($fileWorksheet) . ".rels") , 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions()); //~ http://schemas.openxmlformats.org/package/2006/relationships"); foreach ($relsWorksheet->Relationship as $ele) { if ($ele["Type"] == "http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink") { $hyperlinks[(string)$ele["Id"]] = (string)$ele["Target"]; @@ -1351,9 +1251,12 @@ class PHPExcel_Reader_Excel2007 implements PHPExcel_Reader_IReader foreach (PHPExcel_Cell::extractAllCellReferencesInRange($hyperlink['ref']) as $cellReference) { $cell = $docSheet->getCell( $cellReference ); if (isset($linkRel['id'])) { - $cell->getHyperlink()->setUrl( $hyperlinks[ (string)$linkRel['id'] ] ); - } - if (isset($hyperlink['location'])) { + $hyperlinkUrl = $hyperlinks[ (string)$linkRel['id'] ]; + if (isset($hyperlink['location'])) { + $hyperlinkUrl .= '#' . (string) $hyperlink['location']; + } + $cell->getHyperlink()->setUrl($hyperlinkUrl); + } elseif (isset($hyperlink['location'])) { $cell->getHyperlink()->setUrl( 'sheet://' . (string)$hyperlink['location'] ); } @@ -1372,7 +1275,7 @@ class PHPExcel_Reader_Excel2007 implements PHPExcel_Reader_IReader if (!$this->_readDataOnly) { // Locate comment relations if ($zip->locateName(dirname("$dir/$fileWorksheet") . "/_rels/" . basename($fileWorksheet) . ".rels")) { - $relsWorksheet = simplexml_load_string($this->_getFromZipArchive($zip, dirname("$dir/$fileWorksheet") . "/_rels/" . basename($fileWorksheet) . ".rels") ); //~ http://schemas.openxmlformats.org/package/2006/relationships"); + $relsWorksheet = simplexml_load_string($this->_getFromZipArchive($zip, dirname("$dir/$fileWorksheet") . "/_rels/" . basename($fileWorksheet) . ".rels") , 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions()); //~ http://schemas.openxmlformats.org/package/2006/relationships"); foreach ($relsWorksheet->Relationship as $ele) { if ($ele["Type"] == "http://schemas.openxmlformats.org/officeDocument/2006/relationships/comments") { $comments[(string)$ele["Id"]] = (string)$ele["Target"]; @@ -1387,7 +1290,7 @@ class PHPExcel_Reader_Excel2007 implements PHPExcel_Reader_IReader foreach ($comments as $relName => $relPath) { // Load comments file $relPath = PHPExcel_Shared_File::realpath(dirname("$dir/$fileWorksheet") . "/" . $relPath); - $commentsFile = simplexml_load_string($this->_getFromZipArchive($zip, $relPath) ); + $commentsFile = simplexml_load_string($this->_getFromZipArchive($zip, $relPath) , 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions()); // Utility variables $authors = array(); @@ -1408,7 +1311,7 @@ class PHPExcel_Reader_Excel2007 implements PHPExcel_Reader_IReader foreach ($vmlComments as $relName => $relPath) { // Load VML comments file $relPath = PHPExcel_Shared_File::realpath(dirname("$dir/$fileWorksheet") . "/" . $relPath); - $vmlCommentsFile = simplexml_load_string( $this->_getFromZipArchive($zip, $relPath) ); + $vmlCommentsFile = simplexml_load_string( $this->_getFromZipArchive($zip, $relPath) , 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions()); $vmlCommentsFile->registerXPathNamespace('v', 'urn:schemas-microsoft-com:vml'); $shapes = $vmlCommentsFile->xpath('//v:shape'); @@ -1459,7 +1362,7 @@ class PHPExcel_Reader_Excel2007 implements PHPExcel_Reader_IReader // Header/footer images if ($xmlSheet && $xmlSheet->legacyDrawingHF && !$this->_readDataOnly) { if ($zip->locateName(dirname("$dir/$fileWorksheet") . "/_rels/" . basename($fileWorksheet) . ".rels")) { - $relsWorksheet = simplexml_load_string($this->_getFromZipArchive($zip, dirname("$dir/$fileWorksheet") . "/_rels/" . basename($fileWorksheet) . ".rels") ); //~ http://schemas.openxmlformats.org/package/2006/relationships"); + $relsWorksheet = simplexml_load_string($this->_getFromZipArchive($zip, dirname("$dir/$fileWorksheet") . "/_rels/" . basename($fileWorksheet) . ".rels") , 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions()); //~ http://schemas.openxmlformats.org/package/2006/relationships"); $vmlRelationship = ''; foreach ($relsWorksheet->Relationship as $ele) { @@ -1470,7 +1373,7 @@ class PHPExcel_Reader_Excel2007 implements PHPExcel_Reader_IReader if ($vmlRelationship != '') { // Fetch linked images - $relsVML = simplexml_load_string($this->_getFromZipArchive($zip, dirname($vmlRelationship) . '/_rels/' . basename($vmlRelationship) . '.rels' )); //~ http://schemas.openxmlformats.org/package/2006/relationships"); + $relsVML = simplexml_load_string($this->_getFromZipArchive($zip, dirname($vmlRelationship) . '/_rels/' . basename($vmlRelationship) . '.rels' ), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions()); //~ http://schemas.openxmlformats.org/package/2006/relationships"); $drawings = array(); foreach ($relsVML->Relationship as $ele) { if ($ele["Type"] == "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image") { @@ -1479,16 +1382,16 @@ class PHPExcel_Reader_Excel2007 implements PHPExcel_Reader_IReader } // Fetch VML document - $vmlDrawing = simplexml_load_string($this->_getFromZipArchive($zip, $vmlRelationship)); + $vmlDrawing = simplexml_load_string($this->_getFromZipArchive($zip, $vmlRelationship), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions()); $vmlDrawing->registerXPathNamespace('v', 'urn:schemas-microsoft-com:vml'); $hfImages = array(); $shapes = $vmlDrawing->xpath('//v:shape'); - foreach ($shapes as $shape) { + foreach ($shapes as $idx => $shape) { $shape->registerXPathNamespace('v', 'urn:schemas-microsoft-com:vml'); $imageData = $shape->xpath('//v:imagedata'); - $imageData = $imageData[0]; + $imageData = $imageData[$idx]; $imageData = $imageData->attributes('urn:schemas-microsoft-com:office:office'); $style = self::toCSSArray( (string)$shape['style'] ); @@ -1498,11 +1401,13 @@ class PHPExcel_Reader_Excel2007 implements PHPExcel_Reader_IReader $hfImages[ (string)$shape['id'] ]->setName( (string)$imageData['title'] ); } - $hfImages[ (string)$shape['id'] ]->setPath("zip://$pFilename#" . $drawings[(string)$imageData['relid']], false); + $hfImages[ (string)$shape['id'] ]->setPath("zip://".PHPExcel_Shared_File::realpath($pFilename)."#" . $drawings[(string)$imageData['relid']], false); $hfImages[ (string)$shape['id'] ]->setResizeProportional(false); $hfImages[ (string)$shape['id'] ]->setWidth($style['width']); $hfImages[ (string)$shape['id'] ]->setHeight($style['height']); - $hfImages[ (string)$shape['id'] ]->setOffsetX($style['margin-left']); + if (isset($style['margin-left'])) { + $hfImages[ (string)$shape['id'] ]->setOffsetX($style['margin-left']); + } $hfImages[ (string)$shape['id'] ]->setOffsetY($style['margin-top']); $hfImages[ (string)$shape['id'] ]->setResizeProportional(true); } @@ -1514,9 +1419,9 @@ class PHPExcel_Reader_Excel2007 implements PHPExcel_Reader_IReader } -// TODO: Autoshapes from twoCellAnchors! + // TODO: Autoshapes from twoCellAnchors! if ($zip->locateName(dirname("$dir/$fileWorksheet") . "/_rels/" . basename($fileWorksheet) . ".rels")) { - $relsWorksheet = simplexml_load_string($this->_getFromZipArchive($zip, dirname("$dir/$fileWorksheet") . "/_rels/" . basename($fileWorksheet) . ".rels") ); //~ http://schemas.openxmlformats.org/package/2006/relationships"); + $relsWorksheet = simplexml_load_string($this->_getFromZipArchive($zip, dirname("$dir/$fileWorksheet") . "/_rels/" . basename($fileWorksheet) . ".rels") , 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions()); //~ http://schemas.openxmlformats.org/package/2006/relationships"); $drawings = array(); foreach ($relsWorksheet->Relationship as $ele) { if ($ele["Type"] == "http://schemas.openxmlformats.org/officeDocument/2006/relationships/drawing") { @@ -1526,7 +1431,7 @@ class PHPExcel_Reader_Excel2007 implements PHPExcel_Reader_IReader if ($xmlSheet->drawing && !$this->_readDataOnly) { foreach ($xmlSheet->drawing as $drawing) { $fileDrawing = $drawings[(string) self::array_item($drawing->attributes("http://schemas.openxmlformats.org/officeDocument/2006/relationships"), "id")]; - $relsDrawing = simplexml_load_string($this->_getFromZipArchive($zip, dirname($fileDrawing) . "/_rels/" . basename($fileDrawing) . ".rels") ); //~ http://schemas.openxmlformats.org/package/2006/relationships"); + $relsDrawing = simplexml_load_string($this->_getFromZipArchive($zip, dirname($fileDrawing) . "/_rels/" . basename($fileDrawing) . ".rels") , 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions()); //~ http://schemas.openxmlformats.org/package/2006/relationships"); $images = array(); if ($relsDrawing && $relsDrawing->Relationship) { @@ -1542,7 +1447,7 @@ class PHPExcel_Reader_Excel2007 implements PHPExcel_Reader_IReader } } } - $xmlDrawing = simplexml_load_string($this->_getFromZipArchive($zip, $fileDrawing))->children("http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing"); + $xmlDrawing = simplexml_load_string($this->_getFromZipArchive($zip, $fileDrawing), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions())->children("http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing"); if ($xmlDrawing->oneCellAnchor) { foreach ($xmlDrawing->oneCellAnchor as $oneCellAnchor) { @@ -1553,7 +1458,7 @@ class PHPExcel_Reader_Excel2007 implements PHPExcel_Reader_IReader $objDrawing = new PHPExcel_Worksheet_Drawing; $objDrawing->setName((string) self::array_item($oneCellAnchor->pic->nvPicPr->cNvPr->attributes(), "name")); $objDrawing->setDescription((string) self::array_item($oneCellAnchor->pic->nvPicPr->cNvPr->attributes(), "descr")); - $objDrawing->setPath("zip://$pFilename#" . $images[(string) self::array_item($blip->attributes("http://schemas.openxmlformats.org/officeDocument/2006/relationships"), "embed")], false); + $objDrawing->setPath("zip://".PHPExcel_Shared_File::realpath($pFilename)."#" . $images[(string) self::array_item($blip->attributes("http://schemas.openxmlformats.org/officeDocument/2006/relationships"), "embed")], false); $objDrawing->setCoordinates(PHPExcel_Cell::stringFromColumnIndex((string) $oneCellAnchor->from->col) . ($oneCellAnchor->from->row + 1)); $objDrawing->setOffsetX(PHPExcel_Shared_Drawing::EMUToPixels($oneCellAnchor->from->colOff)); $objDrawing->setOffsetY(PHPExcel_Shared_Drawing::EMUToPixels($oneCellAnchor->from->rowOff)); @@ -1593,7 +1498,7 @@ class PHPExcel_Reader_Excel2007 implements PHPExcel_Reader_IReader $objDrawing = new PHPExcel_Worksheet_Drawing; $objDrawing->setName((string) self::array_item($twoCellAnchor->pic->nvPicPr->cNvPr->attributes(), "name")); $objDrawing->setDescription((string) self::array_item($twoCellAnchor->pic->nvPicPr->cNvPr->attributes(), "descr")); - $objDrawing->setPath("zip://$pFilename#" . $images[(string) self::array_item($blip->attributes("http://schemas.openxmlformats.org/officeDocument/2006/relationships"), "embed")], false); + $objDrawing->setPath("zip://".PHPExcel_Shared_File::realpath($pFilename)."#" . $images[(string) self::array_item($blip->attributes("http://schemas.openxmlformats.org/officeDocument/2006/relationships"), "embed")], false); $objDrawing->setCoordinates(PHPExcel_Cell::stringFromColumnIndex((string) $twoCellAnchor->from->col) . ($twoCellAnchor->from->row + 1)); $objDrawing->setOffsetX(PHPExcel_Shared_Drawing::EMUToPixels($twoCellAnchor->from->colOff)); $objDrawing->setOffsetY(PHPExcel_Shared_Drawing::EMUToPixels($twoCellAnchor->from->rowOff)); @@ -1679,13 +1584,14 @@ class PHPExcel_Reader_Excel2007 implements PHPExcel_Reader_IReader // Set print titles foreach ($extractedRange as $range) { $matches = array(); + $range = str_replace('$', '', $range); // check for repeating columns, e g. 'A:A' or 'A:D' - if (preg_match('/^([A-Z]+)\:([A-Z]+)$/', $range, $matches)) { + if (preg_match('/!?([A-Z]+)\:([A-Z]+)$/', $range, $matches)) { $docSheet->getPageSetup()->setColumnsToRepeatAtLeft(array($matches[1], $matches[2])); } // check for repeating rows, e.g. '1:1' or '1:5' - elseif (preg_match('/^(\d+)\:(\d+)$/', $range, $matches)) { + elseif (preg_match('/!?(\d+)\:(\d+)$/', $range, $matches)) { $docSheet->getPageSetup()->setRowsToRepeatAtTop(array($matches[1], $matches[2])); } } @@ -1697,6 +1603,9 @@ class PHPExcel_Reader_Excel2007 implements PHPExcel_Reader_IReader foreach($rangeSets as $rangeSet) { $range = explode('!', $rangeSet); // FIXME: what if sheetname contains exclamation mark? $rangeSet = isset($range[1]) ? $range[1] : $range[0]; + if (strpos($rangeSet, ':') === FALSE) { + $rangeSet = $rangeSet . ':' . $rangeSet; + } $newRangeSets[] = str_replace('$', '', $rangeSet); } $docSheet->getPageSetup()->setPrintArea(implode(',',$newRangeSets)); @@ -1742,15 +1651,16 @@ class PHPExcel_Reader_Excel2007 implements PHPExcel_Reader_IReader break; default: - $range = explode('!', (string)$definedName); - if (count($range) == 2) { - $range[0] = str_replace("''", "'", $range[0]); - $range[0] = str_replace("'", "", $range[0]); - if ($worksheet = $docSheet->getParent()->getSheetByName($range[0])) { - $extractedRange = str_replace('$', '', $range[1]); - $scope = $docSheet->getParent()->getSheet((string)$definedName['localSheetId']); - - $excel->addNamedRange( new PHPExcel_NamedRange((string)$definedName['name'], $worksheet, $extractedRange, true, $scope) ); + if ($mapSheetId[(integer) $definedName['localSheetId']] !== null) { + $range = explode('!', (string)$definedName); + if (count($range) == 2) { + $range[0] = str_replace("''", "'", $range[0]); + $range[0] = str_replace("'", "", $range[0]); + if ($worksheet = $docSheet->getParent()->getSheetByName($range[0])) { + $extractedRange = str_replace('$', '', $range[1]); + $scope = $docSheet->getParent()->getSheet($mapSheetId[(integer) $definedName['localSheetId']]); + $excel->addNamedRange( new PHPExcel_NamedRange((string)$definedName['name'], $worksheet, $extractedRange, true, $scope) ); + } } } break; @@ -1780,7 +1690,7 @@ class PHPExcel_Reader_Excel2007 implements PHPExcel_Reader_IReader } } - if (!$this->_readDataOnly) { + if ((!$this->_readDataOnly) || (!empty($this->_loadSheetsOnly))) { // active sheet index $activeTab = intval($xmlWorkbook->bookViews->workbookView["activeTab"]); // refers to old sheet index @@ -1801,13 +1711,13 @@ class PHPExcel_Reader_Excel2007 implements PHPExcel_Reader_IReader if (!$this->_readDataOnly) { - $contentTypes = simplexml_load_string($this->_getFromZipArchive($zip, "[Content_Types].xml")); + $contentTypes = simplexml_load_string($this->_getFromZipArchive($zip, "[Content_Types].xml"), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions()); foreach ($contentTypes->Override as $contentType) { switch ($contentType["ContentType"]) { case "application/vnd.openxmlformats-officedocument.drawingml.chart+xml": if ($this->_includeCharts) { $chartEntryRef = ltrim($contentType['PartName'],'/'); - $chartElements = simplexml_load_string($this->_getFromZipArchive($zip, $chartEntryRef)); + $chartElements = simplexml_load_string($this->_getFromZipArchive($zip, $chartEntryRef), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions()); $objChart = PHPExcel_Reader_Excel2007_Chart::readChart($chartElements,basename($chartEntryRef,'.xml')); // echo 'Chart ',$chartEntryRef,'
'; @@ -1880,13 +1790,13 @@ class PHPExcel_Reader_Excel2007 implements PHPExcel_Reader_IReader $docStyle->getFont()->setName((string) $style->font->name["val"]); $docStyle->getFont()->setSize((string) $style->font->sz["val"]); if (isset($style->font->b)) { - $docStyle->getFont()->setBold(!isset($style->font->b["val"]) || $style->font->b["val"] == 'true' || $style->font->b["val"] == '1'); + $docStyle->getFont()->setBold(!isset($style->font->b["val"]) || self::boolean((string) $style->font->b["val"])); } if (isset($style->font->i)) { - $docStyle->getFont()->setItalic(!isset($style->font->i["val"]) || $style->font->i["val"] == 'true' || $style->font->i["val"] == '1'); + $docStyle->getFont()->setItalic(!isset($style->font->i["val"]) || self::boolean((string) $style->font->i["val"])); } if (isset($style->font->strike)) { - $docStyle->getFont()->setStrikethrough(!isset($style->font->strike["val"]) || $style->font->strike["val"] == 'true' || $style->font->strike["val"] == '1'); + $docStyle->getFont()->setStrikethrough(!isset($style->font->strike["val"]) || self::boolean((string) $style->font->strike["val"])); } $docStyle->getFont()->getColor()->setARGB(self::_readColor($style->font->color)); @@ -1934,21 +1844,15 @@ class PHPExcel_Reader_Excel2007 implements PHPExcel_Reader_IReader // border if (isset($style->border)) { - $diagonalUp = false; - $diagonalDown = false; - if ($style->border["diagonalUp"] == 'true' || $style->border["diagonalUp"] == 1) { - $diagonalUp = true; - } - if ($style->border["diagonalDown"] == 'true' || $style->border["diagonalDown"] == 1) { - $diagonalDown = true; - } - if ($diagonalUp == false && $diagonalDown == false) { + $diagonalUp = self::boolean((string) $style->border["diagonalUp"]); + $diagonalDown = self::boolean((string) $style->border["diagonalDown"]); + if (!$diagonalUp && !$diagonalDown) { $docStyle->getBorders()->setDiagonalDirection(PHPExcel_Style_Borders::DIAGONAL_NONE); - } elseif ($diagonalUp == true && $diagonalDown == false) { + } elseif ($diagonalUp && !$diagonalDown) { $docStyle->getBorders()->setDiagonalDirection(PHPExcel_Style_Borders::DIAGONAL_UP); - } elseif ($diagonalUp == false && $diagonalDown == true) { + } elseif (!$diagonalUp && $diagonalDown) { $docStyle->getBorders()->setDiagonalDirection(PHPExcel_Style_Borders::DIAGONAL_DOWN); - } elseif ($diagonalUp == true && $diagonalDown == true) { + } else { $docStyle->getBorders()->setDiagonalDirection(PHPExcel_Style_Borders::DIAGONAL_BOTH); } self::_readBorder($docStyle->getBorders()->getLeft(), $style->border->left); @@ -1971,15 +1875,15 @@ class PHPExcel_Reader_Excel2007 implements PHPExcel_Reader_IReader } $docStyle->getAlignment()->setTextRotation(intval($textRotation)); - $docStyle->getAlignment()->setWrapText( (string)$style->alignment["wrapText"] == "true" || (string)$style->alignment["wrapText"] == "1" ); - $docStyle->getAlignment()->setShrinkToFit( (string)$style->alignment["shrinkToFit"] == "true" || (string)$style->alignment["shrinkToFit"] == "1" ); + $docStyle->getAlignment()->setWrapText(self::boolean((string) $style->alignment["wrapText"])); + $docStyle->getAlignment()->setShrinkToFit(self::boolean((string) $style->alignment["shrinkToFit"])); $docStyle->getAlignment()->setIndent( intval((string)$style->alignment["indent"]) > 0 ? intval((string)$style->alignment["indent"]) : 0 ); } // protection if (isset($style->protection)) { if (isset($style->protection['locked'])) { - if ((string)$style->protection['locked'] == 'true') { + if (self::boolean((string) $style->protection['locked'])) { $docStyle->getProtection()->setLocked(PHPExcel_Style_Protection::PROTECTION_PROTECTED); } else { $docStyle->getProtection()->setLocked(PHPExcel_Style_Protection::PROTECTION_UNPROTECTED); @@ -1987,13 +1891,18 @@ class PHPExcel_Reader_Excel2007 implements PHPExcel_Reader_IReader } if (isset($style->protection['hidden'])) { - if ((string)$style->protection['hidden'] == 'true') { + if (self::boolean((string) $style->protection['hidden'])) { $docStyle->getProtection()->setHidden(PHPExcel_Style_Protection::PROTECTION_PROTECTED); } else { $docStyle->getProtection()->setHidden(PHPExcel_Style_Protection::PROTECTION_UNPROTECTED); } } } + + // top-level style settings + if (isset($style->quotePrefix)) { + $docStyle->setQuotePrefix($style->quotePrefix); + } } @@ -2032,23 +1941,23 @@ class PHPExcel_Reader_Excel2007 implements PHPExcel_Reader_IReader $objText->getFont()->setColor( new PHPExcel_Style_Color( self::_readColor($run->rPr->color) ) ); } - if ( (isset($run->rPr->b["val"]) && ((string) $run->rPr->b["val"] == 'true' || (string) $run->rPr->b["val"] == '1')) - || (isset($run->rPr->b) && !isset($run->rPr->b["val"])) ) { - $objText->getFont()->setBold(true); + if ((isset($run->rPr->b["val"]) && self::boolean((string) $run->rPr->b["val"])) || + (isset($run->rPr->b) && !isset($run->rPr->b["val"]))) { + $objText->getFont()->setBold(TRUE); } - if ( (isset($run->rPr->i["val"]) && ((string) $run->rPr->i["val"] == 'true' || (string) $run->rPr->i["val"] == '1')) - || (isset($run->rPr->i) && !isset($run->rPr->i["val"])) ) { - $objText->getFont()->setItalic(true); + if ((isset($run->rPr->i["val"]) && self::boolean((string) $run->rPr->i["val"])) || + (isset($run->rPr->i) && !isset($run->rPr->i["val"]))) { + $objText->getFont()->setItalic(TRUE); } if (isset($run->rPr->vertAlign) && isset($run->rPr->vertAlign["val"])) { $vertAlign = strtolower((string)$run->rPr->vertAlign["val"]); if ($vertAlign == 'superscript') { - $objText->getFont()->setSuperScript(true); + $objText->getFont()->setSuperScript(TRUE); } if ($vertAlign == 'subscript') { - $objText->getFont()->setSubScript(true); + $objText->getFont()->setSubScript(TRUE); } } @@ -2058,9 +1967,9 @@ class PHPExcel_Reader_Excel2007 implements PHPExcel_Reader_IReader $objText->getFont()->setUnderline((string)$run->rPr->u["val"]); } - if ( (isset($run->rPr->strike["val"]) && ((string) $run->rPr->strike["val"] == 'true' || (string) $run->rPr->strike["val"] == '1')) - || (isset($run->rPr->strike) && !isset($run->rPr->strike["val"])) ) { - $objText->getFont()->setStrikethrough(true); + if ((isset($run->rPr->strike["val"]) && self::boolean((string) $run->rPr->strike["val"])) || + (isset($run->rPr->strike) && !isset($run->rPr->strike["val"]))) { + $objText->getFont()->setStrikethrough(TRUE); } } } @@ -2069,6 +1978,43 @@ class PHPExcel_Reader_Excel2007 implements PHPExcel_Reader_IReader return $value; } + private function _readRibbon($excel, $customUITarget, $zip) + { + $baseDir = dirname($customUITarget); + $nameCustomUI = basename($customUITarget); + // get the xml file (ribbon) + $localRibbon = $this->_getFromZipArchive($zip, $customUITarget); + $customUIImagesNames = array(); + $customUIImagesBinaries = array(); + // something like customUI/_rels/customUI.xml.rels + $pathRels = $baseDir . '/_rels/' . $nameCustomUI . '.rels'; + $dataRels = $this->_getFromZipArchive($zip, $pathRels); + if ($dataRels) { + // exists and not empty if the ribbon have some pictures (other than internal MSO) + $UIRels = simplexml_load_string($dataRels, 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions()); + if ($UIRels) { + // we need to save id and target to avoid parsing customUI.xml and "guess" if it's a pseudo callback who load the image + foreach ($UIRels->Relationship as $ele) { + if ($ele["Type"] == 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/image') { + // an image ? + $customUIImagesNames[(string) $ele['Id']] = (string)$ele['Target']; + $customUIImagesBinaries[(string)$ele['Target']] = $this->_getFromZipArchive($zip, $baseDir . '/' . (string) $ele['Target']); + } + } + } + } + if ($localRibbon) { + $excel->setRibbonXMLData($customUITarget, $localRibbon); + if (count($customUIImagesNames) > 0 && count($customUIImagesBinaries) > 0) { + $excel->setRibbonBinObjects($customUIImagesNames, $customUIImagesBinaries); + } else { + $excel->setRibbonBinObjects(NULL); + } + } else { + $excel->setRibbonXMLData(NULL); + $excel->setRibbonBinObjects(NULL); + } + } private static function array_item($array, $key = 0) { return (isset($array[$key]) ? $array[$key] : null); @@ -2109,4 +2055,15 @@ class PHPExcel_Reader_Excel2007 implements PHPExcel_Reader_IReader return $style; } + + private static function boolean($value = NULL) + { + if (is_object($value)) { + $value = (string) $value; + } + if (is_numeric($value)) { + return (bool) $value; + } + return ($value === 'true' || $value === 'TRUE'); + } } diff --git a/htdocs/includes/phpexcel/PHPExcel/Reader/Excel2007/Chart.php b/htdocs/includes/phpexcel/PHPExcel/Reader/Excel2007/Chart.php index f4d38bdb44a..0de88acb120 100644 --- a/htdocs/includes/phpexcel/PHPExcel/Reader/Excel2007/Chart.php +++ b/htdocs/includes/phpexcel/PHPExcel/Reader/Excel2007/Chart.php @@ -2,7 +2,7 @@ /** * PHPExcel * - * Copyright (c) 2006 - 2012 PHPExcel + * Copyright (c) 2006 - 2014 PHPExcel * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -19,10 +19,10 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * @category PHPExcel - * @package PHPExcel_Reader_Excel5 - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @package PHPExcel_Reader_Excel2007 + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version 1.7.8, 2012-10-12 + * @version 1.8.0, 2014-03-02 */ /** @@ -30,7 +30,7 @@ * * @category PHPExcel * @package PHPExcel_Reader_Excel2007 - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) */ class PHPExcel_Reader_Excel2007_Chart { @@ -42,7 +42,7 @@ class PHPExcel_Reader_Excel2007_Chart } elseif ($format == 'integer') { return (integer) $attributes[$name]; } elseif ($format == 'boolean') { - return (boolean) ($attributes[$name] == '0') ? false : true; + return (boolean) ($attributes[$name] === '0' || $attributes[$name] !== 'true') ? false : true; } else { return (float) $attributes[$name]; } @@ -347,6 +347,10 @@ class PHPExcel_Reader_Excel2007_Chart } } + if (empty($seriesVal)) { + $seriesVal = NULL; + } + return array( 'formatCode' => $formatCode, 'pointCount' => $pointCount, 'dataValues' => $seriesVal diff --git a/htdocs/includes/phpexcel/PHPExcel/Reader/Excel2007/Theme.php b/htdocs/includes/phpexcel/PHPExcel/Reader/Excel2007/Theme.php index 6b38fa79fb9..820fa96db89 100644 --- a/htdocs/includes/phpexcel/PHPExcel/Reader/Excel2007/Theme.php +++ b/htdocs/includes/phpexcel/PHPExcel/Reader/Excel2007/Theme.php @@ -2,7 +2,7 @@ /** * PHPExcel * - * Copyright (c) 2006 - 2012 PHPExcel + * Copyright (c) 2006 - 2014 PHPExcel * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,9 +20,9 @@ * * @category PHPExcel * @package PHPExcel_Reader_Excel2007 - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version 1.7.8, 2012-10-12 + * @version 1.8.0, 2014-03-02 */ @@ -31,7 +31,7 @@ * * @category PHPExcel * @package PHPExcel_Reader_Excel2007 - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) */ class PHPExcel_Reader_Excel2007_Theme { diff --git a/htdocs/includes/phpexcel/PHPExcel/Reader/Excel5.php b/htdocs/includes/phpexcel/PHPExcel/Reader/Excel5.php index 535654243c2..91e0fa086f7 100644 --- a/htdocs/includes/phpexcel/PHPExcel/Reader/Excel5.php +++ b/htdocs/includes/phpexcel/PHPExcel/Reader/Excel5.php @@ -2,7 +2,7 @@ /** * PHPExcel * - * Copyright (c) 2006 - 2012 PHPExcel + * Copyright (c) 2006 - 2014 PHPExcel * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,9 +20,9 @@ * * @category PHPExcel * @package PHPExcel_Reader_Excel5 - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version 1.7.8, 2012-10-12 + * @version 1.8.0, 2014-03-02 */ // Original file header of ParseXL (used as the base for this class): @@ -73,9 +73,9 @@ if (!defined('PHPEXCEL_ROOT')) { * * @category PHPExcel * @package PHPExcel_Reader_Excel5 - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) */ -class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader +class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExcel_Reader_IReader { // ParseXL definitions const XLS_BIFF8 = 0x0600; @@ -156,32 +156,16 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader const XLS_Type_RANGEPROTECTION = 0x0868; const XLS_Type_SHEETLAYOUT = 0x0862; const XLS_Type_XFEXT = 0x087d; + const XLS_Type_PAGELAYOUTVIEW = 0x088b; const XLS_Type_UNKNOWN = 0xffff; - - /** - * Read data only? - * Identifies whether the Reader should only read data values for cells, and ignore any formatting information; - * or whether it should read both data and formatting - * - * @var boolean - */ - private $_readDataOnly = false; - - /** - * Restrict which sheets should be loaded? - * This property holds an array of worksheet names to be loaded. If null, then all worksheets will be loaded. - * - * @var array of string - */ - private $_loadSheetsOnly = null; - - /** - * PHPExcel_Reader_IReadFilter instance - * - * @var PHPExcel_Reader_IReadFilter - */ - private $_readFilter = null; + // Encryption type + const MS_BIFF_CRYPTO_NONE = 0; + const MS_BIFF_CRYPTO_XOR = 1; + const MS_BIFF_CRYPTO_RC4 = 2; + + // Size of stream blocks when using RC4 encryption + const REKEY_BLOCK = 0x400; /** * Summary Information stream data. @@ -402,6 +386,40 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader */ private $_sharedFormulaParts; + /** + * The type of encryption in use + * + * @var int + */ + private $_encryption = 0; + + /** + * The position in the stream after which contents are encrypted + * + * @var int + */ + private $_encryptionStartPos = false; + + /** + * The current RC4 decryption object + * + * @var PHPExcel_Reader_Excel5_RC4 + */ + private $_rc4Key = null; + + /** + * The position in the stream that the RC4 decryption object was left at + * + * @var int + */ + private $_rc4Pos = 0; + + /** + * The current MD5 context state + * + * @var string + */ + private $_md5Ctxt = null; /** * Create a new PHPExcel_Reader_Excel5 instance @@ -411,112 +429,18 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader } - /** - * Read data only? - * If this is true, then the Reader will only read data values for cells, it will not read any formatting information. - * If false (the default) it will read data and formatting. - * - * @return boolean - */ - public function getReadDataOnly() - { - return $this->_readDataOnly; - } - - - /** - * Set read data only - * Set to true, to advise the Reader only to read data values for cells, and to ignore any formatting information. - * Set to false (the default) to advise the Reader to read both data and formatting for cells. - * - * @param boolean $pValue - * - * @return PHPExcel_Reader_Excel5 - */ - public function setReadDataOnly($pValue = false) - { - $this->_readDataOnly = $pValue; - return $this; - } - - - /** - * Get which sheets to load - * Returns either an array of worksheet names (the list of worksheets that should be loaded), or a null - * indicating that all worksheets in the workbook should be loaded. - * - * @return mixed - */ - public function getLoadSheetsOnly() - { - return $this->_loadSheetsOnly; - } - - - /** - * Set which sheets to load - * - * @param mixed $value - * This should be either an array of worksheet names to be loaded, or a string containing a single worksheet name. - * If NULL, then it tells the Reader to read all worksheets in the workbook - * - * @return PHPExcel_Reader_Excel5 - */ - public function setLoadSheetsOnly($value = null) - { - $this->_loadSheetsOnly = is_array($value) ? - $value : array($value); - return $this; - } - - - /** - * Set all sheets to load - * Tells the Reader to load all worksheets from the workbook. - * - * @return PHPExcel_Reader_Excel5 - */ - public function setLoadAllSheets() - { - $this->_loadSheetsOnly = null; - return $this; - } - - - /** - * Read filter - * - * @return PHPExcel_Reader_IReadFilter - */ - public function getReadFilter() { - return $this->_readFilter; - } - - - /** - * Set read filter - * - * @param PHPExcel_Reader_IReadFilter $pValue - * @return PHPExcel_Reader_Excel5 - */ - public function setReadFilter(PHPExcel_Reader_IReadFilter $pValue) { - $this->_readFilter = $pValue; - return $this; - } - - /** * Can the current PHPExcel_Reader_IReader read the file? * - * @param string $pFileName + * @param string $pFilename * @return boolean - * @throws Exception + * @throws PHPExcel_Reader_Exception */ public function canRead($pFilename) { // Check if file exists if (!file_exists($pFilename)) { - throw new Exception("Could not open " . $pFilename . " for reading! File does not exist."); + throw new PHPExcel_Reader_Exception("Could not open " . $pFilename . " for reading! File does not exist."); } try { @@ -526,8 +450,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader // get excel data $res = $ole->read($pFilename); return true; - - } catch (Exception $e) { + } catch (PHPExcel_Exception $e) { return false; } } @@ -537,13 +460,13 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader * Reads names of the worksheets from a file, without parsing the whole file to a PHPExcel object * * @param string $pFilename - * @throws Exception + * @throws PHPExcel_Reader_Exception */ public function listWorksheetNames($pFilename) { // Check if file exists if (!file_exists($pFilename)) { - throw new Exception("Could not open " . $pFilename . " for reading! File does not exist."); + throw new PHPExcel_Reader_Exception("Could not open " . $pFilename . " for reading! File does not exist."); } $worksheetNames = array(); @@ -586,13 +509,13 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader * Return worksheet info (Name, Last Column Letter, Last Column Index, Total Rows, Total Columns) * * @param string $pFilename - * @throws Exception + * @throws PHPExcel_Reader_Exception */ public function listWorksheetInfo($pFilename) { // Check if file exists if (!file_exists($pFilename)) { - throw new Exception("Could not open " . $pFilename . " for reading! File does not exist."); + throw new PHPExcel_Reader_Exception("Could not open " . $pFilename . " for reading! File does not exist."); } $worksheetInfo = array(); @@ -649,7 +572,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader case self::XLS_Type_BOOLERR: case self::XLS_Type_LABEL: $length = self::_GetInt2d($this->_data, $this->_pos + 2); - $recordData = substr($this->_data, $this->_pos + 4, $length); + $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); // move stream pointer to next record $this->_pos += 4 + $length; @@ -681,7 +604,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader * * @param string $pFilename * @return PHPExcel - * @throws Exception + * @throws PHPExcel_Reader_Exception */ public function load($pFilename) { @@ -903,6 +826,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader case self::XLS_Type_MSODRAWING: $this->_readMsoDrawing(); break; case self::XLS_Type_OBJ: $this->_readObj(); break; case self::XLS_Type_WINDOW2: $this->_readWindow2(); break; + case self::XLS_Type_PAGELAYOUTVIEW: $this->_readPageLayoutView(); break; case self::XLS_Type_SCL: $this->_readScl(); break; case self::XLS_Type_PANE: $this->_readPane(); break; case self::XLS_Type_SELECTION: $this->_readSelection(); break; @@ -1073,7 +997,6 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader case pack('C', 0x06): // print area // in general, formula looks like this: Foo!$C$7:$J$66,Bar!$A$1:$IV$2 - $ranges = explode(',', $definedName['formula']); // FIXME: what if sheetname contains comma? $extractedRanges = array(); @@ -1083,9 +1006,12 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader // Bar!$A$1:$IV$2 $explodes = explode('!', $range); // FIXME: what if sheetname contains exclamation mark? - $sheetName = $explodes[0]; + $sheetName = trim($explodes[0], "'"); if (count($explodes) == 2) { + if (strpos($explodes[1], ':') === FALSE) { + $explodes[1] = $explodes[1] . ':' . $explodes[1]; + } $extractedRanges[] = str_replace('$', '', $explodes[1]); // C7:J66 } } @@ -1166,7 +1092,63 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader return $this->_phpExcel; } + + /** + * Read record data from stream, decrypting as required + * + * @param string $data Data stream to read from + * @param int $pos Position to start reading from + * @param int $length Record data length + * + * @return string Record data + */ + private function _readRecordData($data, $pos, $len) + { + $data = substr($data, $pos, $len); + + // File not encrypted, or record before encryption start point + if ($this->_encryption == self::MS_BIFF_CRYPTO_NONE || $pos < $this->_encryptionStartPos) { + return $data; + } + + $recordData = ''; + if ($this->_encryption == self::MS_BIFF_CRYPTO_RC4) { + $oldBlock = floor($this->_rc4Pos / self::REKEY_BLOCK); + $block = floor($pos / self::REKEY_BLOCK); + $endBlock = floor(($pos + $len) / self::REKEY_BLOCK); + + // Spin an RC4 decryptor to the right spot. If we have a decryptor sitting + // at a point earlier in the current block, re-use it as we can save some time. + if ($block != $oldBlock || $pos < $this->_rc4Pos || !$this->_rc4Key) { + $this->_rc4Key = $this->_makeKey($block, $this->_md5Ctxt); + $step = $pos % self::REKEY_BLOCK; + } else { + $step = $pos - $this->_rc4Pos; + } + $this->_rc4Key->RC4(str_repeat("\0", $step)); + + // Decrypt record data (re-keying at the end of every block) + while ($block != $endBlock) { + $step = self::REKEY_BLOCK - ($pos % self::REKEY_BLOCK); + $recordData .= $this->_rc4Key->RC4(substr($data, 0, $step)); + $data = substr($data, $step); + $pos += $step; + $len -= $step; + $block++; + $this->_rc4Key = $this->_makeKey($block, $this->_md5Ctxt); + } + $recordData .= $this->_rc4Key->RC4(substr($data, 0, $len)); + + // Keep track of the position of this decryptor. + // We'll try and re-use it later if we can to speed things up + $this->_rc4Pos = $pos + $len; + + } elseif ($this->_encryption == self::MS_BIFF_CRYPTO_XOR) { + throw new PHPExcel_Reader_Exception('XOr encryption not supported'); + } + return $recordData; + } /** * Use OLE reader to extract the relevant data streams from the OLE file @@ -1519,7 +1501,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader private function _readDefault() { $length = self::_GetInt2d($this->_data, $this->_pos + 2); -// $recordData = substr($this->_data, $this->_pos + 4, $length); +// $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); // move stream pointer to next record $this->_pos += 4 + $length; @@ -1534,7 +1516,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader { // echo 'Read Cell Annotation
'; $length = self::_GetInt2d($this->_data, $this->_pos + 2); - $recordData = substr($this->_data, $this->_pos + 4, $length); + $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); // move stream pointer to next record $this->_pos += 4 + $length; @@ -1596,7 +1578,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader private function _readTextObject() { $length = self::_GetInt2d($this->_data, $this->_pos + 2); - $recordData = substr($this->_data, $this->_pos + 4, $length); + $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); // move stream pointer to next record $this->_pos += 4 + $length; @@ -1648,7 +1630,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader case self::XLS_WorkbookGlobals: $version = self::_GetInt2d($recordData, 0); if (($version != self::XLS_BIFF8) && ($version != self::XLS_BIFF7)) { - throw new Exception('Cannot read this Excel file. Version is too old.'); + throw new PHPExcel_Reader_Exception('Cannot read this Excel file. Version is too old.'); } $this->_version = $version; break; @@ -1680,18 +1662,156 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader * * -- "OpenOffice.org's Documentation of the Microsoft * Excel File Format" + * + * The decryption functions and objects used from here on in + * are based on the source of Spreadsheet-ParseExcel: + * http://search.cpan.org/~jmcnamara/Spreadsheet-ParseExcel/ */ private function _readFilepass() { $length = self::_GetInt2d($this->_data, $this->_pos + 2); -// $recordData = substr($this->_data, $this->_pos + 4, $length); + if ($length != 54) { + throw new PHPExcel_Reader_Exception('Unexpected file pass record length'); + } + + $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); + // move stream pointer to next record $this->_pos += 4 + $length; + + if (!$this->_verifyPassword( + 'VelvetSweatshop', + substr($recordData, 6, 16), + substr($recordData, 22, 16), + substr($recordData, 38, 16), + $this->_md5Ctxt + )) { + throw new PHPExcel_Reader_Exception('Decryption password incorrect'); + } + + $this->_encryption = self::MS_BIFF_CRYPTO_RC4; - throw new Exception('Cannot read encrypted file'); + // Decryption required from the record after next onwards + $this->_encryptionStartPos = $this->_pos + self::_GetInt2d($this->_data, $this->_pos + 2); } + /** + * Make an RC4 decryptor for the given block + * + * @var int $block Block for which to create decrypto + * @var string $valContext MD5 context state + * + * @return PHPExcel_Reader_Excel5_RC4 + */ + private function _makeKey($block, $valContext) + { + $pwarray = str_repeat("\0", 64); + + for ($i = 0; $i < 5; $i++) { + $pwarray[$i] = $valContext[$i]; + } + + $pwarray[5] = chr($block & 0xff); + $pwarray[6] = chr(($block >> 8) & 0xff); + $pwarray[7] = chr(($block >> 16) & 0xff); + $pwarray[8] = chr(($block >> 24) & 0xff); + + $pwarray[9] = "\x80"; + $pwarray[56] = "\x48"; + + $md5 = new PHPExcel_Reader_Excel5_MD5(); + $md5->add($pwarray); + + $s = $md5->getContext(); + return new PHPExcel_Reader_Excel5_RC4($s); + } + + /** + * Verify RC4 file password + * + * @var string $password Password to check + * @var string $docid Document id + * @var string $salt_data Salt data + * @var string $hashedsalt_data Hashed salt data + * @var string &$valContext Set to the MD5 context of the value + * + * @return bool Success + */ + private function _verifyPassword($password, $docid, $salt_data, $hashedsalt_data, &$valContext) + { + $pwarray = str_repeat("\0", 64); + + for ($i = 0; $i < strlen($password); $i++) { + $o = ord(substr($password, $i, 1)); + $pwarray[2 * $i] = chr($o & 0xff); + $pwarray[2 * $i + 1] = chr(($o >> 8) & 0xff); + } + $pwarray[2 * $i] = chr(0x80); + $pwarray[56] = chr(($i << 4) & 0xff); + + $md5 = new PHPExcel_Reader_Excel5_MD5(); + $md5->add($pwarray); + + $mdContext1 = $md5->getContext(); + + $offset = 0; + $keyoffset = 0; + $tocopy = 5; + + $md5->reset(); + + while ($offset != 16) { + if ((64 - $offset) < 5) { + $tocopy = 64 - $offset; + } + + for ($i = 0; $i <= $tocopy; $i++) { + $pwarray[$offset + $i] = $mdContext1[$keyoffset + $i]; + } + + $offset += $tocopy; + + if ($offset == 64) { + $md5->add($pwarray); + $keyoffset = $tocopy; + $tocopy = 5 - $tocopy; + $offset = 0; + continue; + } + + $keyoffset = 0; + $tocopy = 5; + for ($i = 0; $i < 16; $i++) { + $pwarray[$offset + $i] = $docid[$i]; + } + $offset += 16; + } + + $pwarray[16] = "\x80"; + for ($i = 0; $i < 47; $i++) { + $pwarray[17 + $i] = "\0"; + } + $pwarray[56] = "\x80"; + $pwarray[57] = "\x0a"; + + $md5->add($pwarray); + $valContext = $md5->getContext(); + + $key = $this->_makeKey(0, $valContext); + + $salt = $key->RC4($salt_data); + $hashedsalt = $key->RC4($hashedsalt_data); + + $salt .= "\x80" . str_repeat("\0", 47); + $salt[56] = "\x80"; + + $md5->reset(); + $md5->add($salt); + $mdContext2 = $md5->getContext(); + + return $mdContext2 == $hashedsalt; + } /** * CODEPAGE @@ -1705,7 +1825,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader private function _readCodepage() { $length = self::_GetInt2d($this->_data, $this->_pos + 2); - $recordData = substr($this->_data, $this->_pos + 4, $length); + $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); // move stream pointer to next record $this->_pos += 4 + $length; @@ -1732,7 +1852,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader private function _readDateMode() { $length = self::_GetInt2d($this->_data, $this->_pos + 2); - $recordData = substr($this->_data, $this->_pos + 4, $length); + $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); // move stream pointer to next record $this->_pos += 4 + $length; @@ -1751,7 +1871,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader private function _readFont() { $length = self::_GetInt2d($this->_data, $this->_pos + 2); - $recordData = substr($this->_data, $this->_pos + 4, $length); + $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); // move stream pointer to next record $this->_pos += 4 + $length; @@ -1849,7 +1969,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader private function _readFormat() { $length = self::_GetInt2d($this->_data, $this->_pos + 2); - $recordData = substr($this->_data, $this->_pos + 4, $length); + $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); // move stream pointer to next record $this->_pos += 4 + $length; @@ -1887,7 +2007,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader private function _readXf() { $length = self::_GetInt2d($this->_data, $this->_pos + 2); - $recordData = substr($this->_data, $this->_pos + 4, $length); + $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); // move stream pointer to next record $this->_pos += 4 + $length; @@ -1951,6 +2071,9 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader case 3: $objStyle->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT); break; + case 4: + $objStyle->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_FILL); + break; case 5: $objStyle->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_JUSTIFY); break; @@ -2170,7 +2293,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader private function _readXfExt() { $length = self::_GetInt2d($this->_data, $this->_pos + 2); - $recordData = substr($this->_data, $this->_pos + 4, $length); + $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); // move stream pointer to next record $this->_pos += 4 + $length; @@ -2347,7 +2470,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader private function _readStyle() { $length = self::_GetInt2d($this->_data, $this->_pos + 2); - $recordData = substr($this->_data, $this->_pos + 4, $length); + $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); // move stream pointer to next record $this->_pos += 4 + $length; @@ -2388,7 +2511,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader private function _readPalette() { $length = self::_GetInt2d($this->_data, $this->_pos + 2); - $recordData = substr($this->_data, $this->_pos + 4, $length); + $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); // move stream pointer to next record $this->_pos += 4 + $length; @@ -2421,14 +2544,15 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader private function _readSheet() { $length = self::_GetInt2d($this->_data, $this->_pos + 2); - $recordData = substr($this->_data, $this->_pos + 4, $length); + $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); + + // offset: 0; size: 4; absolute stream position of the BOF record of the sheet + // NOTE: not encrypted + $rec_offset = self::_GetInt4d($this->_data, $this->_pos + 4); // move stream pointer to next record $this->_pos += 4 + $length; - // offset: 0; size: 4; absolute stream position of the BOF record of the sheet - $rec_offset = self::_GetInt4d($recordData, 0); - // offset: 4; size: 1; sheet state switch (ord($recordData{4})) { case 0x00: $sheetState = PHPExcel_Worksheet::SHEETSTATE_VISIBLE; break; @@ -2464,7 +2588,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader private function _readExternalBook() { $length = self::_GetInt2d($this->_data, $this->_pos + 2); - $recordData = substr($this->_data, $this->_pos + 4, $length); + $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); // move stream pointer to next record $this->_pos += 4 + $length; @@ -2528,7 +2652,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader private function _readExternName() { $length = self::_GetInt2d($this->_data, $this->_pos + 2); - $recordData = substr($this->_data, $this->_pos + 4, $length); + $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); // move stream pointer to next record $this->_pos += 4 + $length; @@ -2563,7 +2687,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader private function _readExternSheet() { $length = self::_GetInt2d($this->_data, $this->_pos + 2); - $recordData = substr($this->_data, $this->_pos + 4, $length); + $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); // move stream pointer to next record $this->_pos += 4 + $length; @@ -2600,7 +2724,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader private function _readDefinedName() { $length = self::_GetInt2d($this->_data, $this->_pos + 2); - $recordData = substr($this->_data, $this->_pos + 4, $length); + $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); // move stream pointer to next record $this->_pos += 4 + $length; @@ -2635,7 +2759,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader try { $formula = $this->_getFormulaFromStructure($formulaStructure); - } catch (Exception $e) { + } catch (PHPExcel_Exception $e) { $formula = ''; } @@ -2862,7 +2986,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader private function _readPrintGridlines() { $length = self::_GetInt2d($this->_data, $this->_pos + 2); - $recordData = substr($this->_data, $this->_pos + 4, $length); + $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); // move stream pointer to next record $this->_pos += 4 + $length; @@ -2881,7 +3005,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader private function _readDefaultRowHeight() { $length = self::_GetInt2d($this->_data, $this->_pos + 2); - $recordData = substr($this->_data, $this->_pos + 4, $length); + $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); // move stream pointer to next record $this->_pos += 4 + $length; @@ -2899,7 +3023,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader private function _readSheetPr() { $length = self::_GetInt2d($this->_data, $this->_pos + 2); - $recordData = substr($this->_data, $this->_pos + 4, $length); + $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); // move stream pointer to next record $this->_pos += 4 + $length; @@ -2926,7 +3050,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader private function _readHorizontalPageBreaks() { $length = self::_GetInt2d($this->_data, $this->_pos + 2); - $recordData = substr($this->_data, $this->_pos + 4, $length); + $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); // move stream pointer to next record $this->_pos += 4 + $length; @@ -2955,7 +3079,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader private function _readVerticalPageBreaks() { $length = self::_GetInt2d($this->_data, $this->_pos + 2); - $recordData = substr($this->_data, $this->_pos + 4, $length); + $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); // move stream pointer to next record $this->_pos += 4 + $length; @@ -2983,7 +3107,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader private function _readHeader() { $length = self::_GetInt2d($this->_data, $this->_pos + 2); - $recordData = substr($this->_data, $this->_pos + 4, $length); + $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); // move stream pointer to next record $this->_pos += 4 + $length; @@ -3011,7 +3135,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader private function _readFooter() { $length = self::_GetInt2d($this->_data, $this->_pos + 2); - $recordData = substr($this->_data, $this->_pos + 4, $length); + $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); // move stream pointer to next record $this->_pos += 4 + $length; @@ -3038,7 +3162,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader private function _readHcenter() { $length = self::_GetInt2d($this->_data, $this->_pos + 2); - $recordData = substr($this->_data, $this->_pos + 4, $length); + $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); // move stream pointer to next record $this->_pos += 4 + $length; @@ -3058,7 +3182,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader private function _readVcenter() { $length = self::_GetInt2d($this->_data, $this->_pos + 2); - $recordData = substr($this->_data, $this->_pos + 4, $length); + $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); // move stream pointer to next record $this->_pos += 4 + $length; @@ -3078,7 +3202,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader private function _readLeftMargin() { $length = self::_GetInt2d($this->_data, $this->_pos + 2); - $recordData = substr($this->_data, $this->_pos + 4, $length); + $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); // move stream pointer to next record $this->_pos += 4 + $length; @@ -3096,7 +3220,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader private function _readRightMargin() { $length = self::_GetInt2d($this->_data, $this->_pos + 2); - $recordData = substr($this->_data, $this->_pos + 4, $length); + $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); // move stream pointer to next record $this->_pos += 4 + $length; @@ -3114,7 +3238,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader private function _readTopMargin() { $length = self::_GetInt2d($this->_data, $this->_pos + 2); - $recordData = substr($this->_data, $this->_pos + 4, $length); + $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); // move stream pointer to next record $this->_pos += 4 + $length; @@ -3132,7 +3256,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader private function _readBottomMargin() { $length = self::_GetInt2d($this->_data, $this->_pos + 2); - $recordData = substr($this->_data, $this->_pos + 4, $length); + $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); // move stream pointer to next record $this->_pos += 4 + $length; @@ -3150,7 +3274,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader private function _readPageSetup() { $length = self::_GetInt2d($this->_data, $this->_pos + 2); - $recordData = substr($this->_data, $this->_pos + 4, $length); + $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); // move stream pointer to next record $this->_pos += 4 + $length; @@ -3208,7 +3332,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader private function _readProtect() { $length = self::_GetInt2d($this->_data, $this->_pos + 2); - $recordData = substr($this->_data, $this->_pos + 4, $length); + $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); // move stream pointer to next record $this->_pos += 4 + $length; @@ -3231,7 +3355,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader private function _readScenProtect() { $length = self::_GetInt2d($this->_data, $this->_pos + 2); - $recordData = substr($this->_data, $this->_pos + 4, $length); + $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); // move stream pointer to next record $this->_pos += 4 + $length; @@ -3255,7 +3379,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader private function _readObjectProtect() { $length = self::_GetInt2d($this->_data, $this->_pos + 2); - $recordData = substr($this->_data, $this->_pos + 4, $length); + $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); // move stream pointer to next record $this->_pos += 4 + $length; @@ -3279,7 +3403,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader private function _readPassword() { $length = self::_GetInt2d($this->_data, $this->_pos + 2); - $recordData = substr($this->_data, $this->_pos + 4, $length); + $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); // move stream pointer to next record $this->_pos += 4 + $length; @@ -3298,7 +3422,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader private function _readDefColWidth() { $length = self::_GetInt2d($this->_data, $this->_pos + 2); - $recordData = substr($this->_data, $this->_pos + 4, $length); + $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); // move stream pointer to next record $this->_pos += 4 + $length; @@ -3317,7 +3441,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader private function _readColInfo() { $length = self::_GetInt2d($this->_data, $this->_pos + 2); - $recordData = substr($this->_data, $this->_pos + 4, $length); + $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); // move stream pointer to next record $this->_pos += 4 + $length; @@ -3376,7 +3500,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader private function _readRow() { $length = self::_GetInt2d($this->_data, $this->_pos + 2); - $recordData = substr($this->_data, $this->_pos + 4, $length); + $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); // move stream pointer to next record $this->_pos += 4 + $length; @@ -3446,7 +3570,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader private function _readRk() { $length = self::_GetInt2d($this->_data, $this->_pos + 2); - $recordData = substr($this->_data, $this->_pos + 4, $length); + $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); // move stream pointer to next record $this->_pos += 4 + $length; @@ -3491,7 +3615,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader private function _readLabelSst() { $length = self::_GetInt2d($this->_data, $this->_pos + 2); - $recordData = substr($this->_data, $this->_pos + 4, $length); + $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); // move stream pointer to next record $this->_pos += 4 + $length; @@ -3569,7 +3693,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader private function _readMulRk() { $length = self::_GetInt2d($this->_data, $this->_pos + 2); - $recordData = substr($this->_data, $this->_pos + 4, $length); + $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); // move stream pointer to next record $this->_pos += 4 + $length; @@ -3624,7 +3748,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader private function _readNumber() { $length = self::_GetInt2d($this->_data, $this->_pos + 2); - $recordData = substr($this->_data, $this->_pos + 4, $length); + $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); // move stream pointer to next record $this->_pos += 4 + $length; @@ -3666,7 +3790,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader private function _readFormula() { $length = self::_GetInt2d($this->_data, $this->_pos + 2); - $recordData = substr($this->_data, $this->_pos + 4, $length); + $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); // move stream pointer to next record $this->_pos += 4 + $length; @@ -3777,12 +3901,12 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader // add cell value. If we can read formula, populate with formula, otherwise just used cached value try { if ($this->_version != self::XLS_BIFF8) { - throw new Exception('Not BIFF8. Can only read BIFF8 formulas'); + throw new PHPExcel_Reader_Exception('Not BIFF8. Can only read BIFF8 formulas'); } $formula = $this->_getFormulaFromStructure($formulaStructure); // get formula in human language $cell->setValueExplicit('=' . $formula, PHPExcel_Cell_DataType::TYPE_FORMULA); - } catch (Exception $e) { + } catch (PHPExcel_Exception $e) { $cell->setValueExplicit($value, $dataType); } } else { @@ -3807,7 +3931,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader private function _readSharedFmla() { $length = self::_GetInt2d($this->_data, $this->_pos + 2); - $recordData = substr($this->_data, $this->_pos + 4, $length); + $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); // move stream pointer to next record $this->_pos += 4 + $length; @@ -3840,7 +3964,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader private function _readString() { $length = self::_GetInt2d($this->_data, $this->_pos + 2); - $recordData = substr($this->_data, $this->_pos + 4, $length); + $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); // move stream pointer to next record $this->_pos += 4 + $length; @@ -3868,7 +3992,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader private function _readBoolErr() { $length = self::_GetInt2d($this->_data, $this->_pos + 2); - $recordData = substr($this->_data, $this->_pos + 4, $length); + $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); // move stream pointer to next record $this->_pos += 4 + $length; @@ -3927,7 +4051,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader private function _readMulBlank() { $length = self::_GetInt2d($this->_data, $this->_pos + 2); - $recordData = substr($this->_data, $this->_pos + 4, $length); + $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); // move stream pointer to next record $this->_pos += 4 + $length; @@ -3969,7 +4093,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader private function _readLabel() { $length = self::_GetInt2d($this->_data, $this->_pos + 2); - $recordData = substr($this->_data, $this->_pos + 4, $length); + $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); // move stream pointer to next record $this->_pos += 4 + $length; @@ -4012,7 +4136,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader private function _readBlank() { $length = self::_GetInt2d($this->_data, $this->_pos + 2); - $recordData = substr($this->_data, $this->_pos + 4, $length); + $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); // move stream pointer to next record $this->_pos += 4 + $length; @@ -4059,7 +4183,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader private function _readObj() { $length = self::_GetInt2d($this->_data, $this->_pos + 2); - $recordData = substr($this->_data, $this->_pos + 4, $length); + $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); // move stream pointer to next record $this->_pos += 4 + $length; @@ -4104,7 +4228,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader private function _readWindow2() { $length = self::_GetInt2d($this->_data, $this->_pos + 2); - $recordData = substr($this->_data, $this->_pos + 4, $length); + $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); // move stream pointer to next record $this->_pos += 4 + $length; @@ -4112,6 +4236,22 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader // offset: 0; size: 2; option flags $options = self::_GetInt2d($recordData, 0); + // offset: 2; size: 2; index to first visible row + $firstVisibleRow = self::_GetInt2d($recordData, 2); + + // offset: 4; size: 2; index to first visible colum + $firstVisibleColumn = self::_GetInt2d($recordData, 4); + if ($this->_version === self::XLS_BIFF8) { + // offset: 8; size: 2; not used + // offset: 10; size: 2; cached magnification factor in page break preview (in percent); 0 = Default (60%) + // offset: 12; size: 2; cached magnification factor in normal view (in percent); 0 = Default (100%) + // offset: 14; size: 4; not used + $zoomscaleInPageBreakPreview = self::_GetInt2d($recordData, 10); + if ($zoomscaleInPageBreakPreview === 0) $zoomscaleInPageBreakPreview = 60; + $zoomscaleInNormalView = self::_GetInt2d($recordData, 12); + if ($zoomscaleInNormalView === 0) $zoomscaleInNormalView = 100; + } + // bit: 1; mask: 0x0002; 0 = do not show gridlines, 1 = show gridlines $showGridlines = (bool) ((0x0002 & $options) >> 1); $this->_phpSheet->setShowGridlines($showGridlines); @@ -4131,8 +4271,62 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader if ($isActive) { $this->_phpExcel->setActiveSheetIndex($this->_phpExcel->getIndex($this->_phpSheet)); } + + // bit: 11; mask: 0x0800; 0 = normal view, 1 = page break view + $isPageBreakPreview = (bool) ((0x0800 & $options) >> 11); + + //FIXME: set $firstVisibleRow and $firstVisibleColumn + + if ($this->_phpSheet->getSheetView()->getView() !== PHPExcel_Worksheet_SheetView::SHEETVIEW_PAGE_LAYOUT) { + //NOTE: this setting is inferior to page layout view(Excel2007-) + $view = $isPageBreakPreview? PHPExcel_Worksheet_SheetView::SHEETVIEW_PAGE_BREAK_PREVIEW : + PHPExcel_Worksheet_SheetView::SHEETVIEW_NORMAL; + $this->_phpSheet->getSheetView()->setView($view); + if ($this->_version === self::XLS_BIFF8) { + $zoomScale = $isPageBreakPreview? $zoomscaleInPageBreakPreview : $zoomscaleInNormalView; + $this->_phpSheet->getSheetView()->setZoomScale($zoomScale); + $this->_phpSheet->getSheetView()->setZoomScaleNormal($zoomscaleInNormalView); + } + } } + /** + * Read PLV Record(Created by Excel2007 or upper) + */ + private function _readPageLayoutView(){ + $length = self::_GetInt2d($this->_data, $this->_pos + 2); + $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); + + // move stream pointer to next record + $this->_pos += 4 + $length; + + //var_dump(unpack("vrt/vgrbitFrt/V2reserved/vwScalePLV/vgrbit", $recordData)); + + // offset: 0; size: 2; rt + //->ignore + $rt = self::_GetInt2d($recordData, 0); + // offset: 2; size: 2; grbitfr + //->ignore + $grbitFrt = self::_GetInt2d($recordData, 2); + // offset: 4; size: 8; reserved + //->ignore + + // offset: 12; size 2; zoom scale + $wScalePLV = self::_GetInt2d($recordData, 12); + // offset: 14; size 2; grbit + $grbit = self::_GetInt2d($recordData, 14); + + // decomprise grbit + $fPageLayoutView = $grbit & 0x01; + $fRulerVisible = ($grbit >> 1) & 0x01; //no support + $fWhitespaceHidden = ($grbit >> 3) & 0x01; //no support + + if ($fPageLayoutView === 1) { + $this->_phpSheet->getSheetView()->setView(PHPExcel_Worksheet_SheetView::SHEETVIEW_PAGE_LAYOUT); + $this->_phpSheet->getSheetView()->setZoomScale($wScalePLV); //set by Excel2007 only if SHEETVIEW_PAGE_LAYOUT + } + //otherwise, we cannot know whether SHEETVIEW_PAGE_LAYOUT or SHEETVIEW_PAGE_BREAK_PREVIEW. + } /** * Read SCL record @@ -4140,7 +4334,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader private function _readScl() { $length = self::_GetInt2d($this->_data, $this->_pos + 2); - $recordData = substr($this->_data, $this->_pos + 4, $length); + $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); // move stream pointer to next record $this->_pos += 4 + $length; @@ -4162,7 +4356,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader private function _readPane() { $length = self::_GetInt2d($this->_data, $this->_pos + 2); - $recordData = substr($this->_data, $this->_pos + 4, $length); + $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); // move stream pointer to next record $this->_pos += 4 + $length; @@ -4190,7 +4384,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader private function _readSelection() { $length = self::_GetInt2d($this->_data, $this->_pos + 2); - $recordData = substr($this->_data, $this->_pos + 4, $length); + $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); // move stream pointer to next record $this->_pos += 4 + $length; @@ -4267,7 +4461,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader private function _readMergedCells() { $length = self::_GetInt2d($this->_data, $this->_pos + 2); - $recordData = substr($this->_data, $this->_pos + 4, $length); + $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); // move stream pointer to next record $this->_pos += 4 + $length; @@ -4290,7 +4484,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader private function _readHyperLink() { $length = self::_GetInt2d($this->_data, $this->_pos + 2); - $recordData = substr($this->_data, $this->_pos + 4, $length); + $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); // move stream pointer forward to next record $this->_pos += 4 + $length; @@ -4299,7 +4493,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader // offset: 0; size: 8; cell range address of all cells containing this hyperlink try { $cellRange = $this->_readBIFF8CellRangeAddressFixed($recordData, 0, 8); - } catch (Exception $e) { + } catch (PHPExcel_Exception $e) { return; } @@ -4466,7 +4660,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader private function _readDataValidations() { $length = self::_GetInt2d($this->_data, $this->_pos + 2); - $recordData = substr($this->_data, $this->_pos + 4, $length); + $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); // move stream pointer forward to next record $this->_pos += 4 + $length; @@ -4479,7 +4673,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader private function _readDataValidation() { $length = self::_GetInt2d($this->_data, $this->_pos + 2); - $recordData = substr($this->_data, $this->_pos + 4, $length); + $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); // move stream pointer forward to next record $this->_pos += 4 + $length; @@ -4583,7 +4777,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader if ($type == PHPExcel_Cell_DataValidation::TYPE_LIST) { $formula1 = str_replace(chr(0), ',', $formula1); } - } catch (Exception $e) { + } catch (PHPExcel_Exception $e) { return; } $offset += $sz1; @@ -4600,7 +4794,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader $formula2 = pack('v', $sz2) . $formula2; // prepend the length try { $formula2 = $this->_getFormulaFromStructure($formula2); - } catch (Exception $e) { + } catch (PHPExcel_Exception $e) { return; } $offset += $sz2; @@ -4639,7 +4833,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader private function _readSheetLayout() { $length = self::_GetInt2d($this->_data, $this->_pos + 2); - $recordData = substr($this->_data, $this->_pos + 4, $length); + $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); // move stream pointer to next record $this->_pos += 4 + $length; @@ -4679,7 +4873,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader private function _readSheetProtection() { $length = self::_GetInt2d($this->_data, $this->_pos + 2); - $recordData = substr($this->_data, $this->_pos + 4, $length); + $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); // move stream pointer to next record $this->_pos += 4 + $length; @@ -4780,7 +4974,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader private function _readRangeProtection() { $length = self::_GetInt2d($this->_data, $this->_pos + 2); - $recordData = substr($this->_data, $this->_pos + 4, $length); + $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); // move stream pointer to next record $this->_pos += 4 + $length; @@ -4812,7 +5006,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader for ($i = 0; $i < $cref; ++$i) { try { $cellRange = $this->_readBIFF8CellRangeAddressFixed(substr($recordData, 27 + 8 * $i, 8)); - } catch (Exception $e) { + } catch (PHPExcel_Exception $e) { return; } $cellRanges[] = $cellRange; @@ -4924,7 +5118,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader private function _readContinue() { $length = self::_GetInt2d($this->_data, $this->_pos + 2); - $recordData = substr($this->_data, $this->_pos + 4, $length); + $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); // check if we are reading drawing data // this is in case a free CONTINUE record occurs in other circumstances we are unaware of @@ -4989,7 +5183,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader $identifier = self::_GetInt2d($this->_data, $this->_pos); // offset: 2; size: 2; length $length = self::_GetInt2d($this->_data, $this->_pos + 2); - $data .= substr($this->_data, $this->_pos + 4, $length); + $data .= $this->_readRecordData($this->_data, $this->_pos + 4, $length); $spliceOffsets[$i] = $spliceOffsets[$i - 1] + $length; @@ -5244,7 +5438,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader * @param string Formula data * @param string $baseCell Base cell, only needed when formula contains tRefN tokens, e.g. with shared formulas * @return array - * @throws Exception + * @throws PHPExcel_Reader_Exception */ private function _getNextToken($formulaData, $baseCell = 'A1') { @@ -5345,7 +5539,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader $spacetype = 'type5'; break; default: - throw new Exception('Unrecognized space type in tAttrSpace token'); + throw new PHPExcel_Reader_Exception('Unrecognized space type in tAttrSpace token'); break; } // offset: 3; size: 1; number of inserted spaces/carriage returns @@ -5354,7 +5548,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader $data = array('spacetype' => $spacetype, 'spacecount' => $spacecount); break; default: - throw new Exception('Unrecognized attribute flag in tAttr token'); + throw new PHPExcel_Reader_Exception('Unrecognized attribute flag in tAttr token'); break; } break; @@ -5559,7 +5753,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader case 360: $function = 'PHONETIC'; $args = 1; break; case 368: $function = 'BAHTTEXT'; $args = 1; break; default: - throw new Exception('Unrecognized function in formula'); + throw new PHPExcel_Reader_Exception('Unrecognized function in formula'); break; } $data = array('function' => $function, 'args' => $args); @@ -5663,7 +5857,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader case 366: $function = 'STDEVA'; break; case 367: $function = 'VARA'; break; default: - throw new Exception('Unrecognized function in formula'); + throw new PHPExcel_Reader_Exception('Unrecognized function in formula'); break; } $data = array('function' => $function, 'args' => $args); @@ -5764,7 +5958,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader $cellAddress = $this->_readBIFF8CellAddress(substr($formulaData, 3, 4)); $data = "$sheetRange!$cellAddress"; - } catch (Exception $e) { + } catch (PHPExcel_Exception $e) { // deleted sheet reference $data = '#REF!'; } @@ -5783,7 +5977,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader $cellRangeAddress = $this->_readBIFF8CellRangeAddress(substr($formulaData, 3, 8)); $data = "$sheetRange!$cellRangeAddress"; - } catch (Exception $e) { + } catch (PHPExcel_Exception $e) { // deleted sheet reference $data = '#REF!'; } @@ -5791,7 +5985,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader break; // Unknown cases // don't know how to deal with default: - throw new Exception('Unrecognized token ' . sprintf('%02X', $id) . ' in formula'); + throw new PHPExcel_Reader_Exception('Unrecognized token ' . sprintf('%02X', $id) . ' in formula'); break; } @@ -5885,7 +6079,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader * * @param string $subData * @return string - * @throws Exception + * @throws PHPExcel_Reader_Exception */ private function _readBIFF5CellRangeAddressFixed($subData) { @@ -5903,7 +6097,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader // check values if ($fr > $lr || $fc > $lc) { - throw new Exception('Not a cell range address'); + throw new PHPExcel_Reader_Exception('Not a cell range address'); } // column index to letter @@ -5924,7 +6118,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader * * @param string $subData * @return string - * @throws Exception + * @throws PHPExcel_Reader_Exception */ private function _readBIFF8CellRangeAddressFixed($subData) { @@ -5942,7 +6136,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader // check values if ($fr > $lr || $fc > $lc) { - throw new Exception('Not a cell range address'); + throw new PHPExcel_Reader_Exception('Not a cell range address'); } // column index to letter @@ -6152,11 +6346,11 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader * Get a sheet range like Sheet1:Sheet3 from REF index * Note: If there is only one sheet in the range, one gets e.g Sheet1 * It can also happen that the REF structure uses the -1 (FFFF) code to indicate deleted sheets, - * in which case an exception is thrown + * in which case an PHPExcel_Reader_Exception is thrown * * @param int $index * @return string|false - * @throws Exception + * @throws PHPExcel_Reader_Exception */ private function _readSheetRangeByRefIndex($index) { @@ -6168,7 +6362,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader case 'internal': // check if we have a deleted 3d reference if ($this->_ref[$index]['firstSheetIndex'] == 0xFFFF or $this->_ref[$index]['lastSheetIndex'] == 0xFFFF) { - throw new Exception('Deleted sheet reference'); + throw new PHPExcel_Reader_Exception('Deleted sheet reference'); } // we have normal sheet range (collapsed or uncollapsed) @@ -6198,7 +6392,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader default: // TODO: external sheet support - throw new Exception('Excel5 reader only supports internal sheets in fomulas'); + throw new PHPExcel_Reader_Exception('Excel5 reader only supports internal sheets in fomulas'); break; } } diff --git a/htdocs/includes/phpexcel/PHPExcel/Reader/Excel5/Escher.php b/htdocs/includes/phpexcel/PHPExcel/Reader/Excel5/Escher.php index e167655ffd6..3ed82c62ae6 100644 --- a/htdocs/includes/phpexcel/PHPExcel/Reader/Excel5/Escher.php +++ b/htdocs/includes/phpexcel/PHPExcel/Reader/Excel5/Escher.php @@ -2,7 +2,7 @@ /** * PHPExcel * - * Copyright (c) 2006 - 2012 PHPExcel + * Copyright (c) 2006 - 2014 PHPExcel * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,9 +20,9 @@ * * @category PHPExcel * @package PHPExcel_Reader_Excel5 - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version 1.7.8, 2012-10-12 + * @version 1.8.0, 2014-03-02 */ /** @@ -30,7 +30,7 @@ * * @category PHPExcel * @package PHPExcel_Reader_Excel5 - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) */ class PHPExcel_Reader_Excel5_Escher { diff --git a/htdocs/includes/phpexcel/PHPExcel/Reader/Excel5/MD5.php b/htdocs/includes/phpexcel/PHPExcel/Reader/Excel5/MD5.php new file mode 100644 index 00000000000..946d5a0da70 --- /dev/null +++ b/htdocs/includes/phpexcel/PHPExcel/Reader/Excel5/MD5.php @@ -0,0 +1,221 @@ +reset(); + } + + + /** + * Reset the MD5 stream context + */ + public function reset() + { + $this->a = 0x67452301; + $this->b = 0xEFCDAB89; + $this->c = 0x98BADCFE; + $this->d = 0x10325476; + } + + + /** + * Get MD5 stream context + * + * @return string + */ + public function getContext() + { + $s = ''; + foreach (array('a', 'b', 'c', 'd') as $i) { + $v = $this->{$i}; + $s .= chr($v & 0xff); + $s .= chr(($v >> 8) & 0xff); + $s .= chr(($v >> 16) & 0xff); + $s .= chr(($v >> 24) & 0xff); + } + + return $s; + } + + + /** + * Add data to context + * + * @param string $data Data to add + */ + public function add($data) + { + $words = array_values(unpack('V16', $data)); + + $A = $this->a; + $B = $this->b; + $C = $this->c; + $D = $this->d; + + $F = array('PHPExcel_Reader_Excel5_MD5','F'); + $G = array('PHPExcel_Reader_Excel5_MD5','G'); + $H = array('PHPExcel_Reader_Excel5_MD5','H'); + $I = array('PHPExcel_Reader_Excel5_MD5','I'); + + /* ROUND 1 */ + self::step($F, $A, $B, $C, $D, $words[0], 7, 0xd76aa478); + self::step($F, $D, $A, $B, $C, $words[1], 12, 0xe8c7b756); + self::step($F, $C, $D, $A, $B, $words[2], 17, 0x242070db); + self::step($F, $B, $C, $D, $A, $words[3], 22, 0xc1bdceee); + self::step($F, $A, $B, $C, $D, $words[4], 7, 0xf57c0faf); + self::step($F, $D, $A, $B, $C, $words[5], 12, 0x4787c62a); + self::step($F, $C, $D, $A, $B, $words[6], 17, 0xa8304613); + self::step($F, $B, $C, $D, $A, $words[7], 22, 0xfd469501); + self::step($F, $A, $B, $C, $D, $words[8], 7, 0x698098d8); + self::step($F, $D, $A, $B, $C, $words[9], 12, 0x8b44f7af); + self::step($F, $C, $D, $A, $B, $words[10], 17, 0xffff5bb1); + self::step($F, $B, $C, $D, $A, $words[11], 22, 0x895cd7be); + self::step($F, $A, $B, $C, $D, $words[12], 7, 0x6b901122); + self::step($F, $D, $A, $B, $C, $words[13], 12, 0xfd987193); + self::step($F, $C, $D, $A, $B, $words[14], 17, 0xa679438e); + self::step($F, $B, $C, $D, $A, $words[15], 22, 0x49b40821); + + /* ROUND 2 */ + self::step($G, $A, $B, $C, $D, $words[1], 5, 0xf61e2562); + self::step($G, $D, $A, $B, $C, $words[6], 9, 0xc040b340); + self::step($G, $C, $D, $A, $B, $words[11], 14, 0x265e5a51); + self::step($G, $B, $C, $D, $A, $words[0], 20, 0xe9b6c7aa); + self::step($G, $A, $B, $C, $D, $words[5], 5, 0xd62f105d); + self::step($G, $D, $A, $B, $C, $words[10], 9, 0x02441453); + self::step($G, $C, $D, $A, $B, $words[15], 14, 0xd8a1e681); + self::step($G, $B, $C, $D, $A, $words[4], 20, 0xe7d3fbc8); + self::step($G, $A, $B, $C, $D, $words[9], 5, 0x21e1cde6); + self::step($G, $D, $A, $B, $C, $words[14], 9, 0xc33707d6); + self::step($G, $C, $D, $A, $B, $words[3], 14, 0xf4d50d87); + self::step($G, $B, $C, $D, $A, $words[8], 20, 0x455a14ed); + self::step($G, $A, $B, $C, $D, $words[13], 5, 0xa9e3e905); + self::step($G, $D, $A, $B, $C, $words[2], 9, 0xfcefa3f8); + self::step($G, $C, $D, $A, $B, $words[7], 14, 0x676f02d9); + self::step($G, $B, $C, $D, $A, $words[12], 20, 0x8d2a4c8a); + + /* ROUND 3 */ + self::step($H, $A, $B, $C, $D, $words[5], 4, 0xfffa3942); + self::step($H, $D, $A, $B, $C, $words[8], 11, 0x8771f681); + self::step($H, $C, $D, $A, $B, $words[11], 16, 0x6d9d6122); + self::step($H, $B, $C, $D, $A, $words[14], 23, 0xfde5380c); + self::step($H, $A, $B, $C, $D, $words[1], 4, 0xa4beea44); + self::step($H, $D, $A, $B, $C, $words[4], 11, 0x4bdecfa9); + self::step($H, $C, $D, $A, $B, $words[7], 16, 0xf6bb4b60); + self::step($H, $B, $C, $D, $A, $words[10], 23, 0xbebfbc70); + self::step($H, $A, $B, $C, $D, $words[13], 4, 0x289b7ec6); + self::step($H, $D, $A, $B, $C, $words[0], 11, 0xeaa127fa); + self::step($H, $C, $D, $A, $B, $words[3], 16, 0xd4ef3085); + self::step($H, $B, $C, $D, $A, $words[6], 23, 0x04881d05); + self::step($H, $A, $B, $C, $D, $words[9], 4, 0xd9d4d039); + self::step($H, $D, $A, $B, $C, $words[12], 11, 0xe6db99e5); + self::step($H, $C, $D, $A, $B, $words[15], 16, 0x1fa27cf8); + self::step($H, $B, $C, $D, $A, $words[2], 23, 0xc4ac5665); + + /* ROUND 4 */ + self::step($I, $A, $B, $C, $D, $words[0], 6, 0xf4292244); + self::step($I, $D, $A, $B, $C, $words[7], 10, 0x432aff97); + self::step($I, $C, $D, $A, $B, $words[14], 15, 0xab9423a7); + self::step($I, $B, $C, $D, $A, $words[5], 21, 0xfc93a039); + self::step($I, $A, $B, $C, $D, $words[12], 6, 0x655b59c3); + self::step($I, $D, $A, $B, $C, $words[3], 10, 0x8f0ccc92); + self::step($I, $C, $D, $A, $B, $words[10], 15, 0xffeff47d); + self::step($I, $B, $C, $D, $A, $words[1], 21, 0x85845dd1); + self::step($I, $A, $B, $C, $D, $words[8], 6, 0x6fa87e4f); + self::step($I, $D, $A, $B, $C, $words[15], 10, 0xfe2ce6e0); + self::step($I, $C, $D, $A, $B, $words[6], 15, 0xa3014314); + self::step($I, $B, $C, $D, $A, $words[13], 21, 0x4e0811a1); + self::step($I, $A, $B, $C, $D, $words[4], 6, 0xf7537e82); + self::step($I, $D, $A, $B, $C, $words[11], 10, 0xbd3af235); + self::step($I, $C, $D, $A, $B, $words[2], 15, 0x2ad7d2bb); + self::step($I, $B, $C, $D, $A, $words[9], 21, 0xeb86d391); + + $this->a = ($this->a + $A) & 0xffffffff; + $this->b = ($this->b + $B) & 0xffffffff; + $this->c = ($this->c + $C) & 0xffffffff; + $this->d = ($this->d + $D) & 0xffffffff; + } + + + private static function F($X, $Y, $Z) + { + return (($X & $Y) | ((~ $X) & $Z)); // X AND Y OR NOT X AND Z + } + + + private static function G($X, $Y, $Z) + { + return (($X & $Z) | ($Y & (~ $Z))); // X AND Z OR Y AND NOT Z + } + + + private static function H($X, $Y, $Z) + { + return ($X ^ $Y ^ $Z); // X XOR Y XOR Z + } + + + private static function I($X, $Y, $Z) + { + return ($Y ^ ($X | (~ $Z))) ; // Y XOR (X OR NOT Z) + } + + + private static function step($func, &$A, $B, $C, $D, $M, $s, $t) + { + $A = ($A + call_user_func($func, $B, $C, $D) + $M + $t) & 0xffffffff; + $A = self::rotate($A, $s); + $A = ($B + $A) & 0xffffffff; + } + + + private static function rotate($decimal, $bits) + { + $binary = str_pad(decbin($decimal), 32, "0", STR_PAD_LEFT); + return bindec(substr($binary, $bits).substr($binary, 0, $bits)); + } +} \ No newline at end of file diff --git a/htdocs/includes/phpexcel/PHPExcel/Reader/Excel5/RC4.php b/htdocs/includes/phpexcel/PHPExcel/Reader/Excel5/RC4.php new file mode 100644 index 00000000000..dc6327c0490 --- /dev/null +++ b/htdocs/includes/phpexcel/PHPExcel/Reader/Excel5/RC4.php @@ -0,0 +1,88 @@ +i = 0; $this->i < 256; $this->i++) { + $this->s[$this->i] = $this->i; + } + + $this->j = 0; + for ($this->i = 0; $this->i < 256; $this->i++) { + $this->j = ($this->j + $this->s[$this->i] + ord($key[$this->i % $len])) % 256; + $t = $this->s[$this->i]; + $this->s[$this->i] = $this->s[$this->j]; + $this->s[$this->j] = $t; + } + $this->i = $this->j = 0; + } + + /** + * Symmetric decryption/encryption function + * + * @param string $data Data to encrypt/decrypt + * + * @return string + */ + public function RC4($data) + { + $len = strlen($data); + for ($c = 0; $c < $len; $c++) { + $this->i = ($this->i + 1) % 256; + $this->j = ($this->j + $this->s[$this->i]) % 256; + $t = $this->s[$this->i]; + $this->s[$this->i] = $this->s[$this->j]; + $this->s[$this->j] = $t; + + $t = ($this->s[$this->i] + $this->s[$this->j]) % 256; + + $data[$c] = chr(ord($data[$c]) ^ $this->s[$t]); + } + return $data; + } +} diff --git a/htdocs/includes/phpexcel/PHPExcel/Reader/Exception.php b/htdocs/includes/phpexcel/PHPExcel/Reader/Exception.php new file mode 100644 index 00000000000..f42a1aafca2 --- /dev/null +++ b/htdocs/includes/phpexcel/PHPExcel/Reader/Exception.php @@ -0,0 +1,52 @@ +line = $line; + $e->file = $file; + throw $e; + } +} diff --git a/htdocs/includes/phpexcel/PHPExcel/Reader/Gnumeric.php b/htdocs/includes/phpexcel/PHPExcel/Reader/Gnumeric.php index 5d82f22924f..6db7c4969ee 100644 --- a/htdocs/includes/phpexcel/PHPExcel/Reader/Gnumeric.php +++ b/htdocs/includes/phpexcel/PHPExcel/Reader/Gnumeric.php @@ -2,7 +2,7 @@ /** * PHPExcel * - * Copyright (c) 2006 - 2012 PHPExcel + * Copyright (c) 2006 - 2014 PHPExcel * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,9 +20,9 @@ * * @category PHPExcel * @package PHPExcel_Reader - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version 1.7.8, 2012-10-12 + * @version 1.8.0, 2014-03-02 */ @@ -40,27 +40,10 @@ if (!defined('PHPEXCEL_ROOT')) { * * @category PHPExcel * @package PHPExcel_Reader - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) */ -class PHPExcel_Reader_Gnumeric implements PHPExcel_Reader_IReader +class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPExcel_Reader_IReader { - /** - * Read data only? - * Identifies whether the Reader should only read data values for cells, and ignore any formatting information; - * or whether it should read both data and formatting - * - * @var boolean - */ - private $_readDataOnly = false; - - /** - * Restrict which sheets should be loaded? - * This property holds an array of worksheet names to be loaded. If null, then all worksheets will be loaded. - * - * @var array of string - */ - private $_loadSheetsOnly = null; - /** * Formats * @@ -77,13 +60,6 @@ class PHPExcel_Reader_Gnumeric implements PHPExcel_Reader_IReader private $_referenceHelper = null; - /** - * PHPExcel_Reader_IReadFilter instance - * - * @var PHPExcel_Reader_IReadFilter - */ - private $_readFilter = null; - /** * Create a new PHPExcel_Reader_Gnumeric @@ -94,115 +70,23 @@ class PHPExcel_Reader_Gnumeric implements PHPExcel_Reader_IReader } - /** - * Read data only? - * If this is true, then the Reader will only read data values for cells, it will not read any formatting information. - * If false (the default) it will read data and formatting. - * - * @return boolean - */ - public function getReadDataOnly() { - return $this->_readDataOnly; - } - - - /** - * Set read data only - * Set to true, to advise the Reader only to read data values for cells, and to ignore any formatting information. - * Set to false (the default) to advise the Reader to read both data and formatting for cells. - * - * @param boolean $pValue - * - * @return PHPExcel_Reader_Gnumeric - */ - public function setReadDataOnly($pValue = false) { - $this->_readDataOnly = $pValue; - return $this; - } - - - /** - * Get which sheets to load - * Returns either an array of worksheet names (the list of worksheets that should be loaded), or a null - * indicating that all worksheets in the workbook should be loaded. - * - * @return mixed - */ - public function getLoadSheetsOnly() - { - return $this->_loadSheetsOnly; - } - - - /** - * Set which sheets to load - * - * @param mixed $value - * This should be either an array of worksheet names to be loaded, or a string containing a single worksheet name. - * If NULL, then it tells the Reader to read all worksheets in the workbook - * - * @return PHPExcel_Reader_Gnumeric - */ - public function setLoadSheetsOnly($value = null) - { - $this->_loadSheetsOnly = is_array($value) ? - $value : array($value); - return $this; - } - - - /** - * Set all sheets to load - * Tells the Reader to load all worksheets from the workbook. - * - * @return PHPExcel_Reader_Gnumeric - */ - public function setLoadAllSheets() - { - $this->_loadSheetsOnly = null; - return $this; - } - - - /** - * Read filter - * - * @return PHPExcel_Reader_IReadFilter - */ - public function getReadFilter() { - return $this->_readFilter; - } - - - /** - * Set read filter - * - * @param PHPExcel_Reader_IReadFilter $pValue - * @return PHPExcel_Reader_Gnumeric - */ - public function setReadFilter(PHPExcel_Reader_IReadFilter $pValue) { - $this->_readFilter = $pValue; - return $this; - } - - /** * Can the current PHPExcel_Reader_IReader read the file? * - * @param string $pFileName + * @param string $pFilename * @return boolean - * @throws Exception + * @throws PHPExcel_Reader_Exception */ public function canRead($pFilename) { // Check if file exists if (!file_exists($pFilename)) { - throw new Exception("Could not open " . $pFilename . " for reading! File does not exist."); + throw new PHPExcel_Reader_Exception("Could not open " . $pFilename . " for reading! File does not exist."); } // Check if gzlib functions are available if (!function_exists('gzread')) { - throw new Exception("gzlib library is not enabled"); + throw new PHPExcel_Reader_Exception("gzlib library is not enabled"); } // Read signature data (first 3 bytes) @@ -218,50 +102,87 @@ class PHPExcel_Reader_Gnumeric implements PHPExcel_Reader_IReader } + /** + * Reads names of the worksheets from a file, without parsing the whole file to a PHPExcel object + * + * @param string $pFilename + * @throws PHPExcel_Reader_Exception + */ + public function listWorksheetNames($pFilename) + { + // Check if file exists + if (!file_exists($pFilename)) { + throw new PHPExcel_Reader_Exception("Could not open " . $pFilename . " for reading! File does not exist."); + } + + $xml = new XMLReader(); + $xml->open( + 'compress.zlib://'.realpath($pFilename), null, PHPExcel_Settings::getLibXmlLoaderOptions() + ); + $xml->setParserProperty(2,true); + + $worksheetNames = array(); + while ($xml->read()) { + if ($xml->name == 'gnm:SheetName' && $xml->nodeType == XMLReader::ELEMENT) { + $xml->read(); // Move onto the value node + $worksheetNames[] = (string) $xml->value; + } elseif ($xml->name == 'gnm:Sheets') { + // break out of the loop once we've got our sheet names rather than parse the entire file + break; + } + } + + return $worksheetNames; + } + + /** * Return worksheet info (Name, Last Column Letter, Last Column Index, Total Rows, Total Columns) * * @param string $pFilename - * @throws Exception + * @throws PHPExcel_Reader_Exception */ public function listWorksheetInfo($pFilename) { // Check if file exists if (!file_exists($pFilename)) { - throw new Exception("Could not open " . $pFilename . " for reading! File does not exist."); + throw new PHPExcel_Reader_Exception("Could not open " . $pFilename . " for reading! File does not exist."); } - $gFileData = $this->_gzfileGetContents($pFilename); - - $xml = simplexml_load_string($gFileData); - $namespacesMeta = $xml->getNamespaces(true); - - $gnmXML = $xml->children($namespacesMeta['gnm']); + $xml = new XMLReader(); + $xml->open( + 'compress.zlib://'.realpath($pFilename), null, PHPExcel_Settings::getLibXmlLoaderOptions() + ); + $xml->setParserProperty(2,true); $worksheetInfo = array(); + while ($xml->read()) { + if ($xml->name == 'gnm:Sheet' && $xml->nodeType == XMLReader::ELEMENT) { + $tmpInfo = array( + 'worksheetName' => '', + 'lastColumnLetter' => 'A', + 'lastColumnIndex' => 0, + 'totalRows' => 0, + 'totalColumns' => 0, + ); - foreach ($gnmXML->Sheets->Sheet as $sheet) { - $tmpInfo = array(); - $tmpInfo['worksheetName'] = (string) $sheet->Name; - $tmpInfo['lastColumnLetter'] = 'A'; - $tmpInfo['lastColumnIndex'] = 0; - $tmpInfo['totalRows'] = 0; - $tmpInfo['totalColumns'] = 0; - - foreach ($sheet->Cells->Cell as $cell) { - $cellAttributes = $cell->attributes(); - - $rowIndex = (int) $cellAttributes->Row + 1; - $columnIndex = (int) $cellAttributes->Col; - - $tmpInfo['totalRows'] = max($tmpInfo['totalRows'], $rowIndex); - $tmpInfo['lastColumnIndex'] = max($tmpInfo['lastColumnIndex'], $columnIndex); + while ($xml->read()) { + if ($xml->name == 'gnm:Name' && $xml->nodeType == XMLReader::ELEMENT) { + $xml->read(); // Move onto the value node + $tmpInfo['worksheetName'] = (string) $xml->value; + } elseif ($xml->name == 'gnm:MaxCol' && $xml->nodeType == XMLReader::ELEMENT) { + $xml->read(); // Move onto the value node + $tmpInfo['lastColumnIndex'] = (int) $xml->value; + $tmpInfo['totalColumns'] = (int) $xml->value + 1; + } elseif ($xml->name == 'gnm:MaxRow' && $xml->nodeType == XMLReader::ELEMENT) { + $xml->read(); // Move onto the value node + $tmpInfo['totalRows'] = (int) $xml->value + 1; + break; + } + } + $tmpInfo['lastColumnLetter'] = PHPExcel_Cell::stringFromColumnIndex($tmpInfo['lastColumnIndex']); + $worksheetInfo[] = $tmpInfo; } - - $tmpInfo['lastColumnLetter'] = PHPExcel_Cell::stringFromColumnIndex($tmpInfo['lastColumnIndex']); - $tmpInfo['totalColumns'] = $tmpInfo['lastColumnIndex'] + 1; - - $worksheetInfo[] = $tmpInfo; } return $worksheetInfo; @@ -286,7 +207,7 @@ class PHPExcel_Reader_Gnumeric implements PHPExcel_Reader_IReader * * @param string $pFilename * @return PHPExcel - * @throws Exception + * @throws PHPExcel_Reader_Exception */ public function load($pFilename) { @@ -298,49 +219,19 @@ class PHPExcel_Reader_Gnumeric implements PHPExcel_Reader_IReader } - /** - * Reads names of the worksheets from a file, without parsing the whole file to a PHPExcel object - * - * @param string $pFilename - * @throws Exception - */ - public function listWorksheetNames($pFilename) - { - // Check if file exists - if (!file_exists($pFilename)) { - throw new Exception("Could not open " . $pFilename . " for reading! File does not exist."); - } - - $gFileData = $this->_gzfileGetContents($pFilename); - - $xml = simplexml_load_string($gFileData); - $namespacesMeta = $xml->getNamespaces(true); - - $gnmXML = $xml->children($namespacesMeta['gnm']); - - $worksheetNames = array(); - - foreach($gnmXML->Sheets->Sheet as $sheet) { - $worksheetNames[] = (string) $sheet->Name; - } - - return $worksheetNames; - } - - /** * Loads PHPExcel from file into PHPExcel instance * * @param string $pFilename * @param PHPExcel $objPHPExcel * @return PHPExcel - * @throws Exception + * @throws PHPExcel_Reader_Exception */ public function loadIntoExisting($pFilename, PHPExcel $objPHPExcel) { // Check if file exists if (!file_exists($pFilename)) { - throw new Exception("Could not open " . $pFilename . " for reading! File does not exist."); + throw new PHPExcel_Reader_Exception("Could not open " . $pFilename . " for reading! File does not exist."); } $timezoneObj = new DateTimeZone('Europe/London'); @@ -352,7 +243,7 @@ class PHPExcel_Reader_Gnumeric implements PHPExcel_Reader_IReader // echo htmlentities($gFileData,ENT_QUOTES,'UTF-8'); // echo '
'; // - $xml = simplexml_load_string($gFileData); + $xml = simplexml_load_string($gFileData, 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions()); $namespacesMeta = $xml->getNamespaces(true); // var_dump($namespacesMeta); @@ -620,7 +511,7 @@ class PHPExcel_Reader_Gnumeric implements PHPExcel_Reader_IReader // We still set the number format mask for date/time values, even if _readDataOnly is true if ((!$this->_readDataOnly) || - (PHPExcel_Shared_Date::isDateTimeFormatCode($styleArray['numberformat']['code']))) { + (PHPExcel_Shared_Date::isDateTimeFormatCode((string) $styleAttributes['Format']))) { $styleArray = array(); $styleArray['numberformat']['code'] = (string) $styleAttributes['Format']; // If _readDataOnly is false, we set all formatting information diff --git a/htdocs/includes/phpexcel/PHPExcel/Reader/HTML.php b/htdocs/includes/phpexcel/PHPExcel/Reader/HTML.php index d6068eaa4f4..1696471029d 100644 --- a/htdocs/includes/phpexcel/PHPExcel/Reader/HTML.php +++ b/htdocs/includes/phpexcel/PHPExcel/Reader/HTML.php @@ -2,7 +2,7 @@ /** * PHPExcel * - * Copyright (c) 2006 - 2012 PHPExcel + * Copyright (c) 2006 - 2014 PHPExcel * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,9 +20,9 @@ * * @category PHPExcel * @package PHPExcel_Reader - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version 1.7.8, 2012-10-12 + * @version 1.8.0, 2014-03-02 */ @@ -40,9 +40,9 @@ if (!defined('PHPEXCEL_ROOT')) { * * @category PHPExcel * @package PHPExcel_Reader - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) */ -class PHPExcel_Reader_HTML implements PHPExcel_Reader_IReader +class PHPExcel_Reader_HTML extends PHPExcel_Reader_Abstract implements PHPExcel_Reader_IReader { /** * Input encoding @@ -100,13 +100,6 @@ class PHPExcel_Reader_HTML implements PHPExcel_Reader_IReader ), // Bottom border ); - /** - * PHPExcel_Reader_IReadFilter instance - * - * @var PHPExcel_Reader_IReadFilter - */ - private $_readFilter = null; - /** * Create a new PHPExcel_Reader_HTML @@ -116,25 +109,20 @@ class PHPExcel_Reader_HTML implements PHPExcel_Reader_IReader } /** - * Can the current PHPExcel_Reader_IReader read the file? + * Validate that the current file is an HTML file * - * @param string $pFileName - * @return boolean - * @throws Exception + * @return boolean */ - public function canRead($pFilename) + protected function _isValidFormat() { - // Check if file exists - if (!file_exists($pFilename)) { - throw new Exception("Could not open " . $pFilename . " for reading! File does not exist."); + // Reading 2048 bytes should be enough to validate that the format is HTML + $data = fread($this->_fileHandle, 2048); + if ((strpos($data, '<') !== FALSE) && + (strlen($data) !== strlen(strip_tags($data)))) { + return TRUE; } - // Read sample data (first 2 KB will do) - $fh = fopen($pFilename, 'r'); - $data = fread($fh, 2048); - fclose($fh); - - return true; + return FALSE; } /** @@ -142,7 +130,7 @@ class PHPExcel_Reader_HTML implements PHPExcel_Reader_IReader * * @param string $pFilename * @return PHPExcel - * @throws Exception + * @throws PHPExcel_Reader_Exception */ public function load($pFilename) { @@ -153,25 +141,6 @@ class PHPExcel_Reader_HTML implements PHPExcel_Reader_IReader return $this->loadIntoExisting($pFilename, $objPHPExcel); } - /** - * Read filter - * - * @return PHPExcel_Reader_IReadFilter - */ - public function getReadFilter() { - return $this->_readFilter; - } - - /** - * Set read filter - * - * @param PHPExcel_Reader_IReadFilter $pValue - */ - public function setReadFilter(PHPExcel_Reader_IReadFilter $pValue) { - $this->_readFilter = $pValue; - return $this; - } - /** * Set input encoding * @@ -222,7 +191,7 @@ class PHPExcel_Reader_HTML implements PHPExcel_Reader_IReader // Simple String content if (trim($cellContent) > '') { // Only actually write it if there's content in the string - echo 'FLUSH CELL: ' , $column , $row , ' => ' , $cellContent , '
'; +// echo 'FLUSH CELL: ' , $column , $row , ' => ' , $cellContent , '
'; // Write to worksheet to be done here... // ... we return the cell so we can mess about with styles more easily $cell = $sheet->setCellValue($column.$row,$cellContent,true); @@ -238,7 +207,7 @@ class PHPExcel_Reader_HTML implements PHPExcel_Reader_IReader private function _processDomElement(DOMNode $element, $sheet, &$row, &$column, &$cellContent){ foreach($element->childNodes as $child){ - if ($child instanceOf DOMText) { + if ($child instanceof DOMText) { $domText = preg_replace('/\s+/',' ',trim($child->nodeValue)); if (is_string($cellContent)) { // simply append the text if the cell content is a plain text string @@ -247,12 +216,12 @@ class PHPExcel_Reader_HTML implements PHPExcel_Reader_IReader // but if we have a rich text run instead, we need to append it correctly // TODO } - } elseif($child instanceOf DOMElement) { - echo 'DOM ELEMENT: ' , strtoupper($child->nodeName) , '
'; + } elseif($child instanceof DOMElement) { +// echo 'DOM ELEMENT: ' , strtoupper($child->nodeName) , '
'; $attributeArray = array(); foreach($child->attributes as $attribute) { - echo 'ATTRIBUTE: ' , $attribute->name , ' => ' , $attribute->value , '
'; +// echo 'ATTRIBUTE: ' , $attribute->name , ' => ' , $attribute->value , '
'; $attributeArray[$attribute->name] = $attribute->value; } @@ -280,13 +249,13 @@ class PHPExcel_Reader_HTML implements PHPExcel_Reader_IReader case 'em' : case 'strong': case 'b' : - echo 'STYLING, SPAN OR DIV
'; +// echo 'STYLING, SPAN OR DIV
'; if ($cellContent > '') $cellContent .= ' '; $this->_processDomElement($child,$sheet,$row,$column,$cellContent); if ($cellContent > '') $cellContent .= ' '; - echo 'END OF STYLING, SPAN OR DIV
'; +// echo 'END OF STYLING, SPAN OR DIV
'; break; case 'hr' : $this->_flushCell($sheet,$column,$row,$cellContent); @@ -307,14 +276,14 @@ class PHPExcel_Reader_HTML implements PHPExcel_Reader_IReader $this->_flushCell($sheet,$column,$row,$cellContent); ++$row; } - echo 'HARD LINE BREAK: ' , '
'; +// echo 'HARD LINE BREAK: ' , '
'; break; case 'a' : - echo 'START OF HYPERLINK: ' , '
'; +// echo 'START OF HYPERLINK: ' , '
'; foreach($attributeArray as $attributeName => $attributeValue) { switch($attributeName) { case 'href': - echo 'Link to ' , $attributeValue , '
'; +// echo 'Link to ' , $attributeValue , '
'; $sheet->getCell($column.$row)->getHyperlink()->setUrl($attributeValue); if (isset($this->_formats[$child->nodeName])) { $sheet->getStyle($column.$row)->applyFromArray($this->_formats[$child->nodeName]); @@ -324,7 +293,7 @@ class PHPExcel_Reader_HTML implements PHPExcel_Reader_IReader } $cellContent .= ' '; $this->_processDomElement($child,$sheet,$row,$column,$cellContent); - echo 'END OF HYPERLINK:' , '
'; +// echo 'END OF HYPERLINK:' , '
'; break; case 'h1' : case 'h2' : @@ -338,17 +307,17 @@ class PHPExcel_Reader_HTML implements PHPExcel_Reader_IReader if ($this->_tableLevel > 0) { // If we're inside a table, replace with a \n $cellContent .= "\n"; - echo 'LIST ENTRY: ' , '
'; +// echo 'LIST ENTRY: ' , '
'; $this->_processDomElement($child,$sheet,$row,$column,$cellContent); - echo 'END OF LIST ENTRY:' , '
'; +// echo 'END OF LIST ENTRY:' , '
'; } else { if ($cellContent > '') { $this->_flushCell($sheet,$column,$row,$cellContent); $row += 2; } - echo 'START OF PARAGRAPH: ' , '
'; +// echo 'START OF PARAGRAPH: ' , '
'; $this->_processDomElement($child,$sheet,$row,$column,$cellContent); - echo 'END OF PARAGRAPH:' , '
'; +// echo 'END OF PARAGRAPH:' , '
'; $this->_flushCell($sheet,$column,$row,$cellContent); if (isset($this->_formats[$child->nodeName])) { @@ -363,17 +332,17 @@ class PHPExcel_Reader_HTML implements PHPExcel_Reader_IReader if ($this->_tableLevel > 0) { // If we're inside a table, replace with a \n $cellContent .= "\n"; - echo 'LIST ENTRY: ' , '
'; +// echo 'LIST ENTRY: ' , '
'; $this->_processDomElement($child,$sheet,$row,$column,$cellContent); - echo 'END OF LIST ENTRY:' , '
'; +// echo 'END OF LIST ENTRY:' , '
'; } else { if ($cellContent > '') { $this->_flushCell($sheet,$column,$row,$cellContent); } ++$row; - echo 'LIST ENTRY: ' , '
'; +// echo 'LIST ENTRY: ' , '
'; $this->_processDomElement($child,$sheet,$row,$column,$cellContent); - echo 'END OF LIST ENTRY:' , '
'; +// echo 'END OF LIST ENTRY:' , '
'; $this->_flushCell($sheet,$column,$row,$cellContent); $column = 'A'; } @@ -381,11 +350,11 @@ class PHPExcel_Reader_HTML implements PHPExcel_Reader_IReader case 'table' : $this->_flushCell($sheet,$column,$row,$cellContent); $column = $this->_setTableStartColumn($column); - echo 'START OF TABLE LEVEL ' , $this->_tableLevel , '
'; +// echo 'START OF TABLE LEVEL ' , $this->_tableLevel , '
'; if ($this->_tableLevel > 1) --$row; $this->_processDomElement($child,$sheet,$row,$column,$cellContent); - echo 'END OF TABLE LEVEL ' , $this->_tableLevel , '
'; +// echo 'END OF TABLE LEVEL ' , $this->_tableLevel , '
'; $column = $this->_releaseTableStartColumn(); if ($this->_tableLevel > 1) { ++$column; @@ -401,15 +370,15 @@ class PHPExcel_Reader_HTML implements PHPExcel_Reader_IReader ++$row; $column = $this->_getTableStartColumn(); $cellContent = ''; - echo 'START OF TABLE ' , $this->_tableLevel , ' ROW
'; +// echo 'START OF TABLE ' , $this->_tableLevel , ' ROW
'; $this->_processDomElement($child,$sheet,$row,$column,$cellContent); - echo 'END OF TABLE ' , $this->_tableLevel , ' ROW
'; +// echo 'END OF TABLE ' , $this->_tableLevel , ' ROW
'; break; case 'th' : case 'td' : - echo 'START OF TABLE ' , $this->_tableLevel , ' CELL
'; +// echo 'START OF TABLE ' , $this->_tableLevel , ' CELL
'; $this->_processDomElement($child,$sheet,$row,$column,$cellContent); - echo 'END OF TABLE ' , $this->_tableLevel , ' CELL
'; +// echo 'END OF TABLE ' , $this->_tableLevel , ' CELL
'; $this->_flushCell($sheet,$column,$row,$cellContent); ++$column; break; @@ -433,18 +402,18 @@ class PHPExcel_Reader_HTML implements PHPExcel_Reader_IReader * @param string $pFilename * @param PHPExcel $objPHPExcel * @return PHPExcel - * @throws Exception + * @throws PHPExcel_Reader_Exception */ public function loadIntoExisting($pFilename, PHPExcel $objPHPExcel) { - // Check if file exists - if (!file_exists($pFilename)) { - throw new Exception("Could not open " . $pFilename . " for reading! File does not exist."); - } - - if (!is_file($pFilename)) { - throw new Exception("Could not open " . $pFilename . " for reading! The given file is not a regular file."); + // Open file to validate + $this->_openFile($pFilename); + if (!$this->_isValidFormat()) { + fclose ($this->_fileHandle); + throw new PHPExcel_Reader_Exception($pFilename . " is an Invalid HTML file."); } + // Close after validating + fclose ($this->_fileHandle); // Create new PHPExcel while ($objPHPExcel->getSheetCount() <= $this->_sheetIndex) { @@ -454,10 +423,10 @@ class PHPExcel_Reader_HTML implements PHPExcel_Reader_IReader // Create a new DOM object $dom = new domDocument; - // Load the HTML file into the DOM object - $loaded = $dom->loadHTMLFile($pFilename); - if ($loaded === false) { - throw new Exception('Failed to load ',$pFilename,' as a DOM Document'); + // Reload the HTML file into the DOM object + $loaded = $dom->loadHTMLFile($pFilename, PHPExcel_Settings::getLibXmlLoaderOptions()); + if ($loaded === FALSE) { + throw new PHPExcel_Reader_Exception('Failed to load ',$pFilename,' as a DOM Document'); } // Discard white space @@ -469,8 +438,8 @@ class PHPExcel_Reader_HTML implements PHPExcel_Reader_IReader $content = ''; $this->_processDomElement($dom,$objPHPExcel->getActiveSheet(),$row,$column,$content); - echo '
'; - var_dump($this->_dataArray); +// echo '
'; +// var_dump($this->_dataArray); // Return return $objPHPExcel; diff --git a/htdocs/includes/phpexcel/PHPExcel/Reader/IReadFilter.php b/htdocs/includes/phpexcel/PHPExcel/Reader/IReadFilter.php index 50e92c8045a..5a691a5fb77 100644 --- a/htdocs/includes/phpexcel/PHPExcel/Reader/IReadFilter.php +++ b/htdocs/includes/phpexcel/PHPExcel/Reader/IReadFilter.php @@ -2,7 +2,7 @@ /** * PHPExcel * - * Copyright (c) 2006 - 2012 PHPExcel + * Copyright (c) 2006 - 2014 PHPExcel * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,9 +20,9 @@ * * @category PHPExcel * @package PHPExcel_Reader - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version 1.7.8, 2012-10-12 + * @version 1.8.0, 2014-03-02 */ @@ -31,7 +31,7 @@ * * @category PHPExcel * @package PHPExcel_Reader - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) */ interface PHPExcel_Reader_IReadFilter { diff --git a/htdocs/includes/phpexcel/PHPExcel/Reader/IReader.php b/htdocs/includes/phpexcel/PHPExcel/Reader/IReader.php index 1c9884730b8..6c3e878e9f6 100644 --- a/htdocs/includes/phpexcel/PHPExcel/Reader/IReader.php +++ b/htdocs/includes/phpexcel/PHPExcel/Reader/IReader.php @@ -2,7 +2,7 @@ /** * PHPExcel * - * Copyright (c) 2006 - 2012 PHPExcel + * Copyright (c) 2006 - 2014 PHPExcel * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,9 +20,9 @@ * * @category PHPExcel * @package PHPExcel_Reader - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version 1.7.8, 2012-10-12 + * @version 1.8.0, 2014-03-02 */ @@ -31,14 +31,14 @@ * * @category PHPExcel * @package PHPExcel_Reader - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) */ interface PHPExcel_Reader_IReader { /** * Can the current PHPExcel_Reader_IReader read the file? * - * @param string $pFileName + * @param string $pFilename * @return boolean */ public function canRead($pFilename); @@ -46,8 +46,8 @@ interface PHPExcel_Reader_IReader /** * Loads PHPExcel from file * - * @param string $pFileName - * @throws Exception + * @param string $pFilename + * @throws PHPExcel_Reader_Exception */ public function load($pFilename); } diff --git a/htdocs/includes/phpexcel/PHPExcel/Reader/OOCalc.php b/htdocs/includes/phpexcel/PHPExcel/Reader/OOCalc.php index 22ad1173b4f..8ad7061ce90 100644 --- a/htdocs/includes/phpexcel/PHPExcel/Reader/OOCalc.php +++ b/htdocs/includes/phpexcel/PHPExcel/Reader/OOCalc.php @@ -2,7 +2,7 @@ /** * PHPExcel * - * Copyright (c) 2006 - 2012 PHPExcel + * Copyright (c) 2006 - 2014 PHPExcel * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,9 +20,9 @@ * * @category PHPExcel * @package PHPExcel_Reader - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version 1.7.8, 2012-10-12 + * @version 1.8.0, 2014-03-02 */ @@ -40,27 +40,10 @@ if (!defined('PHPEXCEL_ROOT')) { * * @category PHPExcel * @package PHPExcel_Reader - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) */ -class PHPExcel_Reader_OOCalc implements PHPExcel_Reader_IReader +class PHPExcel_Reader_OOCalc extends PHPExcel_Reader_Abstract implements PHPExcel_Reader_IReader { - /** - * Read data only? - * Identifies whether the Reader should only read data values for cells, and ignore any formatting information; - * or whether it should read both data and formatting - * - * @var boolean - */ - private $_readDataOnly = false; - - /** - * Restrict which sheets should be loaded? - * This property holds an array of worksheet names to be loaded. If null, then all worksheets will be loaded. - * - * @var array of string - */ - private $_loadSheetsOnly = null; - /** * Formats * @@ -68,13 +51,6 @@ class PHPExcel_Reader_OOCalc implements PHPExcel_Reader_IReader */ private $_styles = array(); - /** - * PHPExcel_Reader_IReadFilter instance - * - * @var PHPExcel_Reader_IReadFilter - */ - private $_readFilter = null; - /** * Create a new PHPExcel_Reader_OOCalc @@ -84,126 +60,48 @@ class PHPExcel_Reader_OOCalc implements PHPExcel_Reader_IReader } - /** - * Read data only? - * If this is true, then the Reader will only read data values for cells, it will not read any formatting information. - * If false (the default) it will read data and formatting. - * - * @return boolean - */ - public function getReadDataOnly() { - return $this->_readDataOnly; - } - - - /** - * Set read data only - * Set to true, to advise the Reader only to read data values for cells, and to ignore any formatting information. - * Set to false (the default) to advise the Reader to read both data and formatting for cells. - * - * @param boolean $pValue - * @return PHPExcel_Reader_OOCalc - */ - public function setReadDataOnly($pValue = false) { - $this->_readDataOnly = $pValue; - return $this; - } - - - /** - * Get which sheets to load - * Returns either an array of worksheet names (the list of worksheets that should be loaded), or a null - * indicating that all worksheets in the workbook should be loaded. - * - * @return mixed - */ - public function getLoadSheetsOnly() - { - return $this->_loadSheetsOnly; - } - - - /** - * Set which sheets to load - * - * @param mixed $value - * This should be either an array of worksheet names to be loaded, or a string containing a single worksheet name. - * If NULL, then it tells the Reader to read all worksheets in the workbook - * - * @return PHPExcel_Reader_OOCalc - */ - public function setLoadSheetsOnly($value = null) - { - $this->_loadSheetsOnly = is_array($value) ? - $value : array($value); - return $this; - } - - - /** - * Set all sheets to load - * Tells the Reader to load all worksheets from the workbook. - * - * @return PHPExcel_Reader_OOCalc - */ - public function setLoadAllSheets() - { - $this->_loadSheetsOnly = null; - return $this; - } - - - /** - * Read filter - * - * @return PHPExcel_Reader_IReadFilter - */ - public function getReadFilter() { - return $this->_readFilter; - } - - - /** - * Set read filter - * - * @param PHPExcel_Reader_IReadFilter $pValue - * @return PHPExcel_Reader_OOCalc - */ - public function setReadFilter(PHPExcel_Reader_IReadFilter $pValue) { - $this->_readFilter = $pValue; - return $this; - } - - /** * Can the current PHPExcel_Reader_IReader read the file? * - * @param string $pFileName + * @param string $pFilename * @return boolean - * @throws Exception + * @throws PHPExcel_Reader_Exception */ public function canRead($pFilename) { // Check if file exists if (!file_exists($pFilename)) { - throw new Exception("Could not open " . $pFilename . " for reading! File does not exist."); + throw new PHPExcel_Reader_Exception("Could not open " . $pFilename . " for reading! File does not exist."); } + $zipClass = PHPExcel_Settings::getZipClass(); + // Check if zip class exists - if (!class_exists('ZipArchive',FALSE)) { - throw new Exception("ZipArchive library is not enabled"); - } +// if (!class_exists($zipClass, FALSE)) { +// throw new PHPExcel_Reader_Exception($zipClass . " library is not enabled"); +// } + $mimeType = 'UNKNOWN'; // Load file - $zip = new ZipArchive; + $zip = new $zipClass; if ($zip->open($pFilename) === true) { // check if it is an OOXML archive $stat = $zip->statName('mimetype'); if ($stat && ($stat['size'] <= 255)) { $mimeType = $zip->getFromName($stat['name']); - } else { - $zip->close(); - return FALSE; + } elseif($stat = $zip->statName('META-INF/manifest.xml')) { + $xml = simplexml_load_string($zip->getFromName('META-INF/manifest.xml'), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions()); + $namespacesContent = $xml->getNamespaces(true); + if (isset($namespacesContent['manifest'])) { + $manifest = $xml->children($namespacesContent['manifest']); + foreach($manifest as $manifestDataSet) { + $manifestAttributes = $manifestDataSet->attributes($namespacesContent['manifest']); + if ($manifestAttributes->{'full-path'} == '/') { + $mimeType = (string) $manifestAttributes->{'media-type'}; + break; + } + } + } } $zip->close(); @@ -219,30 +117,46 @@ class PHPExcel_Reader_OOCalc implements PHPExcel_Reader_IReader * Reads names of the worksheets from a file, without parsing the whole file to a PHPExcel object * * @param string $pFilename - * @throws Exception + * @throws PHPExcel_Reader_Exception */ public function listWorksheetNames($pFilename) { // Check if file exists if (!file_exists($pFilename)) { - throw new Exception("Could not open " . $pFilename . " for reading! File does not exist."); + throw new PHPExcel_Reader_Exception("Could not open " . $pFilename . " for reading! File does not exist."); + } + + $zipClass = PHPExcel_Settings::getZipClass(); + + $zip = new $zipClass; + if (!$zip->open($pFilename)) { + throw new PHPExcel_Reader_Exception("Could not open " . $pFilename . " for reading! Error opening file."); } $worksheetNames = array(); - $zip = new ZipArchive; - if ($zip->open($pFilename) === true) { + $xml = new XMLReader(); + $res = $xml->open('zip://'.realpath($pFilename).'#content.xml', null, PHPExcel_Settings::getLibXmlLoaderOptions()); + $xml->setParserProperty(2,true); - $xml = simplexml_load_string($zip->getFromName("content.xml")); - $namespacesContent = $xml->getNamespaces(true); - - $workbook = $xml->children($namespacesContent['office']); - foreach($workbook->body->spreadsheet as $workbookData) { - $workbookData = $workbookData->children($namespacesContent['table']); - foreach($workbookData->table as $worksheetDataSet) { - $worksheetDataAttributes = $worksheetDataSet->attributes($namespacesContent['table']); - - $worksheetNames[] = $worksheetDataAttributes['name']; + // Step into the first level of content of the XML + $xml->read(); + while ($xml->read()) { + // Quickly jump through to the office:body node + while ($xml->name !== 'office:body') { + if ($xml->isEmptyElement) + $xml->read(); + else + $xml->next(); + } + // Now read each node until we find our first table:table node + while ($xml->read()) { + if ($xml->name == 'table:table' && $xml->nodeType == XMLReader::ELEMENT) { + // Loop through each table:table node reading the table:name attribute for each worksheet name + do { + $worksheetNames[] = $xml->getAttribute('table:name'); + $xml->next(); + } while ($xml->name == 'table:table' && $xml->nodeType == XMLReader::ELEMENT); } } } @@ -251,12 +165,137 @@ class PHPExcel_Reader_OOCalc implements PHPExcel_Reader_IReader } + /** + * Return worksheet info (Name, Last Column Letter, Last Column Index, Total Rows, Total Columns) + * + * @param string $pFilename + * @throws PHPExcel_Reader_Exception + */ + public function listWorksheetInfo($pFilename) + { + // Check if file exists + if (!file_exists($pFilename)) { + throw new PHPExcel_Reader_Exception("Could not open " . $pFilename . " for reading! File does not exist."); + } + + $worksheetInfo = array(); + + $zipClass = PHPExcel_Settings::getZipClass(); + + $zip = new $zipClass; + if (!$zip->open($pFilename)) { + throw new PHPExcel_Reader_Exception("Could not open " . $pFilename . " for reading! Error opening file."); + } + + $xml = new XMLReader(); + $res = $xml->open('zip://'.realpath($pFilename).'#content.xml', null, PHPExcel_Settings::getLibXmlLoaderOptions()); + $xml->setParserProperty(2,true); + + // Step into the first level of content of the XML + $xml->read(); + while ($xml->read()) { + // Quickly jump through to the office:body node + while ($xml->name !== 'office:body') { + if ($xml->isEmptyElement) + $xml->read(); + else + $xml->next(); + } + // Now read each node until we find our first table:table node + while ($xml->read()) { + if ($xml->name == 'table:table' && $xml->nodeType == XMLReader::ELEMENT) { + $worksheetNames[] = $xml->getAttribute('table:name'); + + $tmpInfo = array( + 'worksheetName' => $xml->getAttribute('table:name'), + 'lastColumnLetter' => 'A', + 'lastColumnIndex' => 0, + 'totalRows' => 0, + 'totalColumns' => 0, + ); + + // Loop through each child node of the table:table element reading + $currCells = 0; + do { + $xml->read(); + if ($xml->name == 'table:table-row' && $xml->nodeType == XMLReader::ELEMENT) { + $rowspan = $xml->getAttribute('table:number-rows-repeated'); + $rowspan = empty($rowspan) ? 1 : $rowspan; + $tmpInfo['totalRows'] += $rowspan; + $tmpInfo['totalColumns'] = max($tmpInfo['totalColumns'],$currCells); + $currCells = 0; + // Step into the row + $xml->read(); + do { + if ($xml->name == 'table:table-cell' && $xml->nodeType == XMLReader::ELEMENT) { + if (!$xml->isEmptyElement) { + $currCells++; + $xml->next(); + } else { + $xml->read(); + } + } elseif ($xml->name == 'table:covered-table-cell' && $xml->nodeType == XMLReader::ELEMENT) { + $mergeSize = $xml->getAttribute('table:number-columns-repeated'); + $currCells += $mergeSize; + $xml->read(); + } + } while ($xml->name != 'table:table-row'); + } + } while ($xml->name != 'table:table'); + + $tmpInfo['totalColumns'] = max($tmpInfo['totalColumns'],$currCells); + $tmpInfo['lastColumnIndex'] = $tmpInfo['totalColumns'] - 1; + $tmpInfo['lastColumnLetter'] = PHPExcel_Cell::stringFromColumnIndex($tmpInfo['lastColumnIndex']); + $worksheetInfo[] = $tmpInfo; + } + } + +// foreach($workbookData->table as $worksheetDataSet) { +// $worksheetData = $worksheetDataSet->children($namespacesContent['table']); +// $worksheetDataAttributes = $worksheetDataSet->attributes($namespacesContent['table']); +// +// $rowIndex = 0; +// foreach ($worksheetData as $key => $rowData) { +// switch ($key) { +// case 'table-row' : +// $rowDataTableAttributes = $rowData->attributes($namespacesContent['table']); +// $rowRepeats = (isset($rowDataTableAttributes['number-rows-repeated'])) ? +// $rowDataTableAttributes['number-rows-repeated'] : 1; +// $columnIndex = 0; +// +// foreach ($rowData as $key => $cellData) { +// $cellDataTableAttributes = $cellData->attributes($namespacesContent['table']); +// $colRepeats = (isset($cellDataTableAttributes['number-columns-repeated'])) ? +// $cellDataTableAttributes['number-columns-repeated'] : 1; +// $cellDataOfficeAttributes = $cellData->attributes($namespacesContent['office']); +// if (isset($cellDataOfficeAttributes['value-type'])) { +// $tmpInfo['lastColumnIndex'] = max($tmpInfo['lastColumnIndex'], $columnIndex + $colRepeats - 1); +// $tmpInfo['totalRows'] = max($tmpInfo['totalRows'], $rowIndex + $rowRepeats); +// } +// $columnIndex += $colRepeats; +// } +// $rowIndex += $rowRepeats; +// break; +// } +// } +// +// $tmpInfo['lastColumnLetter'] = PHPExcel_Cell::stringFromColumnIndex($tmpInfo['lastColumnIndex']); +// $tmpInfo['totalColumns'] = $tmpInfo['lastColumnIndex'] + 1; +// +// } +// } + } + + return $worksheetInfo; + } + + /** * Loads PHPExcel from file * * @param string $pFilename * @return PHPExcel - * @throws Exception + * @throws PHPExcel_Reader_Exception */ public function load($pFilename) { @@ -280,441 +319,376 @@ class PHPExcel_Reader_OOCalc implements PHPExcel_Reader_IReader } - /** - * Return worksheet info (Name, Last Column Letter, Last Column Index, Total Rows, Total Columns) - * - * @param string $pFilename - * @throws Exception - */ - public function listWorksheetInfo($pFilename) - { - // Check if file exists - if (!file_exists($pFilename)) { - throw new Exception("Could not open " . $pFilename . " for reading! File does not exist."); - } - - $worksheetInfo = array(); - - $zip = new ZipArchive; - if ($zip->open($pFilename) === true) { - - $xml = simplexml_load_string($zip->getFromName("content.xml")); - $namespacesContent = $xml->getNamespaces(true); - - $workbook = $xml->children($namespacesContent['office']); - foreach($workbook->body->spreadsheet as $workbookData) { - $workbookData = $workbookData->children($namespacesContent['table']); - foreach($workbookData->table as $worksheetDataSet) { - $worksheetData = $worksheetDataSet->children($namespacesContent['table']); - $worksheetDataAttributes = $worksheetDataSet->attributes($namespacesContent['table']); - - $tmpInfo = array(); - $tmpInfo['worksheetName'] = (string) $worksheetDataAttributes['name']; - $tmpInfo['lastColumnLetter'] = 'A'; - $tmpInfo['lastColumnIndex'] = 0; - $tmpInfo['totalRows'] = 0; - $tmpInfo['totalColumns'] = 0; - - $rowIndex = 0; - foreach ($worksheetData as $key => $rowData) { - switch ($key) { - case 'table-row' : - $rowDataTableAttributes = $rowData->attributes($namespacesContent['table']); - $rowRepeats = (isset($rowDataTableAttributes['number-rows-repeated'])) ? - $rowDataTableAttributes['number-rows-repeated'] : 1; - $columnIndex = 0; - - foreach ($rowData as $key => $cellData) { - $cellDataTableAttributes = $cellData->attributes($namespacesContent['table']); - $colRepeats = (isset($cellDataTableAttributes['number-columns-repeated'])) ? - $cellDataTableAttributes['number-columns-repeated'] : 1; - $cellDataOfficeAttributes = $cellData->attributes($namespacesContent['office']); - if (isset($cellDataOfficeAttributes['value-type'])) { - $tmpInfo['lastColumnIndex'] = max($tmpInfo['lastColumnIndex'], $columnIndex + $colRepeats - 1); - $tmpInfo['totalRows'] = max($tmpInfo['totalRows'], $rowIndex + $rowRepeats); - } - $columnIndex += $colRepeats; - } - $rowIndex += $rowRepeats; - break; - } - } - - $tmpInfo['lastColumnLetter'] = PHPExcel_Cell::stringFromColumnIndex($tmpInfo['lastColumnIndex']); - $tmpInfo['totalColumns'] = $tmpInfo['lastColumnIndex'] + 1; - - $worksheetInfo[] = $tmpInfo; - } - } - } - - return $worksheetInfo; - } - - /** * Loads PHPExcel from file into PHPExcel instance * * @param string $pFilename * @param PHPExcel $objPHPExcel * @return PHPExcel - * @throws Exception + * @throws PHPExcel_Reader_Exception */ public function loadIntoExisting($pFilename, PHPExcel $objPHPExcel) { // Check if file exists if (!file_exists($pFilename)) { - throw new Exception("Could not open " . $pFilename . " for reading! File does not exist."); + throw new PHPExcel_Reader_Exception("Could not open " . $pFilename . " for reading! File does not exist."); } $timezoneObj = new DateTimeZone('Europe/London'); $GMT = new DateTimeZone('UTC'); - $zip = new ZipArchive; - if ($zip->open($pFilename) === true) { -// echo '

Meta Information

'; - $xml = simplexml_load_string($zip->getFromName("meta.xml")); - $namespacesMeta = $xml->getNamespaces(true); -// echo '
';
-//			print_r($namespacesMeta);
-//			echo '

'; + $zipClass = PHPExcel_Settings::getZipClass(); - $docProps = $objPHPExcel->getProperties(); - $officeProperty = $xml->children($namespacesMeta['office']); - foreach($officeProperty as $officePropertyData) { - $officePropertyDC = array(); - if (isset($namespacesMeta['dc'])) { - $officePropertyDC = $officePropertyData->children($namespacesMeta['dc']); - } - foreach($officePropertyDC as $propertyName => $propertyValue) { - switch ($propertyName) { - case 'title' : - $docProps->setTitle($propertyValue); - break; - case 'subject' : - $docProps->setSubject($propertyValue); - break; - case 'creator' : - $docProps->setCreator($propertyValue); - $docProps->setLastModifiedBy($propertyValue); - break; - case 'date' : - $creationDate = strtotime($propertyValue); - $docProps->setCreated($creationDate); - $docProps->setModified($creationDate); - break; - case 'description' : - $docProps->setDescription($propertyValue); - break; - } - } - $officePropertyMeta = array(); - if (isset($namespacesMeta['dc'])) { - $officePropertyMeta = $officePropertyData->children($namespacesMeta['meta']); - } - foreach($officePropertyMeta as $propertyName => $propertyValue) { - $propertyValueAttributes = $propertyValue->attributes($namespacesMeta['meta']); - switch ($propertyName) { - case 'initial-creator' : - $docProps->setCreator($propertyValue); - break; - case 'keyword' : - $docProps->setKeywords($propertyValue); - break; - case 'creation-date' : - $creationDate = strtotime($propertyValue); - $docProps->setCreated($creationDate); - break; - case 'user-defined' : - $propertyValueType = PHPExcel_DocumentProperties::PROPERTY_TYPE_STRING; - foreach ($propertyValueAttributes as $key => $value) { - if ($key == 'name') { - $propertyValueName = (string) $value; - } elseif($key == 'value-type') { - switch ($value) { - case 'date' : - $propertyValue = PHPExcel_DocumentProperties::convertProperty($propertyValue,'date'); - $propertyValueType = PHPExcel_DocumentProperties::PROPERTY_TYPE_DATE; - break; - case 'boolean' : - $propertyValue = PHPExcel_DocumentProperties::convertProperty($propertyValue,'bool'); - $propertyValueType = PHPExcel_DocumentProperties::PROPERTY_TYPE_BOOLEAN; - break; - case 'float' : - $propertyValue = PHPExcel_DocumentProperties::convertProperty($propertyValue,'r4'); - $propertyValueType = PHPExcel_DocumentProperties::PROPERTY_TYPE_FLOAT; - break; - default : - $propertyValueType = PHPExcel_DocumentProperties::PROPERTY_TYPE_STRING; - } - } - } - $docProps->setCustomProperty($propertyValueName,$propertyValue,$propertyValueType); - break; - } + $zip = new $zipClass; + if (!$zip->open($pFilename)) { + throw new PHPExcel_Reader_Exception("Could not open " . $pFilename . " for reading! Error opening file."); + } + +// echo '

Meta Information

'; + $xml = simplexml_load_string($zip->getFromName("meta.xml"), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions()); + $namespacesMeta = $xml->getNamespaces(true); +// echo '
';
+//		print_r($namespacesMeta);
+//		echo '

'; + + $docProps = $objPHPExcel->getProperties(); + $officeProperty = $xml->children($namespacesMeta['office']); + foreach($officeProperty as $officePropertyData) { + $officePropertyDC = array(); + if (isset($namespacesMeta['dc'])) { + $officePropertyDC = $officePropertyData->children($namespacesMeta['dc']); + } + foreach($officePropertyDC as $propertyName => $propertyValue) { + $propertyValue = (string) $propertyValue; + switch ($propertyName) { + case 'title' : + $docProps->setTitle($propertyValue); + break; + case 'subject' : + $docProps->setSubject($propertyValue); + break; + case 'creator' : + $docProps->setCreator($propertyValue); + $docProps->setLastModifiedBy($propertyValue); + break; + case 'date' : + $creationDate = strtotime($propertyValue); + $docProps->setCreated($creationDate); + $docProps->setModified($creationDate); + break; + case 'description' : + $docProps->setDescription($propertyValue); + break; } } - - -// echo '

Workbook Content

'; - $xml = simplexml_load_string($zip->getFromName("content.xml")); - $namespacesContent = $xml->getNamespaces(true); -// echo '
';
-//			print_r($namespacesContent);
-//			echo '

'; - - $workbook = $xml->children($namespacesContent['office']); - foreach($workbook->body->spreadsheet as $workbookData) { - $workbookData = $workbookData->children($namespacesContent['table']); - $worksheetID = 0; - foreach($workbookData->table as $worksheetDataSet) { - $worksheetData = $worksheetDataSet->children($namespacesContent['table']); -// print_r($worksheetData); -// echo '
'; - $worksheetDataAttributes = $worksheetDataSet->attributes($namespacesContent['table']); -// print_r($worksheetDataAttributes); -// echo '
'; - if ((isset($this->_loadSheetsOnly)) && (isset($worksheetDataAttributes['name'])) && - (!in_array($worksheetDataAttributes['name'], $this->_loadSheetsOnly))) { - continue; - } - -// echo '

Worksheet '.$worksheetDataAttributes['name'].'

'; - // Create new Worksheet - $objPHPExcel->createSheet(); - $objPHPExcel->setActiveSheetIndex($worksheetID); - if (isset($worksheetDataAttributes['name'])) { - $worksheetName = (string) $worksheetDataAttributes['name']; - // Use false for $updateFormulaCellReferences to prevent adjustment of worksheet references in - // formula cells... during the load, all formulae should be correct, and we're simply - // bringing the worksheet name in line with the formula, not the reverse - $objPHPExcel->getActiveSheet()->setTitle($worksheetName,false); - } - - $rowID = 1; - foreach($worksheetData as $key => $rowData) { -// echo ''.$key.'
'; - switch ($key) { - case 'table-header-rows': - foreach ($rowData as $key=>$cellData) { - $rowData = $cellData; - break; + $officePropertyMeta = array(); + if (isset($namespacesMeta['dc'])) { + $officePropertyMeta = $officePropertyData->children($namespacesMeta['meta']); + } + foreach($officePropertyMeta as $propertyName => $propertyValue) { + $propertyValueAttributes = $propertyValue->attributes($namespacesMeta['meta']); + $propertyValue = (string) $propertyValue; + switch ($propertyName) { + case 'initial-creator' : + $docProps->setCreator($propertyValue); + break; + case 'keyword' : + $docProps->setKeywords($propertyValue); + break; + case 'creation-date' : + $creationDate = strtotime($propertyValue); + $docProps->setCreated($creationDate); + break; + case 'user-defined' : + $propertyValueType = PHPExcel_DocumentProperties::PROPERTY_TYPE_STRING; + foreach ($propertyValueAttributes as $key => $value) { + if ($key == 'name') { + $propertyValueName = (string) $value; + } elseif($key == 'value-type') { + switch ($value) { + case 'date' : + $propertyValue = PHPExcel_DocumentProperties::convertProperty($propertyValue,'date'); + $propertyValueType = PHPExcel_DocumentProperties::PROPERTY_TYPE_DATE; + break; + case 'boolean' : + $propertyValue = PHPExcel_DocumentProperties::convertProperty($propertyValue,'bool'); + $propertyValueType = PHPExcel_DocumentProperties::PROPERTY_TYPE_BOOLEAN; + break; + case 'float' : + $propertyValue = PHPExcel_DocumentProperties::convertProperty($propertyValue,'r4'); + $propertyValueType = PHPExcel_DocumentProperties::PROPERTY_TYPE_FLOAT; + break; + default : + $propertyValueType = PHPExcel_DocumentProperties::PROPERTY_TYPE_STRING; + } } - case 'table-row' : - $rowDataTableAttributes = $rowData->attributes($namespacesContent['table']); - $rowRepeats = (isset($rowDataTableAttributes['number-rows-repeated'])) ? - $rowDataTableAttributes['number-rows-repeated'] : 1; - $columnID = 'A'; - foreach($rowData as $key => $cellData) { - if ($this->getReadFilter() !== NULL) { - if (!$this->getReadFilter()->readCell($columnID, $rowID, $worksheetName)) { - continue; - } + } + $docProps->setCustomProperty($propertyValueName,$propertyValue,$propertyValueType); + break; + } + } + } + + +// echo '

Workbook Content

'; + $xml = simplexml_load_string($zip->getFromName("content.xml"), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions()); + $namespacesContent = $xml->getNamespaces(true); +// echo '
';
+//		print_r($namespacesContent);
+//		echo '

'; + + $workbook = $xml->children($namespacesContent['office']); + foreach($workbook->body->spreadsheet as $workbookData) { + $workbookData = $workbookData->children($namespacesContent['table']); + $worksheetID = 0; + foreach($workbookData->table as $worksheetDataSet) { + $worksheetData = $worksheetDataSet->children($namespacesContent['table']); +// print_r($worksheetData); +// echo '
'; + $worksheetDataAttributes = $worksheetDataSet->attributes($namespacesContent['table']); +// print_r($worksheetDataAttributes); +// echo '
'; + if ((isset($this->_loadSheetsOnly)) && (isset($worksheetDataAttributes['name'])) && + (!in_array($worksheetDataAttributes['name'], $this->_loadSheetsOnly))) { + continue; + } + +// echo '

Worksheet '.$worksheetDataAttributes['name'].'

'; + // Create new Worksheet + $objPHPExcel->createSheet(); + $objPHPExcel->setActiveSheetIndex($worksheetID); + if (isset($worksheetDataAttributes['name'])) { + $worksheetName = (string) $worksheetDataAttributes['name']; + // Use false for $updateFormulaCellReferences to prevent adjustment of worksheet references in + // formula cells... during the load, all formulae should be correct, and we're simply + // bringing the worksheet name in line with the formula, not the reverse + $objPHPExcel->getActiveSheet()->setTitle($worksheetName,false); + } + + $rowID = 1; + foreach($worksheetData as $key => $rowData) { +// echo ''.$key.'
'; + switch ($key) { + case 'table-header-rows': + foreach ($rowData as $key=>$cellData) { + $rowData = $cellData; + break; + } + case 'table-row' : + $rowDataTableAttributes = $rowData->attributes($namespacesContent['table']); + $rowRepeats = (isset($rowDataTableAttributes['number-rows-repeated'])) ? + $rowDataTableAttributes['number-rows-repeated'] : 1; + $columnID = 'A'; + foreach($rowData as $key => $cellData) { + if ($this->getReadFilter() !== NULL) { + if (!$this->getReadFilter()->readCell($columnID, $rowID, $worksheetName)) { + continue; } + } -// echo ''.$columnID.$rowID.'
'; - $cellDataText = (isset($namespacesContent['text'])) ? - $cellData->children($namespacesContent['text']) : - ''; - $cellDataOffice = $cellData->children($namespacesContent['office']); - $cellDataOfficeAttributes = $cellData->attributes($namespacesContent['office']); - $cellDataTableAttributes = $cellData->attributes($namespacesContent['table']); +// echo ''.$columnID.$rowID.'
'; + $cellDataText = (isset($namespacesContent['text'])) ? + $cellData->children($namespacesContent['text']) : + ''; + $cellDataOffice = $cellData->children($namespacesContent['office']); + $cellDataOfficeAttributes = $cellData->attributes($namespacesContent['office']); + $cellDataTableAttributes = $cellData->attributes($namespacesContent['table']); -// echo 'Office Attributes: '; -// print_r($cellDataOfficeAttributes); -// echo '
Table Attributes: '; -// print_r($cellDataTableAttributes); -// echo '
Cell Data Text'; -// print_r($cellDataText); -// echo '
'; +// echo 'Office Attributes: '; +// print_r($cellDataOfficeAttributes); +// echo '
Table Attributes: '; +// print_r($cellDataTableAttributes); +// echo '
Cell Data Text'; +// print_r($cellDataText); +// echo '
'; // - $type = $formatting = $hyperlink = null; - $hasCalculatedValue = false; - $cellDataFormula = ''; - if (isset($cellDataTableAttributes['formula'])) { - $cellDataFormula = $cellDataTableAttributes['formula']; - $hasCalculatedValue = true; - } + $type = $formatting = $hyperlink = null; + $hasCalculatedValue = false; + $cellDataFormula = ''; + if (isset($cellDataTableAttributes['formula'])) { + $cellDataFormula = $cellDataTableAttributes['formula']; + $hasCalculatedValue = true; + } - if (isset($cellDataOffice->annotation)) { -// echo 'Cell has comment
'; - $annotationText = $cellDataOffice->annotation->children($namespacesContent['text']); - $textArray = array(); - foreach($annotationText as $t) { - foreach($t->span as $text) { - $textArray[] = (string)$text; - } + if (isset($cellDataOffice->annotation)) { +// echo 'Cell has comment
'; + $annotationText = $cellDataOffice->annotation->children($namespacesContent['text']); + $textArray = array(); + foreach($annotationText as $t) { + foreach($t->span as $text) { + $textArray[] = (string)$text; } - $text = implode("\n",$textArray); -// echo $text,'
'; - $objPHPExcel->getActiveSheet()->getComment( $columnID.$rowID ) -// ->setAuthor( $author ) - ->setText($this->_parseRichText($text) ); } + $text = implode("\n",$textArray); +// echo $text,'
'; + $objPHPExcel->getActiveSheet()->getComment( $columnID.$rowID ) +// ->setAuthor( $author ) + ->setText($this->_parseRichText($text) ); + } if (isset($cellDataText->p)) { - // Consolidate if there are multiple p records (maybe with spans as well) - $dataArray = array(); - // Text can have multiple text:p and within those, multiple text:span. - // text:p newlines, but text:span does not. - // Also, here we assume there is no text data is span fields are specified, since - // we have no way of knowing proper positioning anyway. - foreach ($cellDataText->p as $pData) { - if (isset($pData->span)) { - // span sections do not newline, so we just create one large string here - $spanSection = ""; - foreach ($pData->span as $spanData) { - $spanSection .= $spanData; + // Consolidate if there are multiple p records (maybe with spans as well) + $dataArray = array(); + // Text can have multiple text:p and within those, multiple text:span. + // text:p newlines, but text:span does not. + // Also, here we assume there is no text data is span fields are specified, since + // we have no way of knowing proper positioning anyway. + foreach ($cellDataText->p as $pData) { + if (isset($pData->span)) { + // span sections do not newline, so we just create one large string here + $spanSection = ""; + foreach ($pData->span as $spanData) { + $spanSection .= $spanData; + } + array_push($dataArray, $spanSection); + } else { + array_push($dataArray, $pData); + } + } + $allCellDataText = implode($dataArray, "\n"); + +// echo 'Value Type is '.$cellDataOfficeAttributes['value-type'].'
'; + switch ($cellDataOfficeAttributes['value-type']) { + case 'string' : + $type = PHPExcel_Cell_DataType::TYPE_STRING; + $dataValue = $allCellDataText; + if (isset($dataValue->a)) { + $dataValue = $dataValue->a; + $cellXLinkAttributes = $dataValue->attributes($namespacesContent['xlink']); + $hyperlink = $cellXLinkAttributes['href']; } - array_push($dataArray, $spanSection); - } else { - array_push($dataArray, $pData); - } - } - $allCellDataText = implode($dataArray, "\n"); - -// echo 'Value Type is '.$cellDataOfficeAttributes['value-type'].'
'; - switch ($cellDataOfficeAttributes['value-type']) { - case 'string' : - $type = PHPExcel_Cell_DataType::TYPE_STRING; - $dataValue = $allCellDataText; - if (isset($dataValue->a)) { - $dataValue = $dataValue->a; - $cellXLinkAttributes = $dataValue->attributes($namespacesContent['xlink']); - $hyperlink = $cellXLinkAttributes['href']; - } - break; - case 'boolean' : - $type = PHPExcel_Cell_DataType::TYPE_BOOL; - $dataValue = ($allCellDataText == 'TRUE') ? True : False; - break; - case 'percentage' : - $type = PHPExcel_Cell_DataType::TYPE_NUMERIC; - $dataValue = (float) $cellDataOfficeAttributes['value']; - if (floor($dataValue) == $dataValue) { - $dataValue = (integer) $dataValue; - } - $formatting = PHPExcel_Style_NumberFormat::FORMAT_PERCENTAGE_00; - break; - case 'currency' : - $type = PHPExcel_Cell_DataType::TYPE_NUMERIC; - $dataValue = (float) $cellDataOfficeAttributes['value']; - if (floor($dataValue) == $dataValue) { - $dataValue = (integer) $dataValue; - } - $formatting = PHPExcel_Style_NumberFormat::FORMAT_CURRENCY_USD_SIMPLE; - break; - case 'float' : - $type = PHPExcel_Cell_DataType::TYPE_NUMERIC; - $dataValue = (float) $cellDataOfficeAttributes['value']; - if (floor($dataValue) == $dataValue) { - if ($dataValue = (integer) $dataValue) - $dataValue = (integer) $dataValue; - else - $dataValue = (float) $dataValue; - } - break; - case 'date' : - $type = PHPExcel_Cell_DataType::TYPE_NUMERIC; - $dateObj = new DateTime($cellDataOfficeAttributes['date-value'], $GMT); - $dateObj->setTimeZone($timezoneObj); - list($year,$month,$day,$hour,$minute,$second) = explode(' ',$dateObj->format('Y m d H i s')); - $dataValue = PHPExcel_Shared_Date::FormattedPHPToExcel($year,$month,$day,$hour,$minute,$second); - if ($dataValue != floor($dataValue)) { - $formatting = PHPExcel_Style_NumberFormat::FORMAT_DATE_XLSX15.' '.PHPExcel_Style_NumberFormat::FORMAT_DATE_TIME4; - } else { - $formatting = PHPExcel_Style_NumberFormat::FORMAT_DATE_XLSX15; - } - break; - case 'time' : - $type = PHPExcel_Cell_DataType::TYPE_NUMERIC; - $dataValue = PHPExcel_Shared_Date::PHPToExcel(strtotime('01-01-1970 '.implode(':',sscanf($cellDataOfficeAttributes['time-value'],'PT%dH%dM%dS')))); - $formatting = PHPExcel_Style_NumberFormat::FORMAT_DATE_TIME4; - break; - } -// echo 'Data value is '.$dataValue.'
'; -// if ($hyperlink !== NULL) { -// echo 'Hyperlink is '.$hyperlink.'
'; -// } - } else { - $type = PHPExcel_Cell_DataType::TYPE_NULL; - $dataValue = NULL; - } - - if ($hasCalculatedValue) { - $type = PHPExcel_Cell_DataType::TYPE_FORMULA; -// echo 'Formula: '.$cellDataFormula.'
'; - $cellDataFormula = substr($cellDataFormula,strpos($cellDataFormula,':=')+1); - $temp = explode('"',$cellDataFormula); - $tKey = false; - foreach($temp as &$value) { - // Only replace in alternate array entries (i.e. non-quoted blocks) - if ($tKey = !$tKey) { - $value = preg_replace('/\[\.(.*):\.(.*)\]/Ui','$1:$2',$value); - $value = preg_replace('/\[\.(.*)\]/Ui','$1',$value); - $value = PHPExcel_Calculation::_translateSeparator(';',',',$value,$inBraces); - } - } - unset($value); - // Then rebuild the formula string - $cellDataFormula = implode('"',$temp); -// echo 'Adjusted Formula: '.$cellDataFormula.'
'; - } - - $colRepeats = (isset($cellDataTableAttributes['number-columns-repeated'])) ? - $cellDataTableAttributes['number-columns-repeated'] : 1; - if ($type !== NULL) { - for ($i = 0; $i < $colRepeats; ++$i) { - if ($i > 0) { - ++$columnID; - } - if ($type !== PHPExcel_Cell_DataType::TYPE_NULL) { - for ($rowAdjust = 0; $rowAdjust < $rowRepeats; ++$rowAdjust) { - $rID = $rowID + $rowAdjust; - $objPHPExcel->getActiveSheet()->getCell($columnID.$rID)->setValueExplicit((($hasCalculatedValue) ? $cellDataFormula : $dataValue),$type); - if ($hasCalculatedValue) { -// echo 'Forumla result is '.$dataValue.'
'; - $objPHPExcel->getActiveSheet()->getCell($columnID.$rID)->setCalculatedValue($dataValue); - } - if ($formatting !== NULL) { - $objPHPExcel->getActiveSheet()->getStyle($columnID.$rID)->getNumberFormat()->setFormatCode($formatting); - } else { - $objPHPExcel->getActiveSheet()->getStyle($columnID.$rID)->getNumberFormat()->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_GENERAL); - } - if ($hyperlink !== NULL) { - $objPHPExcel->getActiveSheet()->getCell($columnID.$rID)->getHyperlink()->setUrl($hyperlink); - } + break; + case 'boolean' : + $type = PHPExcel_Cell_DataType::TYPE_BOOL; + $dataValue = ($allCellDataText == 'TRUE') ? True : False; + break; + case 'percentage' : + $type = PHPExcel_Cell_DataType::TYPE_NUMERIC; + $dataValue = (float) $cellDataOfficeAttributes['value']; + if (floor($dataValue) == $dataValue) { + $dataValue = (integer) $dataValue; } - } - } + $formatting = PHPExcel_Style_NumberFormat::FORMAT_PERCENTAGE_00; + break; + case 'currency' : + $type = PHPExcel_Cell_DataType::TYPE_NUMERIC; + $dataValue = (float) $cellDataOfficeAttributes['value']; + if (floor($dataValue) == $dataValue) { + $dataValue = (integer) $dataValue; + } + $formatting = PHPExcel_Style_NumberFormat::FORMAT_CURRENCY_USD_SIMPLE; + break; + case 'float' : + $type = PHPExcel_Cell_DataType::TYPE_NUMERIC; + $dataValue = (float) $cellDataOfficeAttributes['value']; + if (floor($dataValue) == $dataValue) { + if ($dataValue == (integer) $dataValue) + $dataValue = (integer) $dataValue; + else + $dataValue = (float) $dataValue; + } + break; + case 'date' : + $type = PHPExcel_Cell_DataType::TYPE_NUMERIC; + $dateObj = new DateTime($cellDataOfficeAttributes['date-value'], $GMT); + $dateObj->setTimeZone($timezoneObj); + list($year,$month,$day,$hour,$minute,$second) = explode(' ',$dateObj->format('Y m d H i s')); + $dataValue = PHPExcel_Shared_Date::FormattedPHPToExcel($year,$month,$day,$hour,$minute,$second); + if ($dataValue != floor($dataValue)) { + $formatting = PHPExcel_Style_NumberFormat::FORMAT_DATE_XLSX15.' '.PHPExcel_Style_NumberFormat::FORMAT_DATE_TIME4; + } else { + $formatting = PHPExcel_Style_NumberFormat::FORMAT_DATE_XLSX15; + } + break; + case 'time' : + $type = PHPExcel_Cell_DataType::TYPE_NUMERIC; + $dataValue = PHPExcel_Shared_Date::PHPToExcel(strtotime('01-01-1970 '.implode(':',sscanf($cellDataOfficeAttributes['time-value'],'PT%dH%dM%dS')))); + $formatting = PHPExcel_Style_NumberFormat::FORMAT_DATE_TIME4; + break; } - - // Merged cells - if ((isset($cellDataTableAttributes['number-columns-spanned'])) || (isset($cellDataTableAttributes['number-rows-spanned']))) { - if (($type !== PHPExcel_Cell_DataType::TYPE_NULL) || (!$this->_readDataOnly)) { - $columnTo = $columnID; - if (isset($cellDataTableAttributes['number-columns-spanned'])) { - $columnTo = PHPExcel_Cell::stringFromColumnIndex(PHPExcel_Cell::columnIndexFromString($columnID) + $cellDataTableAttributes['number-columns-spanned'] -2); - } - $rowTo = $rowID; - if (isset($cellDataTableAttributes['number-rows-spanned'])) { - $rowTo = $rowTo + $cellDataTableAttributes['number-rows-spanned'] - 1; - } - $cellRange = $columnID.$rowID.':'.$columnTo.$rowTo; - $objPHPExcel->getActiveSheet()->mergeCells($cellRange); - } - } - - ++$columnID; +// echo 'Data value is '.$dataValue.'
'; +// if ($hyperlink !== NULL) { +// echo 'Hyperlink is '.$hyperlink.'
'; +// } + } else { + $type = PHPExcel_Cell_DataType::TYPE_NULL; + $dataValue = NULL; } - $rowID += $rowRepeats; - break; - } - } - ++$worksheetID; - } - } + if ($hasCalculatedValue) { + $type = PHPExcel_Cell_DataType::TYPE_FORMULA; +// echo 'Formula: ', $cellDataFormula, PHP_EOL; + $cellDataFormula = substr($cellDataFormula,strpos($cellDataFormula,':=')+1); + $temp = explode('"',$cellDataFormula); + $tKey = false; + foreach($temp as &$value) { + // Only replace in alternate array entries (i.e. non-quoted blocks) + if ($tKey = !$tKey) { + $value = preg_replace('/\[([^\.]+)\.([^\.]+):\.([^\.]+)\]/Ui','$1!$2:$3',$value); // Cell range reference in another sheet + $value = preg_replace('/\[([^\.]+)\.([^\.]+)\]/Ui','$1!$2',$value); // Cell reference in another sheet + $value = preg_replace('/\[\.([^\.]+):\.([^\.]+)\]/Ui','$1:$2',$value); // Cell range reference + $value = preg_replace('/\[\.([^\.]+)\]/Ui','$1',$value); // Simple cell reference + $value = PHPExcel_Calculation::_translateSeparator(';',',',$value,$inBraces); + } + } + unset($value); + // Then rebuild the formula string + $cellDataFormula = implode('"',$temp); +// echo 'Adjusted Formula: ', $cellDataFormula, PHP_EOL; + } + + $colRepeats = (isset($cellDataTableAttributes['number-columns-repeated'])) ? + $cellDataTableAttributes['number-columns-repeated'] : 1; + if ($type !== NULL) { + for ($i = 0; $i < $colRepeats; ++$i) { + if ($i > 0) { + ++$columnID; + } + if ($type !== PHPExcel_Cell_DataType::TYPE_NULL) { + for ($rowAdjust = 0; $rowAdjust < $rowRepeats; ++$rowAdjust) { + $rID = $rowID + $rowAdjust; + $objPHPExcel->getActiveSheet()->getCell($columnID.$rID)->setValueExplicit((($hasCalculatedValue) ? $cellDataFormula : $dataValue),$type); + if ($hasCalculatedValue) { +// echo 'Forumla result is '.$dataValue.'
'; + $objPHPExcel->getActiveSheet()->getCell($columnID.$rID)->setCalculatedValue($dataValue); + } + if ($formatting !== NULL) { + $objPHPExcel->getActiveSheet()->getStyle($columnID.$rID)->getNumberFormat()->setFormatCode($formatting); + } else { + $objPHPExcel->getActiveSheet()->getStyle($columnID.$rID)->getNumberFormat()->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_GENERAL); + } + if ($hyperlink !== NULL) { + $objPHPExcel->getActiveSheet()->getCell($columnID.$rID)->getHyperlink()->setUrl($hyperlink); + } + } + } + } + } + + // Merged cells + if ((isset($cellDataTableAttributes['number-columns-spanned'])) || (isset($cellDataTableAttributes['number-rows-spanned']))) { + if (($type !== PHPExcel_Cell_DataType::TYPE_NULL) || (!$this->_readDataOnly)) { + $columnTo = $columnID; + if (isset($cellDataTableAttributes['number-columns-spanned'])) { + $columnTo = PHPExcel_Cell::stringFromColumnIndex(PHPExcel_Cell::columnIndexFromString($columnID) + $cellDataTableAttributes['number-columns-spanned'] -2); + } + $rowTo = $rowID; + if (isset($cellDataTableAttributes['number-rows-spanned'])) { + $rowTo = $rowTo + $cellDataTableAttributes['number-rows-spanned'] - 1; + } + $cellRange = $columnID.$rowID.':'.$columnTo.$rowTo; + $objPHPExcel->getActiveSheet()->mergeCells($cellRange); + } + } + + ++$columnID; + } + $rowID += $rowRepeats; + break; + } + } + ++$worksheetID; + } } // Return diff --git a/htdocs/includes/phpexcel/PHPExcel/Reader/SYLK.php b/htdocs/includes/phpexcel/PHPExcel/Reader/SYLK.php index 47d5703f56b..cd87ce56c10 100644 --- a/htdocs/includes/phpexcel/PHPExcel/Reader/SYLK.php +++ b/htdocs/includes/phpexcel/PHPExcel/Reader/SYLK.php @@ -2,7 +2,7 @@ /** * PHPExcel * - * Copyright (c) 2006 - 2012 PHPExcel + * Copyright (c) 2006 - 2014 PHPExcel * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,9 +20,9 @@ * * @category PHPExcel * @package PHPExcel_Reader - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version 1.7.8, 2012-10-12 + * @version 1.8.0, 2014-03-02 */ @@ -40,9 +40,9 @@ if (!defined('PHPEXCEL_ROOT')) { * * @category PHPExcel * @package PHPExcel_Reader - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) */ -class PHPExcel_Reader_SYLK implements PHPExcel_Reader_IReader +class PHPExcel_Reader_SYLK extends PHPExcel_Reader_Abstract implements PHPExcel_Reader_IReader { /** * Input encoding @@ -72,14 +72,6 @@ class PHPExcel_Reader_SYLK implements PHPExcel_Reader_IReader */ private $_format = 0; - /** - * PHPExcel_Reader_IReadFilter instance - * - * @var PHPExcel_Reader_IReadFilter - */ - private $_readFilter = null; - - /** * Create a new PHPExcel_Reader_SYLK */ @@ -87,63 +79,31 @@ class PHPExcel_Reader_SYLK implements PHPExcel_Reader_IReader $this->_readFilter = new PHPExcel_Reader_DefaultReadFilter(); } - /** - * Can the current PHPExcel_Reader_IReader read the file? + * Validate that the current file is a SYLK file * - * @param string $pFileName - * @return boolean - * @throws Exception + * @return boolean */ - public function canRead($pFilename) + protected function _isValidFormat() { - // Check if file exists - if (!file_exists($pFilename)) { - throw new Exception("Could not open " . $pFilename . " for reading! File does not exist."); - } - // Read sample data (first 2 KB will do) - $fh = fopen($pFilename, 'r'); - $data = fread($fh, 2048); - fclose($fh); + $data = fread($this->_fileHandle, 2048); // Count delimiters in file $delimiterCount = substr_count($data, ';'); if ($delimiterCount < 1) { - return false; + return FALSE; } // Analyze first line looking for ID; signature $lines = explode("\n", $data); if (substr($lines[0],0,4) != 'ID;P') { - return false; + return FALSE; } - return true; + return TRUE; } - - /** - * Read filter - * - * @return PHPExcel_Reader_IReadFilter - */ - public function getReadFilter() { - return $this->_readFilter; - } - - - /** - * Set read filter - * - * @param PHPExcel_Reader_IReadFilter $pValue - */ - public function setReadFilter(PHPExcel_Reader_IReadFilter $pValue) { - $this->_readFilter = $pValue; - return $this; - } - - /** * Set input encoding * @@ -155,7 +115,6 @@ class PHPExcel_Reader_SYLK implements PHPExcel_Reader_IReader return $this; } - /** * Get input encoding * @@ -166,25 +125,22 @@ class PHPExcel_Reader_SYLK implements PHPExcel_Reader_IReader return $this->_inputEncoding; } - /** * Return worksheet info (Name, Last Column Letter, Last Column Index, Total Rows, Total Columns) * * @param string $pFilename - * @throws Exception + * @throws PHPExcel_Reader_Exception */ public function listWorksheetInfo($pFilename) { - // Check if file exists - if (!file_exists($pFilename)) { - throw new Exception("Could not open " . $pFilename . " for reading! File does not exist."); - } - // Open file - $fileHandle = fopen($pFilename, 'r'); - if ($fileHandle === false) { - throw new Exception("Could not open file " . $pFilename . " for reading."); + $this->_openFile($pFilename); + if (!$this->_isValidFormat()) { + fclose ($this->_fileHandle); + throw new PHPExcel_Reader_Exception($pFilename . " is an Invalid Spreadsheet file."); } + $fileHandle = $this->_fileHandle; + rewind($fileHandle); $worksheetInfo = array(); $worksheetInfo[0]['worksheetName'] = 'Worksheet'; @@ -206,7 +162,7 @@ class PHPExcel_Reader_SYLK implements PHPExcel_Reader_IReader // explode each row at semicolons while taking into account that literal semicolon (;) // is escaped like this (;;) - $rowData = explode("\t",str_replace('?',';',str_replace(';',"\t",str_replace(';;','?',rtrim($rowData))))); + $rowData = explode("\t",str_replace('¤',';',str_replace(';',"\t",str_replace(';;','¤',rtrim($rowData))))); $dataType = array_shift($rowData); if ($dataType == 'C') { @@ -238,13 +194,12 @@ class PHPExcel_Reader_SYLK implements PHPExcel_Reader_IReader return $worksheetInfo; } - /** * Loads PHPExcel from file * * @param string $pFilename * @return PHPExcel - * @throws Exception + * @throws PHPExcel_Reader_Exception */ public function load($pFilename) { @@ -255,21 +210,24 @@ class PHPExcel_Reader_SYLK implements PHPExcel_Reader_IReader return $this->loadIntoExisting($pFilename, $objPHPExcel); } - /** * Loads PHPExcel from file into PHPExcel instance * * @param string $pFilename * @param PHPExcel $objPHPExcel * @return PHPExcel - * @throws Exception + * @throws PHPExcel_Reader_Exception */ public function loadIntoExisting($pFilename, PHPExcel $objPHPExcel) { - // Check if file exists - if (!file_exists($pFilename)) { - throw new Exception("Could not open " . $pFilename . " for reading! File does not exist."); + // Open file + $this->_openFile($pFilename); + if (!$this->_isValidFormat()) { + fclose ($this->_fileHandle); + throw new PHPExcel_Reader_Exception($pFilename . " is an Invalid Spreadsheet file."); } + $fileHandle = $this->_fileHandle; + rewind($fileHandle); // Create new PHPExcel while ($objPHPExcel->getSheetCount() <= $this->_sheetIndex) { @@ -280,12 +238,6 @@ class PHPExcel_Reader_SYLK implements PHPExcel_Reader_IReader $fromFormats = array('\-', '\ '); $toFormats = array('-', ' '); - // Open file - $fileHandle = fopen($pFilename, 'r'); - if ($fileHandle === false) { - throw new Exception("Could not open file $pFilename for reading."); - } - // Loop through file $rowData = array(); $column = $row = ''; @@ -433,7 +385,9 @@ class PHPExcel_Reader_SYLK implements PHPExcel_Reader_IReader } if (($formatStyle > '') && ($column > '') && ($row > '')) { $columnLetter = PHPExcel_Cell::stringFromColumnIndex($column-1); - $objPHPExcel->getActiveSheet()->getStyle($columnLetter.$row)->applyFromArray($this->_formats[$formatStyle]); + if (isset($this->_formats[$formatStyle])) { + $objPHPExcel->getActiveSheet()->getStyle($columnLetter.$row)->applyFromArray($this->_formats[$formatStyle]); + } } if ((!empty($styleData)) && ($column > '') && ($row > '')) { $columnLetter = PHPExcel_Cell::stringFromColumnIndex($column-1); @@ -473,7 +427,6 @@ class PHPExcel_Reader_SYLK implements PHPExcel_Reader_IReader return $objPHPExcel; } - /** * Get sheet index * @@ -483,7 +436,6 @@ class PHPExcel_Reader_SYLK implements PHPExcel_Reader_IReader return $this->_sheetIndex; } - /** * Set sheet index * diff --git a/htdocs/includes/phpexcel/PHPExcel/ReferenceHelper.php b/htdocs/includes/phpexcel/PHPExcel/ReferenceHelper.php index 9113591297a..402f2b472a6 100644 --- a/htdocs/includes/phpexcel/PHPExcel/ReferenceHelper.php +++ b/htdocs/includes/phpexcel/PHPExcel/ReferenceHelper.php @@ -2,7 +2,7 @@ /** * PHPExcel * - * Copyright (c) 2006 - 2012 PHPExcel + * Copyright (c) 2006 - 2014 PHPExcel * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,9 +20,9 @@ * * @category PHPExcel * @package PHPExcel - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version 1.7.8, 2012-10-12 + * @version 1.8.0, 2014-03-02 */ @@ -31,7 +31,7 @@ * * @category PHPExcel * @package PHPExcel - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) */ class PHPExcel_ReferenceHelper { @@ -69,30 +69,336 @@ class PHPExcel_ReferenceHelper } /** - * Insert a new column, updating all possible related data + * Compare two column addresses + * Intended for use as a Callback function for sorting column addresses by column * - * @param int $pBefore Insert before this one - * @param int $pNumCols Number of columns to insert - * @param int $pNumRows Number of rows to insert - * @throws Exception + * @param string $a First column to test (e.g. 'AA') + * @param string $b Second column to test (e.g. 'Z') + * @return integer */ - public function insertNewBefore($pBefore = 'A1', $pNumCols = 0, $pNumRows = 0, PHPExcel_Worksheet $pSheet = null) { + public static function columnSort($a, $b) { + return strcasecmp(strlen($a) . $a, strlen($b) . $b); + } + + /** + * Compare two column addresses + * Intended for use as a Callback function for reverse sorting column addresses by column + * + * @param string $a First column to test (e.g. 'AA') + * @param string $b Second column to test (e.g. 'Z') + * @return integer + */ + public static function columnReverseSort($a, $b) { + return 1 - strcasecmp(strlen($a) . $a, strlen($b) . $b); + } + + /** + * Compare two cell addresses + * Intended for use as a Callback function for sorting cell addresses by column and row + * + * @param string $a First cell to test (e.g. 'AA1') + * @param string $b Second cell to test (e.g. 'Z1') + * @return integer + */ + public static function cellSort($a, $b) { + sscanf($a,'%[A-Z]%d', $ac, $ar); + sscanf($b,'%[A-Z]%d', $bc, $br); + + if ($ar == $br) { + return strcasecmp(strlen($ac) . $ac, strlen($bc) . $bc); + } + return ($ar < $br) ? -1 : 1; + } + + /** + * Compare two cell addresses + * Intended for use as a Callback function for sorting cell addresses by column and row + * + * @param string $a First cell to test (e.g. 'AA1') + * @param string $b Second cell to test (e.g. 'Z1') + * @return integer + */ + public static function cellReverseSort($a, $b) { + sscanf($a,'%[A-Z]%d', $ac, $ar); + sscanf($b,'%[A-Z]%d', $bc, $br); + + if ($ar == $br) { + return 1 - strcasecmp(strlen($ac) . $ac, strlen($bc) . $bc); + } + return ($ar < $br) ? 1 : -1; + } + + /** + * Test whether a cell address falls within a defined range of cells + * + * @param string $cellAddress Address of the cell we're testing + * @param integer $beforeRow Number of the row we're inserting/deleting before + * @param integer $pNumRows Number of rows to insert/delete (negative values indicate deletion) + * @param integer $beforeColumnIndex Index number of the column we're inserting/deleting before + * @param integer $pNumCols Number of columns to insert/delete (negative values indicate deletion) + * @return boolean + */ + private static function cellAddressInDeleteRange($cellAddress, $beforeRow, $pNumRows, $beforeColumnIndex, $pNumCols) { + list($cellColumn, $cellRow) = PHPExcel_Cell::coordinateFromString($cellAddress); + $cellColumnIndex = PHPExcel_Cell::columnIndexFromString($cellColumn); + // Is cell within the range of rows/columns if we're deleting + if ($pNumRows < 0 && + ($cellRow >= ($beforeRow + $pNumRows)) && + ($cellRow < $beforeRow)) { + return TRUE; + } elseif ($pNumCols < 0 && + ($cellColumnIndex >= ($beforeColumnIndex + $pNumCols)) && + ($cellColumnIndex < $beforeColumnIndex)) { + return TRUE; + } + return FALSE; + } + + /** + * Update page breaks when inserting/deleting rows/columns + * + * @param PHPExcel_Worksheet $pSheet The worksheet that we're editing + * @param string $pBefore Insert/Delete before this cell address (e.g. 'A1') + * @param integer $beforeColumnIndex Index number of the column we're inserting/deleting before + * @param integer $pNumCols Number of columns to insert/delete (negative values indicate deletion) + * @param integer $beforeRow Number of the row we're inserting/deleting before + * @param integer $pNumRows Number of rows to insert/delete (negative values indicate deletion) + */ + protected function _adjustPageBreaks(PHPExcel_Worksheet $pSheet, $pBefore, $beforeColumnIndex, $pNumCols, $beforeRow, $pNumRows) + { + $aBreaks = $pSheet->getBreaks(); + ($pNumCols > 0 || $pNumRows > 0) ? + uksort($aBreaks, array('PHPExcel_ReferenceHelper','cellReverseSort')) : + uksort($aBreaks, array('PHPExcel_ReferenceHelper','cellSort')); + + foreach ($aBreaks as $key => $value) { + if (self::cellAddressInDeleteRange($key, $beforeRow, $pNumRows, $beforeColumnIndex, $pNumCols)) { + // If we're deleting, then clear any defined breaks that are within the range + // of rows/columns that we're deleting + $pSheet->setBreak($key, PHPExcel_Worksheet::BREAK_NONE); + } else { + // Otherwise update any affected breaks by inserting a new break at the appropriate point + // and removing the old affected break + $newReference = $this->updateCellReference($key, $pBefore, $pNumCols, $pNumRows); + if ($key != $newReference) { + $pSheet->setBreak($newReference, $value) + ->setBreak($key, PHPExcel_Worksheet::BREAK_NONE); + } + } + } + } + + /** + * Update cell comments when inserting/deleting rows/columns + * + * @param PHPExcel_Worksheet $pSheet The worksheet that we're editing + * @param string $pBefore Insert/Delete before this cell address (e.g. 'A1') + * @param integer $beforeColumnIndex Index number of the column we're inserting/deleting before + * @param integer $pNumCols Number of columns to insert/delete (negative values indicate deletion) + * @param integer $beforeRow Number of the row we're inserting/deleting before + * @param integer $pNumRows Number of rows to insert/delete (negative values indicate deletion) + */ + protected function _adjustComments($pSheet, $pBefore, $beforeColumnIndex, $pNumCols, $beforeRow, $pNumRows) + { + $aComments = $pSheet->getComments(); + $aNewComments = array(); // the new array of all comments + + foreach ($aComments as $key => &$value) { + // Any comments inside a deleted range will be ignored + if (!self::cellAddressInDeleteRange($key, $beforeRow, $pNumRows, $beforeColumnIndex, $pNumCols)) { + // Otherwise build a new array of comments indexed by the adjusted cell reference + $newReference = $this->updateCellReference($key, $pBefore, $pNumCols, $pNumRows); + $aNewComments[$newReference] = $value; + } + } + // Replace the comments array with the new set of comments + $pSheet->setComments($aNewComments); + } + + /** + * Update hyperlinks when inserting/deleting rows/columns + * + * @param PHPExcel_Worksheet $pSheet The worksheet that we're editing + * @param string $pBefore Insert/Delete before this cell address (e.g. 'A1') + * @param integer $beforeColumnIndex Index number of the column we're inserting/deleting before + * @param integer $pNumCols Number of columns to insert/delete (negative values indicate deletion) + * @param integer $beforeRow Number of the row we're inserting/deleting before + * @param integer $pNumRows Number of rows to insert/delete (negative values indicate deletion) + */ + protected function _adjustHyperlinks($pSheet, $pBefore, $beforeColumnIndex, $pNumCols, $beforeRow, $pNumRows) + { + $aHyperlinkCollection = $pSheet->getHyperlinkCollection(); + ($pNumCols > 0 || $pNumRows > 0) ? + uksort($aHyperlinkCollection, array('PHPExcel_ReferenceHelper','cellReverseSort')) : + uksort($aHyperlinkCollection, array('PHPExcel_ReferenceHelper','cellSort')); + + foreach ($aHyperlinkCollection as $key => $value) { + $newReference = $this->updateCellReference($key, $pBefore, $pNumCols, $pNumRows); + if ($key != $newReference) { + $pSheet->setHyperlink( $newReference, $value ); + $pSheet->setHyperlink( $key, null ); + } + } + } + + /** + * Update data validations when inserting/deleting rows/columns + * + * @param PHPExcel_Worksheet $pSheet The worksheet that we're editing + * @param string $pBefore Insert/Delete before this cell address (e.g. 'A1') + * @param integer $beforeColumnIndex Index number of the column we're inserting/deleting before + * @param integer $pNumCols Number of columns to insert/delete (negative values indicate deletion) + * @param integer $beforeRow Number of the row we're inserting/deleting before + * @param integer $pNumRows Number of rows to insert/delete (negative values indicate deletion) + */ + protected function _adjustDataValidations($pSheet, $pBefore, $beforeColumnIndex, $pNumCols, $beforeRow, $pNumRows) + { + $aDataValidationCollection = $pSheet->getDataValidationCollection(); + ($pNumCols > 0 || $pNumRows > 0) ? + uksort($aDataValidationCollection, array('PHPExcel_ReferenceHelper','cellReverseSort')) : + uksort($aDataValidationCollection, array('PHPExcel_ReferenceHelper','cellSort')); + foreach ($aDataValidationCollection as $key => $value) { + $newReference = $this->updateCellReference($key, $pBefore, $pNumCols, $pNumRows); + if ($key != $newReference) { + $pSheet->setDataValidation( $newReference, $value ); + $pSheet->setDataValidation( $key, null ); + } + } + } + + /** + * Update merged cells when inserting/deleting rows/columns + * + * @param PHPExcel_Worksheet $pSheet The worksheet that we're editing + * @param string $pBefore Insert/Delete before this cell address (e.g. 'A1') + * @param integer $beforeColumnIndex Index number of the column we're inserting/deleting before + * @param integer $pNumCols Number of columns to insert/delete (negative values indicate deletion) + * @param integer $beforeRow Number of the row we're inserting/deleting before + * @param integer $pNumRows Number of rows to insert/delete (negative values indicate deletion) + */ + protected function _adjustMergeCells($pSheet, $pBefore, $beforeColumnIndex, $pNumCols, $beforeRow, $pNumRows) + { + $aMergeCells = $pSheet->getMergeCells(); + $aNewMergeCells = array(); // the new array of all merge cells + foreach ($aMergeCells as $key => &$value) { + $newReference = $this->updateCellReference($key, $pBefore, $pNumCols, $pNumRows); + $aNewMergeCells[$newReference] = $newReference; + } + $pSheet->setMergeCells($aNewMergeCells); // replace the merge cells array + } + + /** + * Update protected cells when inserting/deleting rows/columns + * + * @param PHPExcel_Worksheet $pSheet The worksheet that we're editing + * @param string $pBefore Insert/Delete before this cell address (e.g. 'A1') + * @param integer $beforeColumnIndex Index number of the column we're inserting/deleting before + * @param integer $pNumCols Number of columns to insert/delete (negative values indicate deletion) + * @param integer $beforeRow Number of the row we're inserting/deleting before + * @param integer $pNumRows Number of rows to insert/delete (negative values indicate deletion) + */ + protected function _adjustProtectedCells($pSheet, $pBefore, $beforeColumnIndex, $pNumCols, $beforeRow, $pNumRows) + { + $aProtectedCells = $pSheet->getProtectedCells(); + ($pNumCols > 0 || $pNumRows > 0) ? + uksort($aProtectedCells, array('PHPExcel_ReferenceHelper','cellReverseSort')) : + uksort($aProtectedCells, array('PHPExcel_ReferenceHelper','cellSort')); + foreach ($aProtectedCells as $key => $value) { + $newReference = $this->updateCellReference($key, $pBefore, $pNumCols, $pNumRows); + if ($key != $newReference) { + $pSheet->protectCells( $newReference, $value, true ); + $pSheet->unprotectCells( $key ); + } + } + } + + /** + * Update column dimensions when inserting/deleting rows/columns + * + * @param PHPExcel_Worksheet $pSheet The worksheet that we're editing + * @param string $pBefore Insert/Delete before this cell address (e.g. 'A1') + * @param integer $beforeColumnIndex Index number of the column we're inserting/deleting before + * @param integer $pNumCols Number of columns to insert/delete (negative values indicate deletion) + * @param integer $beforeRow Number of the row we're inserting/deleting before + * @param integer $pNumRows Number of rows to insert/delete (negative values indicate deletion) + */ + protected function _adjustColumnDimensions($pSheet, $pBefore, $beforeColumnIndex, $pNumCols, $beforeRow, $pNumRows) + { + $aColumnDimensions = array_reverse($pSheet->getColumnDimensions(), true); + if (!empty($aColumnDimensions)) { + foreach ($aColumnDimensions as $objColumnDimension) { + $newReference = $this->updateCellReference($objColumnDimension->getColumnIndex() . '1', $pBefore, $pNumCols, $pNumRows); + list($newReference) = PHPExcel_Cell::coordinateFromString($newReference); + if ($objColumnDimension->getColumnIndex() != $newReference) { + $objColumnDimension->setColumnIndex($newReference); + } + } + $pSheet->refreshColumnDimensions(); + } + } + + /** + * Update row dimensions when inserting/deleting rows/columns + * + * @param PHPExcel_Worksheet $pSheet The worksheet that we're editing + * @param string $pBefore Insert/Delete before this cell address (e.g. 'A1') + * @param integer $beforeColumnIndex Index number of the column we're inserting/deleting before + * @param integer $pNumCols Number of columns to insert/delete (negative values indicate deletion) + * @param integer $beforeRow Number of the row we're inserting/deleting before + * @param integer $pNumRows Number of rows to insert/delete (negative values indicate deletion) + */ + protected function _adjustRowDimensions($pSheet, $pBefore, $beforeColumnIndex, $pNumCols, $beforeRow, $pNumRows) + { + $aRowDimensions = array_reverse($pSheet->getRowDimensions(), true); + if (!empty($aRowDimensions)) { + foreach ($aRowDimensions as $objRowDimension) { + $newReference = $this->updateCellReference('A' . $objRowDimension->getRowIndex(), $pBefore, $pNumCols, $pNumRows); + list(, $newReference) = PHPExcel_Cell::coordinateFromString($newReference); + if ($objRowDimension->getRowIndex() != $newReference) { + $objRowDimension->setRowIndex($newReference); + } + } + $pSheet->refreshRowDimensions(); + + $copyDimension = $pSheet->getRowDimension($beforeRow - 1); + for ($i = $beforeRow; $i <= $beforeRow - 1 + $pNumRows; ++$i) { + $newDimension = $pSheet->getRowDimension($i); + $newDimension->setRowHeight($copyDimension->getRowHeight()); + $newDimension->setVisible($copyDimension->getVisible()); + $newDimension->setOutlineLevel($copyDimension->getOutlineLevel()); + $newDimension->setCollapsed($copyDimension->getCollapsed()); + } + } + } + + /** + * Insert a new column or row, updating all possible related data + * + * @param string $pBefore Insert before this cell address (e.g. 'A1') + * @param integer $pNumCols Number of columns to insert/delete (negative values indicate deletion) + * @param integer $pNumRows Number of rows to insert/delete (negative values indicate deletion) + * @param PHPExcel_Worksheet $pSheet The worksheet that we're editing + * @throws PHPExcel_Exception + */ + public function insertNewBefore($pBefore = 'A1', $pNumCols = 0, $pNumRows = 0, PHPExcel_Worksheet $pSheet = NULL) + { + $remove = ($pNumCols < 0 || $pNumRows < 0); $aCellCollection = $pSheet->getCellCollection(); // Get coordinates of $pBefore $beforeColumn = 'A'; $beforeRow = 1; - list($beforeColumn, $beforeRow) = PHPExcel_Cell::coordinateFromString( $pBefore ); - + list($beforeColumn, $beforeRow) = PHPExcel_Cell::coordinateFromString($pBefore); + $beforeColumnIndex = PHPExcel_Cell::columnIndexFromString($beforeColumn); // Clear cells if we are removing columns or rows $highestColumn = $pSheet->getHighestColumn(); $highestRow = $pSheet->getHighestRow(); // 1. Clear column strips if we are removing columns - if ($pNumCols < 0 && PHPExcel_Cell::columnIndexFromString($beforeColumn) - 2 + $pNumCols > 0) { + if ($pNumCols < 0 && $beforeColumnIndex - 2 + $pNumCols > 0) { for ($i = 1; $i <= $highestRow - 1; ++$i) { - for ($j = PHPExcel_Cell::columnIndexFromString($beforeColumn) - 1 + $pNumCols; $j <= PHPExcel_Cell::columnIndexFromString($beforeColumn) - 2; ++$j) { + for ($j = $beforeColumnIndex - 1 + $pNumCols; $j <= $beforeColumnIndex - 2; ++$j) { $coordinate = PHPExcel_Cell::stringFromColumnIndex($j) . $i; $pSheet->removeConditionalStyles($coordinate); if ($pSheet->cellExists($coordinate)) { @@ -105,7 +411,7 @@ class PHPExcel_ReferenceHelper // 2. Clear row strips if we are removing rows if ($pNumRows < 0 && $beforeRow - 1 + $pNumRows > 0) { - for ($i = PHPExcel_Cell::columnIndexFromString($beforeColumn) - 1; $i <= PHPExcel_Cell::columnIndexFromString($highestColumn) - 1; ++$i) { + for ($i = $beforeColumnIndex - 1; $i <= PHPExcel_Cell::columnIndexFromString($highestColumn) - 1; ++$i) { for ($j = $beforeRow + $pNumRows; $j <= $beforeRow - 1; ++$j) { $coordinate = PHPExcel_Cell::stringFromColumnIndex($i) . $j; $pSheet->removeConditionalStyles($coordinate); @@ -117,21 +423,28 @@ class PHPExcel_ReferenceHelper } } - // Loop through cells, bottom-up, and change cell coordinates - while (($cellID = ($pNumCols < 0 || $pNumRows < 0) ? array_shift($aCellCollection) : array_pop($aCellCollection))) { + if($remove) { + // It's faster to reverse and pop than to use unshift, especially with large cell collections + $aCellCollection = array_reverse($aCellCollection); + } + while ($cellID = array_pop($aCellCollection)) { $cell = $pSheet->getCell($cellID); + $cellIndex = PHPExcel_Cell::columnIndexFromString($cell->getColumn()); + + if ($cellIndex-1 + $pNumCols < 0) { + continue; + } // New coordinates - $newCoordinates = PHPExcel_Cell::stringFromColumnIndex( PHPExcel_Cell::columnIndexFromString($cell->getColumn()) - 1 + $pNumCols ) . ($cell->getRow() + $pNumRows); + $newCoordinates = PHPExcel_Cell::stringFromColumnIndex($cellIndex-1 + $pNumCols) . ($cell->getRow() + $pNumRows); // Should the cell be updated? Move value and cellXf index from one cell to another. - if ((PHPExcel_Cell::columnIndexFromString( $cell->getColumn() ) >= PHPExcel_Cell::columnIndexFromString($beforeColumn)) && + if (($cellIndex >= $beforeColumnIndex) && ($cell->getRow() >= $beforeRow)) { // Update cell styles $pSheet->getCell($newCoordinates)->setXfIndex($cell->getXfIndex()); - $cell->setXfIndex(0); // Insert this cell at its new location if ($cell->getDataType() == PHPExcel_Cell_DataType::TYPE_FORMULA) { @@ -145,7 +458,7 @@ class PHPExcel_ReferenceHelper } // Clear the original cell - $pSheet->getCell($cell->getCoordinate())->setValue(''); + $pSheet->getCellCacheController()->deleteCacheData($cellID); } else { /* We don't need to update styles for rows/columns before our insertion position, @@ -159,21 +472,20 @@ class PHPExcel_ReferenceHelper } } - // Duplicate styles for the newly inserted cells $highestColumn = $pSheet->getHighestColumn(); $highestRow = $pSheet->getHighestRow(); - if ($pNumCols > 0 && PHPExcel_Cell::columnIndexFromString($beforeColumn) - 2 > 0) { + if ($pNumCols > 0 && $beforeColumnIndex - 2 > 0) { for ($i = $beforeRow; $i <= $highestRow - 1; ++$i) { // Style - $coordinate = PHPExcel_Cell::stringFromColumnIndex( PHPExcel_Cell::columnIndexFromString($beforeColumn) - 2 ) . $i; + $coordinate = PHPExcel_Cell::stringFromColumnIndex( $beforeColumnIndex - 2 ) . $i; if ($pSheet->cellExists($coordinate)) { $xfIndex = $pSheet->getCell($coordinate)->getXfIndex(); $conditionalStyles = $pSheet->conditionalStylesExists($coordinate) ? $pSheet->getConditionalStyles($coordinate) : false; - for ($j = PHPExcel_Cell::columnIndexFromString($beforeColumn) - 1; $j <= PHPExcel_Cell::columnIndexFromString($beforeColumn) - 2 + $pNumCols; ++$j) { + for ($j = $beforeColumnIndex - 1; $j <= $beforeColumnIndex - 2 + $pNumCols; ++$j) { $pSheet->getCellByColumnAndRow($j, $i)->setXfIndex($xfIndex); if ($conditionalStyles) { $cloned = array(); @@ -189,7 +501,7 @@ class PHPExcel_ReferenceHelper } if ($pNumRows > 0 && $beforeRow - 1 > 0) { - for ($i = PHPExcel_Cell::columnIndexFromString($beforeColumn) - 1; $i <= PHPExcel_Cell::columnIndexFromString($highestColumn) - 1; ++$i) { + for ($i = $beforeColumnIndex - 1; $i <= PHPExcel_Cell::columnIndexFromString($highestColumn) - 1; ++$i) { // Style $coordinate = PHPExcel_Cell::stringFromColumnIndex($i) . ($beforeRow - 1); @@ -211,105 +523,29 @@ class PHPExcel_ReferenceHelper } } - // Update worksheet: column dimensions - $aColumnDimensions = array_reverse($pSheet->getColumnDimensions(), true); - if (!empty($aColumnDimensions)) { - foreach ($aColumnDimensions as $objColumnDimension) { - $newReference = $this->updateCellReference($objColumnDimension->getColumnIndex() . '1', $pBefore, $pNumCols, $pNumRows); - list($newReference) = PHPExcel_Cell::coordinateFromString($newReference); - if ($objColumnDimension->getColumnIndex() != $newReference) { - $objColumnDimension->setColumnIndex($newReference); - } - } - $pSheet->refreshColumnDimensions(); - } - + $this->_adjustColumnDimensions($pSheet, $pBefore, $beforeColumnIndex, $pNumCols, $beforeRow, $pNumRows); // Update worksheet: row dimensions - $aRowDimensions = array_reverse($pSheet->getRowDimensions(), true); - if (!empty($aRowDimensions)) { - foreach ($aRowDimensions as $objRowDimension) { - $newReference = $this->updateCellReference('A' . $objRowDimension->getRowIndex(), $pBefore, $pNumCols, $pNumRows); - list(, $newReference) = PHPExcel_Cell::coordinateFromString($newReference); - if ($objRowDimension->getRowIndex() != $newReference) { - $objRowDimension->setRowIndex($newReference); - } - } - $pSheet->refreshRowDimensions(); + $this->_adjustRowDimensions($pSheet, $pBefore, $beforeColumnIndex, $pNumCols, $beforeRow, $pNumRows); - $copyDimension = $pSheet->getRowDimension($beforeRow - 1); - for ($i = $beforeRow; $i <= $beforeRow - 1 + $pNumRows; ++$i) { - $newDimension = $pSheet->getRowDimension($i); - $newDimension->setRowHeight($copyDimension->getRowHeight()); - $newDimension->setVisible($copyDimension->getVisible()); - $newDimension->setOutlineLevel($copyDimension->getOutlineLevel()); - $newDimension->setCollapsed($copyDimension->getCollapsed()); - } - } + // Update worksheet: page breaks + $this->_adjustPageBreaks($pSheet, $pBefore, $beforeColumnIndex, $pNumCols, $beforeRow, $pNumRows); - - // Update worksheet: breaks - $aBreaks = array_reverse($pSheet->getBreaks(), true); - foreach ($aBreaks as $key => $value) { - $newReference = $this->updateCellReference($key, $pBefore, $pNumCols, $pNumRows); - if ($key != $newReference) { - $pSheet->setBreak( $newReference, $value ); - $pSheet->setBreak( $key, PHPExcel_Worksheet::BREAK_NONE ); - } - } - - // Update worksheet: comments - $aComments = $pSheet->getComments(); - $aNewComments = array(); // the new array of all comments - foreach ($aComments as $key => &$value) { - $newReference = $this->updateCellReference($key, $pBefore, $pNumCols, $pNumRows); - $aNewComments[$newReference] = $value; - } - $pSheet->setComments($aNewComments); // replace the comments array + // Update worksheet: comments + $this->_adjustComments($pSheet, $pBefore, $beforeColumnIndex, $pNumCols, $beforeRow, $pNumRows); // Update worksheet: hyperlinks - $aHyperlinkCollection = array_reverse($pSheet->getHyperlinkCollection(), true); - foreach ($aHyperlinkCollection as $key => $value) { - $newReference = $this->updateCellReference($key, $pBefore, $pNumCols, $pNumRows); - if ($key != $newReference) { - $pSheet->setHyperlink( $newReference, $value ); - $pSheet->setHyperlink( $key, null ); - } - } - + $this->_adjustHyperlinks($pSheet, $pBefore, $beforeColumnIndex, $pNumCols, $beforeRow, $pNumRows); // Update worksheet: data validations - $aDataValidationCollection = array_reverse($pSheet->getDataValidationCollection(), true); - foreach ($aDataValidationCollection as $key => $value) { - $newReference = $this->updateCellReference($key, $pBefore, $pNumCols, $pNumRows); - if ($key != $newReference) { - $pSheet->setDataValidation( $newReference, $value ); - $pSheet->setDataValidation( $key, null ); - } - } - + $this->_adjustDataValidations($pSheet, $pBefore, $beforeColumnIndex, $pNumCols, $beforeRow, $pNumRows); // Update worksheet: merge cells - $aMergeCells = $pSheet->getMergeCells(); - $aNewMergeCells = array(); // the new array of all merge cells - foreach ($aMergeCells as $key => &$value) { - $newReference = $this->updateCellReference($key, $pBefore, $pNumCols, $pNumRows); - $aNewMergeCells[$newReference] = $newReference; - } - $pSheet->setMergeCells($aNewMergeCells); // replace the merge cells array - + $this->_adjustMergeCells($pSheet, $pBefore, $beforeColumnIndex, $pNumCols, $beforeRow, $pNumRows); // Update worksheet: protected cells - $aProtectedCells = array_reverse($pSheet->getProtectedCells(), true); - foreach ($aProtectedCells as $key => $value) { - $newReference = $this->updateCellReference($key, $pBefore, $pNumCols, $pNumRows); - if ($key != $newReference) { - $pSheet->protectCells( $newReference, $value, true ); - $pSheet->unprotectCells( $key ); - } - } - + $this->_adjustProtectedCells($pSheet, $pBefore, $beforeColumnIndex, $pNumCols, $beforeRow, $pNumRows); // Update worksheet: autofilter $autoFilter = $pSheet->getAutoFilter(); @@ -318,7 +554,7 @@ class PHPExcel_ReferenceHelper if ($pNumCols != 0) { $autoFilterColumns = array_keys($autoFilter->getColumns()); if (count($autoFilterColumns) > 0) { - list($column,$row) = sscanf($pBefore,'%[A-Z]%d'); + sscanf($pBefore,'%[A-Z]%d', $column, $row); $columnIndex = PHPExcel_Cell::columnIndexFromString($column); list($rangeStart,$rangeEnd) = PHPExcel_Cell::rangeBoundaries($autoFilterRange); if ($columnIndex <= $rangeEnd[0]) { @@ -369,19 +605,16 @@ class PHPExcel_ReferenceHelper $pSheet->setAutoFilter( $this->updateCellReference($autoFilterRange, $pBefore, $pNumCols, $pNumRows) ); } - // Update worksheet: freeze pane if ($pSheet->getFreezePane() != '') { $pSheet->freezePane( $this->updateCellReference($pSheet->getFreezePane(), $pBefore, $pNumCols, $pNumRows) ); } - // Page setup if ($pSheet->getPageSetup()->isPrintAreaSet()) { $pSheet->getPageSetup()->setPrintArea( $this->updateCellReference($pSheet->getPageSetup()->getPrintArea(), $pBefore, $pNumCols, $pNumRows) ); } - // Update worksheet: drawings $aDrawings = $pSheet->getDrawingCollection(); foreach ($aDrawings as $objDrawing) { @@ -391,7 +624,6 @@ class PHPExcel_ReferenceHelper } } - // Update workbook: named ranges if (count($pSheet->getParent()->getNamedRanges()) > 0) { foreach ($pSheet->getParent()->getNamedRanges() as $namedRange) { @@ -414,8 +646,9 @@ class PHPExcel_ReferenceHelper * @param int $pBefore Insert before this one * @param int $pNumCols Number of columns to insert * @param int $pNumRows Number of rows to insert + * @param string $sheetName Worksheet name/title * @return string Updated formula - * @throws Exception + * @throws PHPExcel_Exception */ public function updateFormulaReferences($pFormula = '', $pBefore = 'A1', $pNumCols = 0, $pNumRows = 0, $sheetName = '') { // Update cell references in the formula @@ -445,7 +678,7 @@ class PHPExcel_ReferenceHelper $cellIndex = $column.$row; $newCellTokens[$cellIndex] = preg_quote($toString); - $cellTokens[$cellIndex] = '/(? 0) { foreach($matches as $match) { $fromString = ($match[2] > '') ? $match[2].'!' : ''; $fromString .= $match[3]; - $modified3 = $this->updateCellReference($match[3],$pBefore,$pNumCols,$pNumRows); + $modified3 = $this->updateCellReference($match[3],$pBefore,$pNumCols,$pNumRows); if ($match[3] !== $modified3) { if (($match[2] == '') || (trim($match[2],"'") == $sheetName)) { $toString = ($match[2] > '') ? $match[2].'!' : ''; @@ -518,19 +752,23 @@ class PHPExcel_ReferenceHelper // Max worksheet size is 1,048,576 rows by 16,384 columns in Excel 2007, so our adjustments need to be at least one digit more $column = PHPExcel_Cell::columnIndexFromString(trim($column,'$')) + 100000; $row = trim($row,'$') + 10000000; - $cellIndex = $column.$row; + $cellIndex = $row . $column; $newCellTokens[$cellIndex] = preg_quote($toString); - $cellTokens[$cellIndex] = '/(? 0) { - krsort($cellTokens); - krsort($newCellTokens); - // Update cell references in the formula + if ($pNumCols > 0 || $pNumRows > 0) { + krsort($cellTokens); + krsort($newCellTokens); + } else { + ksort($cellTokens); + ksort($newCellTokens); + } // Update cell references in the formula $formulaBlock = str_replace('\\','',preg_replace($cellTokens,$newCellTokens,$formulaBlock)); } } @@ -549,7 +787,7 @@ class PHPExcel_ReferenceHelper * @param int $pNumCols Number of columns to increment * @param int $pNumRows Number of rows to increment * @return string Updated cell range - * @throws Exception + * @throws PHPExcel_Exception */ public function updateCellReference($pCellRange = 'A1', $pBefore = 'A1', $pNumCols = 0, $pNumRows = 0) { // Is it in another worksheet? Will not have to update anything. @@ -603,7 +841,7 @@ class PHPExcel_ReferenceHelper * @param int $pNumCols Number of columns to increment * @param int $pNumRows Number of rows to increment * @return string Updated cell range - * @throws Exception + * @throws PHPExcel_Exception */ private function _updateCellRange($pCellRange = 'A1:A1', $pBefore = 'A1', $pNumCols = 0, $pNumRows = 0) { if (strpos($pCellRange,':') !== false || strpos($pCellRange, ',') !== false) { @@ -628,7 +866,7 @@ class PHPExcel_ReferenceHelper // Recreate range string return PHPExcel_Cell::buildRange($range); } else { - throw new Exception("Only cell ranges may be passed to this method."); + throw new PHPExcel_Exception("Only cell ranges may be passed to this method."); } } @@ -640,7 +878,7 @@ class PHPExcel_ReferenceHelper * @param int $pNumCols Number of columns to increment * @param int $pNumRows Number of rows to increment * @return string Updated cell reference - * @throws Exception + * @throws PHPExcel_Exception */ private function _updateSingleCellReference($pCellReference = 'A1', $pBefore = 'A1', $pNumCols = 0, $pNumRows = 0) { if (strpos($pCellReference, ':') === false && strpos($pCellReference, ',') === false) { @@ -653,7 +891,6 @@ class PHPExcel_ReferenceHelper // Verify which parts should be updated $updateColumn = (($newColumn{0} != '$') && ($beforeColumn{0} != '$') && PHPExcel_Cell::columnIndexFromString($newColumn) >= PHPExcel_Cell::columnIndexFromString($beforeColumn)); - $updateRow = (($newRow{0} != '$') && ($beforeRow{0} != '$') && $newRow >= $beforeRow); @@ -670,16 +907,16 @@ class PHPExcel_ReferenceHelper // Return new reference return $newColumn . $newRow; } else { - throw new Exception("Only single cell references may be passed to this method."); + throw new PHPExcel_Exception("Only single cell references may be passed to this method."); } } /** * __clone implementation. Cloning should not be allowed in a Singleton! * - * @throws Exception + * @throws PHPExcel_Exception */ public final function __clone() { - throw new Exception("Cloning a Singleton is not allowed!"); + throw new PHPExcel_Exception("Cloning a Singleton is not allowed!"); } } diff --git a/htdocs/includes/phpexcel/PHPExcel/RichText.php b/htdocs/includes/phpexcel/PHPExcel/RichText.php index 17af169cdd6..2f172a0512b 100644 --- a/htdocs/includes/phpexcel/PHPExcel/RichText.php +++ b/htdocs/includes/phpexcel/PHPExcel/RichText.php @@ -2,7 +2,7 @@ /** * PHPExcel * - * Copyright (c) 2006 - 2012 PHPExcel + * Copyright (c) 2006 - 2014 PHPExcel * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,9 +20,9 @@ * * @category PHPExcel * @package PHPExcel_RichText - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version 1.7.8, 2012-10-12 + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) + * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @version 1.8.0, 2014-03-02 */ @@ -31,81 +31,81 @@ * * @category PHPExcel * @package PHPExcel_RichText - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) */ class PHPExcel_RichText implements PHPExcel_IComparable { - /** - * Rich text elements - * - * @var PHPExcel_RichText_ITextElement[] - */ - private $_richTextElements; + /** + * Rich text elements + * + * @var PHPExcel_RichText_ITextElement[] + */ + private $_richTextElements; /** * Create a new PHPExcel_RichText instance * - * @param PHPExcel_Cell $pParent - * @throws Exception + * @param PHPExcel_Cell $pCell + * @throws PHPExcel_Exception */ public function __construct(PHPExcel_Cell $pCell = null) { - // Initialise variables - $this->_richTextElements = array(); + // Initialise variables + $this->_richTextElements = array(); - // Rich-Text string attached to cell? - if ($pCell !== NULL) { - // Add cell text and style - if ($pCell->getValue() != "") { - $objRun = new PHPExcel_RichText_Run($pCell->getValue()); - $objRun->setFont(clone $pCell->getParent()->getStyle($pCell->getCoordinate())->getFont()); - $this->addText($objRun); - } + // Rich-Text string attached to cell? + if ($pCell !== NULL) { + // Add cell text and style + if ($pCell->getValue() != "") { + $objRun = new PHPExcel_RichText_Run($pCell->getValue()); + $objRun->setFont(clone $pCell->getParent()->getStyle($pCell->getCoordinate())->getFont()); + $this->addText($objRun); + } - // Set parent value - $pCell->setValueExplicit($this, PHPExcel_Cell_DataType::TYPE_STRING); - } + // Set parent value + $pCell->setValueExplicit($this, PHPExcel_Cell_DataType::TYPE_STRING); + } } /** * Add text * - * @param PHPExcel_RichText_ITextElement $pText Rich text element - * @throws Exception + * @param PHPExcel_RichText_ITextElement $pText Rich text element + * @throws PHPExcel_Exception * @return PHPExcel_RichText */ public function addText(PHPExcel_RichText_ITextElement $pText = null) { - $this->_richTextElements[] = $pText; - return $this; + $this->_richTextElements[] = $pText; + return $this; } /** * Create text * - * @param string $pText Text - * @return PHPExcel_RichText_TextElement - * @throws Exception + * @param string $pText Text + * @return PHPExcel_RichText_TextElement + * @throws PHPExcel_Exception */ public function createText($pText = '') { - $objText = new PHPExcel_RichText_TextElement($pText); - $this->addText($objText); - return $objText; + $objText = new PHPExcel_RichText_TextElement($pText); + $this->addText($objText); + return $objText; } /** * Create text run * - * @param string $pText Text - * @return PHPExcel_RichText_Run - * @throws Exception + * @param string $pText Text + * @return PHPExcel_RichText_Run + * @throws PHPExcel_Exception */ public function createTextRun($pText = '') { - $objText = new PHPExcel_RichText_Run($pText); - $this->addText($objText); - return $objText; + $objText = new PHPExcel_RichText_Run($pText); + $this->addText($objText); + return $objText; } /** @@ -115,16 +115,16 @@ class PHPExcel_RichText implements PHPExcel_IComparable */ public function getPlainText() { - // Return value - $returnValue = ''; + // Return value + $returnValue = ''; - // Loop through all PHPExcel_RichText_ITextElement - foreach ($this->_richTextElements as $text) { - $returnValue .= $text->getText(); - } + // Loop through all PHPExcel_RichText_ITextElement + foreach ($this->_richTextElements as $text) { + $returnValue .= $text->getText(); + } - // Return - return $returnValue; + // Return + return $returnValue; } /** @@ -132,8 +132,9 @@ class PHPExcel_RichText implements PHPExcel_IComparable * * @return string */ - public function __toString() { - return $this->getPlainText(); + public function __toString() + { + return $this->getPlainText(); } /** @@ -143,54 +144,56 @@ class PHPExcel_RichText implements PHPExcel_IComparable */ public function getRichTextElements() { - return $this->_richTextElements; + return $this->_richTextElements; } /** * Set Rich Text elements * - * @param PHPExcel_RichText_ITextElement[] $pElements Array of elements - * @throws Exception + * @param PHPExcel_RichText_ITextElement[] $pElements Array of elements + * @throws PHPExcel_Exception * @return PHPExcel_RichText */ public function setRichTextElements($pElements = null) { - if (is_array($pElements)) { - $this->_richTextElements = $pElements; - } else { - throw new Exception("Invalid PHPExcel_RichText_ITextElement[] array passed."); - } - return $this; + if (is_array($pElements)) { + $this->_richTextElements = $pElements; + } else { + throw new PHPExcel_Exception("Invalid PHPExcel_RichText_ITextElement[] array passed."); + } + return $this; } - /** - * Get hash code - * - * @return string Hash code - */ - public function getHashCode() { - $hashElements = ''; - foreach ($this->_richTextElements as $element) { - $hashElements .= $element->getHashCode(); - } + /** + * Get hash code + * + * @return string Hash code + */ + public function getHashCode() + { + $hashElements = ''; + foreach ($this->_richTextElements as $element) { + $hashElements .= $element->getHashCode(); + } - return md5( - $hashElements - . __CLASS__ - ); + return md5( + $hashElements + . __CLASS__ + ); } - /** - * Implement PHP __clone to create a deep clone, not just a shallow copy. - */ - public function __clone() { - $vars = get_object_vars($this); - foreach ($vars as $key => $value) { - if (is_object($value)) { - $this->$key = clone $value; - } else { - $this->$key = $value; - } - } - } + /** + * Implement PHP __clone to create a deep clone, not just a shallow copy. + */ + public function __clone() + { + $vars = get_object_vars($this); + foreach ($vars as $key => $value) { + if (is_object($value)) { + $this->$key = clone $value; + } else { + $this->$key = $value; + } + } + } } diff --git a/htdocs/includes/phpexcel/PHPExcel/RichText/ITextElement.php b/htdocs/includes/phpexcel/PHPExcel/RichText/ITextElement.php index 4c658637f62..ec19498d06c 100644 --- a/htdocs/includes/phpexcel/PHPExcel/RichText/ITextElement.php +++ b/htdocs/includes/phpexcel/PHPExcel/RichText/ITextElement.php @@ -18,9 +18,9 @@ * * @category PHPExcel * @package PHPExcel_RichText - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version 1.7.8, 2012-10-12 + * @version 1.8.0, 2014-03-02 */ @@ -29,7 +29,7 @@ * * @category PHPExcel * @package PHPExcel_RichText - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) */ interface PHPExcel_RichText_ITextElement { diff --git a/htdocs/includes/phpexcel/PHPExcel/RichText/Run.php b/htdocs/includes/phpexcel/PHPExcel/RichText/Run.php index 9e33786c195..71545fc2e39 100644 --- a/htdocs/includes/phpexcel/PHPExcel/RichText/Run.php +++ b/htdocs/includes/phpexcel/PHPExcel/RichText/Run.php @@ -18,9 +18,9 @@ * * @category PHPExcel * @package PHPExcel_RichText - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version 1.7.8, 2012-10-12 + * @version 1.8.0, 2014-03-02 */ @@ -29,7 +29,7 @@ * * @category PHPExcel * @package PHPExcel_RichText - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) */ class PHPExcel_RichText_Run extends PHPExcel_RichText_TextElement implements PHPExcel_RichText_ITextElement { @@ -65,7 +65,7 @@ class PHPExcel_RichText_Run extends PHPExcel_RichText_TextElement implements PHP * Set font * * @param PHPExcel_Style_Font $pFont Font - * @throws Exception + * @throws PHPExcel_Exception * @return PHPExcel_RichText_ITextElement */ public function setFont(PHPExcel_Style_Font $pFont = null) { diff --git a/htdocs/includes/phpexcel/PHPExcel/RichText/TextElement.php b/htdocs/includes/phpexcel/PHPExcel/RichText/TextElement.php index 5b9edd07ee4..3593c6e19c0 100644 --- a/htdocs/includes/phpexcel/PHPExcel/RichText/TextElement.php +++ b/htdocs/includes/phpexcel/PHPExcel/RichText/TextElement.php @@ -18,9 +18,9 @@ * * @category PHPExcel * @package PHPExcel_RichText - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version 1.7.8, 2012-10-12 + * @version 1.8.0, 2014-03-02 */ @@ -29,7 +29,7 @@ * * @category PHPExcel * @package PHPExcel_RichText - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) */ class PHPExcel_RichText_TextElement implements PHPExcel_RichText_ITextElement { diff --git a/htdocs/includes/phpexcel/PHPExcel/Settings.php b/htdocs/includes/phpexcel/PHPExcel/Settings.php index 6659b90e956..b89961320e4 100644 --- a/htdocs/includes/phpexcel/PHPExcel/Settings.php +++ b/htdocs/includes/phpexcel/PHPExcel/Settings.php @@ -2,7 +2,7 @@ /** * PHPExcel * - * Copyright (c) 2006 - 2012 PHPExcel + * Copyright (c) 2006 - 2014 PHPExcel * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,313 +20,368 @@ * * @category PHPExcel * @package PHPExcel_Settings - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version 1.7.8, 2012-10-12 + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) + * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @version 1.8.0, 2014-03-02 */ /** PHPExcel root directory */ if (!defined('PHPEXCEL_ROOT')) { - /** - * @ignore - */ - define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../'); - require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php'); + /** + * @ignore + */ + define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../'); + require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php'); } class PHPExcel_Settings { - /** constants */ - /** Available Zip library classes */ - const PCLZIP = 'PHPExcel_Shared_ZipArchive'; - const ZIPARCHIVE = 'ZipArchive'; + /** constants */ + /** Available Zip library classes */ + const PCLZIP = 'PHPExcel_Shared_ZipArchive'; + const ZIPARCHIVE = 'ZipArchive'; - /** Optional Chart Rendering libraries */ - const CHART_RENDERER_JPGRAPH = 'jpgraph'; + /** Optional Chart Rendering libraries */ + const CHART_RENDERER_JPGRAPH = 'jpgraph'; - /** Optional PDF Rendering libraries */ + /** Optional PDF Rendering libraries */ const PDF_RENDERER_TCPDF = 'tcPDF'; const PDF_RENDERER_DOMPDF = 'DomPDF'; - const PDF_RENDERER_MPDF = 'mPDF'; + const PDF_RENDERER_MPDF = 'mPDF'; - private static $_chartRenderers = array( - self::CHART_RENDERER_JPGRAPH, - ); + private static $_chartRenderers = array( + self::CHART_RENDERER_JPGRAPH, + ); - private static $_pdfRenderers = array( - self::PDF_RENDERER_TCPDF, - self::PDF_RENDERER_DOMPDF, - self::PDF_RENDERER_MPDF, - ); + private static $_pdfRenderers = array( + self::PDF_RENDERER_TCPDF, + self::PDF_RENDERER_DOMPDF, + self::PDF_RENDERER_MPDF, + ); - /** - * Name of the class used for Zip file management - * e.g. - * ZipArchive - * - * @var string - */ - private static $_zipClass = self::ZIPARCHIVE; + /** + * Name of the class used for Zip file management + * e.g. + * ZipArchive + * + * @var string + */ + private static $_zipClass = self::ZIPARCHIVE; - /** - * Name of the external Library used for rendering charts - * e.g. - * jpgraph - * - * @var string - */ - private static $_chartRendererName = NULL; + /** + * Name of the external Library used for rendering charts + * e.g. + * jpgraph + * + * @var string + */ + private static $_chartRendererName = NULL; - /** - * Directory Path to the external Library used for rendering charts - * - * @var string - */ - private static $_chartRendererPath = NULL; + /** + * Directory Path to the external Library used for rendering charts + * + * @var string + */ + private static $_chartRendererPath = NULL; - /** - * Name of the external Library used for rendering PDF files - * e.g. - * mPDF - * - * @var string - */ - private static $_pdfRendererName = NULL; + /** + * Name of the external Library used for rendering PDF files + * e.g. + * mPDF + * + * @var string + */ + private static $_pdfRendererName = NULL; - /** - * Directory Path to the external Library used for rendering PDF files - * - * @var string - */ - private static $_pdfRendererPath = NULL; + /** + * Directory Path to the external Library used for rendering PDF files + * + * @var string + */ + private static $_pdfRendererPath = NULL; + + /** + * Default options for libxml loader + * + * @var int + */ + private static $_libXmlLoaderOptions = null; + + /** + * Set the Zip handler Class that PHPExcel should use for Zip file management (PCLZip or ZipArchive) + * + * @param string $zipClass The Zip handler class that PHPExcel should use for Zip file management + * e.g. PHPExcel_Settings::PCLZip or PHPExcel_Settings::ZipArchive + * @return boolean Success or failure + */ + public static function setZipClass($zipClass) + { + if (($zipClass === self::PCLZIP) || + ($zipClass === self::ZIPARCHIVE)) { + self::$_zipClass = $zipClass; + return TRUE; + } + return FALSE; + } // function setZipClass() - /** - * Set the Zip handler Class that PHPExcel should use for Zip file management (PCLZip or ZipArchive) - * - * @param string $zipClass The Zip handler class that PHPExcel should use for Zip file management - * e.g. PHPExcel_Settings::PCLZip or PHPExcel_Settings::ZipArchive - * @return boolean Success or failure - */ - public static function setZipClass($zipClass) { - if (($zipClass === self::PCLZIP) || - ($zipClass === self::ZIPARCHIVE)) { - self::$_zipClass = $zipClass; - return TRUE; - } - return FALSE; - } // function setZipClass() + /** + * Return the name of the Zip handler Class that PHPExcel is configured to use (PCLZip or ZipArchive) + * or Zip file management + * + * @return string Name of the Zip handler Class that PHPExcel is configured to use + * for Zip file management + * e.g. PHPExcel_Settings::PCLZip or PHPExcel_Settings::ZipArchive + */ + public static function getZipClass() + { + return self::$_zipClass; + } // function getZipClass() - /** - * Return the name of the Zip handler Class that PHPExcel is configured to use (PCLZip or ZipArchive) - * for Zip file management - * - * @return string Name of the Zip handler Class that PHPExcel is configured to use - * for Zip file management - * e.g. PHPExcel_Settings::PCLZip or PHPExcel_Settings::ZipArchive - */ - public static function getZipClass() { - return self::$_zipClass; - } // function getZipClass() + /** + * Return the name of the method that is currently configured for cell cacheing + * + * @return string Name of the cacheing method + */ + public static function getCacheStorageMethod() + { + return PHPExcel_CachedObjectStorageFactory::getCacheStorageMethod(); + } // function getCacheStorageMethod() - /** - * Return the name of the method that is currently configured for cell cacheing - * - * @return string Name of the cacheing method - */ - public static function getCacheStorageMethod() { - return PHPExcel_CachedObjectStorageFactory::getCacheStorageMethod(); - } // function getCacheStorageMethod() + /** + * Return the name of the class that is currently being used for cell cacheing + * + * @return string Name of the class currently being used for cacheing + */ + public static function getCacheStorageClass() + { + return PHPExcel_CachedObjectStorageFactory::getCacheStorageClass(); + } // function getCacheStorageClass() - /** - * Return the name of the class that is currently being used for cell cacheing - * - * @return string Name of the class currently being used for cacheing - */ - public static function getCacheStorageClass() { - return PHPExcel_CachedObjectStorageFactory::getCacheStorageClass(); - } // function getCacheStorageClass() + /** + * Set the method that should be used for cell cacheing + * + * @param string $method Name of the cacheing method + * @param array $arguments Optional configuration arguments for the cacheing method + * @return boolean Success or failure + */ + public static function setCacheStorageMethod( + $method = PHPExcel_CachedObjectStorageFactory::cache_in_memory, + $arguments = array() + ) + { + return PHPExcel_CachedObjectStorageFactory::initialize($method, $arguments); + } // function setCacheStorageMethod() - /** - * Set the method that should be used for cell cacheing - * - * @param string $method Name of the cacheing method - * @param array $arguments Optional configuration arguments for the cacheing method - * @return boolean Success or failure - */ - public static function setCacheStorageMethod($method = PHPExcel_CachedObjectStorageFactory::cache_in_memory, - $arguments = array()) { - return PHPExcel_CachedObjectStorageFactory::initialize($method, $arguments); - } // function setCacheStorageMethod() + /** + * Set the locale code to use for formula translations and any special formatting + * + * @param string $locale The locale code to use (e.g. "fr" or "pt_br" or "en_uk") + * @return boolean Success or failure + */ + public static function setLocale($locale='en_us') + { + return PHPExcel_Calculation::getInstance()->setLocale($locale); + } // function setLocale() - /** - * Set the locale code to use for formula translations and any special formatting - * - * @param string $locale The locale code to use (e.g. "fr" or "pt_br" or "en_uk") - * @return boolean Success or failure - */ - public static function setLocale($locale='en_us') { - return PHPExcel_Calculation::getInstance()->setLocale($locale); - } // function setLocale() + /** + * Set details of the external library that PHPExcel should use for rendering charts + * + * @param string $libraryName Internal reference name of the library + * e.g. PHPExcel_Settings::CHART_RENDERER_JPGRAPH + * @param string $libraryBaseDir Directory path to the library's base folder + * + * @return boolean Success or failure + */ + public static function setChartRenderer($libraryName, $libraryBaseDir) + { + if (!self::setChartRendererName($libraryName)) + return FALSE; + return self::setChartRendererPath($libraryBaseDir); + } // function setChartRenderer() - /** - * Set details of the external library that PHPExcel should use for rendering charts - * - * @param string $libraryName Internal reference name of the library - * e.g. PHPExcel_Settings::CHART_RENDERER_JPGRAPH - * @param string $libraryBaseDir Directory path to the library's base folder - * @return boolean Success or failure - */ - public static function setChartRenderer($libraryName, $libraryBaseDir) { - if (!self::setChartRendererName($libraryName)) - return FALSE; - return self::setChartRendererPath($libraryBaseDir); - } // function setChartRenderer() + /** + * Identify to PHPExcel the external library to use for rendering charts + * + * @param string $libraryName Internal reference name of the library + * e.g. PHPExcel_Settings::CHART_RENDERER_JPGRAPH + * + * @return boolean Success or failure + */ + public static function setChartRendererName($libraryName) + { + if (!in_array($libraryName,self::$_chartRenderers)) { + return FALSE; + } + + self::$_chartRendererName = $libraryName; + + return TRUE; + } // function setChartRendererName() - /** - * Identify to PHPExcel the external library to use for rendering charts - * - * @param string $libraryName Internal reference name of the library - * e.g. PHPExcel_Settings::CHART_RENDERER_JPGRAPH - * @return boolean Success or failure - */ - public static function setChartRendererName($libraryName) { - if (!in_array($libraryName,self::$_chartRenderers)) { - return FALSE; - } + /** + * Tell PHPExcel where to find the external library to use for rendering charts + * + * @param string $libraryBaseDir Directory path to the library's base folder + * @return boolean Success or failure + */ + public static function setChartRendererPath($libraryBaseDir) + { + if ((file_exists($libraryBaseDir) === false) || (is_readable($libraryBaseDir) === false)) { + return FALSE; + } + self::$_chartRendererPath = $libraryBaseDir; - self::$_chartRendererName = $libraryName; - - return TRUE; - } // function setChartRendererName() + return TRUE; + } // function setChartRendererPath() - /** - * Tell PHPExcel where to find the external library to use for rendering charts - * - * @param string $libraryBaseDir Directory path to the library's base folder - * @return boolean Success or failure - */ - public static function setChartRendererPath($libraryBaseDir) { - if ((file_exists($libraryBaseDir) === false) || (is_readable($libraryBaseDir) === false)) { - return FALSE; - } - self::$_chartRendererPath = $libraryBaseDir; - - return TRUE; - } // function setChartRendererPath() + /** + * Return the Chart Rendering Library that PHPExcel is currently configured to use (e.g. jpgraph) + * + * @return string|NULL Internal reference name of the Chart Rendering Library that PHPExcel is + * currently configured to use + * e.g. PHPExcel_Settings::CHART_RENDERER_JPGRAPH + */ + public static function getChartRendererName() + { + return self::$_chartRendererName; + } // function getChartRendererName() - /** - * Return the Chart Rendering Library that PHPExcel is currently configured to use (e.g. jpgraph) - * - * @return string|NULL Internal reference name of the Chart Rendering Library that PHPExcel is - * currently configured to use - * e.g. PHPExcel_Settings::CHART_RENDERER_JPGRAPH - */ - public static function getChartRendererName() { - return self::$_chartRendererName; - } // function getChartRendererName() + /** + * Return the directory path to the Chart Rendering Library that PHPExcel is currently configured to use + * + * @return string|NULL Directory Path to the Chart Rendering Library that PHPExcel is + * currently configured to use + */ + public static function getChartRendererPath() + { + return self::$_chartRendererPath; + } // function getChartRendererPath() - /** - * Return the directory path to the Chart Rendering Library that PHPExcel is currently configured to use - * - * @return string|NULL Directory Path to the Chart Rendering Library that PHPExcel is - * currently configured to use - */ - public static function getChartRendererPath() { - return self::$_chartRendererPath; - } // function getChartRendererPath() + /** + * Set details of the external library that PHPExcel should use for rendering PDF files + * + * @param string $libraryName Internal reference name of the library + * e.g. PHPExcel_Settings::PDF_RENDERER_TCPDF, + * PHPExcel_Settings::PDF_RENDERER_DOMPDF + * or PHPExcel_Settings::PDF_RENDERER_MPDF + * @param string $libraryBaseDir Directory path to the library's base folder + * + * @return boolean Success or failure + */ + public static function setPdfRenderer($libraryName, $libraryBaseDir) + { + if (!self::setPdfRendererName($libraryName)) + return FALSE; + return self::setPdfRendererPath($libraryBaseDir); + } // function setPdfRenderer() - /** - * Set details of the external library that PHPExcel should use for rendering PDF files - * - * @param string $libraryName Internal reference name of the library - * e.g. PHPExcel_Settings::PDF_RENDERER_TCPDF, - * PHPExcel_Settings::PDF_RENDERER_DOMPDF - * or PHPExcel_Settings::PDF_RENDERER_MPDF - * @param string $libraryBaseDir Directory path to the library's base folder - * @return boolean Success or failure - */ - public static function setPdfRenderer($libraryName, $libraryBaseDir) { - if (!self::setPdfRendererName($libraryName)) - return FALSE; - return self::setPdfRendererPath($libraryBaseDir); - } // function setPdfRenderer() + /** + * Identify to PHPExcel the external library to use for rendering PDF files + * + * @param string $libraryName Internal reference name of the library + * e.g. PHPExcel_Settings::PDF_RENDERER_TCPDF, + * PHPExcel_Settings::PDF_RENDERER_DOMPDF + * or PHPExcel_Settings::PDF_RENDERER_MPDF + * + * @return boolean Success or failure + */ + public static function setPdfRendererName($libraryName) + { + if (!in_array($libraryName,self::$_pdfRenderers)) { + return FALSE; + } + + self::$_pdfRendererName = $libraryName; + + return TRUE; + } // function setPdfRendererName() - /** - * Identify to PHPExcel the external library to use for rendering PDF files - * - * @param string $libraryName Internal reference name of the library - * e.g. PHPExcel_Settings::PDF_RENDERER_TCPDF, - * PHPExcel_Settings::PDF_RENDERER_DOMPDF - * or PHPExcel_Settings::PDF_RENDERER_MPDF - * @return boolean Success or failure - */ - public static function setPdfRendererName($libraryName) { - if (!in_array($libraryName,self::$_pdfRenderers)) { - return FALSE; - } + /** + * Tell PHPExcel where to find the external library to use for rendering PDF files + * + * @param string $libraryBaseDir Directory path to the library's base folder + * @return boolean Success or failure + */ + public static function setPdfRendererPath($libraryBaseDir) + { + if ((file_exists($libraryBaseDir) === false) || (is_readable($libraryBaseDir) === false)) { + return FALSE; + } + self::$_pdfRendererPath = $libraryBaseDir; - self::$_pdfRendererName = $libraryName; - - return TRUE; - } // function setPdfRendererName() + return TRUE; + } // function setPdfRendererPath() - /** - * Tell PHPExcel where to find the external library to use for rendering PDF files - * - * @param string $libraryBaseDir Directory path to the library's base folder - * @return boolean Success or failure - */ - public static function setPdfRendererPath($libraryBaseDir) { - if ((file_exists($libraryBaseDir) === false) || (is_readable($libraryBaseDir) === false)) { - return FALSE; - } - self::$_pdfRendererPath = $libraryBaseDir; + /** + * Return the PDF Rendering Library that PHPExcel is currently configured to use (e.g. dompdf) + * + * @return string|NULL Internal reference name of the PDF Rendering Library that PHPExcel is + * currently configured to use + * e.g. PHPExcel_Settings::PDF_RENDERER_TCPDF, + * PHPExcel_Settings::PDF_RENDERER_DOMPDF + * or PHPExcel_Settings::PDF_RENDERER_MPDF + */ + public static function getPdfRendererName() + { + return self::$_pdfRendererName; + } // function getPdfRendererName() - return TRUE; - } // function setPdfRendererPath() + /** + * Return the directory path to the PDF Rendering Library that PHPExcel is currently configured to use + * + * @return string|NULL Directory Path to the PDF Rendering Library that PHPExcel is + * currently configured to use + */ + public static function getPdfRendererPath() + { + return self::$_pdfRendererPath; + } // function getPdfRendererPath() + /** + * Set default options for libxml loader + * + * @param int $options Default options for libxml loader + */ + public static function setLibXmlLoaderOptions($options = null) + { + if (is_null($options)) { + $options = LIBXML_DTDLOAD | LIBXML_DTDATTR; + } + @libxml_disable_entity_loader($options == (LIBXML_DTDLOAD | LIBXML_DTDATTR)); + self::$_libXmlLoaderOptions = $options; + } // function setLibXmlLoaderOptions - /** - * Return the PDF Rendering Library that PHPExcel is currently configured to use (e.g. dompdf) - * - * @return string|NULL Internal reference name of the PDF Rendering Library that PHPExcel is - * currently configured to use - * e.g. PHPExcel_Settings::PDF_RENDERER_TCPDF, - * PHPExcel_Settings::PDF_RENDERER_DOMPDF - * or PHPExcel_Settings::PDF_RENDERER_MPDF - */ - public static function getPdfRendererName() { - return self::$_pdfRendererName; - } // function getPdfRendererName() - - - /** - * Return the directory path to the PDF Rendering Library that PHPExcel is currently configured to use - * - * @return string|NULL Directory Path to the PDF Rendering Library that PHPExcel is - * currently configured to use - */ - public static function getPdfRendererPath() { - return self::$_pdfRendererPath; - } // function getPdfRendererPath() - -} \ No newline at end of file + /** + * Get default options for libxml loader. + * Defaults to LIBXML_DTDLOAD | LIBXML_DTDATTR when not set explicitly. + * + * @return int Default options for libxml loader + */ + public static function getLibXmlLoaderOptions() + { + if (is_null(self::$_libXmlLoaderOptions)) { + self::setLibXmlLoaderOptions(LIBXML_DTDLOAD | LIBXML_DTDATTR); + } + @libxml_disable_entity_loader($options == (LIBXML_DTDLOAD | LIBXML_DTDATTR)); + return self::$_libXmlLoaderOptions; + } // function getLibXmlLoaderOptions +} diff --git a/htdocs/includes/phpexcel/PHPExcel/Shared/CodePage.php b/htdocs/includes/phpexcel/PHPExcel/Shared/CodePage.php index 5660e116ce0..2807ab37381 100644 --- a/htdocs/includes/phpexcel/PHPExcel/Shared/CodePage.php +++ b/htdocs/includes/phpexcel/PHPExcel/Shared/CodePage.php @@ -2,7 +2,7 @@ /** * PHPExcel * - * Copyright (c) 2006 - 2012 PHPExcel + * Copyright (c) 2006 - 2014 PHPExcel * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,9 +20,9 @@ * * @category PHPExcel * @package PHPExcel_Shared - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version 1.7.8, 2012-10-12 + * @version 1.8.0, 2014-03-02 */ @@ -31,7 +31,7 @@ * * @category PHPExcel * @package PHPExcel_Shared - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) */ class PHPExcel_Shared_CodePage { @@ -39,16 +39,16 @@ class PHPExcel_Shared_CodePage * Convert Microsoft Code Page Identifier to Code Page Name which iconv * and mbstring understands * - * @param int $number Microsoft Code Page Indentifier + * @param integer $codePage Microsoft Code Page Indentifier * @return string Code Page Name - * @throws Exception + * @throws PHPExcel_Exception */ - public static function NumberToName($codePage = '1252') + public static function NumberToName($codePage = 1252) { switch ($codePage) { case 367: return 'ASCII'; break; // ASCII case 437: return 'CP437'; break; // OEM US - case 720: throw new Exception('Code page 720 not supported.'); + case 720: throw new PHPExcel_Exception('Code page 720 not supported.'); break; // OEM Arabic case 737: return 'CP737'; break; // OEM Greek case 775: return 'CP775'; break; // OEM Baltic @@ -85,17 +85,18 @@ class PHPExcel_Shared_CodePage case 10000: return 'MAC'; break; // Apple Roman case 10006: return 'MACGREEK'; break; // Macintosh Greek case 10007: return 'MACCYRILLIC'; break; // Macintosh Cyrillic + case 10008: return 'CP936'; break; // Macintosh - Simplified Chinese (GB 2312) case 10029: return 'MACCENTRALEUROPE'; break; // Macintosh Central Europe case 10079: return 'MACICELAND'; break; // Macintosh Icelandic case 10081: return 'MACTURKISH'; break; // Macintosh Turkish case 32768: return 'MAC'; break; // Apple Roman - case 32769: throw new Exception('Code page 32769 not supported.'); + case 32769: throw new PHPExcel_Exception('Code page 32769 not supported.'); break; // ANSI Latin I (BIFF2-BIFF3) case 65000: return 'UTF-7'; break; // Unicode (UTF-7) case 65001: return 'UTF-8'; break; // Unicode (UTF-8) } - throw new Exception('Unknown codepage: ' . $codePage); + throw new PHPExcel_Exception('Unknown codepage: ' . $codePage); } } diff --git a/htdocs/includes/phpexcel/PHPExcel/Shared/Date.php b/htdocs/includes/phpexcel/PHPExcel/Shared/Date.php index 2c1ab0088ba..7fe4f4207ef 100644 --- a/htdocs/includes/phpexcel/PHPExcel/Shared/Date.php +++ b/htdocs/includes/phpexcel/PHPExcel/Shared/Date.php @@ -3,7 +3,7 @@ /** * PHPExcel * - * Copyright (c) 2006 - 2012 PHPExcel + * Copyright (c) 2006 - 2014 PHPExcel * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -21,9 +21,9 @@ * * @category PHPExcel * @package PHPExcel_Shared - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version 1.7.8, 2012-10-12 + * @version 1.8.0, 2014-03-02 */ @@ -32,7 +32,7 @@ * * @category PHPExcel * @package PHPExcel_Shared - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) */ class PHPExcel_Shared_Date { @@ -58,36 +58,40 @@ class PHPExcel_Shared_Date 'Sep' => 'September', 'Oct' => 'October', 'Nov' => 'November', - 'Dec' => 'December' + 'Dec' => 'December', ); + /* + * Names of the months of the year, indexed by shortname + * Planned usage for locale settings + * + * @public + * @var string[] + */ + public static $_numberSuffixes = array( 'st', + 'nd', + 'rd', + 'th', + ); + /* * Base calendar year to use for calculations * * @private * @var int */ - private static $ExcelBaseDate = self::CALENDAR_WINDOWS_1900; - - /* - * Object type for PHP Date/Time values - * - * @private - * @var string - */ - public static $dateTimeObjectType = 'DateTime'; - + protected static $_excelBaseDate = self::CALENDAR_WINDOWS_1900; /** * Set the Excel calendar (Windows 1900 or Mac 1904) * - * @param integer $baseDate Excel base date + * @param integer $baseDate Excel base date (1900 or 1904) * @return boolean Success or failure */ public static function setExcelCalendar($baseDate) { if (($baseDate == self::CALENDAR_WINDOWS_1900) || ($baseDate == self::CALENDAR_MAC_1904)) { - self::$ExcelBaseDate = $baseDate; + self::$_excelBaseDate = $baseDate; return TRUE; } return FALSE; @@ -97,33 +101,36 @@ class PHPExcel_Shared_Date /** * Return the Excel calendar (Windows 1900 or Mac 1904) * - * @return integer $baseDate Excel base date + * @return integer Excel base date (1900 or 1904) */ public static function getExcelCalendar() { - return self::$ExcelBaseDate; + return self::$_excelBaseDate; } // function getExcelCalendar() /** - * Convert a date from Excel to PHP + * Convert a date from Excel to PHP * - * @param long $dateValue Excel date/time value - * @return long PHP serialized date/time + * @param long $dateValue Excel date/time value + * @param boolean $adjustToTimezone Flag indicating whether $dateValue should be treated as + * a UST timestamp, or adjusted to UST + * @param string $timezone The timezone for finding the adjustment from UST + * @return long PHP serialized date/time */ - public static function ExcelToPHP($dateValue = 0) { - if (self::$ExcelBaseDate == self::CALENDAR_WINDOWS_1900) { - $myExcelBaseDate = 25569; + public static function ExcelToPHP($dateValue = 0, $adjustToTimezone = FALSE, $timezone = NULL) { + if (self::$_excelBaseDate == self::CALENDAR_WINDOWS_1900) { + $my_excelBaseDate = 25569; // Adjust for the spurious 29-Feb-1900 (Day 60) if ($dateValue < 60) { - --$myExcelBaseDate; + --$my_excelBaseDate; } } else { - $myExcelBaseDate = 24107; + $my_excelBaseDate = 24107; } // Perform conversion if ($dateValue >= 1) { - $utcDays = $dateValue - $myExcelBaseDate; + $utcDays = $dateValue - $my_excelBaseDate; $returnValue = round($utcDays * 86400); if (($returnValue <= PHP_INT_MAX) && ($returnValue >= -PHP_INT_MAX)) { $returnValue = (integer) $returnValue; @@ -135,16 +142,20 @@ class PHPExcel_Shared_Date $returnValue = (integer) gmmktime($hours, $mins, $secs); } + $timezoneAdjustment = ($adjustToTimezone) ? + PHPExcel_Shared_TimeZone::getTimezoneAdjustment($timezone, $returnValue) : + 0; + // Return - return $returnValue; + return $returnValue + $timezoneAdjustment; } // function ExcelToPHP() /** * Convert a date from Excel to a PHP Date/Time object * - * @param long $dateValue Excel date/time value - * @return long PHP date/time object + * @param integer $dateValue Excel date/time value + * @return integer PHP date/time object */ public static function ExcelToPHPObject($dateValue = 0) { $dateTime = self::ExcelToPHP($dateValue); @@ -162,17 +173,20 @@ class PHPExcel_Shared_Date /** - * Convert a date from PHP to Excel + * Convert a date from PHP to Excel * - * @param mixed $dateValue PHP serialized date/time or date object - * @return mixed Excel date/time value - * or boolean FALSE on failure + * @param mixed $dateValue PHP serialized date/time or date object + * @param boolean $adjustToTimezone Flag indicating whether $dateValue should be treated as + * a UST timestamp, or adjusted to UST + * @param string $timezone The timezone for finding the adjustment from UST + * @return mixed Excel date/time value + * or boolean FALSE on failure */ - public static function PHPToExcel($dateValue = 0) { + public static function PHPToExcel($dateValue = 0, $adjustToTimezone = FALSE, $timezone = NULL) { $saveTimeZone = date_default_timezone_get(); date_default_timezone_set('UTC'); $retValue = FALSE; - if ((is_object($dateValue)) && ($dateValue instanceof self::$dateTimeObjectType)) { + if ((is_object($dateValue)) && ($dateValue instanceof DateTime)) { $retValue = self::FormattedPHPToExcel( $dateValue->format('Y'), $dateValue->format('m'), $dateValue->format('d'), $dateValue->format('H'), $dateValue->format('i'), $dateValue->format('s') ); @@ -199,16 +213,16 @@ class PHPExcel_Shared_Date * @return long Excel date/time value */ public static function FormattedPHPToExcel($year, $month, $day, $hours=0, $minutes=0, $seconds=0) { - if (self::$ExcelBaseDate == self::CALENDAR_WINDOWS_1900) { + if (self::$_excelBaseDate == self::CALENDAR_WINDOWS_1900) { // // Fudge factor for the erroneous fact that the year 1900 is treated as a Leap Year in MS Excel // This affects every date following 28th February 1900 // $excel1900isLeapYear = TRUE; if (($year == 1900) && ($month <= 2)) { $excel1900isLeapYear = FALSE; } - $myExcelBaseDate = 2415020; + $my_excelBaseDate = 2415020; } else { - $myExcelBaseDate = 2416481; + $my_excelBaseDate = 2416481; $excel1900isLeapYear = FALSE; } @@ -223,7 +237,7 @@ class PHPExcel_Shared_Date // Calculate the Julian Date, then subtract the Excel base date (JD 2415020 = 31-Dec-1899 Giving Excel Date of 0) $century = substr($year,0,2); $decade = substr($year,2,2); - $excelDate = floor((146097 * $century) / 4) + floor((1461 * $decade) / 4) + floor((153 * $month + 2) / 5) + $day + 1721119 - $myExcelBaseDate + $excel1900isLeapYear; + $excelDate = floor((146097 * $century) / 4) + floor((1461 * $decade) / 4) + floor((153 * $month + 2) / 5) + $day + 1721119 - $my_excelBaseDate + $excel1900isLeapYear; $excelTime = (($hours * 3600) + ($minutes * 60) + $seconds) / 86400; @@ -239,7 +253,7 @@ class PHPExcel_Shared_Date */ public static function isDateTime(PHPExcel_Cell $pCell) { return self::isDateTimeFormat( - $pCell->getParent()->getStyle( + $pCell->getWorksheet()->getStyle( $pCell->getCoordinate() )->getNumberFormat() ); @@ -266,11 +280,14 @@ class PHPExcel_Shared_Date * @return boolean */ public static function isDateTimeFormatCode($pFormatCode = '') { + if (strtolower($pFormatCode) === strtolower(PHPExcel_Style_NumberFormat::FORMAT_GENERAL)) + // "General" contains an epoch letter 'e', so we trap for it explicitly here (case-insensitive check) + return FALSE; + if (preg_match('/[0#]E[+-]0/i', $pFormatCode)) + // Scientific format + return FALSE; // Switch on formatcode switch ($pFormatCode) { - // General contains an epoch letter 'e', so we trap for it explicitly here - case PHPExcel_Style_NumberFormat::FORMAT_GENERAL: - return FALSE; // Explicitly defined date formats case PHPExcel_Style_NumberFormat::FORMAT_DATE_YYYYMMDD: case PHPExcel_Style_NumberFormat::FORMAT_DATE_YYYYMMDD2: @@ -306,10 +323,11 @@ class PHPExcel_Shared_Date // We might also have a format mask containing quoted strings... // we don't want to test for any of our characters within the quoted blocks if (strpos($pFormatCode,'"') !== FALSE) { - $i = FALSE; + $segMatcher = FALSE; foreach(explode('"',$pFormatCode) as $subVal) { // Only test in alternate array entries (the non-quoted blocks) - if (($i = !$i) && (preg_match('/(^|\])[^\[]*['.self::$possibleDateFormatCharacters.']/i',$subVal))) { + if (($segMatcher = !$segMatcher) && + (preg_match('/(^|\])[^\[]*['.self::$possibleDateFormatCharacters.']/i',$subVal))) { return TRUE; } } @@ -353,4 +371,23 @@ class PHPExcel_Shared_Date } + public static function monthStringToNumber($month) { + $monthIndex = 1; + foreach(self::$_monthNames as $shortMonthName => $longMonthName) { + if (($month === $longMonthName) || ($month === $shortMonthName)) { + return $monthIndex; + } + ++$monthIndex; + } + return $month; + } + + public static function dayStringToNumber($day) { + $strippedDayValue = (str_replace(self::$_numberSuffixes,'',$day)); + if (is_numeric($strippedDayValue)) { + return $strippedDayValue; + } + return $day; + } + } diff --git a/htdocs/includes/phpexcel/PHPExcel/Shared/Drawing.php b/htdocs/includes/phpexcel/PHPExcel/Shared/Drawing.php index 9401000dd8a..1d7af16bdc5 100644 --- a/htdocs/includes/phpexcel/PHPExcel/Shared/Drawing.php +++ b/htdocs/includes/phpexcel/PHPExcel/Shared/Drawing.php @@ -2,7 +2,7 @@ /** * PHPExcel * - * Copyright (c) 2006 - 2012 PHPExcel + * Copyright (c) 2006 - 2014 PHPExcel * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,9 +20,9 @@ * * @category PHPExcel * @package PHPExcel_Shared - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version 1.7.8, 2012-10-12 + * @version 1.8.0, 2014-03-02 */ @@ -31,7 +31,7 @@ * * @category PHPExcel * @package PHPExcel_Shared - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) */ class PHPExcel_Shared_Drawing { diff --git a/htdocs/includes/phpexcel/PHPExcel/Shared/Escher.php b/htdocs/includes/phpexcel/PHPExcel/Shared/Escher.php index ecd8216aa4c..983cbdaa029 100644 --- a/htdocs/includes/phpexcel/PHPExcel/Shared/Escher.php +++ b/htdocs/includes/phpexcel/PHPExcel/Shared/Escher.php @@ -2,7 +2,7 @@ /** * PHPExcel * - * Copyright (c) 2006 - 2012 PHPExcel + * Copyright (c) 2006 - 2014 PHPExcel * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,9 +20,9 @@ * * @category PHPExcel * @package PHPExcel_Shared_Escher - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version 1.7.8, 2012-10-12 + * @version 1.8.0, 2014-03-02 */ /** @@ -30,7 +30,7 @@ * * @category PHPExcel * @package PHPExcel_Shared_Escher - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) */ class PHPExcel_Shared_Escher { diff --git a/htdocs/includes/phpexcel/PHPExcel/Shared/Escher/DgContainer.php b/htdocs/includes/phpexcel/PHPExcel/Shared/Escher/DgContainer.php index adbe429dbbc..3ec564c5663 100644 --- a/htdocs/includes/phpexcel/PHPExcel/Shared/Escher/DgContainer.php +++ b/htdocs/includes/phpexcel/PHPExcel/Shared/Escher/DgContainer.php @@ -2,7 +2,7 @@ /** * PHPExcel * - * Copyright (c) 2006 - 2012 PHPExcel + * Copyright (c) 2006 - 2014 PHPExcel * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,9 +20,9 @@ * * @category PHPExcel * @package PHPExcel_Shared_Escher - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version 1.7.8, 2012-10-12 + * @version 1.8.0, 2014-03-02 */ /** @@ -30,7 +30,7 @@ * * @category PHPExcel * @package PHPExcel_Shared_Escher - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) */ class PHPExcel_Shared_Escher_DgContainer { diff --git a/htdocs/includes/phpexcel/PHPExcel/Shared/Escher/DgContainer/SpgrContainer.php b/htdocs/includes/phpexcel/PHPExcel/Shared/Escher/DgContainer/SpgrContainer.php index ea0235e8bfa..651eaf0eef5 100644 --- a/htdocs/includes/phpexcel/PHPExcel/Shared/Escher/DgContainer/SpgrContainer.php +++ b/htdocs/includes/phpexcel/PHPExcel/Shared/Escher/DgContainer/SpgrContainer.php @@ -2,7 +2,7 @@ /** * PHPExcel * - * Copyright (c) 2006 - 2012 PHPExcel + * Copyright (c) 2006 - 2014 PHPExcel * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,9 +20,9 @@ * * @category PHPExcel * @package PHPExcel_Shared_Escher - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version 1.7.8, 2012-10-12 + * @version 1.8.0, 2014-03-02 */ /** @@ -30,7 +30,7 @@ * * @category PHPExcel * @package PHPExcel_Shared_Escher - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) */ class PHPExcel_Shared_Escher_DgContainer_SpgrContainer { diff --git a/htdocs/includes/phpexcel/PHPExcel/Shared/Escher/DgContainer/SpgrContainer/SpContainer.php b/htdocs/includes/phpexcel/PHPExcel/Shared/Escher/DgContainer/SpgrContainer/SpContainer.php index cb4988c8494..dde115401ca 100644 --- a/htdocs/includes/phpexcel/PHPExcel/Shared/Escher/DgContainer/SpgrContainer/SpContainer.php +++ b/htdocs/includes/phpexcel/PHPExcel/Shared/Escher/DgContainer/SpgrContainer/SpContainer.php @@ -2,7 +2,7 @@ /** * PHPExcel * - * Copyright (c) 2006 - 2012 PHPExcel + * Copyright (c) 2006 - 2014 PHPExcel * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,9 +20,9 @@ * * @category PHPExcel * @package PHPExcel_Shared_Escher - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version 1.7.8, 2012-10-12 + * @version 1.8.0, 2014-03-02 */ /** @@ -30,7 +30,7 @@ * * @category PHPExcel * @package PHPExcel_Shared_Escher - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) */ class PHPExcel_Shared_Escher_DgContainer_SpgrContainer_SpContainer { diff --git a/htdocs/includes/phpexcel/PHPExcel/Shared/Escher/DggContainer.php b/htdocs/includes/phpexcel/PHPExcel/Shared/Escher/DggContainer.php index 4fddbdf3fd6..bf5f61f266c 100644 --- a/htdocs/includes/phpexcel/PHPExcel/Shared/Escher/DggContainer.php +++ b/htdocs/includes/phpexcel/PHPExcel/Shared/Escher/DggContainer.php @@ -2,7 +2,7 @@ /** * PHPExcel * - * Copyright (c) 2006 - 2012 PHPExcel + * Copyright (c) 2006 - 2014 PHPExcel * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,9 +20,9 @@ * * @category PHPExcel * @package PHPExcel_Shared_Escher - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version 1.7.8, 2012-10-12 + * @version 1.8.0, 2014-03-02 */ /** @@ -30,7 +30,7 @@ * * @category PHPExcel * @package PHPExcel_Shared_Escher - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) */ class PHPExcel_Shared_Escher_DggContainer { diff --git a/htdocs/includes/phpexcel/PHPExcel/Shared/Escher/DggContainer/BstoreContainer.php b/htdocs/includes/phpexcel/PHPExcel/Shared/Escher/DggContainer/BstoreContainer.php index 428c76e6a41..d16bfc76e8c 100644 --- a/htdocs/includes/phpexcel/PHPExcel/Shared/Escher/DggContainer/BstoreContainer.php +++ b/htdocs/includes/phpexcel/PHPExcel/Shared/Escher/DggContainer/BstoreContainer.php @@ -2,7 +2,7 @@ /** * PHPExcel * - * Copyright (c) 2006 - 2012 PHPExcel + * Copyright (c) 2006 - 2014 PHPExcel * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,9 +20,9 @@ * * @category PHPExcel * @package PHPExcel_Shared_Escher - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version 1.7.8, 2012-10-12 + * @version 1.8.0, 2014-03-02 */ /** @@ -30,7 +30,7 @@ * * @category PHPExcel * @package PHPExcel_Shared_Escher - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) */ class PHPExcel_Shared_Escher_DggContainer_BstoreContainer { diff --git a/htdocs/includes/phpexcel/PHPExcel/Shared/Escher/DggContainer/BstoreContainer/BSE.php b/htdocs/includes/phpexcel/PHPExcel/Shared/Escher/DggContainer/BstoreContainer/BSE.php index 1f10ae1767d..ea3c52a3772 100644 --- a/htdocs/includes/phpexcel/PHPExcel/Shared/Escher/DggContainer/BstoreContainer/BSE.php +++ b/htdocs/includes/phpexcel/PHPExcel/Shared/Escher/DggContainer/BstoreContainer/BSE.php @@ -2,7 +2,7 @@ /** * PHPExcel * - * Copyright (c) 2006 - 2012 PHPExcel + * Copyright (c) 2006 - 2014 PHPExcel * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,9 +20,9 @@ * * @category PHPExcel * @package PHPExcel_Shared_Escher - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version 1.7.8, 2012-10-12 + * @version 1.8.0, 2014-03-02 */ /** @@ -30,7 +30,7 @@ * * @category PHPExcel * @package PHPExcel_Shared_Escher - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) */ class PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE { diff --git a/htdocs/includes/phpexcel/PHPExcel/Shared/Escher/DggContainer/BstoreContainer/BSE/Blip.php b/htdocs/includes/phpexcel/PHPExcel/Shared/Escher/DggContainer/BstoreContainer/BSE/Blip.php index 0d28a6bf561..802ce6d943e 100644 --- a/htdocs/includes/phpexcel/PHPExcel/Shared/Escher/DggContainer/BstoreContainer/BSE/Blip.php +++ b/htdocs/includes/phpexcel/PHPExcel/Shared/Escher/DggContainer/BstoreContainer/BSE/Blip.php @@ -2,7 +2,7 @@ /** * PHPExcel * - * Copyright (c) 2006 - 2012 PHPExcel + * Copyright (c) 2006 - 2014 PHPExcel * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,9 +20,9 @@ * * @category PHPExcel * @package PHPExcel_Shared_Escher - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version 1.7.8, 2012-10-12 + * @version 1.8.0, 2014-03-02 */ /** @@ -30,7 +30,7 @@ * * @category PHPExcel * @package PHPExcel_Shared_Escher - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) */ class PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE_Blip { diff --git a/htdocs/includes/phpexcel/PHPExcel/Shared/Excel5.php b/htdocs/includes/phpexcel/PHPExcel/Shared/Excel5.php index 629f621c8e3..927dace9aca 100644 --- a/htdocs/includes/phpexcel/PHPExcel/Shared/Excel5.php +++ b/htdocs/includes/phpexcel/PHPExcel/Shared/Excel5.php @@ -2,7 +2,7 @@ /** * PHPExcel * - * Copyright (c) 2006 - 2012 PHPExcel + * Copyright (c) 2006 - 2014 PHPExcel * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,9 +20,9 @@ * * @category PHPExcel * @package PHPExcel_Shared - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version 1.7.8, 2012-10-12 + * @version 1.8.0, 2014-03-02 */ /** @@ -30,7 +30,7 @@ * * @category PHPExcel * @package PHPExcel_Shared - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) */ class PHPExcel_Shared_Excel5 { @@ -40,7 +40,7 @@ class PHPExcel_Shared_Excel5 * This holds for Arial 10 * * @param PHPExcel_Worksheet $sheet The sheet - * @param integer $col The column + * @param string $col The column * @return integer The width in pixels */ public static function sizeCol($sheet, $col = 'A') @@ -136,9 +136,9 @@ class PHPExcel_Shared_Excel5 * * @param PHPExcel_Worksheet $sheet * @param string $startColumn - * @param integer $startOffset Offset within start cell measured in 1/1024 of the cell width + * @param integer $startOffsetX Offset within start cell measured in 1/1024 of the cell width * @param string $endColumn - * @param integer $endOffset Offset within end cell measured in 1/1024 of the cell width + * @param integer $endOffsetX Offset within end cell measured in 1/1024 of the cell width * @return integer Horizontal measured in pixels */ public static function getDistanceX(PHPExcel_Worksheet $sheet, $startColumn = 'A', $startOffsetX = 0, $endColumn = 'A', $endOffsetX = 0) @@ -166,10 +166,10 @@ class PHPExcel_Shared_Excel5 * The distanceY is found as sum of all the spanning rows minus two offsets * * @param PHPExcel_Worksheet $sheet - * @param string $startRow (1-based) - * @param integer $startOffset Offset within start cell measured in 1/256 of the cell height - * @param string $endRow (1-based) - * @param integer $endOffset Offset within end cell measured in 1/256 of the cell height + * @param integer $startRow (1-based) + * @param integer $startOffsetY Offset within start cell measured in 1/256 of the cell height + * @param integer $endRow (1-based) + * @param integer $endOffsetY Offset within end cell measured in 1/256 of the cell height * @return integer Vertical distance measured in pixels */ public static function getDistanceY(PHPExcel_Worksheet $sheet, $startRow = 1, $startOffsetY = 0, $endRow = 1, $endOffsetY = 0) diff --git a/htdocs/includes/phpexcel/PHPExcel/Shared/File.php b/htdocs/includes/phpexcel/PHPExcel/Shared/File.php index 575ac3cd22c..70756a0446a 100644 --- a/htdocs/includes/phpexcel/PHPExcel/Shared/File.php +++ b/htdocs/includes/phpexcel/PHPExcel/Shared/File.php @@ -2,7 +2,7 @@ /** * PHPExcel * - * Copyright (c) 2006 - 2012 PHPExcel + * Copyright (c) 2006 - 2014 PHPExcel * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,9 +20,9 @@ * * @category PHPExcel * @package PHPExcel_Shared - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version 1.7.8, 2012-10-12 + * @version 1.8.0, 2014-03-02 */ @@ -31,10 +31,39 @@ * * @category PHPExcel * @package PHPExcel_Shared - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) */ class PHPExcel_Shared_File { + /* + * Use Temp or File Upload Temp for temporary files + * + * @protected + * @var boolean + */ + protected static $_useUploadTempDirectory = FALSE; + + + /** + * Set the flag indicating whether the File Upload Temp directory should be used for temporary files + * + * @param boolean $useUploadTempDir Use File Upload Temporary directory (true or false) + */ + public static function setUseUploadTempDirectory($useUploadTempDir = FALSE) { + self::$_useUploadTempDirectory = (boolean) $useUploadTempDir; + } // function setUseUploadTempDirectory() + + + /** + * Get the flag indicating whether the File Upload Temp directory should be used for temporary files + * + * @return boolean Use File Upload Temporary directory (true or false) + */ + public static function getUseUploadTempDirectory() { + return self::$_useUploadTempDirectory; + } // function getUseUploadTempDirectory() + + /** * Verify if a file exists * @@ -105,9 +134,19 @@ class PHPExcel_Shared_File */ public static function sys_get_temp_dir() { + if (self::$_useUploadTempDirectory) { + // use upload-directory when defined to allow running on environments having very restricted + // open_basedir configs + if (ini_get('upload_tmp_dir') !== FALSE) { + if ($temp = ini_get('upload_tmp_dir')) { + if (file_exists($temp)) + return realpath($temp); + } + } + } + // sys_get_temp_dir is only available since PHP 5.2.1 // http://php.net/manual/en/function.sys-get-temp-dir.php#94119 - if ( !function_exists('sys_get_temp_dir')) { if ($temp = getenv('TMP') ) { if ((!empty($temp)) && (file_exists($temp))) { return realpath($temp); } diff --git a/htdocs/includes/phpexcel/PHPExcel/Shared/Font.php b/htdocs/includes/phpexcel/PHPExcel/Shared/Font.php index 3d0662e8830..203d4ecb4e3 100644 --- a/htdocs/includes/phpexcel/PHPExcel/Shared/Font.php +++ b/htdocs/includes/phpexcel/PHPExcel/Shared/Font.php @@ -2,7 +2,7 @@ /** * PHPExcel * - * Copyright (c) 2006 - 2012 PHPExcel + * Copyright (c) 2006 - 2014 PHPExcel * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,9 +20,9 @@ * * @category PHPExcel * @package PHPExcel_Shared - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version 1.7.8, 2012-10-12 + * @version 1.8.0, 2014-03-02 */ @@ -31,7 +31,7 @@ * * @category PHPExcel * @package PHPExcel_Shared - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) */ class PHPExcel_Shared_Font { @@ -244,11 +244,11 @@ class PHPExcel_Shared_Font /** * Calculate an (approximate) OpenXML column width, based on font size and text contained * - * @param int $fontSize Font size (in pixels or points) - * @param bool $fontSizeInPixels Is the font size specified in pixels (true) or in points (false) ? - * @param string $cellText Text to calculate width - * @param int $rotation Rotation angle - * @return int Column width + * @param PHPExcel_Style_Font $font Font object + * @param PHPExcel_RichText|string $cellText Text to calculate width + * @param integer $rotation Rotation angle + * @param PHPExcel_Style_Font|NULL $defaultFont Font object + * @return integer Column width */ public static function calculateColumnWidth(PHPExcel_Style_Font $font, $cellText = '', $rotation = 0, PHPExcel_Style_Font $defaultFont = null) { @@ -271,7 +271,7 @@ class PHPExcel_Shared_Font try { // If autosize method is set to 'approx', use approximation if (self::$autoSizeMethod == self::AUTOSIZE_METHOD_APPROX) { - throw new Exception('AutoSize method is set to approx'); + throw new PHPExcel_Exception('AutoSize method is set to approx'); } // Width of text in pixels excl. padding @@ -280,7 +280,7 @@ class PHPExcel_Shared_Font // Excel adds some padding, use 1.07 of the width of an 'n' glyph $columnWidth += ceil(self::getTextWidthPixelsExact('0', $font, 0) * 1.07); // pixels incl. padding - } catch (Exception $e) { + } catch (PHPExcel_Exception $e) { // Width of text in pixels excl. padding, approximation $columnWidth = self::getTextWidthPixelsApprox($cellText, $font, $rotation); @@ -302,11 +302,11 @@ class PHPExcel_Shared_Font * @param PHPExcel_Style_Font * @param int $rotation * @return int - * @throws Exception + * @throws PHPExcel_Exception */ public static function getTextWidthPixelsExact($text, PHPExcel_Style_Font $font, $rotation = 0) { if (!function_exists('imagettfbbox')) { - throw new Exception('GD library needs to be enabled'); + throw new PHPExcel_Exception('GD library needs to be enabled'); } // font size should really be supplied in pixels in GD2, @@ -425,7 +425,7 @@ class PHPExcel_Shared_Font */ public static function getTrueTypeFontFileFromFont($font) { if (!file_exists(self::$trueTypeFontPath) || !is_dir(self::$trueTypeFontPath)) { - throw new Exception('Valid directory to TrueType Font files not specified'); + throw new PHPExcel_Exception('Valid directory to TrueType Font files not specified'); } $name = $font->getName(); @@ -530,7 +530,7 @@ class PHPExcel_Shared_Font break; default: - throw new Exception('Unknown font name "'. $name .'". Cannot map to TrueType font file'); + throw new PHPExcel_Exception('Unknown font name "'. $name .'". Cannot map to TrueType font file'); break; } @@ -538,7 +538,7 @@ class PHPExcel_Shared_Font // Check if file actually exists if (!file_exists($fontFile)) { - throw New Exception('TrueType Font file not found'); + throw New PHPExcel_Exception('TrueType Font file not found'); } return $fontFile; diff --git a/htdocs/includes/phpexcel/PHPExcel/Shared/JAMA/CholeskyDecomposition.php b/htdocs/includes/phpexcel/PHPExcel/Shared/JAMA/CholeskyDecomposition.php index 9d064f9e63a..cfbaa53bc8d 100644 --- a/htdocs/includes/phpexcel/PHPExcel/Shared/JAMA/CholeskyDecomposition.php +++ b/htdocs/includes/phpexcel/PHPExcel/Shared/JAMA/CholeskyDecomposition.php @@ -73,7 +73,7 @@ class CholeskyDecomposition { } } } else { - throw new Exception(JAMAError(ArgumentTypeException)); + throw new PHPExcel_Calculation_Exception(JAMAError(ArgumentTypeException)); } } // function __construct() @@ -136,13 +136,13 @@ class CholeskyDecomposition { return new Matrix($X, $this->m, $nx); } else { - throw new Exception(JAMAError(MatrixSPDException)); + throw new PHPExcel_Calculation_Exception(JAMAError(MatrixSPDException)); } } else { - throw new Exception(JAMAError(MatrixDimensionException)); + throw new PHPExcel_Calculation_Exception(JAMAError(MatrixDimensionException)); } } else { - throw new Exception(JAMAError(ArgumentTypeException)); + throw new PHPExcel_Calculation_Exception(JAMAError(ArgumentTypeException)); } } // function solve() diff --git a/htdocs/includes/phpexcel/PHPExcel/Shared/JAMA/LUDecomposition.php b/htdocs/includes/phpexcel/PHPExcel/Shared/JAMA/LUDecomposition.php index 6c797a6ce00..08e500cf75a 100644 --- a/htdocs/includes/phpexcel/PHPExcel/Shared/JAMA/LUDecomposition.php +++ b/htdocs/includes/phpexcel/PHPExcel/Shared/JAMA/LUDecomposition.php @@ -115,7 +115,7 @@ class PHPExcel_Shared_JAMA_LUDecomposition { } } } else { - throw new Exception(PHPExcel_Shared_JAMA_Matrix::ArgumentTypeException); + throw new PHPExcel_Calculation_Exception(PHPExcel_Shared_JAMA_Matrix::ArgumentTypeException); } } // function __construct() @@ -208,7 +208,7 @@ class PHPExcel_Shared_JAMA_LUDecomposition { } return $d; } else { - throw new Exception(PHPExcel_Shared_JAMA_Matrix::MatrixDimensionException); + throw new PHPExcel_Calculation_Exception(PHPExcel_Shared_JAMA_Matrix::MatrixDimensionException); } } // function det() @@ -218,8 +218,8 @@ class PHPExcel_Shared_JAMA_LUDecomposition { * * @param $B A Matrix with as many rows as A and any number of columns. * @return X so that L*U*X = B(piv,:) - * @exception IllegalArgumentException Matrix row dimensions must agree. - * @exception RuntimeException Matrix is singular. + * @PHPExcel_Calculation_Exception IllegalArgumentException Matrix row dimensions must agree. + * @PHPExcel_Calculation_Exception RuntimeException Matrix is singular. */ public function solve($B) { if ($B->getRowDimension() == $this->m) { @@ -248,10 +248,10 @@ class PHPExcel_Shared_JAMA_LUDecomposition { } return $X; } else { - throw new Exception(self::MatrixSingularException); + throw new PHPExcel_Calculation_Exception(self::MatrixSingularException); } } else { - throw new Exception(self::MatrixSquareException); + throw new PHPExcel_Calculation_Exception(self::MatrixSquareException); } } // function solve() diff --git a/htdocs/includes/phpexcel/PHPExcel/Shared/JAMA/Matrix.php b/htdocs/includes/phpexcel/PHPExcel/Shared/JAMA/Matrix.php index aae40e4c57a..b893a447a8e 100644 --- a/htdocs/includes/phpexcel/PHPExcel/Shared/JAMA/Matrix.php +++ b/htdocs/includes/phpexcel/PHPExcel/Shared/JAMA/Matrix.php @@ -102,15 +102,15 @@ class PHPExcel_Shared_JAMA_Matrix { } } } else { - throw new Exception(self::ArrayLengthException); + throw new PHPExcel_Calculation_Exception(self::ArrayLengthException); } break; default: - throw new Exception(self::PolymorphicArgumentException); + throw new PHPExcel_Calculation_Exception(self::PolymorphicArgumentException); break; } } else { - throw new Exception(self::PolymorphicArgumentException); + throw new PHPExcel_Calculation_Exception(self::PolymorphicArgumentException); } } // function __construct() @@ -177,8 +177,8 @@ class PHPExcel_Shared_JAMA_Matrix { //A($i0...; $j0...) case 'integer,integer': list($i0, $j0) = $args; - if ($i0 >= 0) { $m = $this->m - $i0; } else { throw new Exception(self::ArgumentBoundsException); } - if ($j0 >= 0) { $n = $this->n - $j0; } else { throw new Exception(self::ArgumentBoundsException); } + if ($i0 >= 0) { $m = $this->m - $i0; } else { throw new PHPExcel_Calculation_Exception(self::ArgumentBoundsException); } + if ($j0 >= 0) { $n = $this->n - $j0; } else { throw new PHPExcel_Calculation_Exception(self::ArgumentBoundsException); } $R = new PHPExcel_Shared_JAMA_Matrix($m, $n); for($i = $i0; $i < $this->m; ++$i) { for($j = $j0; $j < $this->n; ++$j) { @@ -190,8 +190,8 @@ class PHPExcel_Shared_JAMA_Matrix { //A($i0...$iF; $j0...$jF) case 'integer,integer,integer,integer': list($i0, $iF, $j0, $jF) = $args; - if (($iF > $i0) && ($this->m >= $iF) && ($i0 >= 0)) { $m = $iF - $i0; } else { throw new Exception(self::ArgumentBoundsException); } - if (($jF > $j0) && ($this->n >= $jF) && ($j0 >= 0)) { $n = $jF - $j0; } else { throw new Exception(self::ArgumentBoundsException); } + if (($iF > $i0) && ($this->m >= $iF) && ($i0 >= 0)) { $m = $iF - $i0; } else { throw new PHPExcel_Calculation_Exception(self::ArgumentBoundsException); } + if (($jF > $j0) && ($this->n >= $jF) && ($j0 >= 0)) { $n = $jF - $j0; } else { throw new PHPExcel_Calculation_Exception(self::ArgumentBoundsException); } $R = new PHPExcel_Shared_JAMA_Matrix($m+1, $n+1); for($i = $i0; $i <= $iF; ++$i) { for($j = $j0; $j <= $jF; ++$j) { @@ -203,8 +203,8 @@ class PHPExcel_Shared_JAMA_Matrix { //$R = array of row indices; $C = array of column indices case 'array,array': list($RL, $CL) = $args; - if (count($RL) > 0) { $m = count($RL); } else { throw new Exception(self::ArgumentBoundsException); } - if (count($CL) > 0) { $n = count($CL); } else { throw new Exception(self::ArgumentBoundsException); } + if (count($RL) > 0) { $m = count($RL); } else { throw new PHPExcel_Calculation_Exception(self::ArgumentBoundsException); } + if (count($CL) > 0) { $n = count($CL); } else { throw new PHPExcel_Calculation_Exception(self::ArgumentBoundsException); } $R = new PHPExcel_Shared_JAMA_Matrix($m, $n); for($i = 0; $i < $m; ++$i) { for($j = 0; $j < $n; ++$j) { @@ -216,8 +216,8 @@ class PHPExcel_Shared_JAMA_Matrix { //$RL = array of row indices; $CL = array of column indices case 'array,array': list($RL, $CL) = $args; - if (count($RL) > 0) { $m = count($RL); } else { throw new Exception(self::ArgumentBoundsException); } - if (count($CL) > 0) { $n = count($CL); } else { throw new Exception(self::ArgumentBoundsException); } + if (count($RL) > 0) { $m = count($RL); } else { throw new PHPExcel_Calculation_Exception(self::ArgumentBoundsException); } + if (count($CL) > 0) { $n = count($CL); } else { throw new PHPExcel_Calculation_Exception(self::ArgumentBoundsException); } $R = new PHPExcel_Shared_JAMA_Matrix($m, $n); for($i = 0; $i < $m; ++$i) { for($j = 0; $j < $n; ++$j) { @@ -229,8 +229,8 @@ class PHPExcel_Shared_JAMA_Matrix { //A($i0...$iF); $CL = array of column indices case 'integer,integer,array': list($i0, $iF, $CL) = $args; - if (($iF > $i0) && ($this->m >= $iF) && ($i0 >= 0)) { $m = $iF - $i0; } else { throw new Exception(self::ArgumentBoundsException); } - if (count($CL) > 0) { $n = count($CL); } else { throw new Exception(self::ArgumentBoundsException); } + if (($iF > $i0) && ($this->m >= $iF) && ($i0 >= 0)) { $m = $iF - $i0; } else { throw new PHPExcel_Calculation_Exception(self::ArgumentBoundsException); } + if (count($CL) > 0) { $n = count($CL); } else { throw new PHPExcel_Calculation_Exception(self::ArgumentBoundsException); } $R = new PHPExcel_Shared_JAMA_Matrix($m, $n); for($i = $i0; $i < $iF; ++$i) { for($j = 0; $j < $n; ++$j) { @@ -242,8 +242,8 @@ class PHPExcel_Shared_JAMA_Matrix { //$RL = array of row indices case 'array,integer,integer': list($RL, $j0, $jF) = $args; - if (count($RL) > 0) { $m = count($RL); } else { throw new Exception(self::ArgumentBoundsException); } - if (($jF >= $j0) && ($this->n >= $jF) && ($j0 >= 0)) { $n = $jF - $j0; } else { throw new Exception(self::ArgumentBoundsException); } + if (count($RL) > 0) { $m = count($RL); } else { throw new PHPExcel_Calculation_Exception(self::ArgumentBoundsException); } + if (($jF >= $j0) && ($this->n >= $jF) && ($j0 >= 0)) { $n = $jF - $j0; } else { throw new PHPExcel_Calculation_Exception(self::ArgumentBoundsException); } $R = new PHPExcel_Shared_JAMA_Matrix($m, $n+1); for($i = 0; $i < $m; ++$i) { for($j = $j0; $j <= $jF; ++$j) { @@ -253,11 +253,11 @@ class PHPExcel_Shared_JAMA_Matrix { return $R; break; default: - throw new Exception(self::PolymorphicArgumentException); + throw new PHPExcel_Calculation_Exception(self::PolymorphicArgumentException); break; } } else { - throw new Exception(self::PolymorphicArgumentException); + throw new PHPExcel_Calculation_Exception(self::PolymorphicArgumentException); } } // function getMatrix() @@ -274,10 +274,10 @@ class PHPExcel_Shared_JAMA_Matrix { if (($this->m == $B->getRowDimension()) && ($this->n == $B->getColumnDimension())) { return true; } else { - throw new Exception(self::MatrixDimensionException); + throw new PHPExcel_Calculation_Exception(self::MatrixDimensionException); } } else { - throw new Exception(self::ArgumentTypeException); + throw new PHPExcel_Calculation_Exception(self::ArgumentTypeException); } } // function checkMatrixDimensions() @@ -345,7 +345,7 @@ class PHPExcel_Shared_JAMA_Matrix { return $this->getMatrix($i0, 0, $i0 + 1, $this->n); } } else { - throw new Exception(self::ArgumentTypeException); + throw new PHPExcel_Calculation_Exception(self::ArgumentTypeException); } } // function getMatrixByRow() @@ -366,7 +366,7 @@ class PHPExcel_Shared_JAMA_Matrix { return $this->getMatrix(0, $j0, $this->m, $j0 + 1); } } else { - throw new Exception(self::ArgumentTypeException); + throw new PHPExcel_Calculation_Exception(self::ArgumentTypeException); } } // function getMatrixByCol() @@ -428,13 +428,13 @@ class PHPExcel_Shared_JAMA_Matrix { switch($match) { case 'object': - if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) { $M = $args[0]; } else { throw new Exception(self::ArgumentTypeException); } + if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) { $M = $args[0]; } else { throw new PHPExcel_Calculation_Exception(self::ArgumentTypeException); } break; case 'array': $M = new PHPExcel_Shared_JAMA_Matrix($args[0]); break; default: - throw new Exception(self::PolymorphicArgumentException); + throw new PHPExcel_Calculation_Exception(self::PolymorphicArgumentException); break; } $this->checkMatrixDimensions($M); @@ -445,7 +445,7 @@ class PHPExcel_Shared_JAMA_Matrix { } return $M; } else { - throw new Exception(self::PolymorphicArgumentException); + throw new PHPExcel_Calculation_Exception(self::PolymorphicArgumentException); } } // function plus() @@ -464,13 +464,13 @@ class PHPExcel_Shared_JAMA_Matrix { switch($match) { case 'object': - if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) { $M = $args[0]; } else { throw new Exception(self::ArgumentTypeException); } + if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) { $M = $args[0]; } else { throw new PHPExcel_Calculation_Exception(self::ArgumentTypeException); } break; case 'array': $M = new PHPExcel_Shared_JAMA_Matrix($args[0]); break; default: - throw new Exception(self::PolymorphicArgumentException); + throw new PHPExcel_Calculation_Exception(self::PolymorphicArgumentException); break; } $this->checkMatrixDimensions($M); @@ -495,7 +495,7 @@ class PHPExcel_Shared_JAMA_Matrix { } return $this; } else { - throw new Exception(self::PolymorphicArgumentException); + throw new PHPExcel_Calculation_Exception(self::PolymorphicArgumentException); } } // function plusEquals() @@ -514,13 +514,13 @@ class PHPExcel_Shared_JAMA_Matrix { switch($match) { case 'object': - if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) { $M = $args[0]; } else { throw new Exception(self::ArgumentTypeException); } + if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) { $M = $args[0]; } else { throw new PHPExcel_Calculation_Exception(self::ArgumentTypeException); } break; case 'array': $M = new PHPExcel_Shared_JAMA_Matrix($args[0]); break; default: - throw new Exception(self::PolymorphicArgumentException); + throw new PHPExcel_Calculation_Exception(self::PolymorphicArgumentException); break; } $this->checkMatrixDimensions($M); @@ -531,7 +531,7 @@ class PHPExcel_Shared_JAMA_Matrix { } return $M; } else { - throw new Exception(self::PolymorphicArgumentException); + throw new PHPExcel_Calculation_Exception(self::PolymorphicArgumentException); } } // function minus() @@ -550,13 +550,13 @@ class PHPExcel_Shared_JAMA_Matrix { switch($match) { case 'object': - if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) { $M = $args[0]; } else { throw new Exception(self::ArgumentTypeException); } + if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) { $M = $args[0]; } else { throw new PHPExcel_Calculation_Exception(self::ArgumentTypeException); } break; case 'array': $M = new PHPExcel_Shared_JAMA_Matrix($args[0]); break; default: - throw new Exception(self::PolymorphicArgumentException); + throw new PHPExcel_Calculation_Exception(self::PolymorphicArgumentException); break; } $this->checkMatrixDimensions($M); @@ -581,7 +581,7 @@ class PHPExcel_Shared_JAMA_Matrix { } return $this; } else { - throw new Exception(self::PolymorphicArgumentException); + throw new PHPExcel_Calculation_Exception(self::PolymorphicArgumentException); } } // function minusEquals() @@ -601,13 +601,13 @@ class PHPExcel_Shared_JAMA_Matrix { switch($match) { case 'object': - if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) { $M = $args[0]; } else { throw new Exception(self::ArgumentTypeException); } + if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) { $M = $args[0]; } else { throw new PHPExcel_Calculation_Exception(self::ArgumentTypeException); } break; case 'array': $M = new PHPExcel_Shared_JAMA_Matrix($args[0]); break; default: - throw new Exception(self::PolymorphicArgumentException); + throw new PHPExcel_Calculation_Exception(self::PolymorphicArgumentException); break; } $this->checkMatrixDimensions($M); @@ -618,7 +618,7 @@ class PHPExcel_Shared_JAMA_Matrix { } return $M; } else { - throw new Exception(self::PolymorphicArgumentException); + throw new PHPExcel_Calculation_Exception(self::PolymorphicArgumentException); } } // function arrayTimes() @@ -638,13 +638,13 @@ class PHPExcel_Shared_JAMA_Matrix { switch($match) { case 'object': - if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) { $M = $args[0]; } else { throw new Exception(self::ArgumentTypeException); } + if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) { $M = $args[0]; } else { throw new PHPExcel_Calculation_Exception(self::ArgumentTypeException); } break; case 'array': $M = new PHPExcel_Shared_JAMA_Matrix($args[0]); break; default: - throw new Exception(self::PolymorphicArgumentException); + throw new PHPExcel_Calculation_Exception(self::PolymorphicArgumentException); break; } $this->checkMatrixDimensions($M); @@ -669,7 +669,7 @@ class PHPExcel_Shared_JAMA_Matrix { } return $this; } else { - throw new Exception(self::PolymorphicArgumentException); + throw new PHPExcel_Calculation_Exception(self::PolymorphicArgumentException); } } // function arrayTimesEquals() @@ -689,13 +689,13 @@ class PHPExcel_Shared_JAMA_Matrix { switch($match) { case 'object': - if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) { $M = $args[0]; } else { throw new Exception(self::ArgumentTypeException); } + if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) { $M = $args[0]; } else { throw new PHPExcel_Calculation_Exception(self::ArgumentTypeException); } break; case 'array': $M = new PHPExcel_Shared_JAMA_Matrix($args[0]); break; default: - throw new Exception(self::PolymorphicArgumentException); + throw new PHPExcel_Calculation_Exception(self::PolymorphicArgumentException); break; } $this->checkMatrixDimensions($M); @@ -725,7 +725,7 @@ class PHPExcel_Shared_JAMA_Matrix { } return $M; } else { - throw new Exception(self::PolymorphicArgumentException); + throw new PHPExcel_Calculation_Exception(self::PolymorphicArgumentException); } } // function arrayRightDivide() @@ -745,13 +745,13 @@ class PHPExcel_Shared_JAMA_Matrix { switch($match) { case 'object': - if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) { $M = $args[0]; } else { throw new Exception(self::ArgumentTypeException); } + if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) { $M = $args[0]; } else { throw new PHPExcel_Calculation_Exception(self::ArgumentTypeException); } break; case 'array': $M = new PHPExcel_Shared_JAMA_Matrix($args[0]); break; default: - throw new Exception(self::PolymorphicArgumentException); + throw new PHPExcel_Calculation_Exception(self::PolymorphicArgumentException); break; } $this->checkMatrixDimensions($M); @@ -762,7 +762,7 @@ class PHPExcel_Shared_JAMA_Matrix { } return $M; } else { - throw new Exception(self::PolymorphicArgumentException); + throw new PHPExcel_Calculation_Exception(self::PolymorphicArgumentException); } } // function arrayRightDivideEquals() @@ -782,13 +782,13 @@ class PHPExcel_Shared_JAMA_Matrix { switch($match) { case 'object': - if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) { $M = $args[0]; } else { throw new Exception(self::ArgumentTypeException); } + if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) { $M = $args[0]; } else { throw new PHPExcel_Calculation_Exception(self::ArgumentTypeException); } break; case 'array': $M = new PHPExcel_Shared_JAMA_Matrix($args[0]); break; default: - throw new Exception(self::PolymorphicArgumentException); + throw new PHPExcel_Calculation_Exception(self::PolymorphicArgumentException); break; } $this->checkMatrixDimensions($M); @@ -799,7 +799,7 @@ class PHPExcel_Shared_JAMA_Matrix { } return $M; } else { - throw new Exception(self::PolymorphicArgumentException); + throw new PHPExcel_Calculation_Exception(self::PolymorphicArgumentException); } } // function arrayLeftDivide() @@ -819,13 +819,13 @@ class PHPExcel_Shared_JAMA_Matrix { switch($match) { case 'object': - if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) { $M = $args[0]; } else { throw new Exception(self::ArgumentTypeException); } + if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) { $M = $args[0]; } else { throw new PHPExcel_Calculation_Exception(self::ArgumentTypeException); } break; case 'array': $M = new PHPExcel_Shared_JAMA_Matrix($args[0]); break; default: - throw new Exception(self::PolymorphicArgumentException); + throw new PHPExcel_Calculation_Exception(self::PolymorphicArgumentException); break; } $this->checkMatrixDimensions($M); @@ -836,7 +836,7 @@ class PHPExcel_Shared_JAMA_Matrix { } return $M; } else { - throw new Exception(self::PolymorphicArgumentException); + throw new PHPExcel_Calculation_Exception(self::PolymorphicArgumentException); } } // function arrayLeftDivideEquals() @@ -855,7 +855,7 @@ class PHPExcel_Shared_JAMA_Matrix { switch($match) { case 'object': - if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) { $B = $args[0]; } else { throw new Exception(self::ArgumentTypeException); } + if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) { $B = $args[0]; } else { throw new PHPExcel_Calculation_Exception(self::ArgumentTypeException); } if ($this->n == $B->m) { $C = new PHPExcel_Shared_JAMA_Matrix($this->m, $B->n); for($j = 0; $j < $B->n; ++$j) { @@ -873,7 +873,7 @@ class PHPExcel_Shared_JAMA_Matrix { } return $C; } else { - throw new Exception(JAMAError(MatrixDimensionMismatch)); + throw new PHPExcel_Calculation_Exception(JAMAError(MatrixDimensionMismatch)); } break; case 'array': @@ -891,7 +891,7 @@ class PHPExcel_Shared_JAMA_Matrix { } return $C; } else { - throw new Exception(JAMAError(MatrixDimensionMismatch)); + throw new PHPExcel_Calculation_Exception(JAMAError(MatrixDimensionMismatch)); } return $M; break; @@ -923,11 +923,11 @@ class PHPExcel_Shared_JAMA_Matrix { return $C; break; default: - throw new Exception(self::PolymorphicArgumentException); + throw new PHPExcel_Calculation_Exception(self::PolymorphicArgumentException); break; } } else { - throw new Exception(self::PolymorphicArgumentException); + throw new PHPExcel_Calculation_Exception(self::PolymorphicArgumentException); } } // function times() @@ -946,13 +946,13 @@ class PHPExcel_Shared_JAMA_Matrix { switch($match) { case 'object': - if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) { $M = $args[0]; } else { throw new Exception(self::ArgumentTypeException); } + if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) { $M = $args[0]; } else { throw new PHPExcel_Calculation_Exception(self::ArgumentTypeException); } break; case 'array': $M = new PHPExcel_Shared_JAMA_Matrix($args[0]); break; default: - throw new Exception(self::PolymorphicArgumentException); + throw new PHPExcel_Calculation_Exception(self::PolymorphicArgumentException); break; } $this->checkMatrixDimensions($M); @@ -977,7 +977,7 @@ class PHPExcel_Shared_JAMA_Matrix { } return $this; } else { - throw new Exception(self::PolymorphicArgumentException); + throw new PHPExcel_Calculation_Exception(self::PolymorphicArgumentException); } } // function power() @@ -996,12 +996,12 @@ class PHPExcel_Shared_JAMA_Matrix { switch($match) { case 'object': - if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) { $M = $args[0]; } else { throw new Exception(self::ArgumentTypeException); } + if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) { $M = $args[0]; } else { throw new PHPExcel_Calculation_Exception(self::ArgumentTypeException); } case 'array': $M = new PHPExcel_Shared_JAMA_Matrix($args[0]); break; default: - throw new Exception(self::PolymorphicArgumentException); + throw new PHPExcel_Calculation_Exception(self::PolymorphicArgumentException); break; } $this->checkMatrixDimensions($M); @@ -1012,7 +1012,7 @@ class PHPExcel_Shared_JAMA_Matrix { } return $this; } else { - throw new Exception(self::PolymorphicArgumentException); + throw new PHPExcel_Calculation_Exception(self::PolymorphicArgumentException); } } // function concat() diff --git a/htdocs/includes/phpexcel/PHPExcel/Shared/JAMA/QRDecomposition.php b/htdocs/includes/phpexcel/PHPExcel/Shared/JAMA/QRDecomposition.php index 49293d7eca7..7538462987d 100644 --- a/htdocs/includes/phpexcel/PHPExcel/Shared/JAMA/QRDecomposition.php +++ b/htdocs/includes/phpexcel/PHPExcel/Shared/JAMA/QRDecomposition.php @@ -88,7 +88,7 @@ class PHPExcel_Shared_JAMA_QRDecomposition { $this->Rdiag[$k] = -$nrm; } } else { - throw new Exception(PHPExcel_Shared_JAMA_Matrix::ArgumentTypeException); + throw new PHPExcel_Calculation_Exception(PHPExcel_Shared_JAMA_Matrix::ArgumentTypeException); } } // function __construct() @@ -224,10 +224,10 @@ class PHPExcel_Shared_JAMA_QRDecomposition { $X = new PHPExcel_Shared_JAMA_Matrix($X); return ($X->getMatrix(0, $this->n-1, 0, $nx)); } else { - throw new Exception(self::MatrixRankException); + throw new PHPExcel_Calculation_Exception(self::MatrixRankException); } } else { - throw new Exception(PHPExcel_Shared_JAMA_Matrix::MatrixDimensionException); + throw new PHPExcel_Calculation_Exception(PHPExcel_Shared_JAMA_Matrix::MatrixDimensionException); } } // function solve() diff --git a/htdocs/includes/phpexcel/PHPExcel/Shared/JAMA/examples/LMQuadTest.php b/htdocs/includes/phpexcel/PHPExcel/Shared/JAMA/examples/LMQuadTest.php deleted file mode 100644 index 2f316de9730..00000000000 --- a/htdocs/includes/phpexcel/PHPExcel/Shared/JAMA/examples/LMQuadTest.php +++ /dev/null @@ -1,116 +0,0 @@ -val($x[$i], $a); - print("Quad ".$c.",".$r." -> ".$y[$i]."
"); - $s[$i] = 1.; - ++$i; - } - } - print("quad x= "); - - $qx = new Matrix($x); - $qx->print(10, 2); - - print("quad y= "); - $qy = new Matrix($y, $npts); - $qy->print(10, 2); - - $o[0] = $x; - $o[1] = $a; - $o[2] = $y; - $o[3] = $s; - - return $o; - } // function testdata() - -} // class LMQuadTest diff --git a/htdocs/includes/phpexcel/PHPExcel/Shared/JAMA/examples/LagrangeInterpolation.php b/htdocs/includes/phpexcel/PHPExcel/Shared/JAMA/examples/LagrangeInterpolation.php deleted file mode 100644 index 5b742861350..00000000000 --- a/htdocs/includes/phpexcel/PHPExcel/Shared/JAMA/examples/LagrangeInterpolation.php +++ /dev/null @@ -1,59 +0,0 @@ -solve($b); - - return $s->getRowPackedCopy(); - } // function findPolynomialFactors() - -} // class LagrangeInterpolation - - -$x = array(2.0, 1.0, 3.0); -$y = array(3.0, 4.0, 7.0); - -$li = new LagrangeInterpolation; -$f = $li->findPolynomialFactors($x, $y); - - -for ($i = 0; $i < 3; ++$i) { - echo $f[$i]."
"; -} diff --git a/htdocs/includes/phpexcel/PHPExcel/Shared/JAMA/examples/LagrangeInterpolation2.php b/htdocs/includes/phpexcel/PHPExcel/Shared/JAMA/examples/LagrangeInterpolation2.php deleted file mode 100644 index e7529c5f162..00000000000 --- a/htdocs/includes/phpexcel/PHPExcel/Shared/JAMA/examples/LagrangeInterpolation2.php +++ /dev/null @@ -1,59 +0,0 @@ -solve($b); - - return $s->getRowPackedCopy(); - } // function findPolynomialFactors() - -} // class LagrangeInterpolation - - -$x = array(2.0, 1.0, 3.0); -$y = array(3.0, 4.0, 7.0); - -$li = new LagrangeInterpolation; -$f = $li->findPolynomialFactors($x, $y); - -for ($i = 0; $i < 3; ++$i) { - echo $f[$i]."
"; -} diff --git a/htdocs/includes/phpexcel/PHPExcel/Shared/JAMA/examples/LevenbergMarquardt.php b/htdocs/includes/phpexcel/PHPExcel/Shared/JAMA/examples/LevenbergMarquardt.php deleted file mode 100644 index 7cfd5f89976..00000000000 --- a/htdocs/includes/phpexcel/PHPExcel/Shared/JAMA/examples/LevenbergMarquardt.php +++ /dev/null @@ -1,185 +0,0 @@ -val($x[$i], $a); - $d = $d / $s[$i]; - $sum = $sum + ($d*$d); - } - - return $sum; - } // function chiSquared() - - - /** - * Minimize E = sum {(y[k] - f(x[k],a)) / s[k]}^2 - * The individual errors are optionally scaled by s[k]. - * Note that LMfunc implements the value and gradient of f(x,a), - * NOT the value and gradient of E with respect to a! - * - * @param x array of domain points, each may be multidimensional - * @param y corresponding array of values - * @param a the parameters/state of the model - * @param vary false to indicate the corresponding a[k] is to be held fixed - * @param s2 sigma^2 for point i - * @param lambda blend between steepest descent (lambda high) and - * jump to bottom of quadratic (lambda zero). - * Start with 0.001. - * @param termepsilon termination accuracy (0.01) - * @param maxiter stop and return after this many iterations if not done - * @param verbose set to zero (no prints), 1, 2 - * - * @return the new lambda for future iterations. - * Can use this and maxiter to interleave the LM descent with some other - * task, setting maxiter to something small. - */ - function solve($x, $a, $y, $s, $vary, $f, $lambda, $termepsilon, $maxiter, $verbose) { - $npts = count($y); - $nparm = count($a); - - if ($verbose > 0) { - print("solve x[".count($x)."][".count($x[0])."]"); - print(" a[".count($a)."]"); - println(" y[".count(length)."]"); - } - - $e0 = $this->chiSquared($x, $a, $y, $s, $f); - - //double lambda = 0.001; - $done = false; - - // g = gradient, H = hessian, d = step to minimum - // H d = -g, solve for d - $H = array(); - $g = array(); - - //double[] d = new double[nparm]; - - $oos2 = array(); - - for($i = 0; $i < $npts; ++$i) { - $oos2[$i] = 1./($s[$i]*$s[$i]); - } - $iter = 0; - $term = 0; // termination count test - - do { - ++$iter; - - // hessian approximation - for( $r = 0; $r < $nparm; ++$r) { - for( $c = 0; $c < $nparm; ++$c) { - for( $i = 0; $i < $npts; ++$i) { - if ($i == 0) $H[$r][$c] = 0.; - $xi = $x[$i]; - $H[$r][$c] += ($oos2[$i] * $f->grad($xi, $a, $r) * $f->grad($xi, $a, $c)); - } //npts - } //c - } //r - - // boost diagonal towards gradient descent - for( $r = 0; $r < $nparm; ++$r) - $H[$r][$r] *= (1. + $lambda); - - // gradient - for( $r = 0; $r < $nparm; ++$r) { - for( $i = 0; $i < $npts; ++$i) { - if ($i == 0) $g[$r] = 0.; - $xi = $x[$i]; - $g[$r] += ($oos2[$i] * ($y[$i]-$f->val($xi,$a)) * $f->grad($xi, $a, $r)); - } - } //npts - - // scale (for consistency with NR, not necessary) - if ($false) { - for( $r = 0; $r < $nparm; ++$r) { - $g[$r] = -0.5 * $g[$r]; - for( $c = 0; $c < $nparm; ++$c) { - $H[$r][$c] *= 0.5; - } - } - } - - // solve H d = -g, evaluate error at new location - //double[] d = DoubleMatrix.solve(H, g); -// double[] d = (new Matrix(H)).lu().solve(new Matrix(g, nparm)).getRowPackedCopy(); - //double[] na = DoubleVector.add(a, d); -// double[] na = (new Matrix(a, nparm)).plus(new Matrix(d, nparm)).getRowPackedCopy(); -// double e1 = chiSquared(x, na, y, s, f); - -// if (verbose > 0) { -// System.out.println("\n\niteration "+iter+" lambda = "+lambda); -// System.out.print("a = "); -// (new Matrix(a, nparm)).print(10, 2); -// if (verbose > 1) { -// System.out.print("H = "); -// (new Matrix(H)).print(10, 2); -// System.out.print("g = "); -// (new Matrix(g, nparm)).print(10, 2); -// System.out.print("d = "); -// (new Matrix(d, nparm)).print(10, 2); -// } -// System.out.print("e0 = " + e0 + ": "); -// System.out.print("moved from "); -// (new Matrix(a, nparm)).print(10, 2); -// System.out.print("e1 = " + e1 + ": "); -// if (e1 < e0) { -// System.out.print("to "); -// (new Matrix(na, nparm)).print(10, 2); -// } else { -// System.out.println("move rejected"); -// } -// } - - // termination test (slightly different than NR) -// if (Math.abs(e1-e0) > termepsilon) { -// term = 0; -// } else { -// term++; -// if (term == 4) { -// System.out.println("terminating after " + iter + " iterations"); -// done = true; -// } -// } -// if (iter >= maxiter) done = true; - - // in the C++ version, found that changing this to e1 >= e0 - // was not a good idea. See comment there. - // -// if (e1 > e0 || Double.isNaN(e1)) { // new location worse than before -// lambda *= 10.; -// } else { // new location better, accept new parameters -// lambda *= 0.1; -// e0 = e1; -// // simply assigning a = na will not get results copied back to caller -// for( int i = 0; i < nparm; i++ ) { -// if (vary[i]) a[i] = na[i]; -// } -// } - } while(!$done); - - return $lambda; - } // function solve() - -} // class LevenbergMarquardt diff --git a/htdocs/includes/phpexcel/PHPExcel/Shared/JAMA/examples/MagicSquareExample.php b/htdocs/includes/phpexcel/PHPExcel/Shared/JAMA/examples/MagicSquareExample.php deleted file mode 100644 index e6c93d05b20..00000000000 --- a/htdocs/includes/phpexcel/PHPExcel/Shared/JAMA/examples/MagicSquareExample.php +++ /dev/null @@ -1,182 +0,0 @@ -magic($p); - $M = array(); - for ($j = 0; $j < $p; ++$j) { - for ($i = 0; $i < $p; ++$i) { - $aij = $A->get($i,$j); - $M[$i][$j] = $aij; - $M[$i][$j+$p] = $aij + 2*$p*$p; - $M[$i+$p][$j] = $aij + 3*$p*$p; - $M[$i+$p][$j+$p] = $aij + $p*$p; - } - } - - for ($i = 0; $i < $p; ++$i) { - for ($j = 0; $j < $k; ++$j) { - $t = $M[$i][$j]; - $M[$i][$j] = $M[$i+$p][$j]; - $M[$i+$p][$j] = $t; - } - for ($j = $n-$k+1; $j < $n; ++$j) { - $t = $M[$i][$j]; - $M[$i][$j] = $M[$i+$p][$j]; - $M[$i+$p][$j] = $t; - } - } - - $t = $M[$k][0]; $M[$k][0] = $M[$k+$p][0]; $M[$k+$p][0] = $t; - $t = $M[$k][$k]; $M[$k][$k] = $M[$k+$p][$k]; $M[$k+$p][$k] = $t; - - } - - return new Matrix($M); - - } - - /** - * Simple function to replicate PHP 5 behaviour - */ - function microtime_float() { - list($usec, $sec) = explode(" ", microtime()); - return ((float)$usec + (float)$sec); - } - - /** - * Tests LU, QR, SVD and symmetric Eig decompositions. - * - * n = order of magic square. - * trace = diagonal sum, should be the magic sum, (n^3 + n)/2. - * max_eig = maximum eigenvalue of (A + A')/2, should equal trace. - * rank = linear algebraic rank, should equal n if n is odd, - * be less than n if n is even. - * cond = L_2 condition number, ratio of singular values. - * lu_res = test of LU factorization, norm1(L*U-A(p,:))/(n*eps). - * qr_res = test of QR factorization, norm1(Q*R-A)/(n*eps). - */ - function main() { - ?> -

Test of Matrix Class, using magic squares.

-

See MagicSquareExample.main() for an explanation.

- - - - - - - - - - - microtime_float(); - $eps = pow(2.0,-52.0); - for ($n = 3; $n <= 6; ++$n) { - echo ""; - - echo ""; - - $M = $this->magic($n); - $t = (int) $M->trace(); - - echo ""; - - $O = $M->plus($M->transpose()); - $E = new EigenvalueDecomposition($O->times(0.5)); - $d = $E->getRealEigenvalues(); - - echo ""; - - $r = $M->rank(); - - echo ""; - - $c = $M->cond(); - - if ($c < 1/$eps) - echo ""; - else - echo ""; - - $LU = new LUDecomposition($M); - $L = $LU->getL(); - $U = $LU->getU(); - $p = $LU->getPivot(); - // Java version: R = L.times(U).minus(M.getMatrix(p,0,n-1)); - $S = $L->times($U); - $R = $S->minus($M->getMatrix($p,0,$n-1)); - $res = $R->norm1()/($n*$eps); - - echo ""; - - $QR = new QRDecomposition($M); - $Q = $QR->getQ(); - $R = $QR->getR(); - $S = $Q->times($R); - $R = $S->minus($M); - $res = $R->norm1()/($n*$eps); - - echo ""; - - echo ""; - - } - echo "
ntracemax_eigrankcondlu_resqr_res
$n$t".$d[$n-1]."".$r."".sprintf("%.3f",$c)."Inf".sprintf("%.3f",$res)."".sprintf("%.3f",$res)."
"; - echo "
"; - - $stop_time = $this->microtime_float(); - $etime = $stop_time - $start_time; - - echo "

Elapsed time is ". sprintf("%.4f",$etime) ." seconds.

"; - - } - -} - -$magic = new MagicSquareExample(); -$magic->main(); - -?> diff --git a/htdocs/includes/phpexcel/PHPExcel/Shared/JAMA/examples/Stats.php b/htdocs/includes/phpexcel/PHPExcel/Shared/JAMA/examples/Stats.php deleted file mode 100644 index 38bc4b7d86c..00000000000 --- a/htdocs/includes/phpexcel/PHPExcel/Shared/JAMA/examples/Stats.php +++ /dev/null @@ -1,1605 +0,0 @@ - | -// +----------------------------------------------------------------------+ -// -// $Id: Stats.php,v 1.15 2003/06/01 11:40:30 jmcastagnetto Exp $ -// - -include_once 'PEAR.php'; - -/** -* @package Math_Stats -*/ - -// Constants for defining the statistics to calculate /*{{{*/ -/** -* STATS_BASIC to generate the basic descriptive statistics -*/ -define('STATS_BASIC', 1); -/** -* STATS_FULL to generate also higher moments, mode, median, etc. -*/ -define('STATS_FULL', 2); -/*}}}*/ - -// Constants describing the data set format /*{{{*/ -/** -* STATS_DATA_SIMPLE for an array of numeric values. This is the default. -* e.g. $data = array(2,3,4,5,1,1,6); -*/ -define('STATS_DATA_SIMPLE', 0); -/** -* STATS_DATA_CUMMULATIVE for an associative array of frequency values, -* where in each array entry, the index is the data point and the -* value the count (frequency): -* e.g. $data = array(3=>4, 2.3=>5, 1.25=>6, 0.5=>3) -*/ -define('STATS_DATA_CUMMULATIVE', 1); -/*}}}*/ - -// Constants defining how to handle nulls /*{{{*/ -/** -* STATS_REJECT_NULL, reject data sets with null values. This is the default. -* Any non-numeric value is considered a null in this context. -*/ -define('STATS_REJECT_NULL', -1); -/** -* STATS_IGNORE_NULL, ignore null values and prune them from the data. -* Any non-numeric value is considered a null in this context. -*/ -define('STATS_IGNORE_NULL', -2); -/** -* STATS_USE_NULL_AS_ZERO, assign the value of 0 (zero) to null values. -* Any non-numeric value is considered a null in this context. -*/ -define('STATS_USE_NULL_AS_ZERO', -3); -/*}}}*/ - -/** -* A class to calculate descriptive statistics from a data set. -* Data sets can be simple arrays of data, or a cummulative hash. -* The second form is useful when passing large data set, -* for example the data set: -* -*
-* $data1 = array (1,2,1,1,1,1,3,3,4.1,3,2,2,4.1,1,1,2,3,3,2,2,1,1,2,2);
-* 
-* -* can be epxressed more compactly as: -* -*
-* $data2 = array('1'=>9, '2'=>8, '3'=>5, '4.1'=>2);
-* 
-* -* Example of use: -* -*
-* include_once 'Math/Stats.php';
-* $s = new Math_Stats();
-* $s->setData($data1);
-* // or
-* // $s->setData($data2, STATS_DATA_CUMMULATIVE);
-* $stats = $s->calcBasic();
-* echo 'Mean: '.$stats['mean'].' StDev: '.$stats['stdev'].' 
\n'; -* -* // using data with nulls -* // first ignoring them: -* $data3 = array(1.2, 'foo', 2.4, 3.1, 4.2, 3.2, null, 5.1, 6.2); -* $s->setNullOption(STATS_IGNORE_NULL); -* $s->setData($data3); -* $stats3 = $s->calcFull(); -* -* // and then assuming nulls == 0 -* $s->setNullOption(STATS_USE_NULL_AS_ZERO); -* $s->setData($data3); -* $stats3 = $s->calcFull(); -*
-* -* Originally this class was part of NumPHP (Numeric PHP package) -* -* @author Jesus M. Castagnetto -* @version 0.8 -* @access public -* @package Math_Stats -*/ -class Base {/*{{{*/ - // properties /*{{{*/ - - /** - * The simple or cummulative data set. - * Null by default. - * - * @access private - * @var array - */ - public $_data = null; - - /** - * Expanded data set. Only set when cummulative data - * is being used. Null by default. - * - * @access private - * @var array - */ - public $_dataExpanded = null; - - /** - * Flag for data type, one of STATS_DATA_SIMPLE or - * STATS_DATA_CUMMULATIVE. Null by default. - * - * @access private - * @var int - */ - public $_dataOption = null; - - /** - * Flag for null handling options. One of STATS_REJECT_NULL, - * STATS_IGNORE_NULL or STATS_USE_NULL_AS_ZERO - * - * @access private - * @var int - */ - public $_nullOption; - - /** - * Array for caching result values, should be reset - * when using setData() - * - * @access private - * @var array - */ - public $_calculatedValues = array(); - - /*}}}*/ - - /** - * Constructor for the class - * - * @access public - * @param optional int $nullOption how to handle null values - * @return object Math_Stats - */ - function Math_Stats($nullOption=STATS_REJECT_NULL) {/*{{{*/ - $this->_nullOption = $nullOption; - }/*}}}*/ - - /** - * Sets and verifies the data, checking for nulls and using - * the current null handling option - * - * @access public - * @param array $arr the data set - * @param optional int $opt data format: STATS_DATA_CUMMULATIVE or STATS_DATA_SIMPLE (default) - * @return mixed true on success, a PEAR_Error object otherwise - */ - function setData($arr, $opt=STATS_DATA_SIMPLE) {/*{{{*/ - if (!is_array($arr)) { - return PEAR::raiseError('invalid data, an array of numeric data was expected'); - } - $this->_data = null; - $this->_dataExpanded = null; - $this->_dataOption = null; - $this->_calculatedValues = array(); - if ($opt == STATS_DATA_SIMPLE) { - $this->_dataOption = $opt; - $this->_data = array_values($arr); - } else if ($opt == STATS_DATA_CUMMULATIVE) { - $this->_dataOption = $opt; - $this->_data = $arr; - $this->_dataExpanded = array(); - } - return $this->_validate(); - }/*}}}*/ - - /** - * Returns the data which might have been modified - * according to the current null handling options. - * - * @access public - * @param boolean $expanded whether to return a expanded list, default is false - * @return mixed array of data on success, a PEAR_Error object otherwise - * @see _validate() - */ - function getData($expanded=false) {/*{{{*/ - if ($this->_data == null) { - return PEAR::raiseError('data has not been set'); - } - if ($this->_dataOption == STATS_DATA_CUMMULATIVE && $expanded) { - return $this->_dataExpanded; - } else { - return $this->_data; - } - }/*}}}*/ - - /** - * Sets the null handling option. - * Must be called before assigning a new data set containing null values - * - * @access public - * @return mixed true on success, a PEAR_Error object otherwise - * @see _validate() - */ - function setNullOption($nullOption) {/*{{{*/ - if ($nullOption == STATS_REJECT_NULL - || $nullOption == STATS_IGNORE_NULL - || $nullOption == STATS_USE_NULL_AS_ZERO) { - $this->_nullOption = $nullOption; - return true; - } else { - return PEAR::raiseError('invalid null handling option expecting: '. - 'STATS_REJECT_NULL, STATS_IGNORE_NULL or STATS_USE_NULL_AS_ZERO'); - } - }/*}}}*/ - - /** - * Transforms the data by substracting each entry from the mean and - * dividing by its standard deviation. This will reset all pre-calculated - * values to their original (unset) defaults. - * - * @access public - * @return mixed true on success, a PEAR_Error object otherwise - * @see mean() - * @see stDev() - * @see setData() - */ - function studentize() {/*{{{*/ - $mean = $this->mean(); - if (PEAR::isError($mean)) { - return $mean; - } - $std = $this->stDev(); - if (PEAR::isError($std)) { - return $std; - } - if ($std == 0) { - return PEAR::raiseError('cannot studentize data, standard deviation is zero.'); - } - $arr = array(); - if ($this->_dataOption == STATS_DATA_CUMMULATIVE) { - foreach ($this->_data as $val=>$freq) { - $newval = ($val - $mean) / $std; - $arr["$newval"] = $freq; - } - } else { - foreach ($this->_data as $val) { - $newval = ($val - $mean) / $std; - $arr[] = $newval; - } - } - return $this->setData($arr, $this->_dataOption); - }/*}}}*/ - - /** - * Transforms the data by substracting each entry from the mean. - * This will reset all pre-calculated values to their original (unset) defaults. - * - * @access public - * @return mixed true on success, a PEAR_Error object otherwise - * @see mean() - * @see setData() - */ - function center() {/*{{{*/ - $mean = $this->mean(); - if (PEAR::isError($mean)) { - return $mean; - } - $arr = array(); - if ($this->_dataOption == STATS_DATA_CUMMULATIVE) { - foreach ($this->_data as $val=>$freq) { - $newval = $val - $mean; - $arr["$newval"] = $freq; - } - } else { - foreach ($this->_data as $val) { - $newval = $val - $mean; - $arr[] = $newval; - } - } - return $this->setData($arr, $this->_dataOption); - }/*}}}*/ - - /** - * Calculates the basic or full statistics for the data set - * - * @access public - * @param int $mode one of STATS_BASIC or STATS_FULL - * @param boolean $returnErrorObject whether the raw PEAR_Error (when true, default), - * or only the error message will be returned (when false), if an error happens. - * @return mixed an associative array of statistics on success, a PEAR_Error object otherwise - * @see calcBasic() - * @see calcFull() - */ - function calc($mode, $returnErrorObject=true) {/*{{{*/ - if ($this->_data == null) { - return PEAR::raiseError('data has not been set'); - } - if ($mode == STATS_BASIC) { - return $this->calcBasic($returnErrorObject); - } elseif ($mode == STATS_FULL) { - return $this->calcFull($returnErrorObject); - } else { - return PEAR::raiseError('incorrect mode, expected STATS_BASIC or STATS_FULL'); - } - }/*}}}*/ - - /** - * Calculates a basic set of statistics - * - * @access public - * @param boolean $returnErrorObject whether the raw PEAR_Error (when true, default), - * or only the error message will be returned (when false), if an error happens. - * @return mixed an associative array of statistics on success, a PEAR_Error object otherwise - * @see calc() - * @see calcFull() - */ - function calcBasic($returnErrorObject=true) {/*{{{*/ - return array ( - 'min' => $this->__format($this->min(), $returnErrorObject), - 'max' => $this->__format($this->max(), $returnErrorObject), - 'sum' => $this->__format($this->sum(), $returnErrorObject), - 'sum2' => $this->__format($this->sum2(), $returnErrorObject), - 'count' => $this->__format($this->count(), $returnErrorObject), - 'mean' => $this->__format($this->mean(), $returnErrorObject), - 'stdev' => $this->__format($this->stDev(), $returnErrorObject), - 'variance' => $this->__format($this->variance(), $returnErrorObject), - 'range' => $this->__format($this->range(), $returnErrorObject) - ); - }/*}}}*/ - - /** - * Calculates a full set of statistics - * - * @access public - * @param boolean $returnErrorObject whether the raw PEAR_Error (when true, default), - * or only the error message will be returned (when false), if an error happens. - * @return mixed an associative array of statistics on success, a PEAR_Error object otherwise - * @see calc() - * @see calcBasic() - */ - function calcFull($returnErrorObject=true) {/*{{{*/ - return array ( - 'min' => $this->__format($this->min(), $returnErrorObject), - 'max' => $this->__format($this->max(), $returnErrorObject), - 'sum' => $this->__format($this->sum(), $returnErrorObject), - 'sum2' => $this->__format($this->sum2(), $returnErrorObject), - 'count' => $this->__format($this->count(), $returnErrorObject), - 'mean' => $this->__format($this->mean(), $returnErrorObject), - 'median' => $this->__format($this->median(), $returnErrorObject), - 'mode' => $this->__format($this->mode(), $returnErrorObject), - 'midrange' => $this->__format($this->midrange(), $returnErrorObject), - 'geometric_mean' => $this->__format($this->geometricMean(), $returnErrorObject), - 'harmonic_mean' => $this->__format($this->harmonicMean(), $returnErrorObject), - 'stdev' => $this->__format($this->stDev(), $returnErrorObject), - 'absdev' => $this->__format($this->absDev(), $returnErrorObject), - 'variance' => $this->__format($this->variance(), $returnErrorObject), - 'range' => $this->__format($this->range(), $returnErrorObject), - 'std_error_of_mean' => $this->__format($this->stdErrorOfMean(), $returnErrorObject), - 'skewness' => $this->__format($this->skewness(), $returnErrorObject), - 'kurtosis' => $this->__format($this->kurtosis(), $returnErrorObject), - 'coeff_of_variation' => $this->__format($this->coeffOfVariation(), $returnErrorObject), - 'sample_central_moments' => array ( - 1 => $this->__format($this->sampleCentralMoment(1), $returnErrorObject), - 2 => $this->__format($this->sampleCentralMoment(2), $returnErrorObject), - 3 => $this->__format($this->sampleCentralMoment(3), $returnErrorObject), - 4 => $this->__format($this->sampleCentralMoment(4), $returnErrorObject), - 5 => $this->__format($this->sampleCentralMoment(5), $returnErrorObject) - ), - 'sample_raw_moments' => array ( - 1 => $this->__format($this->sampleRawMoment(1), $returnErrorObject), - 2 => $this->__format($this->sampleRawMoment(2), $returnErrorObject), - 3 => $this->__format($this->sampleRawMoment(3), $returnErrorObject), - 4 => $this->__format($this->sampleRawMoment(4), $returnErrorObject), - 5 => $this->__format($this->sampleRawMoment(5), $returnErrorObject) - ), - 'frequency' => $this->__format($this->frequency(), $returnErrorObject), - 'quartiles' => $this->__format($this->quartiles(), $returnErrorObject), - 'interquartile_range' => $this->__format($this->interquartileRange(), $returnErrorObject), - 'interquartile_mean' => $this->__format($this->interquartileMean(), $returnErrorObject), - 'quartile_deviation' => $this->__format($this->quartileDeviation(), $returnErrorObject), - 'quartile_variation_coefficient' => $this->__format($this->quartileVariationCoefficient(), $returnErrorObject), - 'quartile_skewness_coefficient' => $this->__format($this->quartileSkewnessCoefficient(), $returnErrorObject) - ); - }/*}}}*/ - - /** - * Calculates the minimum of a data set. - * Handles cummulative data sets correctly - * - * @access public - * @return mixed the minimum value on success, a PEAR_Error object otherwise - * @see calc() - * @see max() - */ - function min() {/*{{{*/ - if ($this->_data == null) { - return PEAR::raiseError('data has not been set'); - } - if (!array_key_exists('min', $this->_calculatedValues)) { - if ($this->_dataOption == STATS_DATA_CUMMULATIVE) { - $min = min(array_keys($this->_data)); - } else { - $min = min($this->_data); - } - $this->_calculatedValues['min'] = $min; - } - return $this->_calculatedValues['min']; - }/*}}}*/ - - /** - * Calculates the maximum of a data set. - * Handles cummulative data sets correctly - * - * @access public - * @return mixed the maximum value on success, a PEAR_Error object otherwise - * @see calc() - * @see min() - */ - function max() {/*{{{*/ - if ($this->_data == null) { - return PEAR::raiseError('data has not been set'); - } - if (!array_key_exists('max', $this->_calculatedValues)) { - if ($this->_dataOption == STATS_DATA_CUMMULATIVE) { - $max = max(array_keys($this->_data)); - } else { - $max = max($this->_data); - } - $this->_calculatedValues['max'] = $max; - } - return $this->_calculatedValues['max']; - }/*}}}*/ - - /** - * Calculates SUM { xi } - * Handles cummulative data sets correctly - * - * @access public - * @return mixed the sum on success, a PEAR_Error object otherwise - * @see calc() - * @see sum2() - * @see sumN() - */ - function sum() {/*{{{*/ - if (!array_key_exists('sum', $this->_calculatedValues)) { - $sum = $this->sumN(1); - if (PEAR::isError($sum)) { - return $sum; - } else { - $this->_calculatedValues['sum'] = $sum; - } - } - return $this->_calculatedValues['sum']; - }/*}}}*/ - - /** - * Calculates SUM { (xi)^2 } - * Handles cummulative data sets correctly - * - * @access public - * @return mixed the sum on success, a PEAR_Error object otherwise - * @see calc() - * @see sum() - * @see sumN() - */ - function sum2() {/*{{{*/ - if (!array_key_exists('sum2', $this->_calculatedValues)) { - $sum2 = $this->sumN(2); - if (PEAR::isError($sum2)) { - return $sum2; - } else { - $this->_calculatedValues['sum2'] = $sum2; - } - } - return $this->_calculatedValues['sum2']; - }/*}}}*/ - - /** - * Calculates SUM { (xi)^n } - * Handles cummulative data sets correctly - * - * @access public - * @param numeric $n the exponent - * @return mixed the sum on success, a PEAR_Error object otherwise - * @see calc() - * @see sum() - * @see sum2() - */ - function sumN($n) {/*{{{*/ - if ($this->_data == null) { - return PEAR::raiseError('data has not been set'); - } - $sumN = 0; - if ($this->_dataOption == STATS_DATA_CUMMULATIVE) { - foreach($this->_data as $val=>$freq) { - $sumN += $freq * pow((double)$val, (double)$n); - } - } else { - foreach($this->_data as $val) { - $sumN += pow((double)$val, (double)$n); - } - } - return $sumN; - }/*}}}*/ - - /** - * Calculates PROD { (xi) }, (the product of all observations) - * Handles cummulative data sets correctly - * - * @access public - * @return mixed the product on success, a PEAR_Error object otherwise - * @see productN() - */ - function product() {/*{{{*/ - if (!array_key_exists('product', $this->_calculatedValues)) { - $product = $this->productN(1); - if (PEAR::isError($product)) { - return $product; - } else { - $this->_calculatedValues['product'] = $product; - } - } - return $this->_calculatedValues['product']; - }/*}}}*/ - - /** - * Calculates PROD { (xi)^n }, which is the product of all observations - * Handles cummulative data sets correctly - * - * @access public - * @param numeric $n the exponent - * @return mixed the product on success, a PEAR_Error object otherwise - * @see product() - */ - function productN($n) {/*{{{*/ - if ($this->_data == null) { - return PEAR::raiseError('data has not been set'); - } - $prodN = 1.0; - if ($this->_dataOption == STATS_DATA_CUMMULATIVE) { - foreach($this->_data as $val=>$freq) { - if ($val == 0) { - return 0.0; - } - $prodN *= $freq * pow((double)$val, (double)$n); - } - } else { - foreach($this->_data as $val) { - if ($val == 0) { - return 0.0; - } - $prodN *= pow((double)$val, (double)$n); - } - } - return $prodN; - - }/*}}}*/ - - /** - * Calculates the number of data points in the set - * Handles cummulative data sets correctly - * - * @access public - * @return mixed the count on success, a PEAR_Error object otherwise - * @see calc() - */ - function count() {/*{{{*/ - if ($this->_data == null) { - return PEAR::raiseError('data has not been set'); - } - if (!array_key_exists('count', $this->_calculatedValues)) { - if ($this->_dataOption == STATS_DATA_CUMMULATIVE) { - $count = count($this->_dataExpanded); - } else { - $count = count($this->_data); - } - $this->_calculatedValues['count'] = $count; - } - return $this->_calculatedValues['count']; - }/*}}}*/ - - /** - * Calculates the mean (average) of the data points in the set - * Handles cummulative data sets correctly - * - * @access public - * @return mixed the mean value on success, a PEAR_Error object otherwise - * @see calc() - * @see sum() - * @see count() - */ - function mean() {/*{{{*/ - if (!array_key_exists('mean', $this->_calculatedValues)) { - $sum = $this->sum(); - if (PEAR::isError($sum)) { - return $sum; - } - $count = $this->count(); - if (PEAR::isError($count)) { - return $count; - } - $this->_calculatedValues['mean'] = $sum / $count; - } - return $this->_calculatedValues['mean']; - }/*}}}*/ - - /** - * Calculates the range of the data set = max - min - * - * @access public - * @return mixed the value of the range on success, a PEAR_Error object otherwise. - */ - function range() {/*{{{*/ - if (!array_key_exists('range', $this->_calculatedValues)) { - $min = $this->min(); - if (PEAR::isError($min)) { - return $min; - } - $max = $this->max(); - if (PEAR::isError($max)) { - return $max; - } - $this->_calculatedValues['range'] = $max - $min; - } - return $this->_calculatedValues['range']; - - }/*}}}*/ - - /** - * Calculates the variance (unbiased) of the data points in the set - * Handles cummulative data sets correctly - * - * @access public - * @return mixed the variance value on success, a PEAR_Error object otherwise - * @see calc() - * @see __sumdiff() - * @see count() - */ - function variance() {/*{{{*/ - if (!array_key_exists('variance', $this->_calculatedValues)) { - $variance = $this->__calcVariance(); - if (PEAR::isError($variance)) { - return $variance; - } - $this->_calculatedValues['variance'] = $variance; - } - return $this->_calculatedValues['variance']; - }/*}}}*/ - - /** - * Calculates the standard deviation (unbiased) of the data points in the set - * Handles cummulative data sets correctly - * - * @access public - * @return mixed the standard deviation on success, a PEAR_Error object otherwise - * @see calc() - * @see variance() - */ - function stDev() {/*{{{*/ - if (!array_key_exists('stDev', $this->_calculatedValues)) { - $variance = $this->variance(); - if (PEAR::isError($variance)) { - return $variance; - } - $this->_calculatedValues['stDev'] = sqrt($variance); - } - return $this->_calculatedValues['stDev']; - }/*}}}*/ - - /** - * Calculates the variance (unbiased) of the data points in the set - * given a fixed mean (average) value. Not used in calcBasic(), calcFull() - * or calc(). - * Handles cummulative data sets correctly - * - * @access public - * @param numeric $mean the fixed mean value - * @return mixed the variance on success, a PEAR_Error object otherwise - * @see __sumdiff() - * @see count() - * @see variance() - */ - function varianceWithMean($mean) {/*{{{*/ - return $this->__calcVariance($mean); - }/*}}}*/ - - /** - * Calculates the standard deviation (unbiased) of the data points in the set - * given a fixed mean (average) value. Not used in calcBasic(), calcFull() - * or calc(). - * Handles cummulative data sets correctly - * - * @access public - * @param numeric $mean the fixed mean value - * @return mixed the standard deviation on success, a PEAR_Error object otherwise - * @see varianceWithMean() - * @see stDev() - */ - function stDevWithMean($mean) {/*{{{*/ - $varianceWM = $this->varianceWithMean($mean); - if (PEAR::isError($varianceWM)) { - return $varianceWM; - } - return sqrt($varianceWM); - }/*}}}*/ - - /** - * Calculates the absolute deviation of the data points in the set - * Handles cummulative data sets correctly - * - * @access public - * @return mixed the absolute deviation on success, a PEAR_Error object otherwise - * @see calc() - * @see __sumabsdev() - * @see count() - * @see absDevWithMean() - */ - function absDev() {/*{{{*/ - if (!array_key_exists('absDev', $this->_calculatedValues)) { - $absDev = $this->__calcAbsoluteDeviation(); - if (PEAR::isError($absdev)) { - return $absdev; - } - $this->_calculatedValues['absDev'] = $absDev; - } - return $this->_calculatedValues['absDev']; - }/*}}}*/ - - /** - * Calculates the absolute deviation of the data points in the set - * given a fixed mean (average) value. Not used in calcBasic(), calcFull() - * or calc(). - * Handles cummulative data sets correctly - * - * @access public - * @param numeric $mean the fixed mean value - * @return mixed the absolute deviation on success, a PEAR_Error object otherwise - * @see __sumabsdev() - * @see absDev() - */ - function absDevWithMean($mean) {/*{{{*/ - return $this->__calcAbsoluteDeviation($mean); - }/*}}}*/ - - /** - * Calculates the skewness of the data distribution in the set - * The skewness measures the degree of asymmetry of a distribution, - * and is related to the third central moment of a distribution. - * A normal distribution has a skewness = 0 - * A distribution with a tail off towards the high end of the scale - * (positive skew) has a skewness > 0 - * A distribution with a tail off towards the low end of the scale - * (negative skew) has a skewness < 0 - * Handles cummulative data sets correctly - * - * @access public - * @return mixed the skewness value on success, a PEAR_Error object otherwise - * @see __sumdiff() - * @see count() - * @see stDev() - * @see calc() - */ - function skewness() {/*{{{*/ - if (!array_key_exists('skewness', $this->_calculatedValues)) { - $count = $this->count(); - if (PEAR::isError($count)) { - return $count; - } - $stDev = $this->stDev(); - if (PEAR::isError($stDev)) { - return $stDev; - } - $sumdiff3 = $this->__sumdiff(3); - if (PEAR::isError($sumdiff3)) { - return $sumdiff3; - } - $this->_calculatedValues['skewness'] = ($sumdiff3 / ($count * pow($stDev, 3))); - } - return $this->_calculatedValues['skewness']; - }/*}}}*/ - - /** - * Calculates the kurtosis of the data distribution in the set - * The kurtosis measures the degrees of peakedness of a distribution. - * It is also called the "excess" or "excess coefficient", and is - * a normalized form of the fourth central moment of a distribution. - * A normal distributions has kurtosis = 0 - * A narrow and peaked (leptokurtic) distribution has a - * kurtosis > 0 - * A flat and wide (platykurtic) distribution has a kurtosis < 0 - * Handles cummulative data sets correctly - * - * @access public - * @return mixed the kurtosis value on success, a PEAR_Error object otherwise - * @see __sumdiff() - * @see count() - * @see stDev() - * @see calc() - */ - function kurtosis() {/*{{{*/ - if (!array_key_exists('kurtosis', $this->_calculatedValues)) { - $count = $this->count(); - if (PEAR::isError($count)) { - return $count; - } - $stDev = $this->stDev(); - if (PEAR::isError($stDev)) { - return $stDev; - } - $sumdiff4 = $this->__sumdiff(4); - if (PEAR::isError($sumdiff4)) { - return $sumdiff4; - } - $this->_calculatedValues['kurtosis'] = ($sumdiff4 / ($count * pow($stDev, 4))) - 3; - } - return $this->_calculatedValues['kurtosis']; - }/*}}}*/ - - /** - * Calculates the median of a data set. - * The median is the value such that half of the points are below it - * in a sorted data set. - * If the number of values is odd, it is the middle item. - * If the number of values is even, is the average of the two middle items. - * Handles cummulative data sets correctly - * - * @access public - * @return mixed the median value on success, a PEAR_Error object otherwise - * @see count() - * @see calc() - */ - function median() {/*{{{*/ - if ($this->_data == null) { - return PEAR::raiseError('data has not been set'); - } - if (!array_key_exists('median', $this->_calculatedValues)) { - if ($this->_dataOption == STATS_DATA_CUMMULATIVE) { - $arr =& $this->_dataExpanded; - } else { - $arr =& $this->_data; - } - $n = $this->count(); - if (PEAR::isError($n)) { - return $n; - } - $h = intval($n / 2); - if ($n % 2 == 0) { - $median = ($arr[$h] + $arr[$h - 1]) / 2; - } else { - $median = $arr[$h + 1]; - } - $this->_calculatedValues['median'] = $median; - } - return $this->_calculatedValues['median']; - }/*}}}*/ - - /** - * Calculates the mode of a data set. - * The mode is the value with the highest frequency in the data set. - * There can be more than one mode. - * Handles cummulative data sets correctly - * - * @access public - * @return mixed an array of mode value on success, a PEAR_Error object otherwise - * @see frequency() - * @see calc() - */ - function mode() {/*{{{*/ - if ($this->_data == null) { - return PEAR::raiseError('data has not been set'); - } - if (!array_key_exists('mode', $this->_calculatedValues)) { - if ($this->_dataOption == STATS_DATA_CUMMULATIVE) { - $arr = $this->_data; - } else { - $arr = $this->frequency(); - } - arsort($arr); - $mcount = 1; - foreach ($arr as $val=>$freq) { - if ($mcount == 1) { - $mode = array($val); - $mfreq = $freq; - ++$mcount; - continue; - } - if ($mfreq == $freq) - $mode[] = $val; - if ($mfreq > $freq) - break; - } - $this->_calculatedValues['mode'] = $mode; - } - return $this->_calculatedValues['mode']; - }/*}}}*/ - - /** - * Calculates the midrange of a data set. - * The midrange is the average of the minimum and maximum of the data set. - * Handles cummulative data sets correctly - * - * @access public - * @return mixed the midrange value on success, a PEAR_Error object otherwise - * @see min() - * @see max() - * @see calc() - */ - function midrange() {/*{{{*/ - if (!array_key_exists('midrange', $this->_calculatedValues)) { - $min = $this->min(); - if (PEAR::isError($min)) { - return $min; - } - $max = $this->max(); - if (PEAR::isError($max)) { - return $max; - } - $this->_calculatedValues['midrange'] = (($max + $min) / 2); - } - return $this->_calculatedValues['midrange']; - }/*}}}*/ - - /** - * Calculates the geometrical mean of the data points in the set - * Handles cummulative data sets correctly - * - * @access public - * @return mixed the geometrical mean value on success, a PEAR_Error object otherwise - * @see calc() - * @see product() - * @see count() - */ - function geometricMean() {/*{{{*/ - if (!array_key_exists('geometricMean', $this->_calculatedValues)) { - $count = $this->count(); - if (PEAR::isError($count)) { - return $count; - } - $prod = $this->product(); - if (PEAR::isError($prod)) { - return $prod; - } - if ($prod == 0.0) { - return 0.0; - } - if ($prod < 0) { - return PEAR::raiseError('The product of the data set is negative, geometric mean undefined.'); - } - $this->_calculatedValues['geometricMean'] = pow($prod , 1 / $count); - } - return $this->_calculatedValues['geometricMean']; - }/*}}}*/ - - /** - * Calculates the harmonic mean of the data points in the set - * Handles cummulative data sets correctly - * - * @access public - * @return mixed the harmonic mean value on success, a PEAR_Error object otherwise - * @see calc() - * @see count() - */ - function harmonicMean() {/*{{{*/ - if ($this->_data == null) { - return PEAR::raiseError('data has not been set'); - } - if (!array_key_exists('harmonicMean', $this->_calculatedValues)) { - $count = $this->count(); - if (PEAR::isError($count)) { - return $count; - } - $invsum = 0.0; - if ($this->_dataOption == STATS_DATA_CUMMULATIVE) { - foreach($this->_data as $val=>$freq) { - if ($val == 0) { - return PEAR::raiseError('cannot calculate a '. - 'harmonic mean with data values of zero.'); - } - $invsum += $freq / $val; - } - } else { - foreach($this->_data as $val) { - if ($val == 0) { - return PEAR::raiseError('cannot calculate a '. - 'harmonic mean with data values of zero.'); - } - $invsum += 1 / $val; - } - } - $this->_calculatedValues['harmonicMean'] = $count / $invsum; - } - return $this->_calculatedValues['harmonicMean']; - }/*}}}*/ - - /** - * Calculates the nth central moment (m{n}) of a data set. - * - * The definition of a sample central moment is: - * - * m{n} = 1/N * SUM { (xi - avg)^n } - * - * where: N = sample size, avg = sample mean. - * - * @access public - * @param integer $n moment to calculate - * @return mixed the numeric value of the moment on success, PEAR_Error otherwise - */ - function sampleCentralMoment($n) {/*{{{*/ - if (!is_int($n) || $n < 1) { - return PEAR::isError('moment must be a positive integer >= 1.'); - } - - if ($n == 1) { - return 0; - } - $count = $this->count(); - if (PEAR::isError($count)) { - return $count; - } - if ($count == 0) { - return PEAR::raiseError("Cannot calculate {$n}th sample moment, ". - 'there are zero data entries'); - } - $sum = $this->__sumdiff($n); - if (PEAR::isError($sum)) { - return $sum; - } - return ($sum / $count); - }/*}}}*/ - - /** - * Calculates the nth raw moment (m{n}) of a data set. - * - * The definition of a sample central moment is: - * - * m{n} = 1/N * SUM { xi^n } - * - * where: N = sample size, avg = sample mean. - * - * @access public - * @param integer $n moment to calculate - * @return mixed the numeric value of the moment on success, PEAR_Error otherwise - */ - function sampleRawMoment($n) {/*{{{*/ - if (!is_int($n) || $n < 1) { - return PEAR::isError('moment must be a positive integer >= 1.'); - } - - $count = $this->count(); - if (PEAR::isError($count)) { - return $count; - } - if ($count == 0) { - return PEAR::raiseError("Cannot calculate {$n}th raw moment, ". - 'there are zero data entries.'); - } - $sum = $this->sumN($n); - if (PEAR::isError($sum)) { - return $sum; - } - return ($sum / $count); - }/*}}}*/ - - - /** - * Calculates the coefficient of variation of a data set. - * The coefficient of variation measures the spread of a set of data - * as a proportion of its mean. It is often expressed as a percentage. - * Handles cummulative data sets correctly - * - * @access public - * @return mixed the coefficient of variation on success, a PEAR_Error object otherwise - * @see stDev() - * @see mean() - * @see calc() - */ - function coeffOfVariation() {/*{{{*/ - if (!array_key_exists('coeffOfVariation', $this->_calculatedValues)) { - $mean = $this->mean(); - if (PEAR::isError($mean)) { - return $mean; - } - if ($mean == 0.0) { - return PEAR::raiseError('cannot calculate the coefficient '. - 'of variation, mean of sample is zero'); - } - $stDev = $this->stDev(); - if (PEAR::isError($stDev)) { - return $stDev; - } - - $this->_calculatedValues['coeffOfVariation'] = $stDev / $mean; - } - return $this->_calculatedValues['coeffOfVariation']; - }/*}}}*/ - - /** - * Calculates the standard error of the mean. - * It is the standard deviation of the sampling distribution of - * the mean. The formula is: - * - * S.E. Mean = SD / (N)^(1/2) - * - * This formula does not assume a normal distribution, and shows - * that the size of the standard error of the mean is inversely - * proportional to the square root of the sample size. - * - * @access public - * @return mixed the standard error of the mean on success, a PEAR_Error object otherwise - * @see stDev() - * @see count() - * @see calc() - */ - function stdErrorOfMean() {/*{{{*/ - if (!array_key_exists('stdErrorOfMean', $this->_calculatedValues)) { - $count = $this->count(); - if (PEAR::isError($count)) { - return $count; - } - $stDev = $this->stDev(); - if (PEAR::isError($stDev)) { - return $stDev; - } - $this->_calculatedValues['stdErrorOfMean'] = $stDev / sqrt($count); - } - return $this->_calculatedValues['stdErrorOfMean']; - }/*}}}*/ - - /** - * Calculates the value frequency table of a data set. - * Handles cummulative data sets correctly - * - * @access public - * @return mixed an associative array of value=>frequency items on success, a PEAR_Error object otherwise - * @see min() - * @see max() - * @see calc() - */ - function frequency() {/*{{{*/ - if ($this->_data == null) { - return PEAR::raiseError('data has not been set'); - } - if (!array_key_exists('frequency', $this->_calculatedValues)) { - if ($this->_dataOption == STATS_DATA_CUMMULATIVE) { - $freq = $this->_data; - } else { - $freq = array(); - foreach ($this->_data as $val) { - $freq["$val"]++; - } - ksort($freq); - } - $this->_calculatedValues['frequency'] = $freq; - } - return $this->_calculatedValues['frequency']; - }/*}}}*/ - - /** - * The quartiles are defined as the values that divide a sorted - * data set into four equal-sized subsets, and correspond to the - * 25th, 50th, and 75th percentiles. - * - * @access public - * @return mixed an associative array of quartiles on success, a PEAR_Error otherwise - * @see percentile() - */ - function quartiles() {/*{{{*/ - if (!array_key_exists('quartiles', $this->_calculatedValues)) { - $q1 = $this->percentile(25); - if (PEAR::isError($q1)) { - return $q1; - } - $q2 = $this->percentile(50); - if (PEAR::isError($q2)) { - return $q2; - } - $q3 = $this->percentile(75); - if (PEAR::isError($q3)) { - return $q3; - } - $this->_calculatedValues['quartiles'] = array ( - '25' => $q1, - '50' => $q2, - '75' => $q3 - ); - } - return $this->_calculatedValues['quartiles']; - }/*}}}*/ - - /** - * The interquartile mean is defined as the mean of the values left - * after discarding the lower 25% and top 25% ranked values, i.e.: - * - * interquart mean = mean() - * - * where: P = percentile - * - * @todo need to double check the equation - * @access public - * @return mixed a numeric value on success, a PEAR_Error otherwise - * @see quartiles() - */ - function interquartileMean() {/*{{{*/ - if (!array_key_exists('interquartileMean', $this->_calculatedValues)) { - $quart = $this->quartiles(); - if (PEAR::isError($quart)) { - return $quart; - } - $q3 = $quart['75']; - $q1 = $quart['25']; - $sum = 0; - $n = 0; - foreach ($this->getData(true) as $val) { - if ($val >= $q1 && $val <= $q3) { - $sum += $val; - ++$n; - } - } - if ($n == 0) { - return PEAR::raiseError('error calculating interquartile mean, '. - 'empty interquartile range of values.'); - } - $this->_calculatedValues['interquartileMean'] = $sum / $n; - } - return $this->_calculatedValues['interquartileMean']; - }/*}}}*/ - - /** - * The interquartile range is the distance between the 75th and 25th - * percentiles. Basically the range of the middle 50% of the data set, - * and thus is not affected by outliers or extreme values. - * - * interquart range = P(75) - P(25) - * - * where: P = percentile - * - * @access public - * @return mixed a numeric value on success, a PEAR_Error otherwise - * @see quartiles() - */ - function interquartileRange() {/*{{{*/ - if (!array_key_exists('interquartileRange', $this->_calculatedValues)) { - $quart = $this->quartiles(); - if (PEAR::isError($quart)) { - return $quart; - } - $q3 = $quart['75']; - $q1 = $quart['25']; - $this->_calculatedValues['interquartileRange'] = $q3 - $q1; - } - return $this->_calculatedValues['interquartileRange']; - }/*}}}*/ - - /** - * The quartile deviation is half of the interquartile range value - * - * quart dev = (P(75) - P(25)) / 2 - * - * where: P = percentile - * - * @access public - * @return mixed a numeric value on success, a PEAR_Error otherwise - * @see quartiles() - * @see interquartileRange() - */ - function quartileDeviation() {/*{{{*/ - if (!array_key_exists('quartileDeviation', $this->_calculatedValues)) { - $iqr = $this->interquartileRange(); - if (PEAR::isError($iqr)) { - return $iqr; - } - $this->_calculatedValues['quartileDeviation'] = $iqr / 2; - } - return $this->_calculatedValues['quartileDeviation']; - }/*}}}*/ - - /** - * The quartile variation coefficient is defines as follows: - * - * quart var coeff = 100 * (P(75) - P(25)) / (P(75) + P(25)) - * - * where: P = percentile - * - * @todo need to double check the equation - * @access public - * @return mixed a numeric value on success, a PEAR_Error otherwise - * @see quartiles() - */ - function quartileVariationCoefficient() {/*{{{*/ - if (!array_key_exists('quartileVariationCoefficient', $this->_calculatedValues)) { - $quart = $this->quartiles(); - if (PEAR::isError($quart)) { - return $quart; - } - $q3 = $quart['75']; - $q1 = $quart['25']; - $d = $q3 - $q1; - $s = $q3 + $q1; - $this->_calculatedValues['quartileVariationCoefficient'] = 100 * $d / $s; - } - return $this->_calculatedValues['quartileVariationCoefficient']; - }/*}}}*/ - - /** - * The quartile skewness coefficient (also known as Bowley Skewness), - * is defined as follows: - * - * quart skewness coeff = (P(25) - 2*P(50) + P(75)) / (P(75) - P(25)) - * - * where: P = percentile - * - * @todo need to double check the equation - * @access public - * @return mixed a numeric value on success, a PEAR_Error otherwise - * @see quartiles() - */ - function quartileSkewnessCoefficient() {/*{{{*/ - if (!array_key_exists('quartileSkewnessCoefficient', $this->_calculatedValues)) { - $quart = $this->quartiles(); - if (PEAR::isError($quart)) { - return $quart; - } - $q3 = $quart['75']; - $q2 = $quart['50']; - $q1 = $quart['25']; - $d = $q3 - 2*$q2 + $q1; - $s = $q3 - $q1; - $this->_calculatedValues['quartileSkewnessCoefficient'] = $d / $s; - } - return $this->_calculatedValues['quartileSkewnessCoefficient']; - }/*}}}*/ - - /** - * The pth percentile is the value such that p% of the a sorted data set - * is smaller than it, and (100 - p)% of the data is larger. - * - * A quick algorithm to pick the appropriate value from a sorted data - * set is as follows: - * - * - Count the number of values: n - * - Calculate the position of the value in the data list: i = p * (n + 1) - * - if i is an integer, return the data at that position - * - if i < 1, return the minimum of the data set - * - if i > n, return the maximum of the data set - * - otherwise, average the entries at adjacent positions to i - * - * The median is the 50th percentile value. - * - * @todo need to double check generality of the algorithm - * - * @access public - * @param numeric $p the percentile to estimate, e.g. 25 for 25th percentile - * @return mixed a numeric value on success, a PEAR_Error otherwise - * @see quartiles() - * @see median() - */ - function percentile($p) {/*{{{*/ - $count = $this->count(); - if (PEAR::isError($count)) { - return $count; - } - if ($this->_dataOption == STATS_DATA_CUMMULATIVE) { - $data =& $this->_dataExpanded; - } else { - $data =& $this->_data; - } - $obsidx = $p * ($count + 1) / 100; - if (intval($obsidx) == $obsidx) { - return $data[($obsidx - 1)]; - } elseif ($obsidx < 1) { - return $data[0]; - } elseif ($obsidx > $count) { - return $data[($count - 1)]; - } else { - $left = floor($obsidx - 1); - $right = ceil($obsidx - 1); - return ($data[$left] + $data[$right]) / 2; - } - }/*}}}*/ - - // private methods - - /** - * Utility function to calculate: SUM { (xi - mean)^n } - * - * @access private - * @param numeric $power the exponent - * @param optional double $mean the data set mean value - * @return mixed the sum on success, a PEAR_Error object otherwise - * - * @see stDev() - * @see variaceWithMean(); - * @see skewness(); - * @see kurtosis(); - */ - function __sumdiff($power, $mean=null) {/*{{{*/ - if ($this->_data == null) { - return PEAR::raiseError('data has not been set'); - } - if (is_null($mean)) { - $mean = $this->mean(); - if (PEAR::isError($mean)) { - return $mean; - } - } - $sdiff = 0; - if ($this->_dataOption == STATS_DATA_CUMMULATIVE) { - foreach ($this->_data as $val=>$freq) { - $sdiff += $freq * pow((double)($val - $mean), (double)$power); - } - } else { - foreach ($this->_data as $val) - $sdiff += pow((double)($val - $mean), (double)$power); - } - return $sdiff; - }/*}}}*/ - - /** - * Utility function to calculate the variance with or without - * a fixed mean - * - * @access private - * @param $mean the fixed mean to use, null as default - * @return mixed a numeric value on success, a PEAR_Error otherwise - * @see variance() - * @see varianceWithMean() - */ - function __calcVariance($mean = null) {/*{{{*/ - if ($this->_data == null) { - return PEAR::raiseError('data has not been set'); - } - $sumdiff2 = $this->__sumdiff(2, $mean); - if (PEAR::isError($sumdiff2)) { - return $sumdiff2; - } - $count = $this->count(); - if (PEAR::isError($count)) { - return $count; - } - if ($count == 1) { - return PEAR::raiseError('cannot calculate variance of a singe data point'); - } - return ($sumdiff2 / ($count - 1)); - }/*}}}*/ - - /** - * Utility function to calculate the absolute deviation with or without - * a fixed mean - * - * @access private - * @param $mean the fixed mean to use, null as default - * @return mixed a numeric value on success, a PEAR_Error otherwise - * @see absDev() - * @see absDevWithMean() - */ - function __calcAbsoluteDeviation($mean = null) {/*{{{*/ - if ($this->_data == null) { - return PEAR::raiseError('data has not been set'); - } - $count = $this->count(); - if (PEAR::isError($count)) { - return $count; - } - $sumabsdev = $this->__sumabsdev($mean); - if (PEAR::isError($sumabsdev)) { - return $sumabsdev; - } - return $sumabsdev / $count; - }/*}}}*/ - - /** - * Utility function to calculate: SUM { | xi - mean | } - * - * @access private - * @param optional double $mean the mean value for the set or population - * @return mixed the sum on success, a PEAR_Error object otherwise - * - * @see absDev() - * @see absDevWithMean() - */ - function __sumabsdev($mean=null) {/*{{{*/ - if ($this->_data == null) { - return PEAR::raiseError('data has not been set'); - } - if (is_null($mean)) { - $mean = $this->mean(); - } - $sdev = 0; - if ($this->_dataOption == STATS_DATA_CUMMULATIVE) { - foreach ($this->_data as $val=>$freq) { - $sdev += $freq * abs($val - $mean); - } - } else { - foreach ($this->_data as $val) { - $sdev += abs($val - $mean); - } - } - return $sdev; - }/*}}}*/ - - /** - * Utility function to format a PEAR_Error to be used by calc(), - * calcBasic() and calcFull() - * - * @access private - * @param mixed $v value to be formatted - * @param boolean $returnErrorObject whether the raw PEAR_Error (when true, default), - * or only the error message will be returned (when false) - * @return mixed if the value is a PEAR_Error object, and $useErrorObject - * is false, then a string with the error message will be returned, - * otherwise the value will not be modified and returned as passed. - */ - function __format($v, $useErrorObject=true) {/*{{{*/ - if (PEAR::isError($v) && $useErrorObject == false) { - return $v->getMessage(); - } else { - return $v; - } - }/*}}}*/ - - /** - * Utility function to validate the data and modify it - * according to the current null handling option - * - * @access private - * @return mixed true on success, a PEAR_Error object otherwise - * - * @see setData() - */ - function _validate() {/*{{{*/ - $flag = ($this->_dataOption == STATS_DATA_CUMMULATIVE); - foreach ($this->_data as $key=>$value) { - $d = ($flag) ? $key : $value; - $v = ($flag) ? $value : $key; - if (!is_numeric($d)) { - switch ($this->_nullOption) { - case STATS_IGNORE_NULL : - unset($this->_data["$key"]); - break; - case STATS_USE_NULL_AS_ZERO: - if ($flag) { - unset($this->_data["$key"]); - $this->_data[0] += $v; - } else { - $this->_data[$key] = 0; - } - break; - case STATS_REJECT_NULL : - default: - return PEAR::raiseError('data rejected, contains NULL values'); - break; - } - } - } - if ($flag) { - ksort($this->_data); - $this->_dataExpanded = array(); - foreach ($this->_data as $val=>$freq) { - $this->_dataExpanded = array_pad($this->_dataExpanded, count($this->_dataExpanded) + $freq, $val); - } - sort($this->_dataExpanded); - } else { - sort($this->_data); - } - return true; - }/*}}}*/ - -}/*}}}*/ - -// vim: ts=4:sw=4:et: -// vim6: fdl=1: fdm=marker: - -?> diff --git a/htdocs/includes/phpexcel/PHPExcel/Shared/JAMA/examples/benchmark.php b/htdocs/includes/phpexcel/PHPExcel/Shared/JAMA/examples/benchmark.php deleted file mode 100644 index 1b963b46be2..00000000000 --- a/htdocs/includes/phpexcel/PHPExcel/Shared/JAMA/examples/benchmark.php +++ /dev/null @@ -1,263 +0,0 @@ -stat->setData($times); - $stats = $this->stat->calcFull(); - - echo '
'; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo '
n:' . $stats['count'] . '
Mean:' . $stats['mean'] . '
Min.:' . $stats['min'] . '
Max.:' . $stats['max'] . '
σ:' . $stats['stdev'] . '
Variance:' . $stats['variance'] . '
Range:' . $stats['range'] . '
'; - - return $stats; - } // function displayStats() - - - function runEig($n = 4, $t = 100) { - $times = array(); - - for ($i = 0; $i < $t; ++$i) { - $M = Matrix::random($n, $n); - $start_time = $this->microtime_float(); - $E = new EigenvalueDecomposition($M); - $stop_time = $this->microtime_float(); - $times[] = $stop_time - $start_time; - } - - return $times; - } // function runEig() - - - function runLU($n = 4, $t = 100) { - $times = array(); - - for ($i = 0; $i < $t; ++$i) { - $M = Matrix::random($n, $n); - $start_time = $this->microtime_float(); - $E = new LUDecomposition($M); - $stop_time = $this->microtime_float(); - $times[] = $stop_time - $start_time; - } - - return $times; - } // function runLU() - - - function runQR($n = 4, $t = 100) { - $times = array(); - - for ($i = 0; $i < $t; ++$i) { - $M = Matrix::random($n, $n); - $start_time = $this->microtime_float(); - $E = new QRDecomposition($M); - $stop_time = $this->microtime_float(); - $times[] = $stop_time - $start_time; - } - - return $times; - } // function runQR() - - - function runCholesky($n = 4, $t = 100) { - $times = array(); - - for ($i = 0; $i < $t; ++$i) { - $M = Matrix::random($n, $n); - $start_time = $this->microtime_float(); - $E = new CholeskyDecomposition($M); - $stop_time = $this->microtime_float(); - $times[] = $stop_time - $start_time; - } - - return $times; - } // function runCholesky() - - - function runSVD($n = 4, $t = 100) { - $times = array(); - - for ($i = 0; $i < $t; ++$i) { - $M = Matrix::random($n, $n); - $start_time = $this->microtime_float(); - $E = new SingularValueDecomposition($M); - $stop_time = $this->microtime_float(); - $times[] = $stop_time - $start_time; - } - - return $times; - } // function runSVD() - - - function run() { - $n = 8; - $t = 16; - $sum = 0; - echo "Cholesky decomposition: $t random {$n}x{$n} matrices
"; - $r = $this->displayStats($this->runCholesky($n, $t)); - $sum += $r['mean'] * $n; - - echo '
'; - - echo "Eigenvalue decomposition: $t random {$n}x{$n} matrices
"; - $r = $this->displayStats($this->runEig($n, $t)); - $sum += $r['mean'] * $n; - - echo '
'; - - echo "LU decomposition: $t random {$n}x{$n} matrices
"; - $r = $this->displayStats($this->runLU($n, $t)); - $sum += $r['mean'] * $n; - - echo '
'; - - echo "QR decomposition: $t random {$n}x{$n} matrices
"; - $r = $this->displayStats($this->runQR($n, $t)); - $sum += $r['mean'] * $n; - - echo '
'; - - echo "Singular Value decomposition: $t random {$n}x{$n} matrices
"; - $r = $this->displayStats($this->runSVD($n, $t)); - $sum += $r['mean'] * $n; - - return $sum; - } // function run() - - - public function __construct() { - $this->stat = new Base(); - } // function Benchmark() - -} // class Benchmark (end MagicSquareExample) - - -$benchmark = new Benchmark(); - -switch($_REQUEST['decomposition']) { - case 'cholesky': - $m = array(); - for ($i = 2; $i <= 8; $i *= 2) { - $t = 32 / $i; - echo "Cholesky decomposition: $t random {$i}x{$i} matrices
"; - $s = $benchmark->displayStats($benchmark->runCholesky($i, $t)); - $m[$i] = $s['mean']; - echo "
"; - } - echo '
';
-		foreach($m as $x => $y) {
-			echo "$x\t" . 1000*$y . "\n";
-		}
-		echo '
'; - break; - case 'eigenvalue': - $m = array(); - for ($i = 2; $i <= 8; $i *= 2) { - $t = 32 / $i; - echo "Eigenvalue decomposition: $t random {$i}x{$i} matrices
"; - $s = $benchmark->displayStats($benchmark->runEig($i, $t)); - $m[$i] = $s['mean']; - echo "
"; - } - echo '
';
-		foreach($m as $x => $y) {
-			echo "$x\t" . 1000*$y . "\n";
-		}
-		echo '
'; - break; - case 'lu': - $m = array(); - for ($i = 2; $i <= 8; $i *= 2) { - $t = 32 / $i; - echo "LU decomposition: $t random {$i}x{$i} matrices
"; - $s = $benchmark->displayStats($benchmark->runLU($i, $t)); - $m[$i] = $s['mean']; - echo "
"; - } - echo '
';
-		foreach($m as $x => $y) {
-			echo "$x\t" . 1000*$y . "\n";
-		}
-		echo '
'; - break; - case 'qr': - $m = array(); - for ($i = 2; $i <= 8; $i *= 2) { - $t = 32 / $i; - echo "QR decomposition: $t random {$i}x{$i} matrices
"; - $s = $benchmark->displayStats($benchmark->runQR($i, $t)); - $m[$i] = $s['mean']; - echo "
"; - } - echo '
';
-		foreach($m as $x => $y) {
-			echo "$x\t" . 1000*$y . "\n";
-		}
-		echo '
'; - break; - case 'svd': - $m = array(); - for($i = 2; $i <= 8; $i *= 2) { - $t = 32 / $i; - echo "Singular value decomposition: $t random {$i}x{$i} matrices
"; - $s = $benchmark->displayStats($benchmark->runSVD($i, $t)); - $m[$i] = $s['mean']; - echo "
"; - } - echo '
';
-		foreach($m as $x => $y) {
-			echo "$x\t" . 1000*$y . "\n";
-		}
-		echo '
'; - break; - case 'all': - $s = $benchmark->run(); - print("
Total: {$s}s
"); - break; - default: - ?> - - $n+1 -*/ -function polyfit($X, $Y, $n) { - for ($i = 0; $i < sizeof($X); ++$i) - for ($j = 0; $j <= $n; ++$j) - $A[$i][$j] = pow($X[$i], $j); - for ($i=0; $i < sizeof($Y); ++$i) - $B[$i] = array($Y[$i]); - $matrixA = new Matrix($A); - $matrixB = new Matrix($B); - $C = $matrixA->solve($matrixB); - return $C->getMatrix(0, $n, 0, 1); -} - -function printpoly( $C = null ) { - for($i = $C->m - 1; $i >= 0; --$i) { - $r = $C->get($i, 0); - if ( abs($r) <= pow(10, -9) ) - $r = 0; - if ($i == $C->m - 1) - echo $r . "x$i"; - else if ($i < $C->m - 1) - echo " + " . $r . "x$i"; - else if ($i == 0) - echo " + " . $r; - } -} - -$X = array(0,1,2,3,4,5); -$Y = array(4,3,12,67,228, 579); -$points = new Matrix(array($X, $Y)); -$points->toHTML(); -printpoly(polyfit($X, $Y, 4)); - -echo '
'; - -$X = array(0,1,2,3,4,5); -$Y = array(1,2,5,10,17, 26); -$points = new Matrix(array($X, $Y)); -$points->toHTML(); -printpoly(polyfit($X, $Y, 2)); - -echo '
'; - -$X = array(0,1,2,3,4,5,6); -$Y = array(-90,-104,-178,-252,-26, 1160, 4446); -$points = new Matrix(array($X, $Y)); -$points->toHTML(); -printpoly(polyfit($X, $Y, 5)); - -echo '
'; - -$X = array(0,1,2,3,4); -$Y = array(mt_rand(0, 10), mt_rand(40, 80), mt_rand(240, 400), mt_rand(1800, 2215), mt_rand(8000, 9000)); -$points = new Matrix(array($X, $Y)); -$points->toHTML(); -printpoly(polyfit($X, $Y, 3)); -?> diff --git a/htdocs/includes/phpexcel/PHPExcel/Shared/JAMA/examples/tile.php b/htdocs/includes/phpexcel/PHPExcel/Shared/JAMA/examples/tile.php deleted file mode 100644 index 7a47ea57b2a..00000000000 --- a/htdocs/includes/phpexcel/PHPExcel/Shared/JAMA/examples/tile.php +++ /dev/null @@ -1,78 +0,0 @@ -getArray(); - print_r($xArray); - - $countRow = 0; - $countColumn = 0; - - $m = $X->getRowDimension(); - $n = $X->getColumnDimension(); - - if( $rowWise<1 || $colWise<1 ){ - die("tile : Array index is out-of-bound."); - } - - $newRowDim = $m*$rowWise; - $newColDim = $n*$colWise; - - $result = array(); - - for($i=0 ; $i<$newRowDim; ++$i) { - - $holder = array(); - - for($j=0 ; $j<$newColDim ; ++$j) { - - $holder[$j] = $xArray[$countRow][$countColumn++]; - - // reset the column-index to zero to avoid reference to out-of-bound index in xArray[][] - - if($countColumn == $n) { $countColumn = 0; } - - } // end for - - ++$countRow; - - // reset the row-index to zero to avoid reference to out-of-bound index in xArray[][] - - if($countRow == $m) { $countRow = 0; } - - $result[$i] = $holder; - - } // end for - - return new Matrix($result); - -} - - -$X =array(1,2,3,4,5,6,7,8,9); -$nRow = 3; -$nCol = 3; -$tiled_matrix = tile(new Matrix($X), $nRow, $nCol); -echo "
";
-print_r($tiled_matrix);
-echo "
"; -?> diff --git a/htdocs/includes/phpexcel/PHPExcel/Shared/JAMA/tests/TestMatrix.php b/htdocs/includes/phpexcel/PHPExcel/Shared/JAMA/tests/TestMatrix.php deleted file mode 100644 index 5290ceb5af2..00000000000 --- a/htdocs/includes/phpexcel/PHPExcel/Shared/JAMA/tests/TestMatrix.php +++ /dev/null @@ -1,415 +0,0 @@ -Testing constructors and constructor-like methods...

"; - - $A = new Matrix($columnwise, 3); - if($A instanceof Matrix) { - $this->try_success("Column-packed constructor..."); - } else - $errorCount = $this->try_failure($errorCount, "Column-packed constructor...", "Unable to construct Matrix"); - - $T = new Matrix($tvals); - if($T instanceof Matrix) - $this->try_success("2D array constructor..."); - else - $errorCount = $this->try_failure($errorCount, "2D array constructor...", "Unable to construct Matrix"); - - $A = new Matrix($columnwise, $validID); - $B = new Matrix($avals); - $tmp = $B->get(0,0); - $avals[0][0] = 0.0; - $C = $B->minus($A); - $avals[0][0] = $tmp; - $B = Matrix::constructWithCopy($avals); - $tmp = $B->get(0,0); - $avals[0][0] = 0.0; - /** check that constructWithCopy behaves properly **/ - if ( ( $tmp - $B->get(0,0) ) != 0.0 ) - $errorCount = $this->try_failure($errorCount,"constructWithCopy... ","copy not effected... data visible outside"); - else - $this->try_success("constructWithCopy... ",""); - - $I = new Matrix($ivals); - if ( $this->checkMatrices($I,Matrix::identity(3,4)) ) - $this->try_success("identity... ",""); - else - $errorCount = $this->try_failure($errorCount,"identity... ","identity Matrix not successfully created"); - - /** - * Access Methods: - * - * getColumnDimension() - * getRowDimension() - * getArray() - * getArrayCopy() - * getColumnPackedCopy() - * getRowPackedCopy() - * get(int,int) - * getMatrix(int,int,int,int) - * getMatrix(int,int,int[]) - * getMatrix(int[],int,int) - * getMatrix(int[],int[]) - * set(int,int,double) - * setMatrix(int,int,int,int,Matrix) - * setMatrix(int,int,int[],Matrix) - * setMatrix(int[],int,int,Matrix) - * setMatrix(int[],int[],Matrix) - */ - print "

Testing access methods...

"; - - $B = new Matrix($avals); - if($B->getRowDimension() == $rows) - $this->try_success("getRowDimension..."); - else - $errorCount = $this->try_failure($errorCount, "getRowDimension..."); - - if($B->getColumnDimension() == $cols) - $this->try_success("getColumnDimension..."); - else - $errorCount = $this->try_failure($errorCount, "getColumnDimension..."); - - $barray = $B->getArray(); - if($this->checkArrays($barray, $avals)) - $this->try_success("getArray..."); - else - $errorCount = $this->try_failure($errorCount, "getArray..."); - - $bpacked = $B->getColumnPackedCopy(); - if($this->checkArrays($bpacked, $columnwise)) - $this->try_success("getColumnPackedCopy..."); - else - $errorCount = $this->try_failure($errorCount, "getColumnPackedCopy..."); - - $bpacked = $B->getRowPackedCopy(); - if($this->checkArrays($bpacked, $rowwise)) - $this->try_success("getRowPackedCopy..."); - else - $errorCount = $this->try_failure($errorCount, "getRowPackedCopy..."); - - /** - * Array-like methods: - * minus - * minusEquals - * plus - * plusEquals - * arrayLeftDivide - * arrayLeftDivideEquals - * arrayRightDivide - * arrayRightDivideEquals - * arrayTimes - * arrayTimesEquals - * uminus - */ - print "

Testing array-like methods...

"; - - /** - * I/O methods: - * read - * print - * serializable: - * writeObject - * readObject - */ - print "

Testing I/O methods...

"; - - /** - * Test linear algebra methods - */ - echo "

Testing linear algebra methods...

"; - - $A = new Matrix($columnwise, 3); - if( $this->checkMatrices($A->transpose(), $T) ) - $this->try_success("Transpose check..."); - else - $errorCount = $this->try_failure($errorCount, "Transpose check...", "Matrices are not equal"); - - if($this->checkScalars($A->norm1(), $columnsummax)) - $this->try_success("Maximum column sum..."); - else - $errorCount = $this->try_failure($errorCount, "Maximum column sum...", "Incorrect: " . $A->norm1() . " != " . $columnsummax); - - if($this->checkScalars($A->normInf(), $rowsummax)) - $this->try_success("Maximum row sum..."); - else - $errorCount = $this->try_failure($errorCount, "Maximum row sum...", "Incorrect: " . $A->normInf() . " != " . $rowsummax ); - - if($this->checkScalars($A->normF(), sqrt($sumofsquares))) - $this->try_success("Frobenius norm..."); - else - $errorCount = $this->try_failure($errorCount, "Frobenius norm...", "Incorrect:" . $A->normF() . " != " . sqrt($sumofsquares)); - - if($this->checkScalars($A->trace(), $sumofdiagonals)) - $this->try_success("Matrix trace..."); - else - $errorCount = $this->try_failure($errorCount, "Matrix trace...", "Incorrect: " . $A->trace() . " != " . $sumofdiagonals); - - $B = $A->getMatrix(0, $A->getRowDimension(), 0, $A->getRowDimension()); - if( $B->det() == 0 ) - $this->try_success("Matrix determinant..."); - else - $errorCount = $this->try_failure($errorCount, "Matrix determinant...", "Incorrect: " . $B->det() . " != " . 0); - - $A = new Matrix($columnwise,3); - $SQ = new Matrix($square); - if ($this->checkMatrices($SQ, $A->times($A->transpose()))) - $this->try_success("times(Matrix)..."); - else { - $errorCount = $this->try_failure($errorCount, "times(Matrix)...", "Unable to multiply matrices"); - $SQ->toHTML(); - $AT->toHTML(); - } - - $A = new Matrix($columnwise, 4); - - $QR = $A->qr(); - $R = $QR->getR(); - $Q = $QR->getQ(); - if($this->checkMatrices($A, $Q->times($R))) - $this->try_success("QRDecomposition...",""); - else - $errorCount = $this->try_failure($errorCount,"QRDecomposition...","incorrect qr decomposition calculation"); - - $A = new Matrix($columnwise, 4); - $SVD = $A->svd(); - $U = $SVD->getU(); - $S = $SVD->getS(); - $V = $SVD->getV(); - if ($this->checkMatrices($A, $U->times($S->times($V->transpose())))) - $this->try_success("SingularValueDecomposition...",""); - else - $errorCount = $this->try_failure($errorCount,"SingularValueDecomposition...","incorrect singular value decomposition calculation"); - - $n = $A->getColumnDimension(); - $A = $A->getMatrix(0,$n-1,0,$n-1); - $A->set(0,0,0.); - - $LU = $A->lu(); - $L = $LU->getL(); - if ( $this->checkMatrices($A->getMatrix($LU->getPivot(),0,$n-1), $L->times($LU->getU())) ) - $this->try_success("LUDecomposition...",""); - else - $errorCount = $this->try_failure($errorCount,"LUDecomposition...","incorrect LU decomposition calculation"); - - $X = $A->inverse(); - if ( $this->checkMatrices($A->times($X),Matrix::identity(3,3)) ) - $this->try_success("inverse()...",""); - else - $errorCount = $this->try_failure($errorCount, "inverse()...","incorrect inverse calculation"); - - $DEF = new Matrix($rankdef); - if($this->checkScalars($DEF->rank(), min($DEF->getRowDimension(), $DEF->getColumnDimension())-1)) - $this->try_success("Rank..."); - else - $this->try_failure("Rank...", "incorrect rank calculation"); - - $B = new Matrix($condmat); - $SVD = $B->svd(); - $singularvalues = $SVD->getSingularValues(); - if($this->checkScalars($B->cond(), $singularvalues[0]/$singularvalues[min($B->getRowDimension(), $B->getColumnDimension())-1])) - $this->try_success("Condition number..."); - else - $this->try_failure("Condition number...", "incorrect condition number calculation"); - - $SUB = new Matrix($subavals); - $O = new Matrix($SUB->getRowDimension(),1,1.0); - $SOL = new Matrix($sqSolution); - $SQ = $SUB->getMatrix(0,$SUB->getRowDimension()-1,0,$SUB->getRowDimension()-1); - if ( $this->checkMatrices($SQ->solve($SOL),$O) ) - $this->try_success("solve()...",""); - else - $errorCount = $this->try_failure($errorCount,"solve()...","incorrect lu solve calculation"); - - $A = new Matrix($pvals); - $Chol = $A->chol(); - $L = $Chol->getL(); - if ( $this->checkMatrices($A, $L->times($L->transpose())) ) - $this->try_success("CholeskyDecomposition...",""); - else - $errorCount = $this->try_failure($errorCount,"CholeskyDecomposition...","incorrect Cholesky decomposition calculation"); - - $X = $Chol->solve(Matrix::identity(3,3)); - if ( $this->checkMatrices($A->times($X), Matrix::identity(3,3)) ) - $this->try_success("CholeskyDecomposition solve()...",""); - else - $errorCount = $this->try_failure($errorCount,"CholeskyDecomposition solve()...","incorrect Choleskydecomposition solve calculation"); - - $Eig = $A->eig(); - $D = $Eig->getD(); - $V = $Eig->getV(); - if( $this->checkMatrices($A->times($V),$V->times($D)) ) - $this->try_success("EigenvalueDecomposition (symmetric)...",""); - else - $errorCount = $this->try_failure($errorCount,"EigenvalueDecomposition (symmetric)...","incorrect symmetric Eigenvalue decomposition calculation"); - - $A = new Matrix($evals); - $Eig = $A->eig(); - $D = $Eig->getD(); - $V = $Eig->getV(); - if ( $this->checkMatrices($A->times($V),$V->times($D)) ) - $this->try_success("EigenvalueDecomposition (nonsymmetric)...",""); - else - $errorCount = $this->try_failure($errorCount,"EigenvalueDecomposition (nonsymmetric)...","incorrect nonsymmetric Eigenvalue decomposition calculation"); - - print("{$errorCount} total errors."); - } - - /** - * Print appropriate messages for successful outcome try - * @param string $s - * @param string $e - */ - function try_success($s, $e = "") { - print "> ". $s ."success
"; - if ($e != "") - print "> Message: ". $e ."
"; - } - - /** - * Print appropriate messages for unsuccessful outcome try - * @param int $count - * @param string $s - * @param string $e - * @return int incremented counter - */ - function try_failure($count, $s, $e="") { - print "> ". $s ."*** failure ***
> Message: ". $e ."
"; - return ++$count; - } - - /** - * Print appropriate messages for unsuccessful outcome try - * @param int $count - * @param string $s - * @param string $e - * @return int incremented counter - */ - function try_warning($count, $s, $e="") { - print "> ". $s ."*** warning ***
> Message: ". $e ."
"; - return ++$count; - } - - /** - * Check magnitude of difference of "scalars". - * @param float $x - * @param float $y - */ - function checkScalars($x, $y) { - $eps = pow(2.0,-52.0); - if ($x == 0 & abs($y) < 10*$eps) return; - if ($y == 0 & abs($x) < 10*$eps) return; - if (abs($x-$y) > 10 * $eps * max(abs($x),abs($y))) - return false; - else - return true; - } - - /** - * Check norm of difference of "vectors". - * @param float $x[] - * @param float $y[] - */ - function checkVectors($x, $y) { - $nx = count($x); - $ny = count($y); - if ($nx == $ny) - for($i=0; $i < $nx; ++$i) - $this->checkScalars($x[$i],$y[$i]); - else - die("Attempt to compare vectors of different lengths"); - } - - /** - * Check norm of difference of "arrays". - * @param float $x[][] - * @param float $y[][] - */ - function checkArrays($x, $y) { - $A = new Matrix($x); - $B = new Matrix($y); - return $this->checkMatrices($A,$B); - } - - /** - * Check norm of difference of "matrices". - * @param matrix $X - * @param matrix $Y - */ - function checkMatrices($X = null, $Y = null) { - if( $X == null || $Y == null ) - return false; - - $eps = pow(2.0,-52.0); - if ($X->norm1() == 0. & $Y->norm1() < 10*$eps) return true; - if ($Y->norm1() == 0. & $X->norm1() < 10*$eps) return true; - - $A = $X->minus($Y); - - if ($A->norm1() > 1000 * $eps * max($X->norm1(),$Y->norm1())) - die("The norm of (X-Y) is too large: ".$A->norm1()); - else - return true; - } - -} - -$test = new TestMatrix; -?> diff --git a/htdocs/includes/phpexcel/PHPExcel/Shared/JAMA/utils/Maths.php b/htdocs/includes/phpexcel/PHPExcel/Shared/JAMA/utils/Maths.php index f5e2a372165..aa09a8bbbfa 100644 --- a/htdocs/includes/phpexcel/PHPExcel/Shared/JAMA/utils/Maths.php +++ b/htdocs/includes/phpexcel/PHPExcel/Shared/JAMA/utils/Maths.php @@ -35,7 +35,7 @@ function hypot() { if (is_numeric($d)) { $s += pow($d, 2); } else { - throw new Exception(JAMAError(ArgumentTypeException)); + throw new PHPExcel_Calculation_Exception(JAMAError(ArgumentTypeException)); } } return sqrt($s); diff --git a/htdocs/includes/phpexcel/PHPExcel/Shared/OLE.php b/htdocs/includes/phpexcel/PHPExcel/Shared/OLE.php index a5c8dd1d000..9796282a806 100644 --- a/htdocs/includes/phpexcel/PHPExcel/Shared/OLE.php +++ b/htdocs/includes/phpexcel/PHPExcel/Shared/OLE.php @@ -97,18 +97,18 @@ class PHPExcel_Shared_OLE { $fh = fopen($file, "r"); if (!$fh) { - throw new Exception("Can't open file $file"); + throw new PHPExcel_Reader_Exception("Can't open file $file"); } $this->_file_handle = $fh; $signature = fread($fh, 8); if ("\xD0\xCF\x11\xE0\xA1\xB1\x1A\xE1" != $signature) { - throw new Exception("File doesn't seem to be an OLE container."); + throw new PHPExcel_Reader_Exception("File doesn't seem to be an OLE container."); } fseek($fh, 28); if (fread($fh, 2) != "\xFE\xFF") { // This shouldn't be a problem in practice - throw new Exception("Only Little-Endian encoding is supported."); + throw new PHPExcel_Reader_Exception("Only Little-Endian encoding is supported."); } // Size of blocks and short blocks in bytes $this->bigBlockSize = pow(2, self::_readInt2($fh)); diff --git a/htdocs/includes/phpexcel/PHPExcel/Shared/OLE/ChainedBlockStream.php b/htdocs/includes/phpexcel/PHPExcel/Shared/OLE/ChainedBlockStream.php index 4e233ad0436..3dcd7e1dad0 100644 --- a/htdocs/includes/phpexcel/PHPExcel/Shared/OLE/ChainedBlockStream.php +++ b/htdocs/includes/phpexcel/PHPExcel/Shared/OLE/ChainedBlockStream.php @@ -2,7 +2,7 @@ /** * PHPExcel * - * Copyright (C) 2006 - 2012 PHPExcel + * Copyright (C) 2006 - 2014 PHPExcel * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -22,7 +22,7 @@ * @package PHPExcel_Shared_OLE * @copyright Copyright (c) 2006 - 2007 Christian Schmidt * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version 1.7.8, 2012-10-12 + * @version 1.8.0, 2014-03-02 */ /** @@ -161,14 +161,15 @@ class PHPExcel_Shared_OLE_ChainedBlockStream */ public function stream_eof() { - $eof = $this->pos >= strlen($this->data); - // Workaround for bug in PHP 5.0.x: http://bugs.php.net/27508 - if (version_compare(PHP_VERSION, '5.0', '>=') && - version_compare(PHP_VERSION, '5.1', '<')) { - - $eof = !$eof; - } - return $eof; +// As we don't support below 5.2 anymore, this is simply redundancy and overhead +// $eof = $this->pos >= strlen($this->data); +// // Workaround for bug in PHP 5.0.x: http://bugs.php.net/27508 +// if (version_compare(PHP_VERSION, '5.0', '>=') && +// version_compare(PHP_VERSION, '5.1', '<')) { +// $eof = !$eof; +// } +// return $eof; + return $this->pos >= strlen($this->data); } /** diff --git a/htdocs/includes/phpexcel/PHPExcel/Shared/OLE/PPS/Root.php b/htdocs/includes/phpexcel/PHPExcel/Shared/OLE/PPS/Root.php index 7046a0a3aeb..8c6dcda078a 100644 --- a/htdocs/includes/phpexcel/PHPExcel/Shared/OLE/PPS/Root.php +++ b/htdocs/includes/phpexcel/PHPExcel/Shared/OLE/PPS/Root.php @@ -84,13 +84,13 @@ class PHPExcel_Shared_OLE_PPS_Root extends PHPExcel_Shared_OLE_PPS $this->_tmp_filename = tempnam($this->_tmp_dir, "OLE_PPS_Root"); $this->_FILEH_ = fopen($this->_tmp_filename,"w+b"); if ($this->_FILEH_ == false) { - throw new Exception("Can't create temporary file."); + throw new PHPExcel_Writer_Exception("Can't create temporary file."); } } else { $this->_FILEH_ = fopen($filename, "wb"); } if ($this->_FILEH_ == false) { - throw new Exception("Can't open $filename. It may be in use or protected."); + throw new PHPExcel_Writer_Exception("Can't open $filename. It may be in use or protected."); } // Make an array of PPS's (for Save) $aList = array(); diff --git a/htdocs/includes/phpexcel/PHPExcel/Shared/OLERead.php b/htdocs/includes/phpexcel/PHPExcel/Shared/OLERead.php index 2a5eb7d7a12..c4cb7da3064 100644 --- a/htdocs/includes/phpexcel/PHPExcel/Shared/OLERead.php +++ b/htdocs/includes/phpexcel/PHPExcel/Shared/OLERead.php @@ -2,7 +2,7 @@ /** * PHPExcel * - * Copyright (c) 2006 - 2012 PHPExcel + * Copyright (c) 2006 - 2014 PHPExcel * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,12 +20,13 @@ * * @category PHPExcel * @package PHPExcel_Shared - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version 1.7.8, 2012-10-12 + * @version 1.8.0, 2014-03-02 */ -define('IDENTIFIER_OLE', pack('CCCCCCCC', 0xd0, 0xcf, 0x11, 0xe0, 0xa1, 0xb1, 0x1a, 0xe1)); +defined('IDENTIFIER_OLE') || + define('IDENTIFIER_OLE', pack('CCCCCCCC', 0xd0, 0xcf, 0x11, 0xe0, 0xa1, 0xb1, 0x1a, 0xe1)); class PHPExcel_Shared_OLERead { private $data = ''; @@ -70,23 +71,27 @@ class PHPExcel_Shared_OLERead { * Read the file * * @param $sFileName string Filename - * @throws Exception + * @throws PHPExcel_Reader_Exception */ public function read($sFileName) { // Check if file exists and is readable if(!is_readable($sFileName)) { - throw new Exception("Could not open " . $sFileName . " for reading! File does not exist, or it is not readable."); + throw new PHPExcel_Reader_Exception("Could not open " . $sFileName . " for reading! File does not exist, or it is not readable."); + } + + // Get the file identifier + // Don't bother reading the whole file until we know it's a valid OLE file + $this->data = file_get_contents($sFileName, FALSE, NULL, 0, 8); + + // Check OLE identifier + if ($this->data != self::IDENTIFIER_OLE) { + throw new PHPExcel_Reader_Exception('The filename ' . $sFileName . ' is not recognised as an OLE file'); } // Get the file data $this->data = file_get_contents($sFileName); - // Check OLE identifier - if (substr($this->data, 0, 8) != self::IDENTIFIER_OLE) { - throw new Exception('The filename ' . $sFileName . ' is not recognised as an OLE file'); - } - // Total number of sectors used for the SAT $this->numBigBlockDepotBlocks = self::_GetInt4d($this->data, self::NUM_BIG_BLOCK_DEPOT_BLOCKS_POS); @@ -131,34 +136,26 @@ class PHPExcel_Shared_OLERead { } } - $pos = $index = 0; - $this->bigBlockChain = array(); - + $pos = 0; + $this->bigBlockChain = ''; $bbs = self::BIG_BLOCK_SIZE / 4; for ($i = 0; $i < $this->numBigBlockDepotBlocks; ++$i) { $pos = ($bigBlockDepotBlocks[$i] + 1) * self::BIG_BLOCK_SIZE; - for ($j = 0 ; $j < $bbs; ++$j) { - $this->bigBlockChain[$index] = self::_GetInt4d($this->data, $pos); - $pos += 4 ; - ++$index; - } + $this->bigBlockChain .= substr($this->data, $pos, 4*$bbs); + $pos += 4*$bbs; } - $pos = $index = 0; + $pos = 0; $sbdBlock = $this->sbdStartBlock; - $this->smallBlockChain = array(); - + $this->smallBlockChain = ''; while ($sbdBlock != -2) { $pos = ($sbdBlock + 1) * self::BIG_BLOCK_SIZE; - for ($j = 0; $j < $bbs; ++$j) { - $this->smallBlockChain[$index] = self::_GetInt4d($this->data, $pos); - $pos += 4; - ++$index; - } + $this->smallBlockChain .= substr($this->data, $pos, 4*$bbs); + $pos += 4*$bbs; - $sbdBlock = $this->bigBlockChain[$sbdBlock]; + $sbdBlock = self::_GetInt4d($this->bigBlockChain, $sbdBlock*4); } // read the directory stream @@ -190,7 +187,7 @@ class PHPExcel_Shared_OLERead { $pos = $block * self::SMALL_BLOCK_SIZE; $streamData .= substr($rootdata, $pos, self::SMALL_BLOCK_SIZE); - $block = $this->smallBlockChain[$block]; + $block = self::_GetInt4d($this->smallBlockChain, $block*4); } return $streamData; @@ -207,7 +204,7 @@ class PHPExcel_Shared_OLERead { while ($block != -2) { $pos = ($block + 1) * self::BIG_BLOCK_SIZE; $streamData .= substr($this->data, $pos, self::BIG_BLOCK_SIZE); - $block = $this->bigBlockChain[$block]; + $block = self::_GetInt4d($this->bigBlockChain, $block*4); } return $streamData; @@ -228,7 +225,7 @@ class PHPExcel_Shared_OLERead { while ($block != -2) { $pos = ($block + 1) * self::BIG_BLOCK_SIZE; $data .= substr($this->data, $pos, self::BIG_BLOCK_SIZE); - $block = $this->bigBlockChain[$block]; + $block = self::_GetInt4d($this->bigBlockChain, $block*4); } return $data; } @@ -259,19 +256,22 @@ class PHPExcel_Shared_OLERead { $name = str_replace("\x00", "", substr($d,0,$nameSize)); + $this->props[] = array ( 'name' => $name, 'type' => $type, 'startBlock' => $startBlock, 'size' => $size); + // tmp helper to simplify checks + $upName = strtoupper($name); + // Workbook directory entry (BIFF5 uses Book, BIFF8 uses Workbook) - if (($name == 'Workbook') || ($name == 'Book') || ($name == 'WORKBOOK') || ($name == 'BOOK')) { + if (($upName === 'WORKBOOK') || ($upName === 'BOOK')) { $this->wrkbook = count($this->props) - 1; } - - // Root entry - if ($name == 'Root Entry' || $name == 'ROOT ENTRY' || $name == 'R') { + else if ( $upName === 'ROOT ENTRY' || $upName === 'R') { + // Root entry $this->rootentry = count($this->props) - 1; } diff --git a/htdocs/includes/phpexcel/PHPExcel/Shared/PasswordHasher.php b/htdocs/includes/phpexcel/PHPExcel/Shared/PasswordHasher.php index 65317d55b43..4f505a2aca6 100644 --- a/htdocs/includes/phpexcel/PHPExcel/Shared/PasswordHasher.php +++ b/htdocs/includes/phpexcel/PHPExcel/Shared/PasswordHasher.php @@ -2,7 +2,7 @@ /** * PHPExcel * - * Copyright (c) 2006 - 2012 PHPExcel + * Copyright (c) 2006 - 2014 PHPExcel * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,9 +20,9 @@ * * @category PHPExcel * @package PHPExcel_Shared - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version 1.7.8, 2012-10-12 + * @version 1.8.0, 2014-03-02 */ @@ -31,7 +31,7 @@ * * @category PHPExcel * @package PHPExcel_Shared - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) */ class PHPExcel_Shared_PasswordHasher { @@ -46,17 +46,16 @@ class PHPExcel_Shared_PasswordHasher * @return string Hashed password */ public static function hashPassword($pPassword = '') { - $password = 0x0000; - $i = 1; // char position + $password = 0x0000; + $charPos = 1; // char position // split the plain text password in its component characters $chars = preg_split('//', $pPassword, -1, PREG_SPLIT_NO_EMPTY); foreach ($chars as $char) { - $value = ord($char) << $i; // shifted ASCII value - $rotated_bits = $value >> 15; // rotated bits beyond bit 15 - $value &= 0x7fff; // first 15 bits - $password ^= ($value | $rotated_bits); - ++$i; + $value = ord($char) << $charPos++; // shifted ASCII value + $rotated_bits = $value >> 15; // rotated bits beyond bit 15 + $value &= 0x7fff; // first 15 bits + $password ^= ($value | $rotated_bits); } $password ^= strlen($pPassword); diff --git a/htdocs/includes/phpexcel/PHPExcel/Shared/String.php b/htdocs/includes/phpexcel/PHPExcel/Shared/String.php index a62a681662a..49d217a5cbd 100644 --- a/htdocs/includes/phpexcel/PHPExcel/Shared/String.php +++ b/htdocs/includes/phpexcel/PHPExcel/Shared/String.php @@ -2,7 +2,7 @@ /** * PHPExcel * - * Copyright (c) 2006 - 2012 PHPExcel + * Copyright (c) 2006 - 2014 PHPExcel * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,9 +20,9 @@ * * @category PHPExcel * @package PHPExcel_Shared - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version 1.7.8, 2012-10-12 + * @version 1.8.0, 2014-03-02 */ @@ -31,7 +31,7 @@ * * @category PHPExcel * @package PHPExcel_Shared - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) */ class PHPExcel_Shared_String { @@ -403,7 +403,7 @@ class PHPExcel_Shared_String * @return boolean */ public static function IsUTF8($value = '') { - return utf8_encode(utf8_decode($value)) === $value; + return $string === '' || preg_match('/^./su', $string) === 1; } /** @@ -427,14 +427,14 @@ class PHPExcel_Shared_String * although this will give wrong results for non-ASCII strings * see OpenOffice.org's Documentation of the Microsoft Excel File Format, sect. 2.5.3 * - * @param string $value UTF-8 encoded string + * @param string $value UTF-8 encoded string + * @param mixed[] $arrcRuns Details of rich text runs in $value * @return string */ public static function UTF8toBIFF8UnicodeShort($value, $arrcRuns = array()) { // character count $ln = self::CountCharacters($value, 'UTF-8'); - // option flags if(empty($arrcRuns)){ $opt = (self::getIsIconvEnabled() || self::getIsMbstringEnabled()) ? @@ -444,10 +444,10 @@ class PHPExcel_Shared_String $data .= self::ConvertEncoding($value, 'UTF-16LE', 'UTF-8'); } else { - $data = pack('vC', $ln, 0x08); + $data = pack('vC', $ln, 0x09); $data .= pack('v', count($arrcRuns)); // characters - $data .= $value; + $data .= self::ConvertEncoding($value, 'UTF-16LE', 'UTF-8'); foreach ($arrcRuns as $cRun){ $data .= pack('v', $cRun['strlen']); $data .= pack('v', $cRun['fontidx']); @@ -483,7 +483,7 @@ class PHPExcel_Shared_String } /** - * Convert string from one encoding to another. First try iconv, then mbstring, or no convertion + * Convert string from one encoding to another. First try mbstring, then iconv, finally strlen * * @param string $value * @param string $to Encoding to convert to, e.g. 'UTF-8' @@ -493,14 +493,13 @@ class PHPExcel_Shared_String public static function ConvertEncoding($value, $to, $from) { if (self::getIsIconvEnabled()) { - $value = iconv($from, $to, $value); - return $value; + return iconv($from, $to, $value); } if (self::getIsMbstringEnabled()) { - $value = mb_convert_encoding($value, $to, $from); - return $value; + return mb_convert_encoding($value, $to, $from); } + if($from == 'UTF-16LE'){ return self::utf16_decode($value, false); }else if($from == 'UTF-16BE'){ @@ -525,7 +524,7 @@ class PHPExcel_Shared_String * @author Rasmus Andersson {@link http://rasmusandersson.se/} * @author vadik56 */ - public static function utf16_decode( $str, $bom_be=true ) { + public static function utf16_decode($str, $bom_be = TRUE) { if( strlen($str) < 2 ) return $str; $c0 = ord($str{0}); $c1 = ord($str{1}); @@ -550,40 +549,82 @@ class PHPExcel_Shared_String */ public static function CountCharacters($value, $enc = 'UTF-8') { - if (self::getIsIconvEnabled()) { - return iconv_strlen($value, $enc); - } - if (self::getIsMbstringEnabled()) { return mb_strlen($value, $enc); } + if (self::getIsIconvEnabled()) { + return iconv_strlen($value, $enc); + } + // else strlen return strlen($value); } /** - * Get a substring of a UTF-8 encoded string + * Get a substring of a UTF-8 encoded string. First try mbstring, then iconv, finally strlen * * @param string $pValue UTF-8 encoded string - * @param int $start Start offset - * @param int $length Maximum number of characters in substring + * @param int $pStart Start offset + * @param int $pLength Maximum number of characters in substring * @return string */ public static function Substring($pValue = '', $pStart = 0, $pLength = 0) { - if (self::getIsIconvEnabled()) { - return iconv_substr($pValue, $pStart, $pLength, 'UTF-8'); - } - if (self::getIsMbstringEnabled()) { return mb_substr($pValue, $pStart, $pLength, 'UTF-8'); } + if (self::getIsIconvEnabled()) { + return iconv_substr($pValue, $pStart, $pLength, 'UTF-8'); + } + // else substr return substr($pValue, $pStart, $pLength); } + /** + * Convert a UTF-8 encoded string to upper case + * + * @param string $pValue UTF-8 encoded string + * @return string + */ + public static function StrToUpper($pValue = '') + { + if (function_exists('mb_convert_case')) { + return mb_convert_case($pValue, MB_CASE_UPPER, "UTF-8"); + } + return strtoupper($pValue); + } + + /** + * Convert a UTF-8 encoded string to lower case + * + * @param string $pValue UTF-8 encoded string + * @return string + */ + public static function StrToLower($pValue = '') + { + if (function_exists('mb_convert_case')) { + return mb_convert_case($pValue, MB_CASE_LOWER, "UTF-8"); + } + return strtolower($pValue); + } + + /** + * Convert a UTF-8 encoded string to title/proper case + * (uppercase every first character in each word, lower case all other characters) + * + * @param string $pValue UTF-8 encoded string + * @return string + */ + public static function StrToTitle($pValue = '') + { + if (function_exists('mb_convert_case')) { + return mb_convert_case($pValue, MB_CASE_TITLE, "UTF-8"); + } + return ucwords($pValue); + } /** * Identify whether a string contains a fractional numeric value, @@ -646,6 +687,11 @@ class PHPExcel_Shared_String $localeconv = localeconv(); self::$_thousandsSeparator = ($localeconv['thousands_sep'] != '') ? $localeconv['thousands_sep'] : $localeconv['mon_thousands_sep']; + + if (self::$_thousandsSeparator == '') { + // Default to . + self::$_thousandsSeparator = ','; + } } return self::$_thousandsSeparator; } diff --git a/htdocs/includes/phpexcel/PHPExcel/Shared/TimeZone.php b/htdocs/includes/phpexcel/PHPExcel/Shared/TimeZone.php new file mode 100644 index 00000000000..d5fa2ade694 --- /dev/null +++ b/htdocs/includes/phpexcel/PHPExcel/Shared/TimeZone.php @@ -0,0 +1,140 @@ +getTransitions(); + $transitions = array(); + foreach($allTransitions as $key => $transition) { + if ($transition['ts'] > $timestamp) { + $transitions[] = ($key > 0) ? $allTransitions[$key - 1] : $transition; + break; + } + if (empty($transitions)) { + $transitions[] = end($allTransitions); + } + } + + return $transitions; + } + + /** + * Return the Timezone offset used for date/time conversions to/from UST + * This requires both the timezone and the calculated date/time to allow for local DST + * + * @param string $timezone The timezone for finding the adjustment to UST + * @param integer $timestamp PHP date/time value + * @return integer Number of seconds for timezone adjustment + * @throws PHPExcel_Exception + */ + public static function getTimeZoneAdjustment($timezone, $timestamp) { + if ($timezone !== NULL) { + if (!self::_validateTimezone($timezone)) { + throw new PHPExcel_Exception("Invalid timezone " . $timezone); + } + } else { + $timezone = self::$_timezone; + } + + if ($timezone == 'UST') { + return 0; + } + + $objTimezone = new DateTimeZone($timezone); + if (version_compare(PHP_VERSION, '5.3.0') >= 0) { + $transitions = $objTimezone->getTransitions($timestamp,$timestamp); + } else { + $transitions = self::_getTimezoneTransitions($objTimezone, $timestamp); + } + + return (count($transitions) > 0) ? $transitions[0]['offset'] : 0; + } + +} diff --git a/htdocs/includes/phpexcel/PHPExcel/Shared/XMLWriter.php b/htdocs/includes/phpexcel/PHPExcel/Shared/XMLWriter.php index 403c0996adb..0b0b5539d47 100644 --- a/htdocs/includes/phpexcel/PHPExcel/Shared/XMLWriter.php +++ b/htdocs/includes/phpexcel/PHPExcel/Shared/XMLWriter.php @@ -2,7 +2,7 @@ /** * PHPExcel * - * Copyright (c) 2006 - 2012 PHPExcel + * Copyright (c) 2006 - 2014 PHPExcel * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,9 +20,9 @@ * * @category PHPExcel * @package PHPExcel_Shared - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version 1.7.8, 2012-10-12 + * @version 1.8.0, 2014-03-02 */ if (!defined('DATE_W3C')) { @@ -39,7 +39,7 @@ if (!defined('DEBUGMODE_ENABLED')) { * * @category PHPExcel * @package PHPExcel_Shared - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) */ class PHPExcel_Shared_XMLWriter extends XMLWriter { /** Temporary storage method */ diff --git a/htdocs/includes/phpexcel/PHPExcel/Shared/ZipArchive.php b/htdocs/includes/phpexcel/PHPExcel/Shared/ZipArchive.php index 56d7c391854..ab551afe946 100644 --- a/htdocs/includes/phpexcel/PHPExcel/Shared/ZipArchive.php +++ b/htdocs/includes/phpexcel/PHPExcel/Shared/ZipArchive.php @@ -2,7 +2,7 @@ /** * PHPExcel * - * Copyright (c) 2006 - 2012 PHPExcel + * Copyright (c) 2006 - 2014 PHPExcel * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,9 +20,9 @@ * * @category PHPExcel * @package PHPExcel_Shared_ZipArchive - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version 1.7.8, 2012-10-12 + * @version 1.8.0, 2014-03-02 */ if (!defined('PCLZIP_TEMPORARY_DIR')) { @@ -36,7 +36,7 @@ require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/PCLZip/pclzip.lib.php'; * * @category PHPExcel * @package PHPExcel_Shared_ZipArchive - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) */ class PHPExcel_Shared_ZipArchive { @@ -105,10 +105,71 @@ class PHPExcel_Shared_ZipArchive PCLZIP_OPT_ADD_PATH, $filenameParts["dirname"] ); if ($res == 0) { - throw new Exception("Error zipping files : " . $this->_zip->errorInfo(true)); + throw new PHPExcel_Writer_Exception("Error zipping files : " . $this->_zip->errorInfo(true)); } unlink($this->_tempDir.'/'.$filenameParts["basename"]); } + /** + * Find if given fileName exist in archive (Emulate ZipArchive locateName()) + * + * @param string $fileName Filename for the file in zip archive + * @return boolean + */ + public function locateName($fileName) + { + $list = $this->_zip->listContent(); + $listCount = count($list); + $list_index = -1; + for ($i = 0; $i < $listCount; ++$i) { + if (strtolower($list[$i]["filename"]) == strtolower($fileName) || + strtolower($list[$i]["stored_filename"]) == strtolower($fileName)) { + $list_index = $i; + break; + } + } + return ($list_index > -1); + } + + /** + * Extract file from archive by given fileName (Emulate ZipArchive getFromName()) + * + * @param string $fileName Filename for the file in zip archive + * @return string $contents File string contents + */ + public function getFromName($fileName) + { + $list = $this->_zip->listContent(); + $listCount = count($list); + $list_index = -1; + for ($i = 0; $i < $listCount; ++$i) { + if (strtolower($list[$i]["filename"]) == strtolower($fileName) || + strtolower($list[$i]["stored_filename"]) == strtolower($fileName)) { + $list_index = $i; + break; + } + } + + $extracted = ""; + if ($list_index != -1) { + $extracted = $this->_zip->extractByIndex($list_index, PCLZIP_OPT_EXTRACT_AS_STRING); + } else { + $filename = substr($fileName, 1); + $list_index = -1; + for ($i = 0; $i < $listCount; ++$i) { + if (strtolower($list[$i]["filename"]) == strtolower($fileName) || + strtolower($list[$i]["stored_filename"]) == strtolower($fileName)) { + $list_index = $i; + break; + } + } + $extracted = $this->_zip->extractByIndex($list_index, PCLZIP_OPT_EXTRACT_AS_STRING); + } + if ((is_array($extracted)) && ($extracted != 0)) { + $contents = $extracted[0]["content"]; + } + + return $contents; + } } diff --git a/htdocs/includes/phpexcel/PHPExcel/Shared/ZipStreamWrapper.php b/htdocs/includes/phpexcel/PHPExcel/Shared/ZipStreamWrapper.php index 58d7e020a1c..696072bb0bd 100644 --- a/htdocs/includes/phpexcel/PHPExcel/Shared/ZipStreamWrapper.php +++ b/htdocs/includes/phpexcel/PHPExcel/Shared/ZipStreamWrapper.php @@ -2,7 +2,7 @@ /** * PHPExcel * - * Copyright (c) 2006 - 2012 PHPExcel + * Copyright (c) 2006 - 2014 PHPExcel * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,9 +20,9 @@ * * @category PHPExcel * @package PHPExcel_Shared - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version 1.7.8, 2012-10-12 + * @version 1.8.0, 2014-03-02 */ @@ -31,7 +31,7 @@ * * @category PHPExcel * @package PHPExcel_Shared - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) */ class PHPExcel_Shared_ZipStreamWrapper { /** @@ -82,7 +82,7 @@ class PHPExcel_Shared_ZipStreamWrapper { public function stream_open($path, $mode, $options, &$opened_path) { // Check for mode if ($mode{0} != 'r') { - throw new Exception('Mode ' . $mode . ' is not supported. Only read mode is supported.'); + throw new PHPExcel_Reader_Exception('Mode ' . $mode . ' is not supported. Only read mode is supported.'); } $pos = strrpos($path, '#'); @@ -100,6 +100,24 @@ class PHPExcel_Shared_ZipStreamWrapper { return true; } + /** + * Implements support for fstat(). + * + * @return boolean + */ + public function statName() { + return $this->_fileNameInArchive; + } + + /** + * Implements support for fstat(). + * + * @return boolean + */ + public function url_stat() { + return $this->statName( $this->_fileNameInArchive ); + } + /** * Implements support for fstat(). * diff --git a/htdocs/includes/phpexcel/PHPExcel/Shared/trend/bestFitClass.php b/htdocs/includes/phpexcel/PHPExcel/Shared/trend/bestFitClass.php index d86424f1a0d..088ce067cb1 100644 --- a/htdocs/includes/phpexcel/PHPExcel/Shared/trend/bestFitClass.php +++ b/htdocs/includes/phpexcel/PHPExcel/Shared/trend/bestFitClass.php @@ -2,7 +2,7 @@ /** * PHPExcel * - * Copyright (c) 2006 - 2012 PHPExcel + * Copyright (c) 2006 - 2014 PHPExcel * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,9 +20,9 @@ * * @category PHPExcel * @package PHPExcel_Shared_Trend - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version 1.7.8, 2012-10-12 + * @version 1.8.0, 2014-03-02 */ @@ -31,7 +31,7 @@ * * @category PHPExcel * @package PHPExcel_Shared_Trend - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) */ class PHPExcel_Best_Fit { diff --git a/htdocs/includes/phpexcel/PHPExcel/Shared/trend/exponentialBestFitClass.php b/htdocs/includes/phpexcel/PHPExcel/Shared/trend/exponentialBestFitClass.php index cc44678bea8..44c7aee8519 100644 --- a/htdocs/includes/phpexcel/PHPExcel/Shared/trend/exponentialBestFitClass.php +++ b/htdocs/includes/phpexcel/PHPExcel/Shared/trend/exponentialBestFitClass.php @@ -2,7 +2,7 @@ /** * PHPExcel * - * Copyright (c) 2006 - 2012 PHPExcel + * Copyright (c) 2006 - 2014 PHPExcel * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,9 +20,9 @@ * * @category PHPExcel * @package PHPExcel_Shared_Trend - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version 1.7.8, 2012-10-12 + * @version 1.8.0, 2014-03-02 */ @@ -34,7 +34,7 @@ require_once(PHPEXCEL_ROOT . 'PHPExcel/Shared/trend/bestFitClass.php'); * * @category PHPExcel * @package PHPExcel_Shared_Trend - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) */ class PHPExcel_Exponential_Best_Fit extends PHPExcel_Best_Fit { diff --git a/htdocs/includes/phpexcel/PHPExcel/Shared/trend/linearBestFitClass.php b/htdocs/includes/phpexcel/PHPExcel/Shared/trend/linearBestFitClass.php index 9aa44fec24e..00da841168f 100644 --- a/htdocs/includes/phpexcel/PHPExcel/Shared/trend/linearBestFitClass.php +++ b/htdocs/includes/phpexcel/PHPExcel/Shared/trend/linearBestFitClass.php @@ -2,7 +2,7 @@ /** * PHPExcel * - * Copyright (c) 2006 - 2012 PHPExcel + * Copyright (c) 2006 - 2014 PHPExcel * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,9 +20,9 @@ * * @category PHPExcel * @package PHPExcel_Shared_Trend - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version 1.7.8, 2012-10-12 + * @version 1.8.0, 2014-03-02 */ @@ -34,7 +34,7 @@ require_once(PHPEXCEL_ROOT . 'PHPExcel/Shared/trend/bestFitClass.php'); * * @category PHPExcel * @package PHPExcel_Shared_Trend - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) */ class PHPExcel_Linear_Best_Fit extends PHPExcel_Best_Fit { diff --git a/htdocs/includes/phpexcel/PHPExcel/Shared/trend/logarithmicBestFitClass.php b/htdocs/includes/phpexcel/PHPExcel/Shared/trend/logarithmicBestFitClass.php index 38aaa880381..ac9c1e200bf 100644 --- a/htdocs/includes/phpexcel/PHPExcel/Shared/trend/logarithmicBestFitClass.php +++ b/htdocs/includes/phpexcel/PHPExcel/Shared/trend/logarithmicBestFitClass.php @@ -2,7 +2,7 @@ /** * PHPExcel * - * Copyright (c) 2006 - 2012 PHPExcel + * Copyright (c) 2006 - 2014 PHPExcel * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,9 +20,9 @@ * * @category PHPExcel * @package PHPExcel_Shared_Trend - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version 1.7.8, 2012-10-12 + * @version 1.8.0, 2014-03-02 */ @@ -34,7 +34,7 @@ require_once(PHPEXCEL_ROOT . 'PHPExcel/Shared/trend/bestFitClass.php'); * * @category PHPExcel * @package PHPExcel_Shared_Trend - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) */ class PHPExcel_Logarithmic_Best_Fit extends PHPExcel_Best_Fit { diff --git a/htdocs/includes/phpexcel/PHPExcel/Shared/trend/polynomialBestFitClass.php b/htdocs/includes/phpexcel/PHPExcel/Shared/trend/polynomialBestFitClass.php index 7c05faf61be..a5079752927 100644 --- a/htdocs/includes/phpexcel/PHPExcel/Shared/trend/polynomialBestFitClass.php +++ b/htdocs/includes/phpexcel/PHPExcel/Shared/trend/polynomialBestFitClass.php @@ -2,7 +2,7 @@ /** * PHPExcel * - * Copyright (c) 2006 - 2012 PHPExcel + * Copyright (c) 2006 - 2014 PHPExcel * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,9 +20,9 @@ * * @category PHPExcel * @package PHPExcel_Shared_Trend - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version 1.7.8, 2012-10-12 + * @version 1.8.0, 2014-03-02 */ @@ -35,7 +35,7 @@ require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/JAMA/Matrix.php'; * * @category PHPExcel * @package PHPExcel_Shared_Trend - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) */ class PHPExcel_Polynomial_Best_Fit extends PHPExcel_Best_Fit { diff --git a/htdocs/includes/phpexcel/PHPExcel/Shared/trend/powerBestFitClass.php b/htdocs/includes/phpexcel/PHPExcel/Shared/trend/powerBestFitClass.php index 20b36741e3f..158e0c4592e 100644 --- a/htdocs/includes/phpexcel/PHPExcel/Shared/trend/powerBestFitClass.php +++ b/htdocs/includes/phpexcel/PHPExcel/Shared/trend/powerBestFitClass.php @@ -2,7 +2,7 @@ /** * PHPExcel * - * Copyright (c) 2006 - 2012 PHPExcel + * Copyright (c) 2006 - 2014 PHPExcel * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,9 +20,9 @@ * * @category PHPExcel * @package PHPExcel_Shared_Trend - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version 1.7.8, 2012-10-12 + * @version 1.8.0, 2014-03-02 */ @@ -34,7 +34,7 @@ require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/trend/bestFitClass.php'; * * @category PHPExcel * @package PHPExcel_Shared_Trend - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) */ class PHPExcel_Power_Best_Fit extends PHPExcel_Best_Fit { diff --git a/htdocs/includes/phpexcel/PHPExcel/Shared/trend/trendClass.php b/htdocs/includes/phpexcel/PHPExcel/Shared/trend/trendClass.php index 63ccc04c311..d891a7dc6ca 100644 --- a/htdocs/includes/phpexcel/PHPExcel/Shared/trend/trendClass.php +++ b/htdocs/includes/phpexcel/PHPExcel/Shared/trend/trendClass.php @@ -2,7 +2,7 @@ /** * PHPExcel * - * Copyright (c) 2006 - 2012 PHPExcel + * Copyright (c) 2006 - 2014 PHPExcel * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,9 +20,9 @@ * * @category PHPExcel * @package PHPExcel_Shared_Trend - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version 1.7.8, 2012-10-12 + * @version 1.8.0, 2014-03-02 */ @@ -38,7 +38,7 @@ require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/trend/polynomialBestFitClass.php'; * * @category PHPExcel * @package PHPExcel_Shared_Trend - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) */ class trendClass { diff --git a/htdocs/includes/phpexcel/PHPExcel/Style.php b/htdocs/includes/phpexcel/PHPExcel/Style.php index 2fdef0e4cc9..715ae11319c 100644 --- a/htdocs/includes/phpexcel/PHPExcel/Style.php +++ b/htdocs/includes/phpexcel/PHPExcel/Style.php @@ -2,7 +2,7 @@ /** * PHPExcel * - * Copyright (c) 2006 - 2012 PHPExcel + * Copyright (c) 2006 - 2014 PHPExcel * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,9 +20,9 @@ * * @category PHPExcel * @package PHPExcel_Style - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version 1.7.8, 2012-10-12 + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) + * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @version 1.8.0, 2014-03-02 */ @@ -31,197 +31,147 @@ * * @category PHPExcel * @package PHPExcel_Style - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) */ -class PHPExcel_Style implements PHPExcel_IComparable +class PHPExcel_Style extends PHPExcel_Style_Supervisor implements PHPExcel_IComparable { - /** - * Font - * - * @var PHPExcel_Style_Font - */ - private $_font; + /** + * Font + * + * @var PHPExcel_Style_Font + */ + protected $_font; - /** - * Fill - * - * @var PHPExcel_Style_Fill - */ - private $_fill; + /** + * Fill + * + * @var PHPExcel_Style_Fill + */ + protected $_fill; - /** - * Borders - * - * @var PHPExcel_Style_Borders - */ - private $_borders; + /** + * Borders + * + * @var PHPExcel_Style_Borders + */ + protected $_borders; - /** - * Alignment - * - * @var PHPExcel_Style_Alignment - */ - private $_alignment; + /** + * Alignment + * + * @var PHPExcel_Style_Alignment + */ + protected $_alignment; - /** - * Number Format - * - * @var PHPExcel_Style_NumberFormat - */ - private $_numberFormat; + /** + * Number Format + * + * @var PHPExcel_Style_NumberFormat + */ + protected $_numberFormat; - /** - * Conditional styles - * - * @var PHPExcel_Style_Conditional[] - */ - private $_conditionalStyles; + /** + * Conditional styles + * + * @var PHPExcel_Style_Conditional[] + */ + protected $_conditionalStyles; - /** - * Protection - * - * @var PHPExcel_Style_Protection - */ - private $_protection; + /** + * Protection + * + * @var PHPExcel_Style_Protection + */ + protected $_protection; - /** - * Style supervisor? - * - * @var boolean - */ - private $_isSupervisor; + /** + * Index of style in collection. Only used for real style. + * + * @var int + */ + protected $_index; - /** - * Parent. Only used for style supervisor - * - * @var PHPExcel - */ - private $_parent; - - /** - * Index of style in collection. Only used for real style. - * - * @var int - */ - private $_index; + /** + * Use Quote Prefix when displaying in cell editor. Only used for real style. + * + * @var boolean + */ + protected $_quotePrefix = false; /** * Create a new PHPExcel_Style - * - * @param boolean $isSupervisor Flag indicating if this is a supervisor or not - * Leave this value at default unless you understand exactly what - * its ramifications are - * @param boolean $isConditional Flag indicating if this is a conditional style or not - * Leave this value at default unless you understand exactly what - * its ramifications are + * + * @param boolean $isSupervisor Flag indicating if this is a supervisor or not + * Leave this value at default unless you understand exactly what + * its ramifications are + * @param boolean $isConditional Flag indicating if this is a conditional style or not + * Leave this value at default unless you understand exactly what + * its ramifications are */ public function __construct($isSupervisor = false, $isConditional = false) { - // Supervisor? - $this->_isSupervisor = $isSupervisor; + // Supervisor? + $this->_isSupervisor = $isSupervisor; - // Initialise values - $this->_conditionalStyles = array(); - $this->_font = new PHPExcel_Style_Font($isSupervisor, $isConditional); - $this->_fill = new PHPExcel_Style_Fill($isSupervisor, $isConditional); - $this->_borders = new PHPExcel_Style_Borders($isSupervisor, $isConditional); - $this->_alignment = new PHPExcel_Style_Alignment($isSupervisor, $isConditional); - $this->_numberFormat = new PHPExcel_Style_NumberFormat($isSupervisor, $isConditional); - $this->_protection = new PHPExcel_Style_Protection($isSupervisor, $isConditional); + // Initialise values + $this->_conditionalStyles = array(); + $this->_font = new PHPExcel_Style_Font($isSupervisor, $isConditional); + $this->_fill = new PHPExcel_Style_Fill($isSupervisor, $isConditional); + $this->_borders = new PHPExcel_Style_Borders($isSupervisor, $isConditional); + $this->_alignment = new PHPExcel_Style_Alignment($isSupervisor, $isConditional); + $this->_numberFormat = new PHPExcel_Style_NumberFormat($isSupervisor, $isConditional); + $this->_protection = new PHPExcel_Style_Protection($isSupervisor, $isConditional); - // bind parent if we are a supervisor - if ($isSupervisor) { - $this->_font->bindParent($this); - $this->_fill->bindParent($this); - $this->_borders->bindParent($this); - $this->_alignment->bindParent($this); - $this->_numberFormat->bindParent($this); - $this->_protection->bindParent($this); - } + // bind parent if we are a supervisor + if ($isSupervisor) { + $this->_font->bindParent($this); + $this->_fill->bindParent($this); + $this->_borders->bindParent($this); + $this->_alignment->bindParent($this); + $this->_numberFormat->bindParent($this); + $this->_protection->bindParent($this); + } + } + + /** + * Get the shared style component for the currently active cell in currently active sheet. + * Only used for style supervisor + * + * @return PHPExcel_Style + */ + public function getSharedComponent() + { + $activeSheet = $this->getActiveSheet(); + $selectedCell = $this->getActiveCell(); // e.g. 'A1' + + if ($activeSheet->cellExists($selectedCell)) { + $xfIndex = $activeSheet->getCell($selectedCell)->getXfIndex(); + } else { + $xfIndex = 0; + } + + return $this->_parent->getCellXfByIndex($xfIndex); + } + + /** + * Get parent. Only used for style supervisor + * + * @return PHPExcel + */ + public function getParent() + { + return $this->_parent; } /** - * Bind parent. Only used for supervisor + * Build style array from subcomponents * - * @param PHPExcel $parent - * @return PHPExcel_Style + * @param array $array + * @return array */ - public function bindParent($parent) + public function getStyleArray($array) { - $this->_parent = $parent; - return $this; - } - - /** - * Is this a supervisor or a real style component? - * - * @return boolean - */ - public function getIsSupervisor() - { - return $this->_isSupervisor; - } - - /** - * Get the shared style component for the currently active cell in currently active sheet. - * Only used for style supervisor - * - * @return PHPExcel_Style - */ - public function getSharedComponent() - { - $activeSheet = $this->getActiveSheet(); - $selectedCell = $this->getActiveCell(); // e.g. 'A1' - - if ($activeSheet->cellExists($selectedCell)) { - $xfIndex = $activeSheet->getCell($selectedCell)->getXfIndex(); - } else { - $xfIndex = 0; - } - - return $this->_parent->getCellXfByIndex($xfIndex); - } - - /** - * Get the currently active sheet. Only used for supervisor - * - * @return PHPExcel_Worksheet - */ - public function getActiveSheet() - { - return $this->_parent->getActiveSheet(); - } - - /** - * Get the currently active cell coordinate in currently active sheet. - * Only used for supervisor - * - * @return string E.g. 'A1' - */ - public function getSelectedCells() - { - return $this->_parent->getActiveSheet()->getSelectedCells(); - } - - /** - * Get the currently active cell coordinate in currently active sheet. - * Only used for supervisor - * - * @return string E.g. 'A1' - */ - public function getActiveCell() - { - return $this->_parent->getActiveSheet()->getActiveCell(); - } - - /** - * Get parent. Only used for style supervisor - * - * @return PHPExcel - */ - public function getParent() - { - return $this->_parent; + return array('quotePrefix' => $array); } /** @@ -229,321 +179,327 @@ class PHPExcel_Style implements PHPExcel_IComparable * * * $objPHPExcel->getActiveSheet()->getStyle('B2')->applyFromArray( - * array( - * 'font' => array( - * 'name' => 'Arial', - * 'bold' => true, - * 'italic' => false, - * 'underline' => PHPExcel_Style_Font::UNDERLINE_DOUBLE, - * 'strike' => false, - * 'color' => array( - * 'rgb' => '808080' - * ) - * ), - * 'borders' => array( - * 'bottom' => array( - * 'style' => PHPExcel_Style_Border::BORDER_DASHDOT, - * 'color' => array( - * 'rgb' => '808080' - * ) - * ), - * 'top' => array( - * 'style' => PHPExcel_Style_Border::BORDER_DASHDOT, - * 'color' => array( - * 'rgb' => '808080' - * ) - * ) - * ) - * ) + * array( + * 'font' => array( + * 'name' => 'Arial', + * 'bold' => true, + * 'italic' => false, + * 'underline' => PHPExcel_Style_Font::UNDERLINE_DOUBLE, + * 'strike' => false, + * 'color' => array( + * 'rgb' => '808080' + * ) + * ), + * 'borders' => array( + * 'bottom' => array( + * 'style' => PHPExcel_Style_Border::BORDER_DASHDOT, + * 'color' => array( + * 'rgb' => '808080' + * ) + * ), + * 'top' => array( + * 'style' => PHPExcel_Style_Border::BORDER_DASHDOT, + * 'color' => array( + * 'rgb' => '808080' + * ) + * ) + * ), + * 'quotePrefix' => true + * ) * ); * * - * @param array $pStyles Array containing style information - * @param boolean $pAdvanced Advanced mode for setting borders. - * @throws Exception + * @param array $pStyles Array containing style information + * @param boolean $pAdvanced Advanced mode for setting borders. + * @throws PHPExcel_Exception * @return PHPExcel_Style */ - public function applyFromArray($pStyles = null, $pAdvanced = true) { - if (is_array($pStyles)) { - if ($this->_isSupervisor) { + public function applyFromArray($pStyles = null, $pAdvanced = true) + { + if (is_array($pStyles)) { + if ($this->_isSupervisor) { - $pRange = $this->getSelectedCells(); + $pRange = $this->getSelectedCells(); - // Uppercase coordinate - $pRange = strtoupper($pRange); + // Uppercase coordinate + $pRange = strtoupper($pRange); - // Is it a cell range or a single cell? - if (strpos($pRange, ':') === false) { - $rangeA = $pRange; - $rangeB = $pRange; - } else { - list($rangeA, $rangeB) = explode(':', $pRange); - } + // Is it a cell range or a single cell? + if (strpos($pRange, ':') === false) { + $rangeA = $pRange; + $rangeB = $pRange; + } else { + list($rangeA, $rangeB) = explode(':', $pRange); + } - // Calculate range outer borders - $rangeStart = PHPExcel_Cell::coordinateFromString($rangeA); - $rangeEnd = PHPExcel_Cell::coordinateFromString($rangeB); + // Calculate range outer borders + $rangeStart = PHPExcel_Cell::coordinateFromString($rangeA); + $rangeEnd = PHPExcel_Cell::coordinateFromString($rangeB); - // Translate column into index - $rangeStart[0] = PHPExcel_Cell::columnIndexFromString($rangeStart[0]) - 1; - $rangeEnd[0] = PHPExcel_Cell::columnIndexFromString($rangeEnd[0]) - 1; + // Translate column into index + $rangeStart[0] = PHPExcel_Cell::columnIndexFromString($rangeStart[0]) - 1; + $rangeEnd[0] = PHPExcel_Cell::columnIndexFromString($rangeEnd[0]) - 1; - // Make sure we can loop upwards on rows and columns - if ($rangeStart[0] > $rangeEnd[0] && $rangeStart[1] > $rangeEnd[1]) { - $tmp = $rangeStart; - $rangeStart = $rangeEnd; - $rangeEnd = $tmp; - } + // Make sure we can loop upwards on rows and columns + if ($rangeStart[0] > $rangeEnd[0] && $rangeStart[1] > $rangeEnd[1]) { + $tmp = $rangeStart; + $rangeStart = $rangeEnd; + $rangeEnd = $tmp; + } - // ADVANCED MODE: + // ADVANCED MODE: - if ($pAdvanced && isset($pStyles['borders'])) { + if ($pAdvanced && isset($pStyles['borders'])) { - // 'allborders' is a shorthand property for 'outline' and 'inside' and - // it applies to components that have not been set explicitly - if (isset($pStyles['borders']['allborders'])) { - foreach (array('outline', 'inside') as $component) { - if (!isset($pStyles['borders'][$component])) { - $pStyles['borders'][$component] = $pStyles['borders']['allborders']; - } - } - unset($pStyles['borders']['allborders']); // not needed any more - } + // 'allborders' is a shorthand property for 'outline' and 'inside' and + // it applies to components that have not been set explicitly + if (isset($pStyles['borders']['allborders'])) { + foreach (array('outline', 'inside') as $component) { + if (!isset($pStyles['borders'][$component])) { + $pStyles['borders'][$component] = $pStyles['borders']['allborders']; + } + } + unset($pStyles['borders']['allborders']); // not needed any more + } - // 'outline' is a shorthand property for 'top', 'right', 'bottom', 'left' - // it applies to components that have not been set explicitly - if (isset($pStyles['borders']['outline'])) { - foreach (array('top', 'right', 'bottom', 'left') as $component) { - if (!isset($pStyles['borders'][$component])) { - $pStyles['borders'][$component] = $pStyles['borders']['outline']; - } - } - unset($pStyles['borders']['outline']); // not needed any more - } + // 'outline' is a shorthand property for 'top', 'right', 'bottom', 'left' + // it applies to components that have not been set explicitly + if (isset($pStyles['borders']['outline'])) { + foreach (array('top', 'right', 'bottom', 'left') as $component) { + if (!isset($pStyles['borders'][$component])) { + $pStyles['borders'][$component] = $pStyles['borders']['outline']; + } + } + unset($pStyles['borders']['outline']); // not needed any more + } - // 'inside' is a shorthand property for 'vertical' and 'horizontal' - // it applies to components that have not been set explicitly - if (isset($pStyles['borders']['inside'])) { - foreach (array('vertical', 'horizontal') as $component) { - if (!isset($pStyles['borders'][$component])) { - $pStyles['borders'][$component] = $pStyles['borders']['inside']; - } - } - unset($pStyles['borders']['inside']); // not needed any more - } + // 'inside' is a shorthand property for 'vertical' and 'horizontal' + // it applies to components that have not been set explicitly + if (isset($pStyles['borders']['inside'])) { + foreach (array('vertical', 'horizontal') as $component) { + if (!isset($pStyles['borders'][$component])) { + $pStyles['borders'][$component] = $pStyles['borders']['inside']; + } + } + unset($pStyles['borders']['inside']); // not needed any more + } - // width and height characteristics of selection, 1, 2, or 3 (for 3 or more) - $xMax = min($rangeEnd[0] - $rangeStart[0] + 1, 3); - $yMax = min($rangeEnd[1] - $rangeStart[1] + 1, 3); + // width and height characteristics of selection, 1, 2, or 3 (for 3 or more) + $xMax = min($rangeEnd[0] - $rangeStart[0] + 1, 3); + $yMax = min($rangeEnd[1] - $rangeStart[1] + 1, 3); - // loop through up to 3 x 3 = 9 regions - for ($x = 1; $x <= $xMax; ++$x) { - // start column index for region - $colStart = ($x == 3) ? - PHPExcel_Cell::stringFromColumnIndex($rangeEnd[0]) - : PHPExcel_Cell::stringFromColumnIndex($rangeStart[0] + $x - 1); + // loop through up to 3 x 3 = 9 regions + for ($x = 1; $x <= $xMax; ++$x) { + // start column index for region + $colStart = ($x == 3) ? + PHPExcel_Cell::stringFromColumnIndex($rangeEnd[0]) + : PHPExcel_Cell::stringFromColumnIndex($rangeStart[0] + $x - 1); - // end column index for region - $colEnd = ($x == 1) ? - PHPExcel_Cell::stringFromColumnIndex($rangeStart[0]) - : PHPExcel_Cell::stringFromColumnIndex($rangeEnd[0] - $xMax + $x); + // end column index for region + $colEnd = ($x == 1) ? + PHPExcel_Cell::stringFromColumnIndex($rangeStart[0]) + : PHPExcel_Cell::stringFromColumnIndex($rangeEnd[0] - $xMax + $x); - for ($y = 1; $y <= $yMax; ++$y) { + for ($y = 1; $y <= $yMax; ++$y) { - // which edges are touching the region - $edges = array(); + // which edges are touching the region + $edges = array(); - // are we at left edge - if ($x == 1) { - $edges[] = 'left'; - } + // are we at left edge + if ($x == 1) { + $edges[] = 'left'; + } - // are we at right edge - if ($x == $xMax) { - $edges[] = 'right'; - } + // are we at right edge + if ($x == $xMax) { + $edges[] = 'right'; + } - // are we at top edge? - if ($y == 1) { - $edges[] = 'top'; - } + // are we at top edge? + if ($y == 1) { + $edges[] = 'top'; + } - // are we at bottom edge? - if ($y == $yMax) { - $edges[] = 'bottom'; - } + // are we at bottom edge? + if ($y == $yMax) { + $edges[] = 'bottom'; + } - // start row index for region - $rowStart = ($y == 3) ? - $rangeEnd[1] : $rangeStart[1] + $y - 1; + // start row index for region + $rowStart = ($y == 3) ? + $rangeEnd[1] : $rangeStart[1] + $y - 1; - // end row index for region - $rowEnd = ($y == 1) ? - $rangeStart[1] : $rangeEnd[1] - $yMax + $y; + // end row index for region + $rowEnd = ($y == 1) ? + $rangeStart[1] : $rangeEnd[1] - $yMax + $y; - // build range for region - $range = $colStart . $rowStart . ':' . $colEnd . $rowEnd; + // build range for region + $range = $colStart . $rowStart . ':' . $colEnd . $rowEnd; - // retrieve relevant style array for region - $regionStyles = $pStyles; - unset($regionStyles['borders']['inside']); + // retrieve relevant style array for region + $regionStyles = $pStyles; + unset($regionStyles['borders']['inside']); - // what are the inner edges of the region when looking at the selection - $innerEdges = array_diff( array('top', 'right', 'bottom', 'left'), $edges ); + // what are the inner edges of the region when looking at the selection + $innerEdges = array_diff( array('top', 'right', 'bottom', 'left'), $edges ); - // inner edges that are not touching the region should take the 'inside' border properties if they have been set - foreach ($innerEdges as $innerEdge) { - switch ($innerEdge) { - case 'top': - case 'bottom': - // should pick up 'horizontal' border property if set - if (isset($pStyles['borders']['horizontal'])) { - $regionStyles['borders'][$innerEdge] = $pStyles['borders']['horizontal']; - } else { - unset($regionStyles['borders'][$innerEdge]); - } - break; - case 'left': - case 'right': - // should pick up 'vertical' border property if set - if (isset($pStyles['borders']['vertical'])) { - $regionStyles['borders'][$innerEdge] = $pStyles['borders']['vertical']; - } else { - unset($regionStyles['borders'][$innerEdge]); - } - break; - } - } + // inner edges that are not touching the region should take the 'inside' border properties if they have been set + foreach ($innerEdges as $innerEdge) { + switch ($innerEdge) { + case 'top': + case 'bottom': + // should pick up 'horizontal' border property if set + if (isset($pStyles['borders']['horizontal'])) { + $regionStyles['borders'][$innerEdge] = $pStyles['borders']['horizontal']; + } else { + unset($regionStyles['borders'][$innerEdge]); + } + break; + case 'left': + case 'right': + // should pick up 'vertical' border property if set + if (isset($pStyles['borders']['vertical'])) { + $regionStyles['borders'][$innerEdge] = $pStyles['borders']['vertical']; + } else { + unset($regionStyles['borders'][$innerEdge]); + } + break; + } + } - // apply region style to region by calling applyFromArray() in simple mode - $this->getActiveSheet()->getStyle($range)->applyFromArray($regionStyles, false); - } - } - return $this; - } + // apply region style to region by calling applyFromArray() in simple mode + $this->getActiveSheet()->getStyle($range)->applyFromArray($regionStyles, false); + } + } + return $this; + } - // SIMPLE MODE: + // SIMPLE MODE: - // Selection type, inspect - if (preg_match('/^[A-Z]+1:[A-Z]+1048576$/', $pRange)) { - $selectionType = 'COLUMN'; - } else if (preg_match('/^A[0-9]+:XFD[0-9]+$/', $pRange)) { - $selectionType = 'ROW'; - } else { - $selectionType = 'CELL'; - } + // Selection type, inspect + if (preg_match('/^[A-Z]+1:[A-Z]+1048576$/', $pRange)) { + $selectionType = 'COLUMN'; + } else if (preg_match('/^A[0-9]+:XFD[0-9]+$/', $pRange)) { + $selectionType = 'ROW'; + } else { + $selectionType = 'CELL'; + } - // First loop through columns, rows, or cells to find out which styles are affected by this operation - switch ($selectionType) { - case 'COLUMN': - $oldXfIndexes = array(); - for ($col = $rangeStart[0]; $col <= $rangeEnd[0]; ++$col) { - $oldXfIndexes[$this->getActiveSheet()->getColumnDimensionByColumn($col)->getXfIndex()] = true; - } - break; + // First loop through columns, rows, or cells to find out which styles are affected by this operation + switch ($selectionType) { + case 'COLUMN': + $oldXfIndexes = array(); + for ($col = $rangeStart[0]; $col <= $rangeEnd[0]; ++$col) { + $oldXfIndexes[$this->getActiveSheet()->getColumnDimensionByColumn($col)->getXfIndex()] = true; + } + break; - case 'ROW': - $oldXfIndexes = array(); - for ($row = $rangeStart[1]; $row <= $rangeEnd[1]; ++$row) { - if ($this->getActiveSheet()->getRowDimension($row)->getXfIndex() == null) { - $oldXfIndexes[0] = true; // row without explicit style should be formatted based on default style - } else { - $oldXfIndexes[$this->getActiveSheet()->getRowDimension($row)->getXfIndex()] = true; - } - } - break; + case 'ROW': + $oldXfIndexes = array(); + for ($row = $rangeStart[1]; $row <= $rangeEnd[1]; ++$row) { + if ($this->getActiveSheet()->getRowDimension($row)->getXfIndex() == null) { + $oldXfIndexes[0] = true; // row without explicit style should be formatted based on default style + } else { + $oldXfIndexes[$this->getActiveSheet()->getRowDimension($row)->getXfIndex()] = true; + } + } + break; - case 'CELL': - $oldXfIndexes = array(); - for ($col = $rangeStart[0]; $col <= $rangeEnd[0]; ++$col) { - for ($row = $rangeStart[1]; $row <= $rangeEnd[1]; ++$row) { - $oldXfIndexes[$this->getActiveSheet()->getCellByColumnAndRow($col, $row)->getXfIndex()] = true; - } - } - break; - } + case 'CELL': + $oldXfIndexes = array(); + for ($col = $rangeStart[0]; $col <= $rangeEnd[0]; ++$col) { + for ($row = $rangeStart[1]; $row <= $rangeEnd[1]; ++$row) { + $oldXfIndexes[$this->getActiveSheet()->getCellByColumnAndRow($col, $row)->getXfIndex()] = true; + } + } + break; + } - // clone each of the affected styles, apply the style arrray, and add the new styles to the workbook - $workbook = $this->getActiveSheet()->getParent(); - foreach ($oldXfIndexes as $oldXfIndex => $dummy) { - $style = $workbook->getCellXfByIndex($oldXfIndex); - $newStyle = clone $style; - $newStyle->applyFromArray($pStyles); + // clone each of the affected styles, apply the style array, and add the new styles to the workbook + $workbook = $this->getActiveSheet()->getParent(); + foreach ($oldXfIndexes as $oldXfIndex => $dummy) { + $style = $workbook->getCellXfByIndex($oldXfIndex); + $newStyle = clone $style; + $newStyle->applyFromArray($pStyles); - if ($existingStyle = $workbook->getCellXfByHashCode($newStyle->getHashCode())) { - // there is already such cell Xf in our collection - $newXfIndexes[$oldXfIndex] = $existingStyle->getIndex(); - } else { - // we don't have such a cell Xf, need to add - $workbook->addCellXf($newStyle); - $newXfIndexes[$oldXfIndex] = $newStyle->getIndex(); - } - } + if ($existingStyle = $workbook->getCellXfByHashCode($newStyle->getHashCode())) { + // there is already such cell Xf in our collection + $newXfIndexes[$oldXfIndex] = $existingStyle->getIndex(); + } else { + // we don't have such a cell Xf, need to add + $workbook->addCellXf($newStyle); + $newXfIndexes[$oldXfIndex] = $newStyle->getIndex(); + } + } - // Loop through columns, rows, or cells again and update the XF index - switch ($selectionType) { - case 'COLUMN': - for ($col = $rangeStart[0]; $col <= $rangeEnd[0]; ++$col) { - $columnDimension = $this->getActiveSheet()->getColumnDimensionByColumn($col); - $oldXfIndex = $columnDimension->getXfIndex(); - $columnDimension->setXfIndex($newXfIndexes[$oldXfIndex]); - } - break; + // Loop through columns, rows, or cells again and update the XF index + switch ($selectionType) { + case 'COLUMN': + for ($col = $rangeStart[0]; $col <= $rangeEnd[0]; ++$col) { + $columnDimension = $this->getActiveSheet()->getColumnDimensionByColumn($col); + $oldXfIndex = $columnDimension->getXfIndex(); + $columnDimension->setXfIndex($newXfIndexes[$oldXfIndex]); + } + break; - case 'ROW': - for ($row = $rangeStart[1]; $row <= $rangeEnd[1]; ++$row) { - $rowDimension = $this->getActiveSheet()->getRowDimension($row); - $oldXfIndex = $rowDimension->getXfIndex() === null ? - 0 : $rowDimension->getXfIndex(); // row without explicit style should be formatted based on default style - $rowDimension->setXfIndex($newXfIndexes[$oldXfIndex]); - } - break; + case 'ROW': + for ($row = $rangeStart[1]; $row <= $rangeEnd[1]; ++$row) { + $rowDimension = $this->getActiveSheet()->getRowDimension($row); + $oldXfIndex = $rowDimension->getXfIndex() === null ? + 0 : $rowDimension->getXfIndex(); // row without explicit style should be formatted based on default style + $rowDimension->setXfIndex($newXfIndexes[$oldXfIndex]); + } + break; - case 'CELL': - for ($col = $rangeStart[0]; $col <= $rangeEnd[0]; ++$col) { - for ($row = $rangeStart[1]; $row <= $rangeEnd[1]; ++$row) { - $cell = $this->getActiveSheet()->getCellByColumnAndRow($col, $row); - $oldXfIndex = $cell->getXfIndex(); - $cell->setXfIndex($newXfIndexes[$oldXfIndex]); - } - } - break; - } + case 'CELL': + for ($col = $rangeStart[0]; $col <= $rangeEnd[0]; ++$col) { + for ($row = $rangeStart[1]; $row <= $rangeEnd[1]; ++$row) { + $cell = $this->getActiveSheet()->getCellByColumnAndRow($col, $row); + $oldXfIndex = $cell->getXfIndex(); + $cell->setXfIndex($newXfIndexes[$oldXfIndex]); + } + } + break; + } - } else { - // not a supervisor, just apply the style array directly on style object - if (array_key_exists('fill', $pStyles)) { - $this->getFill()->applyFromArray($pStyles['fill']); - } - if (array_key_exists('font', $pStyles)) { - $this->getFont()->applyFromArray($pStyles['font']); - } - if (array_key_exists('borders', $pStyles)) { - $this->getBorders()->applyFromArray($pStyles['borders']); - } - if (array_key_exists('alignment', $pStyles)) { - $this->getAlignment()->applyFromArray($pStyles['alignment']); - } - if (array_key_exists('numberformat', $pStyles)) { - $this->getNumberFormat()->applyFromArray($pStyles['numberformat']); - } - if (array_key_exists('protection', $pStyles)) { - $this->getProtection()->applyFromArray($pStyles['protection']); - } - } - } else { - throw new Exception("Invalid style array passed."); - } - return $this; - } + } else { + // not a supervisor, just apply the style array directly on style object + if (array_key_exists('fill', $pStyles)) { + $this->getFill()->applyFromArray($pStyles['fill']); + } + if (array_key_exists('font', $pStyles)) { + $this->getFont()->applyFromArray($pStyles['font']); + } + if (array_key_exists('borders', $pStyles)) { + $this->getBorders()->applyFromArray($pStyles['borders']); + } + if (array_key_exists('alignment', $pStyles)) { + $this->getAlignment()->applyFromArray($pStyles['alignment']); + } + if (array_key_exists('numberformat', $pStyles)) { + $this->getNumberFormat()->applyFromArray($pStyles['numberformat']); + } + if (array_key_exists('protection', $pStyles)) { + $this->getProtection()->applyFromArray($pStyles['protection']); + } + if (array_key_exists('quotePrefix', $pStyles)) { + $this->_quotePrefix = $pStyles['quotePrefix']; + } + } + } else { + throw new PHPExcel_Exception("Invalid style array passed."); + } + return $this; + } /** * Get Fill * * @return PHPExcel_Style_Fill */ - public function getFill() { - return $this->_fill; + public function getFill() + { + return $this->_fill; } /** @@ -551,29 +507,31 @@ class PHPExcel_Style implements PHPExcel_IComparable * * @return PHPExcel_Style_Font */ - public function getFont() { - return $this->_font; + public function getFont() + { + return $this->_font; } - /** - * Set font - * - * @param PHPExcel_Style_Font $font - * @return PHPExcel_Style - */ - public function setFont(PHPExcel_Style_Font $font) - { - $this->_font = $font; - return $this; - } + /** + * Set font + * + * @param PHPExcel_Style_Font $font + * @return PHPExcel_Style + */ + public function setFont(PHPExcel_Style_Font $font) + { + $this->_font = $font; + return $this; + } /** * Get Borders * * @return PHPExcel_Style_Borders */ - public function getBorders() { - return $this->_borders; + public function getBorders() + { + return $this->_borders; } /** @@ -581,8 +539,9 @@ class PHPExcel_Style implements PHPExcel_IComparable * * @return PHPExcel_Style_Alignment */ - public function getAlignment() { - return $this->_alignment; + public function getAlignment() + { + return $this->_alignment; } /** @@ -590,8 +549,9 @@ class PHPExcel_Style implements PHPExcel_IComparable * * @return PHPExcel_Style_NumberFormat */ - public function getNumberFormat() { - return $this->_numberFormat; + public function getNumberFormat() + { + return $this->_numberFormat; } /** @@ -599,21 +559,23 @@ class PHPExcel_Style implements PHPExcel_IComparable * * @return PHPExcel_Style_Conditional[] */ - public function getConditionalStyles() { - return $this->getActiveSheet()->getConditionalStyles($this->getActiveCell()); + public function getConditionalStyles() + { + return $this->getActiveSheet()->getConditionalStyles($this->getActiveCell()); } /** * Set Conditional Styles. Only used on supervisor. * - * @param PHPExcel_Style_Conditional[] $pValue Array of condtional styles + * @param PHPExcel_Style_Conditional[] $pValue Array of condtional styles * @return PHPExcel_Style */ - public function setConditionalStyles($pValue = null) { - if (is_array($pValue)) { - $this->getActiveSheet()->setConditionalStyles($this->getSelectedCells(), $pValue); - } - return $this; + public function setConditionalStyles($pValue = null) + { + if (is_array($pValue)) { + $this->getActiveSheet()->setConditionalStyles($this->getSelectedCells(), $pValue); + } + return $this; } /** @@ -621,64 +583,86 @@ class PHPExcel_Style implements PHPExcel_IComparable * * @return PHPExcel_Style_Protection */ - public function getProtection() { - return $this->_protection; + public function getProtection() + { + return $this->_protection; } - /** - * Get hash code - * - * @return string Hash code - */ - public function getHashCode() { - $hashConditionals = ''; - foreach ($this->_conditionalStyles as $conditional) { - $hashConditionals .= $conditional->getHashCode(); - } - - return md5( - $this->_fill->getHashCode() - . $this->_font->getHashCode() - . $this->_borders->getHashCode() - . $this->_alignment->getHashCode() - . $this->_numberFormat->getHashCode() - . $hashConditionals - . $this->_protection->getHashCode() - . __CLASS__ - ); + /** + * Get quote prefix + * + * @return boolean + */ + public function getQuotePrefix() + { + if ($this->_isSupervisor) { + return $this->getSharedComponent()->getQuotePrefix(); + } + return $this->_quotePrefix; } - /** - * Get own index in style collection - * - * @return int - */ - public function getIndex() - { - return $this->_index; - } + /** + * Set quote prefix + * + * @param boolean $pValue + */ + public function setQuotePrefix($pValue) + { + if ($pValue == '') { + $pValue = false; + } + if ($this->_isSupervisor) { + $styleArray = array('quotePrefix' => $pValue); + $this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray); + } else { + $this->_quotePrefix = (boolean) $pValue; + } + return $this; + } - /** - * Set own index in style collection - * - * @param int $pValue - */ - public function setIndex($pValue) - { - $this->_index = $pValue; - } + /** + * Get hash code + * + * @return string Hash code + */ + public function getHashCode() + { + $hashConditionals = ''; + foreach ($this->_conditionalStyles as $conditional) { + $hashConditionals .= $conditional->getHashCode(); + } + + return md5( + $this->_fill->getHashCode() + . $this->_font->getHashCode() + . $this->_borders->getHashCode() + . $this->_alignment->getHashCode() + . $this->_numberFormat->getHashCode() + . $hashConditionals + . $this->_protection->getHashCode() + . ($this->_quotePrefix ? 't' : 'f') + . __CLASS__ + ); + } + + /** + * Get own index in style collection + * + * @return int + */ + public function getIndex() + { + return $this->_index; + } + + /** + * Set own index in style collection + * + * @param int $pValue + */ + public function setIndex($pValue) + { + $this->_index = $pValue; + } - /** - * Implement PHP __clone to create a deep clone, not just a shallow copy. - */ - public function __clone() { - $vars = get_object_vars($this); - foreach ($vars as $key => $value) { - if ((is_object($value)) && ($key != '_parent')) { - $this->$key = clone $value; - } else { - $this->$key = $value; - } - } - } } diff --git a/htdocs/includes/phpexcel/PHPExcel/Style/Alignment.php b/htdocs/includes/phpexcel/PHPExcel/Style/Alignment.php index 81ca387c5be..0d9e076799e 100644 --- a/htdocs/includes/phpexcel/PHPExcel/Style/Alignment.php +++ b/htdocs/includes/phpexcel/PHPExcel/Style/Alignment.php @@ -2,7 +2,7 @@ /** * PHPExcel * - * Copyright (c) 2006 - 2012 PHPExcel + * Copyright (c) 2006 - 2014 PHPExcel * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,9 +20,9 @@ * * @category PHPExcel * @package PHPExcel_Style - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version 1.7.8, 2012-10-12 + * @version 1.8.0, 2014-03-02 */ @@ -31,9 +31,9 @@ * * @category PHPExcel * @package PHPExcel_Style - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) */ -class PHPExcel_Style_Alignment implements PHPExcel_IComparable +class PHPExcel_Style_Alignment extends PHPExcel_Style_Supervisor implements PHPExcel_IComparable { /* Horizontal alignment styles */ const HORIZONTAL_GENERAL = 'general'; @@ -42,75 +42,57 @@ class PHPExcel_Style_Alignment implements PHPExcel_IComparable const HORIZONTAL_CENTER = 'center'; const HORIZONTAL_CENTER_CONTINUOUS = 'centerContinuous'; const HORIZONTAL_JUSTIFY = 'justify'; + const HORIZONTAL_FILL = 'fill'; + const HORIZONTAL_DISTRIBUTED = 'distributed'; // Excel2007 only /* Vertical alignment styles */ const VERTICAL_BOTTOM = 'bottom'; const VERTICAL_TOP = 'top'; const VERTICAL_CENTER = 'center'; const VERTICAL_JUSTIFY = 'justify'; + const VERTICAL_DISTRIBUTED = 'distributed'; // Excel2007 only /** * Horizontal * * @var string */ - private $_horizontal = PHPExcel_Style_Alignment::HORIZONTAL_GENERAL; + protected $_horizontal = PHPExcel_Style_Alignment::HORIZONTAL_GENERAL; /** * Vertical * * @var string */ - private $_vertical = PHPExcel_Style_Alignment::VERTICAL_BOTTOM; + protected $_vertical = PHPExcel_Style_Alignment::VERTICAL_BOTTOM; /** * Text rotation * * @var int */ - private $_textRotation = 0; + protected $_textRotation = 0; /** * Wrap text * * @var boolean */ - private $_wrapText = false; + protected $_wrapText = FALSE; /** * Shrink to fit * * @var boolean */ - private $_shrinkToFit = false; + protected $_shrinkToFit = FALSE; /** * Indent - only possible with horizontal alignment left and right * * @var int */ - private $_indent = 0; - - /** - * Parent Borders - * - * @var _parentPropertyName string - */ - private $_parentPropertyName; - - /** - * Supervisor? - * - * @var boolean - */ - private $_isSupervisor; - - /** - * Parent. Only used for supervisor - * - * @var PHPExcel_Style - */ - private $_parent; + protected $_indent = 0; /** * Create a new PHPExcel_Style_Alignment @@ -122,10 +104,10 @@ class PHPExcel_Style_Alignment implements PHPExcel_IComparable * Leave this value at default unless you understand exactly what * its ramifications are */ - public function __construct($isSupervisor = false, $isConditional = false) + public function __construct($isSupervisor = FALSE, $isConditional = FALSE) { // Supervisor? - $this->_isSupervisor = $isSupervisor; + parent::__construct($isSupervisor); if ($isConditional) { $this->_horizontal = NULL; @@ -134,28 +116,6 @@ class PHPExcel_Style_Alignment implements PHPExcel_IComparable } } - /** - * Bind parent. Only used for supervisor - * - * @param PHPExcel $parent - * @return PHPExcel_Style_Alignment - */ - public function bindParent($parent) - { - $this->_parent = $parent; - return $this; - } - - /** - * Is this a supervisor or a real style component? - * - * @return boolean - */ - public function getIsSupervisor() - { - return $this->_isSupervisor; - } - /** * Get the shared style component for the currently active cell in currently active sheet. * Only used for style supervisor @@ -167,38 +127,6 @@ class PHPExcel_Style_Alignment implements PHPExcel_IComparable return $this->_parent->getSharedComponent()->getAlignment(); } - /** - * Get the currently active sheet. Only used for supervisor - * - * @return PHPExcel_Worksheet - */ - public function getActiveSheet() - { - return $this->_parent->getActiveSheet(); - } - - /** - * Get the currently active cell coordinate in currently active sheet. - * Only used for supervisor - * - * @return string E.g. 'A1' - */ - public function getSelectedCells() - { - return $this->getActiveSheet()->getSelectedCells(); - } - - /** - * Get the currently active cell coordinate in currently active sheet. - * Only used for supervisor - * - * @return string E.g. 'A1' - */ - public function getActiveCell() - { - return $this->getActiveSheet()->getActiveCell(); - } - /** * Build style array from subcomponents * @@ -219,41 +147,42 @@ class PHPExcel_Style_Alignment implements PHPExcel_IComparable * 'horizontal' => PHPExcel_Style_Alignment::HORIZONTAL_CENTER, * 'vertical' => PHPExcel_Style_Alignment::VERTICAL_CENTER, * 'rotation' => 0, - * 'wrap' => true + * 'wrap' => TRUE * ) * ); * * * @param array $pStyles Array containing style information - * @throws Exception + * @throws PHPExcel_Exception * @return PHPExcel_Style_Alignment */ - public function applyFromArray($pStyles = null) { + public function applyFromArray($pStyles = NULL) { if (is_array($pStyles)) { if ($this->_isSupervisor) { - $this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($this->getStyleArray($pStyles)); + $this->getActiveSheet()->getStyle($this->getSelectedCells()) + ->applyFromArray($this->getStyleArray($pStyles)); } else { - if (array_key_exists('horizontal', $pStyles)) { + if (isset($pStyles['horizontal'])) { $this->setHorizontal($pStyles['horizontal']); } - if (array_key_exists('vertical', $pStyles)) { + if (isset($pStyles['vertical'])) { $this->setVertical($pStyles['vertical']); } - if (array_key_exists('rotation', $pStyles)) { + if (isset($pStyles['rotation'])) { $this->setTextRotation($pStyles['rotation']); } - if (array_key_exists('wrap', $pStyles)) { + if (isset($pStyles['wrap'])) { $this->setWrapText($pStyles['wrap']); } - if (array_key_exists('shrinkToFit', $pStyles)) { + if (isset($pStyles['shrinkToFit'])) { $this->setShrinkToFit($pStyles['shrinkToFit']); } - if (array_key_exists('indent', $pStyles)) { + if (isset($pStyles['indent'])) { $this->setIndent($pStyles['indent']); } } } else { - throw new Exception("Invalid style array passed."); + throw new PHPExcel_Exception("Invalid style array passed."); } return $this; } @@ -339,7 +268,7 @@ class PHPExcel_Style_Alignment implements PHPExcel_IComparable * Set TextRotation * * @param int $pValue - * @throws Exception + * @throws PHPExcel_Exception * @return PHPExcel_Style_Alignment */ public function setTextRotation($pValue = 0) { @@ -357,7 +286,7 @@ class PHPExcel_Style_Alignment implements PHPExcel_IComparable $this->_textRotation = $pValue; } } else { - throw new Exception("Text rotation should be a value between -90 and 90."); + throw new PHPExcel_Exception("Text rotation should be a value between -90 and 90."); } return $this; @@ -381,9 +310,9 @@ class PHPExcel_Style_Alignment implements PHPExcel_IComparable * @param boolean $pValue * @return PHPExcel_Style_Alignment */ - public function setWrapText($pValue = false) { + public function setWrapText($pValue = FALSE) { if ($pValue == '') { - $pValue = false; + $pValue = FALSE; } if ($this->_isSupervisor) { $styleArray = $this->getStyleArray(array('wrap' => $pValue)); @@ -412,9 +341,9 @@ class PHPExcel_Style_Alignment implements PHPExcel_IComparable * @param boolean $pValue * @return PHPExcel_Style_Alignment */ - public function setShrinkToFit($pValue = false) { + public function setShrinkToFit($pValue = FALSE) { if ($pValue == '') { - $pValue = false; + $pValue = FALSE; } if ($this->_isSupervisor) { $styleArray = $this->getStyleArray(array('shrinkToFit' => $pValue)); @@ -445,7 +374,9 @@ class PHPExcel_Style_Alignment implements PHPExcel_IComparable */ public function setIndent($pValue = 0) { if ($pValue > 0) { - if ($this->getHorizontal() != self::HORIZONTAL_GENERAL && $this->getHorizontal() != self::HORIZONTAL_LEFT && $this->getHorizontal() != self::HORIZONTAL_RIGHT) { + if ($this->getHorizontal() != self::HORIZONTAL_GENERAL && + $this->getHorizontal() != self::HORIZONTAL_LEFT && + $this->getHorizontal() != self::HORIZONTAL_RIGHT) { $pValue = 0; // indent not supported } } @@ -478,17 +409,4 @@ class PHPExcel_Style_Alignment implements PHPExcel_IComparable ); } - /** - * Implement PHP __clone to create a deep clone, not just a shallow copy. - */ - public function __clone() { - $vars = get_object_vars($this); - foreach ($vars as $key => $value) { - if ((is_object($value)) && ($key != '_parent')) { - $this->$key = clone $value; - } else { - $this->$key = $value; - } - } - } } diff --git a/htdocs/includes/phpexcel/PHPExcel/Style/Border.php b/htdocs/includes/phpexcel/PHPExcel/Style/Border.php index 6f8767fb277..3b7eba9af9c 100644 --- a/htdocs/includes/phpexcel/PHPExcel/Style/Border.php +++ b/htdocs/includes/phpexcel/PHPExcel/Style/Border.php @@ -2,7 +2,7 @@ /** * PHPExcel * - * Copyright (c) 2006 - 2012 PHPExcel + * Copyright (c) 2006 - 2014 PHPExcel * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,9 +20,9 @@ * * @category PHPExcel * @package PHPExcel_Style - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version 1.7.8, 2012-10-12 + * @version 1.8.0, 2014-03-02 */ @@ -31,9 +31,9 @@ * * @category PHPExcel * @package PHPExcel_Style - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) */ -class PHPExcel_Style_Border implements PHPExcel_IComparable +class PHPExcel_Style_Border extends PHPExcel_Style_Supervisor implements PHPExcel_IComparable { /* Border style */ const BORDER_NONE = 'none'; @@ -56,35 +56,21 @@ class PHPExcel_Style_Border implements PHPExcel_IComparable * * @var string */ - private $_borderStyle = PHPExcel_Style_Border::BORDER_NONE; + protected $_borderStyle = PHPExcel_Style_Border::BORDER_NONE; /** * Border color * * @var PHPExcel_Style_Color */ - private $_color; - - /** - * Supervisor? - * - * @var boolean - */ - private $_isSupervisor; - - /** - * Parent. Only used for supervisor - * - * @var PHPExcel_Style_Borders - */ - private $_parent; + protected $_color; /** * Parent property name * * @var string */ - private $_parentPropertyName; + protected $_parentPropertyName; /** * Create a new PHPExcel_Style_Border @@ -96,10 +82,10 @@ class PHPExcel_Style_Border implements PHPExcel_IComparable * Leave this value at default unless you understand exactly what * its ramifications are */ - public function __construct($isSupervisor = false, $isConditional = false) + public function __construct($isSupervisor = FALSE, $isConditional = FALSE) { // Supervisor? - $this->_isSupervisor = $isSupervisor; + parent::__construct($isSupervisor); // Initialise values $this->_color = new PHPExcel_Style_Color(PHPExcel_Style_Color::COLOR_BLACK, $isSupervisor); @@ -117,29 +103,19 @@ class PHPExcel_Style_Border implements PHPExcel_IComparable * @param string $parentPropertyName * @return PHPExcel_Style_Border */ - public function bindParent($parent, $parentPropertyName) + public function bindParent($parent, $parentPropertyName=NULL) { $this->_parent = $parent; $this->_parentPropertyName = $parentPropertyName; return $this; } - /** - * Is this a supervisor or a real style component? - * - * @return boolean - */ - public function getIsSupervisor() - { - return $this->_isSupervisor; - } - /** * Get the shared style component for the currently active cell in currently active sheet. * Only used for style supervisor * * @return PHPExcel_Style_Border - * @throws Exception + * @throws PHPExcel_Exception */ public function getSharedComponent() { @@ -149,64 +125,22 @@ class PHPExcel_Style_Border implements PHPExcel_IComparable case '_inside': case '_outline': case '_vertical': - throw new Exception('Cannot get shared component for a pseudo-border.'); + throw new PHPExcel_Exception('Cannot get shared component for a pseudo-border.'); break; - case '_bottom': - return $this->_parent->getSharedComponent()->getBottom(); - break; - + return $this->_parent->getSharedComponent()->getBottom(); break; case '_diagonal': - return $this->_parent->getSharedComponent()->getDiagonal(); - break; - + return $this->_parent->getSharedComponent()->getDiagonal(); break; case '_left': - return $this->_parent->getSharedComponent()->getLeft(); - break; - + return $this->_parent->getSharedComponent()->getLeft(); break; case '_right': - return $this->_parent->getSharedComponent()->getRight(); - break; - + return $this->_parent->getSharedComponent()->getRight(); break; case '_top': - return $this->_parent->getSharedComponent()->getTop(); - break; + return $this->_parent->getSharedComponent()->getTop(); break; } } - /** - * Get the currently active sheet. Only used for supervisor - * - * @return PHPExcel_Worksheet - */ - public function getActiveSheet() - { - return $this->_parent->getActiveSheet(); - } - - /** - * Get the currently active cell coordinate in currently active sheet. - * Only used for supervisor - * - * @return string E.g. 'A1' - */ - public function getSelectedCells() - { - return $this->getActiveSheet()->getSelectedCells(); - } - - /** - * Get the currently active cell coordinate in currently active sheet. - * Only used for supervisor - * - * @return string E.g. 'A1' - */ - public function getActiveCell() - { - return $this->getActiveSheet()->getActiveCell(); - } - /** * Build style array from subcomponents * @@ -217,44 +151,25 @@ class PHPExcel_Style_Border implements PHPExcel_IComparable { switch ($this->_parentPropertyName) { case '_allBorders': - $key = 'allborders'; - break; - + $key = 'allborders'; break; case '_bottom': - $key = 'bottom'; - break; - + $key = 'bottom'; break; case '_diagonal': - $key = 'diagonal'; - break; - + $key = 'diagonal'; break; case '_horizontal': - $key = 'horizontal'; - break; - + $key = 'horizontal'; break; case '_inside': - $key = 'inside'; - break; - + $key = 'inside'; break; case '_left': - $key = 'left'; - break; - + $key = 'left'; break; case '_outline': - $key = 'outline'; - break; - + $key = 'outline'; break; case '_right': - $key = 'right'; - break; - + $key = 'right'; break; case '_top': - $key = 'top'; - break; - + $key = 'top'; break; case '_vertical': - $key = 'vertical'; - break; + $key = 'vertical'; break; } return $this->_parent->getStyleArray(array($key => $array)); } @@ -274,7 +189,7 @@ class PHPExcel_Style_Border implements PHPExcel_IComparable * * * @param array $pStyles Array containing style information - * @throws Exception + * @throws PHPExcel_Exception * @return PHPExcel_Style_Border */ public function applyFromArray($pStyles = null) { @@ -282,15 +197,15 @@ class PHPExcel_Style_Border implements PHPExcel_IComparable if ($this->_isSupervisor) { $this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($this->getStyleArray($pStyles)); } else { - if (array_key_exists('style', $pStyles)) { + if (isset($pStyles['style'])) { $this->setBorderStyle($pStyles['style']); } - if (array_key_exists('color', $pStyles)) { + if (isset($pStyles['color'])) { $this->getColor()->applyFromArray($pStyles['color']); } } } else { - throw new Exception("Invalid style array passed."); + throw new PHPExcel_Exception("Invalid style array passed."); } return $this; } @@ -310,13 +225,17 @@ class PHPExcel_Style_Border implements PHPExcel_IComparable /** * Set Border style * - * @param string $pValue + * @param string|boolean $pValue + * When passing a boolean, FALSE equates PHPExcel_Style_Border::BORDER_NONE + * and TRUE to PHPExcel_Style_Border::BORDER_MEDIUM * @return PHPExcel_Style_Border */ public function setBorderStyle($pValue = PHPExcel_Style_Border::BORDER_NONE) { - if ($pValue == '') { + if (empty($pValue)) { $pValue = PHPExcel_Style_Border::BORDER_NONE; + } elseif(is_bool($pValue) && $pValue) { + $pValue = PHPExcel_Style_Border::BORDER_MEDIUM; } if ($this->_isSupervisor) { $styleArray = $this->getStyleArray(array('style' => $pValue)); @@ -340,7 +259,7 @@ class PHPExcel_Style_Border implements PHPExcel_IComparable * Set Border Color * * @param PHPExcel_Style_Color $pValue - * @throws Exception + * @throws PHPExcel_Exception * @return PHPExcel_Style_Border */ public function setColor(PHPExcel_Style_Color $pValue = null) { @@ -372,17 +291,4 @@ class PHPExcel_Style_Border implements PHPExcel_IComparable ); } - /** - * Implement PHP __clone to create a deep clone, not just a shallow copy. - */ - public function __clone() { - $vars = get_object_vars($this); - foreach ($vars as $key => $value) { - if ((is_object($value)) && ($key != '_parent')) { - $this->$key = clone $value; - } else { - $this->$key = $value; - } - } - } } diff --git a/htdocs/includes/phpexcel/PHPExcel/Style/Borders.php b/htdocs/includes/phpexcel/PHPExcel/Style/Borders.php index d8a3196e3af..b90838a60dc 100644 --- a/htdocs/includes/phpexcel/PHPExcel/Style/Borders.php +++ b/htdocs/includes/phpexcel/PHPExcel/Style/Borders.php @@ -2,7 +2,7 @@ /** * PHPExcel * - * Copyright (c) 2006 - 2012 PHPExcel + * Copyright (c) 2006 - 2014 PHPExcel * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,9 +20,9 @@ * * @category PHPExcel * @package PHPExcel_Style - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version 1.7.8, 2012-10-12 + * @version 1.8.0, 2014-03-02 */ @@ -31,9 +31,9 @@ * * @category PHPExcel * @package PHPExcel_Style - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) */ -class PHPExcel_Style_Borders implements PHPExcel_IComparable +class PHPExcel_Style_Borders extends PHPExcel_Style_Supervisor implements PHPExcel_IComparable { /* Diagonal directions */ const DIAGONAL_NONE = 0; @@ -46,98 +46,77 @@ class PHPExcel_Style_Borders implements PHPExcel_IComparable * * @var PHPExcel_Style_Border */ - private $_left; + protected $_left; /** * Right * * @var PHPExcel_Style_Border */ - private $_right; + protected $_right; /** * Top * * @var PHPExcel_Style_Border */ - private $_top; + protected $_top; /** * Bottom * * @var PHPExcel_Style_Border */ - private $_bottom; + protected $_bottom; /** * Diagonal * * @var PHPExcel_Style_Border */ - private $_diagonal; + protected $_diagonal; /** * DiagonalDirection * * @var int */ - private $_diagonalDirection; + protected $_diagonalDirection; /** * All borders psedo-border. Only applies to supervisor. * * @var PHPExcel_Style_Border */ - private $_allBorders; + protected $_allBorders; /** * Outline psedo-border. Only applies to supervisor. * * @var PHPExcel_Style_Border */ - private $_outline; + protected $_outline; /** * Inside psedo-border. Only applies to supervisor. * * @var PHPExcel_Style_Border */ - private $_inside; + protected $_inside; /** * Vertical pseudo-border. Only applies to supervisor. * * @var PHPExcel_Style_Border */ - private $_vertical; + protected $_vertical; /** * Horizontal pseudo-border. Only applies to supervisor. * * @var PHPExcel_Style_Border */ - private $_horizontal; - - /** - * Parent Borders - * - * @var _parentPropertyName string - */ - private $_parentPropertyName; - - /** - * Supervisor? - * - * @var boolean - */ - private $_isSupervisor; - - /** - * Parent. Only used for supervisor - * - * @var PHPExcel_Style - */ - private $_parent; + protected $_horizontal; /** * Create a new PHPExcel_Style_Borders @@ -149,10 +128,10 @@ class PHPExcel_Style_Borders implements PHPExcel_IComparable * Leave this value at default unless you understand exactly what * its ramifications are */ - public function __construct($isSupervisor = false, $isConditional = false) + public function __construct($isSupervisor = FALSE, $isConditional = FALSE) { // Supervisor? - $this->_isSupervisor = $isSupervisor; + parent::__construct($isSupervisor); // Initialise values $this->_left = new PHPExcel_Style_Border($isSupervisor, $isConditional); @@ -165,11 +144,11 @@ class PHPExcel_Style_Borders implements PHPExcel_IComparable // Specially for supervisor if ($isSupervisor) { // Initialize pseudo-borders - $this->_allBorders = new PHPExcel_Style_Border(true); - $this->_outline = new PHPExcel_Style_Border(true); - $this->_inside = new PHPExcel_Style_Border(true); - $this->_vertical = new PHPExcel_Style_Border(true); - $this->_horizontal = new PHPExcel_Style_Border(true); + $this->_allBorders = new PHPExcel_Style_Border(TRUE); + $this->_outline = new PHPExcel_Style_Border(TRUE); + $this->_inside = new PHPExcel_Style_Border(TRUE); + $this->_vertical = new PHPExcel_Style_Border(TRUE); + $this->_horizontal = new PHPExcel_Style_Border(TRUE); // bind parent if we are a supervisor $this->_left->bindParent($this, '_left'); @@ -185,28 +164,6 @@ class PHPExcel_Style_Borders implements PHPExcel_IComparable } } - /** - * Bind parent. Only used for supervisor - * - * @param PHPExcel_Style $parent - * @return PHPExcel_Style_Borders - */ - public function bindParent($parent) - { - $this->_parent = $parent; - return $this; - } - - /** - * Is this a supervisor or a real style component? - * - * @return boolean - */ - public function getIsSupervisor() - { - return $this->_isSupervisor; - } - /** * Get the shared style component for the currently active cell in currently active sheet. * Only used for style supervisor @@ -218,38 +175,6 @@ class PHPExcel_Style_Borders implements PHPExcel_IComparable return $this->_parent->getSharedComponent()->getBorders(); } - /** - * Get the currently active sheet. Only used for supervisor - * - * @return PHPExcel_Worksheet - */ - public function getActiveSheet() - { - return $this->_parent->getActiveSheet(); - } - - /** - * Get the currently active cell coordinate in currently active sheet. - * Only used for supervisor - * - * @return string E.g. 'A1' - */ - public function getSelectedCells() - { - return $this->getActiveSheet()->getSelectedCells(); - } - - /** - * Get the currently active cell coordinate in currently active sheet. - * Only used for supervisor - * - * @return string E.g. 'A1' - */ - public function getActiveCell() - { - return $this->getActiveSheet()->getActiveCell(); - } - /** * Build style array from subcomponents * @@ -296,7 +221,7 @@ class PHPExcel_Style_Borders implements PHPExcel_IComparable * * * @param array $pStyles Array containing style information - * @throws Exception + * @throws PHPExcel_Exception * @return PHPExcel_Style_Borders */ public function applyFromArray($pStyles = null) { @@ -330,7 +255,7 @@ class PHPExcel_Style_Borders implements PHPExcel_IComparable } } } else { - throw new Exception("Invalid style array passed."); + throw new PHPExcel_Exception("Invalid style array passed."); } return $this; } @@ -384,11 +309,11 @@ class PHPExcel_Style_Borders implements PHPExcel_IComparable * Get AllBorders (pseudo-border). Only applies to supervisor. * * @return PHPExcel_Style_Border - * @throws Exception + * @throws PHPExcel_Exception */ public function getAllBorders() { if (!$this->_isSupervisor) { - throw new Exception('Can only get pseudo-border for supervisor.'); + throw new PHPExcel_Exception('Can only get pseudo-border for supervisor.'); } return $this->_allBorders; } @@ -397,11 +322,11 @@ class PHPExcel_Style_Borders implements PHPExcel_IComparable * Get Outline (pseudo-border). Only applies to supervisor. * * @return boolean - * @throws Exception + * @throws PHPExcel_Exception */ public function getOutline() { if (!$this->_isSupervisor) { - throw new Exception('Can only get pseudo-border for supervisor.'); + throw new PHPExcel_Exception('Can only get pseudo-border for supervisor.'); } return $this->_outline; } @@ -410,11 +335,11 @@ class PHPExcel_Style_Borders implements PHPExcel_IComparable * Get Inside (pseudo-border). Only applies to supervisor. * * @return boolean - * @throws Exception + * @throws PHPExcel_Exception */ public function getInside() { if (!$this->_isSupervisor) { - throw new Exception('Can only get pseudo-border for supervisor.'); + throw new PHPExcel_Exception('Can only get pseudo-border for supervisor.'); } return $this->_inside; } @@ -423,11 +348,11 @@ class PHPExcel_Style_Borders implements PHPExcel_IComparable * Get Vertical (pseudo-border). Only applies to supervisor. * * @return PHPExcel_Style_Border - * @throws Exception + * @throws PHPExcel_Exception */ public function getVertical() { if (!$this->_isSupervisor) { - throw new Exception('Can only get pseudo-border for supervisor.'); + throw new PHPExcel_Exception('Can only get pseudo-border for supervisor.'); } return $this->_vertical; } @@ -436,11 +361,11 @@ class PHPExcel_Style_Borders implements PHPExcel_IComparable * Get Horizontal (pseudo-border). Only applies to supervisor. * * @return PHPExcel_Style_Border - * @throws Exception + * @throws PHPExcel_Exception */ public function getHorizontal() { if (!$this->_isSupervisor) { - throw new Exception('Can only get pseudo-border for supervisor.'); + throw new PHPExcel_Exception('Can only get pseudo-border for supervisor.'); } return $this->_horizontal; } @@ -496,17 +421,4 @@ class PHPExcel_Style_Borders implements PHPExcel_IComparable ); } - /** - * Implement PHP __clone to create a deep clone, not just a shallow copy. - */ - public function __clone() { - $vars = get_object_vars($this); - foreach ($vars as $key => $value) { - if ((is_object($value)) && ($key != '_parent')) { - $this->$key = clone $value; - } else { - $this->$key = $value; - } - } - } } diff --git a/htdocs/includes/phpexcel/PHPExcel/Style/Color.php b/htdocs/includes/phpexcel/PHPExcel/Style/Color.php index 1c0f3f6808e..4d34504f397 100644 --- a/htdocs/includes/phpexcel/PHPExcel/Style/Color.php +++ b/htdocs/includes/phpexcel/PHPExcel/Style/Color.php @@ -2,7 +2,7 @@ /** * PHPExcel * - * Copyright (c) 2006 - 2012 PHPExcel + * Copyright (c) 2006 - 2014 PHPExcel * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,9 +20,9 @@ * * @category PHPExcel * @package PHPExcel_Style - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version 1.7.8, 2012-10-12 + * @version 1.8.0, 2014-03-02 */ @@ -31,9 +31,9 @@ * * @category PHPExcel * @package PHPExcel_Style - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) */ -class PHPExcel_Style_Color implements PHPExcel_IComparable +class PHPExcel_Style_Color extends PHPExcel_Style_Supervisor implements PHPExcel_IComparable { /* Colors */ const COLOR_BLACK = 'FF000000'; @@ -52,35 +52,21 @@ class PHPExcel_Style_Color implements PHPExcel_IComparable * * @var array */ - private static $_indexedColors; + protected static $_indexedColors; /** * ARGB - Alpha RGB * * @var string */ - private $_argb = NULL; - - /** - * Supervisor? - * - * @var boolean - */ - private $_isSupervisor; - - /** - * Parent. Only used for supervisor - * - * @var mixed - */ - private $_parent; + protected $_argb = NULL; /** * Parent property name * * @var string */ - private $_parentPropertyName; + protected $_parentPropertyName; /** @@ -94,10 +80,10 @@ class PHPExcel_Style_Color implements PHPExcel_IComparable * Leave this value at default unless you understand exactly what * its ramifications are */ - public function __construct($pARGB = PHPExcel_Style_Color::COLOR_BLACK, $isSupervisor = false, $isConditional = false) + public function __construct($pARGB = PHPExcel_Style_Color::COLOR_BLACK, $isSupervisor = FALSE, $isConditional = FALSE) { // Supervisor? - $this->_isSupervisor = $isSupervisor; + parent::__construct($isSupervisor); // Initialise values if (!$isConditional) { @@ -112,23 +98,13 @@ class PHPExcel_Style_Color implements PHPExcel_IComparable * @param string $parentPropertyName * @return PHPExcel_Style_Color */ - public function bindParent($parent, $parentPropertyName) + public function bindParent($parent, $parentPropertyName=NULL) { $this->_parent = $parent; $this->_parentPropertyName = $parentPropertyName; return $this; } - /** - * Is this a supervisor or a real style component? - * - * @return boolean - */ - public function getIsSupervisor() - { - return $this->_isSupervisor; - } - /** * Get the shared style component for the currently active cell in currently active sheet. * Only used for style supervisor @@ -147,38 +123,6 @@ class PHPExcel_Style_Color implements PHPExcel_IComparable } } - /** - * Get the currently active sheet. Only used for supervisor - * - * @return PHPExcel_Worksheet - */ - public function getActiveSheet() - { - return $this->_parent->getActiveSheet(); - } - - /** - * Get the currently active cell coordinate in currently active sheet. - * Only used for supervisor - * - * @return string E.g. 'A1' - */ - public function getSelectedCells() - { - return $this->getActiveSheet()->getSelectedCells(); - } - - /** - * Get the currently active cell coordinate in currently active sheet. - * Only used for supervisor - * - * @return string E.g. 'A1' - */ - public function getActiveCell() - { - return $this->getActiveSheet()->getActiveCell(); - } - /** * Build style array from subcomponents * @@ -210,7 +154,7 @@ class PHPExcel_Style_Color implements PHPExcel_IComparable * * * @param array $pStyles Array containing style information - * @throws Exception + * @throws PHPExcel_Exception * @return PHPExcel_Style_Color */ public function applyFromArray($pStyles = NULL) { @@ -226,7 +170,7 @@ class PHPExcel_Style_Color implements PHPExcel_IComparable } } } else { - throw new Exception("Invalid style array passed."); + throw new PHPExcel_Exception("Invalid style array passed."); } return $this; } @@ -319,11 +263,7 @@ class PHPExcel_Style_Color implements PHPExcel_IComparable * @return string The red colour component */ public static function getRed($RGB,$hex=TRUE) { - if (strlen($RGB) == 8) { - return self::_getColourComponent($RGB, 2, $hex); - } elseif (strlen($RGB) == 6) { - return self::_getColourComponent($RGB, 0, $hex); - } + return self::_getColourComponent($RGB, strlen($RGB) - 6, $hex); } /** @@ -335,11 +275,7 @@ class PHPExcel_Style_Color implements PHPExcel_IComparable * @return string The green colour component */ public static function getGreen($RGB,$hex=TRUE) { - if (strlen($RGB) == 8) { - return self::_getColourComponent($RGB, 4, $hex); - } elseif (strlen($RGB) == 6) { - return self::_getColourComponent($RGB, 2, $hex); - } + return self::_getColourComponent($RGB, strlen($RGB) - 4, $hex); } /** @@ -351,11 +287,7 @@ class PHPExcel_Style_Color implements PHPExcel_IComparable * @return string The blue colour component */ public static function getBlue($RGB,$hex=TRUE) { - if (strlen($RGB) == 8) { - return self::_getColourComponent($RGB, 6, $hex); - } elseif (strlen($RGB) == 6) { - return self::_getColourComponent($RGB, 4, $hex); - } + return self::_getColourComponent($RGB, strlen($RGB) - 2, $hex); } /** @@ -494,17 +426,4 @@ class PHPExcel_Style_Color implements PHPExcel_IComparable ); } - /** - * Implement PHP __clone to create a deep clone, not just a shallow copy. - */ - public function __clone() { - $vars = get_object_vars($this); - foreach ($vars as $key => $value) { - if ((is_object($value)) && ($key != '_parent')) { - $this->$key = clone $value; - } else { - $this->$key = $value; - } - } - } } diff --git a/htdocs/includes/phpexcel/PHPExcel/Style/Conditional.php b/htdocs/includes/phpexcel/PHPExcel/Style/Conditional.php index d9f7dd4cf5f..ffd7a9f9b57 100644 --- a/htdocs/includes/phpexcel/PHPExcel/Style/Conditional.php +++ b/htdocs/includes/phpexcel/PHPExcel/Style/Conditional.php @@ -2,7 +2,7 @@ /** * PHPExcel * - * Copyright (c) 2006 - 2012 PHPExcel + * Copyright (c) 2006 - 2014 PHPExcel * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,9 +20,9 @@ * * @category PHPExcel * @package PHPExcel_Style - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version 1.7.8, 2012-10-12 + * @version 1.8.0, 2014-03-02 */ @@ -31,7 +31,7 @@ * * @category PHPExcel * @package PHPExcel_Style - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) */ class PHPExcel_Style_Conditional implements PHPExcel_IComparable { @@ -238,7 +238,7 @@ class PHPExcel_Style_Conditional implements PHPExcel_IComparable * Set Style * * @param PHPExcel_Style $pValue - * @throws Exception + * @throws PHPExcel_Exception * @return PHPExcel_Style_Conditional */ public function setStyle(PHPExcel_Style $pValue = null) { diff --git a/htdocs/includes/phpexcel/PHPExcel/Style/Fill.php b/htdocs/includes/phpexcel/PHPExcel/Style/Fill.php index afede653c74..1b4d0ad34d1 100644 --- a/htdocs/includes/phpexcel/PHPExcel/Style/Fill.php +++ b/htdocs/includes/phpexcel/PHPExcel/Style/Fill.php @@ -2,7 +2,7 @@ /** * PHPExcel * - * Copyright (c) 2006 - 2012 PHPExcel + * Copyright (c) 2006 - 2014 PHPExcel * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,9 +20,9 @@ * * @category PHPExcel * @package PHPExcel_Style - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version 1.7.8, 2012-10-12 + * @version 1.8.0, 2014-03-02 */ @@ -31,9 +31,9 @@ * * @category PHPExcel * @package PHPExcel_Style - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) */ -class PHPExcel_Style_Fill implements PHPExcel_IComparable +class PHPExcel_Style_Fill extends PHPExcel_Style_Supervisor implements PHPExcel_IComparable { /* Fill types */ const FILL_NONE = 'none'; @@ -63,49 +63,28 @@ class PHPExcel_Style_Fill implements PHPExcel_IComparable * * @var string */ - private $_fillType = PHPExcel_Style_Fill::FILL_NONE; + protected $_fillType = PHPExcel_Style_Fill::FILL_NONE; /** * Rotation * * @var double */ - private $_rotation = 0; + protected $_rotation = 0; /** * Start color * * @var PHPExcel_Style_Color */ - private $_startColor; + protected $_startColor; /** * End color * * @var PHPExcel_Style_Color */ - private $_endColor; - - /** - * Parent Borders - * - * @var _parentPropertyName string - */ - private $_parentPropertyName; - - /** - * Supervisor? - * - * @var boolean - */ - private $_isSupervisor; - - /** - * Parent. Only used for supervisor - * - * @var PHPExcel_Style - */ - private $_parent; + protected $_endColor; /** * Create a new PHPExcel_Style_Fill @@ -117,10 +96,10 @@ class PHPExcel_Style_Fill implements PHPExcel_IComparable * Leave this value at default unless you understand exactly what * its ramifications are */ - public function __construct($isSupervisor = false, $isConditional = false) + public function __construct($isSupervisor = FALSE, $isConditional = FALSE) { // Supervisor? - $this->_isSupervisor = $isSupervisor; + parent::__construct($isSupervisor); // Initialise values if ($isConditional) { @@ -136,28 +115,6 @@ class PHPExcel_Style_Fill implements PHPExcel_IComparable } } - /** - * Bind parent. Only used for supervisor - * - * @param PHPExcel_Style $parent - * @return PHPExcel_Style_Fill - */ - public function bindParent($parent) - { - $this->_parent = $parent; - return $this; - } - - /** - * Is this a supervisor or a real style component? - * - * @return boolean - */ - public function getIsSupervisor() - { - return $this->_isSupervisor; - } - /** * Get the shared style component for the currently active cell in currently active sheet. * Only used for style supervisor @@ -169,38 +126,6 @@ class PHPExcel_Style_Fill implements PHPExcel_IComparable return $this->_parent->getSharedComponent()->getFill(); } - /** - * Get the currently active sheet. Only used for supervisor - * - * @return PHPExcel_Worksheet - */ - public function getActiveSheet() - { - return $this->_parent->getActiveSheet(); - } - - /** - * Get the currently active cell coordinate in currently active sheet. - * Only used for supervisor - * - * @return string E.g. 'A1' - */ - public function getSelectedCells() - { - return $this->getActiveSheet()->getSelectedCells(); - } - - /** - * Get the currently active cell coordinate in currently active sheet. - * Only used for supervisor - * - * @return string E.g. 'A1' - */ - public function getActiveCell() - { - return $this->getActiveSheet()->getActiveCell(); - } - /** * Build style array from subcomponents * @@ -231,7 +156,7 @@ class PHPExcel_Style_Fill implements PHPExcel_IComparable * * * @param array $pStyles Array containing style information - * @throws Exception + * @throws PHPExcel_Exception * @return PHPExcel_Style_Fill */ public function applyFromArray($pStyles = null) { @@ -256,7 +181,7 @@ class PHPExcel_Style_Fill implements PHPExcel_IComparable } } } else { - throw new Exception("Invalid style array passed."); + throw new PHPExcel_Exception("Invalid style array passed."); } return $this; } @@ -330,7 +255,7 @@ class PHPExcel_Style_Fill implements PHPExcel_IComparable * Set Start Color * * @param PHPExcel_Style_Color $pValue - * @throws Exception + * @throws PHPExcel_Exception * @return PHPExcel_Style_Fill */ public function setStartColor(PHPExcel_Style_Color $pValue = null) { @@ -359,7 +284,7 @@ class PHPExcel_Style_Fill implements PHPExcel_IComparable * Set End Color * * @param PHPExcel_Style_Color $pValue - * @throws Exception + * @throws PHPExcel_Exception * @return PHPExcel_Style_Fill */ public function setEndColor(PHPExcel_Style_Color $pValue = null) { @@ -393,17 +318,4 @@ class PHPExcel_Style_Fill implements PHPExcel_IComparable ); } - /** - * Implement PHP __clone to create a deep clone, not just a shallow copy. - */ - public function __clone() { - $vars = get_object_vars($this); - foreach ($vars as $key => $value) { - if ((is_object($value)) && ($key != '_parent')) { - $this->$key = clone $value; - } else { - $this->$key = $value; - } - } - } } diff --git a/htdocs/includes/phpexcel/PHPExcel/Style/Font.php b/htdocs/includes/phpexcel/PHPExcel/Style/Font.php index 59ae7730956..e89488c2c1c 100644 --- a/htdocs/includes/phpexcel/PHPExcel/Style/Font.php +++ b/htdocs/includes/phpexcel/PHPExcel/Style/Font.php @@ -2,7 +2,7 @@ /** * PHPExcel * - * Copyright (c) 2006 - 2012 PHPExcel + * Copyright (c) 2006 - 2014 PHPExcel * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,9 +20,9 @@ * * @category PHPExcel * @package PHPExcel_Style - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version 1.7.8, 2012-10-12 + * @version 1.8.0, 2014-03-02 */ @@ -31,9 +31,9 @@ * * @category PHPExcel * @package PHPExcel_Style - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) */ -class PHPExcel_Style_Font implements PHPExcel_IComparable +class PHPExcel_Style_Font extends PHPExcel_Style_Supervisor implements PHPExcel_IComparable { /* Underline types */ const UNDERLINE_NONE = 'none'; @@ -47,84 +47,63 @@ class PHPExcel_Style_Font implements PHPExcel_IComparable * * @var string */ - private $_name = 'Calibri'; + protected $_name = 'Calibri'; /** * Font Size * * @var float */ - private $_size = 11; + protected $_size = 11; /** * Bold * * @var boolean */ - private $_bold = false; + protected $_bold = FALSE; /** * Italic * * @var boolean */ - private $_italic = false; + protected $_italic = FALSE; /** * Superscript * * @var boolean */ - private $_superScript = false; + protected $_superScript = FALSE; /** * Subscript * * @var boolean */ - private $_subScript = false; + protected $_subScript = FALSE; /** * Underline * * @var string */ - private $_underline = self::UNDERLINE_NONE; + protected $_underline = self::UNDERLINE_NONE; /** * Strikethrough * * @var boolean */ - private $_strikethrough = false; + protected $_strikethrough = FALSE; /** * Foreground color * * @var PHPExcel_Style_Color */ - private $_color; - - /** - * Parent Borders - * - * @var _parentPropertyName string - */ - private $_parentPropertyName; - - /** - * Supervisor? - * - * @var boolean - */ - private $_isSupervisor; - - /** - * Parent. Only used for supervisor - * - * @var PHPExcel_Style - */ - private $_parent; + protected $_color; /** * Create a new PHPExcel_Style_Font @@ -136,10 +115,10 @@ class PHPExcel_Style_Font implements PHPExcel_IComparable * Leave this value at default unless you understand exactly what * its ramifications are */ - public function __construct($isSupervisor = false, $isConditional = false) + public function __construct($isSupervisor = FALSE, $isConditional = FALSE) { // Supervisor? - $this->_isSupervisor = $isSupervisor; + parent::__construct($isSupervisor); // Initialise values if ($isConditional) { @@ -161,27 +140,6 @@ class PHPExcel_Style_Font implements PHPExcel_IComparable } } - /** - * Bind parent. Only used for supervisor - * - * @param PHPExcel_Style $parent - * @return PHPExcel_Style_Font - */ - public function bindParent($parent) - { - $this->_parent = $parent; - } - - /** - * Is this a supervisor or a real style component? - * - * @return boolean - */ - public function getIsSupervisor() - { - return $this->_isSupervisor; - } - /** * Get the shared style component for the currently active cell in currently active sheet. * Only used for style supervisor @@ -193,38 +151,6 @@ class PHPExcel_Style_Font implements PHPExcel_IComparable return $this->_parent->getSharedComponent()->getFont(); } - /** - * Get the currently active sheet. Only used for supervisor - * - * @return PHPExcel_Worksheet - */ - public function getActiveSheet() - { - return $this->_parent->getActiveSheet(); - } - - /** - * Get the currently active cell coordinate in currently active sheet. - * Only used for supervisor - * - * @return string E.g. 'A1' - */ - public function getSelectedCells() - { - return $this->getActiveSheet()->getSelectedCells(); - } - - /** - * Get the currently active cell coordinate in currently active sheet. - * Only used for supervisor - * - * @return string E.g. 'A1' - */ - public function getActiveCell() - { - return $this->getActiveSheet()->getActiveCell(); - } - /** * Build style array from subcomponents * @@ -242,12 +168,12 @@ class PHPExcel_Style_Font implements PHPExcel_IComparable * * $objPHPExcel->getActiveSheet()->getStyle('B2')->getFont()->applyFromArray( * array( - * 'name' => 'Arial', - * 'bold' => true, - * 'italic' => false, + * 'name' => 'Arial', + * 'bold' => TRUE, + * 'italic' => FALSE, * 'underline' => PHPExcel_Style_Font::UNDERLINE_DOUBLE, - * 'strike' => false, - * 'color' => array( + * 'strike' => FALSE, + * 'color' => array( * 'rgb' => '808080' * ) * ) @@ -255,7 +181,7 @@ class PHPExcel_Style_Font implements PHPExcel_IComparable * * * @param array $pStyles Array containing style information - * @throws Exception + * @throws PHPExcel_Exception * @return PHPExcel_Style_Font */ public function applyFromArray($pStyles = null) { @@ -292,7 +218,7 @@ class PHPExcel_Style_Font implements PHPExcel_IComparable } } } else { - throw new Exception("Invalid style array passed."); + throw new PHPExcel_Exception("Invalid style array passed."); } return $this; } @@ -501,7 +427,7 @@ class PHPExcel_Style_Font implements PHPExcel_IComparable * Set Underline * * @param string|boolean $pValue PHPExcel_Style_Font underline type - * If a boolean is passed, then true equates to UNDERLINE_SINGLE, + * If a boolean is passed, then TRUE equates to UNDERLINE_SINGLE, * false equates to UNDERLINE_NONE * @return PHPExcel_Style_Font */ @@ -520,27 +446,6 @@ class PHPExcel_Style_Font implements PHPExcel_IComparable return $this; } - /** - * Get Striketrough - * - * @deprecated Use getStrikethrough() instead. - * @return boolean - */ - public function getStriketrough() { - return $this->getStrikethrough(); - } - - /** - * Set Striketrough - * - * @deprecated Use setStrikethrough() instead. - * @param boolean $pValue - * @return PHPExcel_Style_Font - */ - public function setStriketrough($pValue = false) { - return $this->setStrikethrough($pValue); - } - /** * Get Strikethrough * @@ -585,7 +490,7 @@ class PHPExcel_Style_Font implements PHPExcel_IComparable * Set Color * * @param PHPExcel_Style_Color $pValue - * @throws Exception + * @throws PHPExcel_Exception * @return PHPExcel_Style_Font */ public function setColor(PHPExcel_Style_Color $pValue = null) { @@ -624,17 +529,4 @@ class PHPExcel_Style_Font implements PHPExcel_IComparable ); } - /** - * Implement PHP __clone to create a deep clone, not just a shallow copy. - */ - public function __clone() { - $vars = get_object_vars($this); - foreach ($vars as $key => $value) { - if ((is_object($value)) && ($key != '_parent')) { - $this->$key = clone $value; - } else { - $this->$key = $value; - } - } - } } diff --git a/htdocs/includes/phpexcel/PHPExcel/Style/NumberFormat.php b/htdocs/includes/phpexcel/PHPExcel/Style/NumberFormat.php index 19e064e4de8..e8a978fb28c 100644 --- a/htdocs/includes/phpexcel/PHPExcel/Style/NumberFormat.php +++ b/htdocs/includes/phpexcel/PHPExcel/Style/NumberFormat.php @@ -2,7 +2,7 @@ /** * PHPExcel * - * Copyright (c) 2006 - 2012 PHPExcel + * Copyright (c) 2006 - 2014 PHPExcel * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,9 +20,9 @@ * * @category PHPExcel * @package PHPExcel_Style - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version 1.7.8, 2012-10-12 + * @version 1.8.0, 2014-03-02 */ @@ -31,9 +31,9 @@ * * @category PHPExcel * @package PHPExcel_Style - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) */ -class PHPExcel_Style_NumberFormat implements PHPExcel_IComparable +class PHPExcel_Style_NumberFormat extends PHPExcel_Style_Supervisor implements PHPExcel_IComparable { /* Pre-defined formats */ const FORMAT_GENERAL = 'General'; @@ -80,49 +80,28 @@ class PHPExcel_Style_NumberFormat implements PHPExcel_IComparable * * @var array */ - private static $_builtInFormats; + protected static $_builtInFormats; /** * Excel built-in number formats (flipped, for faster lookups) * * @var array */ - private static $_flippedBuiltInFormats; + protected static $_flippedBuiltInFormats; /** * Format Code * * @var string */ - private $_formatCode = PHPExcel_Style_NumberFormat::FORMAT_GENERAL; + protected $_formatCode = PHPExcel_Style_NumberFormat::FORMAT_GENERAL; /** * Built-in format Code * * @var string */ - private $_builtInFormatCode = 0; - - /** - * Parent Borders - * - * @var _parentPropertyName string - */ - private $_parentPropertyName; - - /** - * Supervisor? - * - * @var boolean - */ - private $_isSupervisor; - - /** - * Parent. Only used for supervisor - * - * @var PHPExcel_Style - */ - private $_parent; + protected $_builtInFormatCode = 0; /** * Create a new PHPExcel_Style_NumberFormat @@ -134,37 +113,16 @@ class PHPExcel_Style_NumberFormat implements PHPExcel_IComparable * Leave this value at default unless you understand exactly what * its ramifications are */ - public function __construct($isSupervisor = false, $isConditional = false) + public function __construct($isSupervisor = FALSE, $isConditional = FALSE) { // Supervisor? - $this->_isSupervisor = $isSupervisor; + parent::__construct($isSupervisor); if ($isConditional) { $this->_formatCode = NULL; } } - /** - * Bind parent. Only used for supervisor - * - * @param PHPExcel_Style $parent - * @return PHPExcel_Style_NumberFormat - */ - public function bindParent($parent) - { - $this->_parent = $parent; - } - - /** - * Is this a supervisor or a real style component? - * - * @return boolean - */ - public function getIsSupervisor() - { - return $this->_isSupervisor; - } - /** * Get the shared style component for the currently active cell in currently active sheet. * Only used for style supervisor @@ -176,38 +134,6 @@ class PHPExcel_Style_NumberFormat implements PHPExcel_IComparable return $this->_parent->getSharedComponent()->getNumberFormat(); } - /** - * Get the currently active sheet. Only used for supervisor - * - * @return PHPExcel_Worksheet - */ - public function getActiveSheet() - { - return $this->_parent->getActiveSheet(); - } - - /** - * Get the currently active cell coordinate in currently active sheet. - * Only used for supervisor - * - * @return string E.g. 'A1' - */ - public function getSelectedCells() - { - return $this->getActiveSheet()->getSelectedCells(); - } - - /** - * Get the currently active cell coordinate in currently active sheet. - * Only used for supervisor - * - * @return string E.g. 'A1' - */ - public function getActiveCell() - { - return $this->getActiveSheet()->getActiveCell(); - } - /** * Build style array from subcomponents * @@ -231,7 +157,7 @@ class PHPExcel_Style_NumberFormat implements PHPExcel_IComparable * * * @param array $pStyles Array containing style information - * @throws Exception + * @throws PHPExcel_Exception * @return PHPExcel_Style_NumberFormat */ public function applyFromArray($pStyles = null) @@ -245,7 +171,7 @@ class PHPExcel_Style_NumberFormat implements PHPExcel_IComparable } } } else { - throw new Exception("Invalid style array passed."); + throw new PHPExcel_Exception("Invalid style array passed."); } return $this; } @@ -443,21 +369,6 @@ class PHPExcel_Style_NumberFormat implements PHPExcel_IComparable ); } - /** - * Implement PHP __clone to create a deep clone, not just a shallow copy. - */ - public function __clone() - { - $vars = get_object_vars($this); - foreach ($vars as $key => $value) { - if ((is_object($value)) && ($key != '_parent')) { - $this->$key = clone $value; - } else { - $this->$key = $value; - } - } - } - /** * Search/replace values to convert Excel date/time format masks to PHP format masks * @@ -479,8 +390,11 @@ class PHPExcel_Style_NumberFormat implements PHPExcel_IComparable 'mmmm' => 'F', // short month name 'mmm' => 'M', - // mm is minutes if time or month w/leading zero + // mm is minutes if time, but can also be month w/leading zero + // so we try to identify times be the inclusion of a : separator in the mask + // It isn't perfect, but the best way I know how ':mm' => ':i', + 'mm:' => 'i:', // month leading zero 'mm' => 'm', // month no leading zero @@ -517,6 +431,108 @@ class PHPExcel_Style_NumberFormat implements PHPExcel_IComparable 'h' => 'g' ); + private static function _formatAsDate(&$value, &$format) + { + // dvc: convert Excel formats to PHP date formats + + // strip off first part containing e.g. [$-F800] or [$USD-409] + // general syntax: [$-] + // language info is in hexadecimal + $format = preg_replace('/^(\[\$[A-Z]*-[0-9A-F]*\])/i', '', $format); + + // OpenOffice.org uses upper-case number formats, e.g. 'YYYY', convert to lower-case + $format = strtolower($format); + + $format = strtr($format,self::$_dateFormatReplacements); + if (!strpos($format,'A')) { // 24-hour time format + $format = strtr($format,self::$_dateFormatReplacements24); + } else { // 12-hour time format + $format = strtr($format,self::$_dateFormatReplacements12); + } + + $dateObj = PHPExcel_Shared_Date::ExcelToPHPObject($value); + $value = $dateObj->format($format); + } + + private static function _formatAsPercentage(&$value, &$format) + { + if ($format === self::FORMAT_PERCENTAGE) { + $value = round( (100 * $value), 0) . '%'; + } else { + if (preg_match('/\.[#0]+/i', $format, $m)) { + $s = substr($m[0], 0, 1) . (strlen($m[0]) - 1); + $format = str_replace($m[0], $s, $format); + } + if (preg_match('/^[#0]+/', $format, $m)) { + $format = str_replace($m[0], strlen($m[0]), $format); + } + $format = '%' . str_replace('%', 'f%%', $format); + + $value = sprintf($format, 100 * $value); + } + } + + private static function _formatAsFraction(&$value, &$format) + { + $sign = ($value < 0) ? '-' : ''; + + $integerPart = floor(abs($value)); + $decimalPart = trim(fmod(abs($value),1),'0.'); + $decimalLength = strlen($decimalPart); + $decimalDivisor = pow(10,$decimalLength); + + $GCD = PHPExcel_Calculation_MathTrig::GCD($decimalPart,$decimalDivisor); + + $adjustedDecimalPart = $decimalPart/$GCD; + $adjustedDecimalDivisor = $decimalDivisor/$GCD; + + if ((strpos($format,'0') !== false) || (strpos($format,'#') !== false) || (substr($format,0,3) == '? ?')) { + if ($integerPart == 0) { + $integerPart = ''; + } + $value = "$sign$integerPart $adjustedDecimalPart/$adjustedDecimalDivisor"; + } else { + $adjustedDecimalPart += $integerPart * $adjustedDecimalDivisor; + $value = "$sign$adjustedDecimalPart/$adjustedDecimalDivisor"; + } + } + + private static function _complexNumberFormatMask($number, $mask) { + if (strpos($mask,'.') !== false) { + $numbers = explode('.', $number . '.0'); + $masks = explode('.', $mask . '.0'); + $result1 = self::_complexNumberFormatMask($numbers[0], $masks[0]); + $result2 = strrev(self::_complexNumberFormatMask(strrev($numbers[1]), strrev($masks[1]))); + return $result1 . '.' . $result2; + } + + $r = preg_match_all('/0+/', $mask, $result, PREG_OFFSET_CAPTURE); + if ($r > 1) { + $result = array_reverse($result[0]); + + foreach($result as $block) { + $divisor = 1 . $block[0]; + $size = strlen($block[0]); + $offset = $block[1]; + + $blockValue = sprintf( + '%0' . $size . 'd', + fmod($number, $divisor) + ); + $number = floor($number / $divisor); + $mask = substr_replace($mask,$blockValue, $offset, $size); + } + if ($number > 0) { + $mask = substr_replace($mask, $number, $offset, 0); + } + $result = $mask; + } else { + $result = $number; + } + + return $result; + } + /** * Convert a value in a pre-defined format to a PHP string * @@ -525,7 +541,7 @@ class PHPExcel_Style_NumberFormat implements PHPExcel_IComparable * @param array $callBack Callback function for additional formatting of string * @return string Formatted string */ - public static function toFormattedString($value = '', $format = '', $callBack = null) + public static function toFormattedString($value = '0', $format = PHPExcel_Style_NumberFormat::FORMAT_GENERAL, $callBack = null) { // For now we do not treat strings although section 4 of a format code affects strings if (!is_numeric($value)) return $value; @@ -585,46 +601,12 @@ class PHPExcel_Style_NumberFormat implements PHPExcel_IComparable // Let's begin inspecting the format and converting the value to a formatted string if (preg_match('/^(\[\$[A-Z]*-[0-9A-F]*\])*[hmsdy]/i', $format)) { // datetime format - // dvc: convert Excel formats to PHP date formats - - // strip off first part containing e.g. [$-F800] or [$USD-409] - // general syntax: [$-] - // language info is in hexadecimal - $format = preg_replace('/^(\[\$[A-Z]*-[0-9A-F]*\])/i', '', $format); - - // OpenOffice.org uses upper-case number formats, e.g. 'YYYY', convert to lower-case - $format = strtolower($format); - - $format = strtr($format,self::$_dateFormatReplacements); - if (!strpos($format,'A')) { // 24-hour time format - $format = strtr($format,self::$_dateFormatReplacements24); - } else { // 12-hour time format - $format = strtr($format,self::$_dateFormatReplacements12); - } - - $dateObj = PHPExcel_Shared_Date::ExcelToPHPObject($value); - $value = $dateObj->format($format); - + self::_formatAsDate($value, $format); } else if (preg_match('/%$/', $format)) { // % number format - if ($format === self::FORMAT_PERCENTAGE) { - $value = round( (100 * $value), 0) . '%'; - } else { - if (preg_match('/\.[#0]+/i', $format, $m)) { - $s = substr($m[0], 0, 1) . (strlen($m[0]) - 1); - $format = str_replace($m[0], $s, $format); - } - if (preg_match('/^[#0]+/', $format, $m)) { - $format = str_replace($m[0], strlen($m[0]), $format); - } - $format = '%' . str_replace('%', 'f%%', $format); - - $value = sprintf($format, 100 * $value); - } - + self::_formatAsPercentage($value, $format); } else { if ($format === self::FORMAT_CURRENCY_EUR_SIMPLE) { $value = 'EUR ' . sprintf('%1.2f', $value); - } else { // In Excel formats, "_" is used to add spacing, which we can't do in HTML $format = preg_replace('/_./', '', $format); @@ -660,25 +642,7 @@ class PHPExcel_Style_NumberFormat implements PHPExcel_IComparable if (preg_match('/#?.*\?\/\?/', $format, $m)) { //echo 'Format mask is fractional '.$format.'
'; if ($value != (int)$value) { - $sign = ($value < 0) ? '-' : ''; - - $integerPart = floor(abs($value)); - $decimalPart = trim(fmod(abs($value),1),'0.'); - $decimalLength = strlen($decimalPart); - $decimalDivisor = pow(10,$decimalLength); - - $GCD = PHPExcel_Calculation_MathTrig::GCD($decimalPart,$decimalDivisor); - - $adjustedDecimalPart = $decimalPart/$GCD; - $adjustedDecimalDivisor = $decimalDivisor/$GCD; - - if ((strpos($format,'0') !== false) || (strpos($format,'#') !== false) || (substr($format,0,3) == '? ?')) { - if ($integerPart == 0) { $integerPart = ''; } - $value = "$sign$integerPart $adjustedDecimalPart/$adjustedDecimalDivisor"; - } else { - $adjustedDecimalPart += $integerPart * $adjustedDecimalDivisor; - $value = "$sign$adjustedDecimalPart/$adjustedDecimalDivisor"; - } + self::_formatAsFraction($value, $format); } } else { @@ -688,7 +652,7 @@ class PHPExcel_Style_NumberFormat implements PHPExcel_IComparable $value = $value / $scale; // Strip # - $format = preg_replace('/\\#/', '', $format); + $format = preg_replace('/\\#/', '0', $format); $n = "/\[[^\]]+\]/"; $m = preg_replace($n, '', $format); @@ -700,7 +664,6 @@ class PHPExcel_Style_NumberFormat implements PHPExcel_IComparable // minimun width of formatted number (including dot) $minWidth = strlen($left) + strlen($dec) + strlen($right); - if ($useThousands) { $value = number_format( $value @@ -708,12 +671,19 @@ class PHPExcel_Style_NumberFormat implements PHPExcel_IComparable , PHPExcel_Shared_String::getDecimalSeparator() , PHPExcel_Shared_String::getThousandsSeparator() ); + $value = preg_replace($number_regex, $value, $format); } else { - $sprintf_pattern = "%0$minWidth." . strlen($right) . "f"; - $value = sprintf($sprintf_pattern, $value); + if (preg_match('/[0#]E[+-]0/i', $format)) { + // Scientific format + $value = sprintf('%5.2E', $value); + } elseif (preg_match('/0([^\d\.]+)0/', $format)) { + $value = self::_complexNumberFormatMask($value, $format); + } else { + $sprintf_pattern = "%0$minWidth." . strlen($right) . "f"; + $value = sprintf($sprintf_pattern, $value); + $value = preg_replace($number_regex, $value, $format); + } } - - $value = preg_replace($number_regex, $value, $format); } } if (preg_match('/\[\$(.*)\]/u', $format, $m)) { diff --git a/htdocs/includes/phpexcel/PHPExcel/Style/Protection.php b/htdocs/includes/phpexcel/PHPExcel/Style/Protection.php index 477742bd3f5..8dc1f31ad70 100644 --- a/htdocs/includes/phpexcel/PHPExcel/Style/Protection.php +++ b/htdocs/includes/phpexcel/PHPExcel/Style/Protection.php @@ -2,7 +2,7 @@ /** * PHPExcel * - * Copyright (c) 2006 - 2012 PHPExcel + * Copyright (c) 2006 - 2014 PHPExcel * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,7 +20,7 @@ * * @category PHPExcel * @package PHPExcel_Style - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @version 1.4.5, 2007-08-23 */ @@ -31,9 +31,9 @@ * * @category PHPExcel * @package PHPExcel_Style - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) */ -class PHPExcel_Style_Protection implements PHPExcel_IComparable +class PHPExcel_Style_Protection extends PHPExcel_Style_Supervisor implements PHPExcel_IComparable { /** Protection styles */ const PROTECTION_INHERIT = 'inherit'; @@ -45,37 +45,16 @@ class PHPExcel_Style_Protection implements PHPExcel_IComparable * * @var string */ - private $_locked; + protected $_locked; /** * Hidden * * @var string */ - private $_hidden; + protected $_hidden; /** - * Parent Borders - * - * @var _parentPropertyName string - */ - private $_parentPropertyName; - - /** - * Supervisor? - * - * @var boolean - */ - private $_isSupervisor; - - /** - * Parent. Only used for supervisor - * - * @var PHPExcel_Style - */ - private $_parent; - - /** * Create a new PHPExcel_Style_Protection * * @param boolean $isSupervisor Flag indicating if this is a supervisor or not @@ -85,10 +64,10 @@ class PHPExcel_Style_Protection implements PHPExcel_IComparable * Leave this value at default unless you understand exactly what * its ramifications are */ - public function __construct($isSupervisor = false, $isConditional = false) + public function __construct($isSupervisor = FALSE, $isConditional = FALSE) { // Supervisor? - $this->_isSupervisor = $isSupervisor; + parent::__construct($isSupervisor); // Initialise values if (!$isConditional) { @@ -97,28 +76,6 @@ class PHPExcel_Style_Protection implements PHPExcel_IComparable } } - /** - * Bind parent. Only used for supervisor - * - * @param PHPExcel_Style $parent - * @return PHPExcel_Style_Protection - */ - public function bindParent($parent) - { - $this->_parent = $parent; - return $this; - } - - /** - * Is this a supervisor or a real style component? - * - * @return boolean - */ - public function getIsSupervisor() - { - return $this->_isSupervisor; - } - /** * Get the shared style component for the currently active cell in currently active sheet. * Only used for style supervisor @@ -130,38 +87,6 @@ class PHPExcel_Style_Protection implements PHPExcel_IComparable return $this->_parent->getSharedComponent()->getProtection(); } - /** - * Get the currently active sheet. Only used for supervisor - * - * @return PHPExcel_Worksheet - */ - public function getActiveSheet() - { - return $this->_parent->getActiveSheet(); - } - - /** - * Get the currently active cell coordinate in currently active sheet. - * Only used for supervisor - * - * @return string E.g. 'A1' - */ - public function getSelectedCells() - { - return $this->getActiveSheet()->getSelectedCells(); - } - - /** - * Get the currently active cell coordinate in currently active sheet. - * Only used for supervisor - * - * @return string E.g. 'A1' - */ - public function getActiveCell() - { - return $this->getActiveSheet()->getActiveCell(); - } - /** * Build style array from subcomponents * @@ -177,27 +102,32 @@ class PHPExcel_Style_Protection implements PHPExcel_IComparable * Apply styles from array * * - * $objPHPExcel->getActiveSheet()->getStyle('B2')->getLocked()->applyFromArray( array('locked' => true, 'hidden' => false) ); + * $objPHPExcel->getActiveSheet()->getStyle('B2')->getLocked()->applyFromArray( + * array( + * 'locked' => TRUE, + * 'hidden' => FALSE + * ) + * ); * * * @param array $pStyles Array containing style information - * @throws Exception + * @throws PHPExcel_Exception * @return PHPExcel_Style_Protection */ - public function applyFromArray($pStyles = null) { + public function applyFromArray($pStyles = NULL) { if (is_array($pStyles)) { if ($this->_isSupervisor) { $this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($this->getStyleArray($pStyles)); } else { - if (array_key_exists('locked', $pStyles)) { + if (isset($pStyles['locked'])) { $this->setLocked($pStyles['locked']); } - if (array_key_exists('hidden', $pStyles)) { + if (isset($pStyles['hidden'])) { $this->setHidden($pStyles['hidden']); } } } else { - throw new Exception("Invalid style array passed."); + throw new PHPExcel_Exception("Invalid style array passed."); } return $this; } @@ -274,17 +204,4 @@ class PHPExcel_Style_Protection implements PHPExcel_IComparable ); } - /** - * Implement PHP __clone to create a deep clone, not just a shallow copy. - */ - public function __clone() { - $vars = get_object_vars($this); - foreach ($vars as $key => $value) { - if ((is_object($value)) && ($key != '_parent')) { - $this->$key = clone $value; - } else { - $this->$key = $value; - } - } - } } diff --git a/htdocs/includes/phpexcel/PHPExcel/Style/Supervisor.php b/htdocs/includes/phpexcel/PHPExcel/Style/Supervisor.php new file mode 100644 index 00000000000..c2ce9c035ab --- /dev/null +++ b/htdocs/includes/phpexcel/PHPExcel/Style/Supervisor.php @@ -0,0 +1,132 @@ +_isSupervisor = $isSupervisor; + } + + /** + * Bind parent. Only used for supervisor + * + * @param PHPExcel $parent + * @return PHPExcel_Style_Supervisor + */ + public function bindParent($parent, $parentPropertyName=NULL) + { + $this->_parent = $parent; + return $this; + } + + /** + * Is this a supervisor or a cell style component? + * + * @return boolean + */ + public function getIsSupervisor() + { + return $this->_isSupervisor; + } + + /** + * Get the currently active sheet. Only used for supervisor + * + * @return PHPExcel_Worksheet + */ + public function getActiveSheet() + { + return $this->_parent->getActiveSheet(); + } + + /** + * Get the currently active cell coordinate in currently active sheet. + * Only used for supervisor + * + * @return string E.g. 'A1' + */ + public function getSelectedCells() + { + return $this->getActiveSheet()->getSelectedCells(); + } + + /** + * Get the currently active cell coordinate in currently active sheet. + * Only used for supervisor + * + * @return string E.g. 'A1' + */ + public function getActiveCell() + { + return $this->getActiveSheet()->getActiveCell(); + } + + /** + * Implement PHP __clone to create a deep clone, not just a shallow copy. + */ + public function __clone() { + $vars = get_object_vars($this); + foreach ($vars as $key => $value) { + if ((is_object($value)) && ($key != '_parent')) { + $this->$key = clone $value; + } else { + $this->$key = $value; + } + } + } +} diff --git a/htdocs/includes/phpexcel/PHPExcel/Worksheet.php b/htdocs/includes/phpexcel/PHPExcel/Worksheet.php index 17ed5da962b..682ad9838ea 100644 --- a/htdocs/includes/phpexcel/PHPExcel/Worksheet.php +++ b/htdocs/includes/phpexcel/PHPExcel/Worksheet.php @@ -2,7 +2,7 @@ /** * PHPExcel * - * Copyright (c) 2006 - 2012 PHPExcel + * Copyright (c) 2006 - 2014 PHPExcel * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -19,10 +19,10 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * @category PHPExcel - * @package PHPExcel_Worksheet - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version 1.7.8, 2012-10-12 + * @package PHPExcel_Worksheet + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) + * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @version 1.8.0, 2014-03-02 */ @@ -30,779 +30,2846 @@ * PHPExcel_Worksheet * * @category PHPExcel - * @package PHPExcel_Worksheet - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @package PHPExcel_Worksheet + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) */ class PHPExcel_Worksheet implements PHPExcel_IComparable { - /* Break types */ - const BREAK_NONE = 0; - const BREAK_ROW = 1; - const BREAK_COLUMN = 2; + /* Break types */ + const BREAK_NONE = 0; + const BREAK_ROW = 1; + const BREAK_COLUMN = 2; - /* Sheet state */ - const SHEETSTATE_VISIBLE = 'visible'; - const SHEETSTATE_HIDDEN = 'hidden'; - const SHEETSTATE_VERYHIDDEN = 'veryHidden'; + /* Sheet state */ + const SHEETSTATE_VISIBLE = 'visible'; + const SHEETSTATE_HIDDEN = 'hidden'; + const SHEETSTATE_VERYHIDDEN = 'veryHidden'; + + /** + * Invalid characters in sheet title + * + * @var array + */ + private static $_invalidCharacters = array('*', ':', '/', '\\', '?', '[', ']'); + + /** + * Parent spreadsheet + * + * @var PHPExcel + */ + private $_parent; + + /** + * Cacheable collection of cells + * + * @var PHPExcel_CachedObjectStorage_xxx + */ + private $_cellCollection = null; + + /** + * Collection of row dimensions + * + * @var PHPExcel_Worksheet_RowDimension[] + */ + private $_rowDimensions = array(); + + /** + * Default row dimension + * + * @var PHPExcel_Worksheet_RowDimension + */ + private $_defaultRowDimension = null; + + /** + * Collection of column dimensions + * + * @var PHPExcel_Worksheet_ColumnDimension[] + */ + private $_columnDimensions = array(); + + /** + * Default column dimension + * + * @var PHPExcel_Worksheet_ColumnDimension + */ + private $_defaultColumnDimension = null; + + /** + * Collection of drawings + * + * @var PHPExcel_Worksheet_BaseDrawing[] + */ + private $_drawingCollection = null; + + /** + * Collection of Chart objects + * + * @var PHPExcel_Chart[] + */ + private $_chartCollection = array(); + + /** + * Worksheet title + * + * @var string + */ + private $_title; + + /** + * Sheet state + * + * @var string + */ + private $_sheetState; + + /** + * Page setup + * + * @var PHPExcel_Worksheet_PageSetup + */ + private $_pageSetup; + + /** + * Page margins + * + * @var PHPExcel_Worksheet_PageMargins + */ + private $_pageMargins; + + /** + * Page header/footer + * + * @var PHPExcel_Worksheet_HeaderFooter + */ + private $_headerFooter; + + /** + * Sheet view + * + * @var PHPExcel_Worksheet_SheetView + */ + private $_sheetView; + + /** + * Protection + * + * @var PHPExcel_Worksheet_Protection + */ + private $_protection; + + /** + * Collection of styles + * + * @var PHPExcel_Style[] + */ + private $_styles = array(); + + /** + * Conditional styles. Indexed by cell coordinate, e.g. 'A1' + * + * @var array + */ + private $_conditionalStylesCollection = array(); + + /** + * Is the current cell collection sorted already? + * + * @var boolean + */ + private $_cellCollectionIsSorted = false; + + /** + * Collection of breaks + * + * @var array + */ + private $_breaks = array(); + + /** + * Collection of merged cell ranges + * + * @var array + */ + private $_mergeCells = array(); + + /** + * Collection of protected cell ranges + * + * @var array + */ + private $_protectedCells = array(); + + /** + * Autofilter Range and selection + * + * @var PHPExcel_Worksheet_AutoFilter + */ + private $_autoFilter = NULL; + + /** + * Freeze pane + * + * @var string + */ + private $_freezePane = ''; + + /** + * Show gridlines? + * + * @var boolean + */ + private $_showGridlines = true; + + /** + * Print gridlines? + * + * @var boolean + */ + private $_printGridlines = false; + + /** + * Show row and column headers? + * + * @var boolean + */ + private $_showRowColHeaders = true; + + /** + * Show summary below? (Row/Column outline) + * + * @var boolean + */ + private $_showSummaryBelow = true; + + /** + * Show summary right? (Row/Column outline) + * + * @var boolean + */ + private $_showSummaryRight = true; + + /** + * Collection of comments + * + * @var PHPExcel_Comment[] + */ + private $_comments = array(); + + /** + * Active cell. (Only one!) + * + * @var string + */ + private $_activeCell = 'A1'; + + /** + * Selected cells + * + * @var string + */ + private $_selectedCells = 'A1'; + + /** + * Cached highest column + * + * @var string + */ + private $_cachedHighestColumn = 'A'; + + /** + * Cached highest row + * + * @var int + */ + private $_cachedHighestRow = 1; + + /** + * Right-to-left? + * + * @var boolean + */ + private $_rightToLeft = false; + + /** + * Hyperlinks. Indexed by cell coordinate, e.g. 'A1' + * + * @var array + */ + private $_hyperlinkCollection = array(); + + /** + * Data validation objects. Indexed by cell coordinate, e.g. 'A1' + * + * @var array + */ + private $_dataValidationCollection = array(); + + /** + * Tab color + * + * @var PHPExcel_Style_Color + */ + private $_tabColor; + + /** + * Dirty flag + * + * @var boolean + */ + private $_dirty = true; + + /** + * Hash + * + * @var string + */ + private $_hash = null; + + /** + * CodeName + * + * @var string + */ + private $_codeName = null; /** - * Invalid characters in sheet title - * - * @var array - */ - private static $_invalidCharacters = array('*', ':', '/', '\\', '?', '[', ']'); + * Create a new worksheet + * + * @param PHPExcel $pParent + * @param string $pTitle + */ + public function __construct(PHPExcel $pParent = null, $pTitle = 'Worksheet') + { + // Set parent and title + $this->_parent = $pParent; + $this->setTitle($pTitle, FALSE); + // setTitle can change $pTitle + $this->setCodeName($this->getTitle()); + $this->setSheetState(PHPExcel_Worksheet::SHEETSTATE_VISIBLE); - /** - * Parent spreadsheet - * - * @var PHPExcel - */ - private $_parent; + $this->_cellCollection = PHPExcel_CachedObjectStorageFactory::getInstance($this); - /** - * Cacheable collection of cells - * - * @var PHPExcel_CachedObjectStorage_xxx - */ - private $_cellCollection = null; + // Set page setup + $this->_pageSetup = new PHPExcel_Worksheet_PageSetup(); - /** - * Collection of row dimensions - * - * @var PHPExcel_Worksheet_RowDimension[] - */ - private $_rowDimensions = array(); + // Set page margins + $this->_pageMargins = new PHPExcel_Worksheet_PageMargins(); - /** - * Default row dimension - * - * @var PHPExcel_Worksheet_RowDimension - */ - private $_defaultRowDimension = null; + // Set page header/footer + $this->_headerFooter = new PHPExcel_Worksheet_HeaderFooter(); - /** - * Collection of column dimensions - * - * @var PHPExcel_Worksheet_ColumnDimension[] - */ - private $_columnDimensions = array(); + // Set sheet view + $this->_sheetView = new PHPExcel_Worksheet_SheetView(); - /** - * Default column dimension - * - * @var PHPExcel_Worksheet_ColumnDimension - */ - private $_defaultColumnDimension = null; + // Drawing collection + $this->_drawingCollection = new ArrayObject(); - /** - * Collection of drawings - * - * @var PHPExcel_Worksheet_BaseDrawing[] - */ - private $_drawingCollection = null; + // Chart collection + $this->_chartCollection = new ArrayObject(); - /** - * Collection of Chart objects - * - * @var PHPExcel_Chart[] - */ - private $_chartCollection = array(); + // Protection + $this->_protection = new PHPExcel_Worksheet_Protection(); - /** - * Worksheet title - * - * @var string - */ - private $_title; + // Default row dimension + $this->_defaultRowDimension = new PHPExcel_Worksheet_RowDimension(NULL); - /** - * Sheet state - * - * @var string - */ - private $_sheetState; + // Default column dimension + $this->_defaultColumnDimension = new PHPExcel_Worksheet_ColumnDimension(NULL); - /** - * Page setup - * - * @var PHPExcel_Worksheet_PageSetup - */ - private $_pageSetup; - - /** - * Page margins - * - * @var PHPExcel_Worksheet_PageMargins - */ - private $_pageMargins; - - /** - * Page header/footer - * - * @var PHPExcel_Worksheet_HeaderFooter - */ - private $_headerFooter; - - /** - * Sheet view - * - * @var PHPExcel_Worksheet_SheetView - */ - private $_sheetView; - - /** - * Protection - * - * @var PHPExcel_Worksheet_Protection - */ - private $_protection; - - /** - * Collection of styles - * - * @var PHPExcel_Style[] - */ - private $_styles = array(); - - /** - * Conditional styles. Indexed by cell coordinate, e.g. 'A1' - * - * @var array - */ - private $_conditionalStylesCollection = array(); - - /** - * Is the current cell collection sorted already? - * - * @var boolean - */ - private $_cellCollectionIsSorted = false; - - /** - * Collection of breaks - * - * @var array - */ - private $_breaks = array(); - - /** - * Collection of merged cell ranges - * - * @var array - */ - private $_mergeCells = array(); - - /** - * Collection of protected cell ranges - * - * @var array - */ - private $_protectedCells = array(); - - /** - * Autofilter Range and selection - * - * @var PHPExcel_Worksheet_AutoFilter - */ - private $_autoFilter = NULL; - - /** - * Freeze pane - * - * @var string - */ - private $_freezePane = ''; - - /** - * Show gridlines? - * - * @var boolean - */ - private $_showGridlines = true; - - /** - * Print gridlines? - * - * @var boolean - */ - private $_printGridlines = false; - - /** - * Show row and column headers? - * - * @var boolean - */ - private $_showRowColHeaders = true; - - /** - * Show summary below? (Row/Column outline) - * - * @var boolean - */ - private $_showSummaryBelow = true; - - /** - * Show summary right? (Row/Column outline) - * - * @var boolean - */ - private $_showSummaryRight = true; - - /** - * Collection of comments - * - * @var PHPExcel_Comment[] - */ - private $_comments = array(); - - /** - * Active cell. (Only one!) - * - * @var string - */ - private $_activeCell = 'A1'; - - /** - * Selected cells - * - * @var string - */ - private $_selectedCells = 'A1'; - - /** - * Cached highest column - * - * @var string - */ - private $_cachedHighestColumn = 'A'; - - /** - * Cached highest row - * - * @var int - */ - private $_cachedHighestRow = 1; - - /** - * Right-to-left? - * - * @var boolean - */ - private $_rightToLeft = false; - - /** - * Hyperlinks. Indexed by cell coordinate, e.g. 'A1' - * - * @var array - */ - private $_hyperlinkCollection = array(); - - /** - * Data validation objects. Indexed by cell coordinate, e.g. 'A1' - * - * @var array - */ - private $_dataValidationCollection = array(); - - /** - * Tab color - * - * @var PHPExcel_Style_Color - */ - private $_tabColor; - - /** - * Dirty flag - * - * @var boolean - */ - private $_dirty = true; - - /** - * Hash - * - * @var string - */ - private $_hash = null; - - /** - * Create a new worksheet - * - * @param PHPExcel $pParent - * @param string $pTitle - */ - public function __construct(PHPExcel $pParent = null, $pTitle = 'Worksheet') - { - // Set parent and title - $this->_parent = $pParent; - $this->setTitle($pTitle, FALSE); - $this->setSheetState(PHPExcel_Worksheet::SHEETSTATE_VISIBLE); - - $this->_cellCollection = PHPExcel_CachedObjectStorageFactory::getInstance($this); - - // Set page setup - $this->_pageSetup = new PHPExcel_Worksheet_PageSetup(); - - // Set page margins - $this->_pageMargins = new PHPExcel_Worksheet_PageMargins(); - - // Set page header/footer - $this->_headerFooter = new PHPExcel_Worksheet_HeaderFooter(); - - // Set sheet view - $this->_sheetView = new PHPExcel_Worksheet_SheetView(); - - // Drawing collection - $this->_drawingCollection = new ArrayObject(); - - // Chart collection - $this->_chartCollection = new ArrayObject(); - - // Protection - $this->_protection = new PHPExcel_Worksheet_Protection(); - - // Default row dimension - $this->_defaultRowDimension = new PHPExcel_Worksheet_RowDimension(NULL); - - // Default column dimension - $this->_defaultColumnDimension = new PHPExcel_Worksheet_ColumnDimension(NULL); - - $this->_autoFilter = new PHPExcel_Worksheet_AutoFilter(NULL, $this); - } + $this->_autoFilter = new PHPExcel_Worksheet_AutoFilter(NULL, $this); + } - /** - * Disconnect all cells from this PHPExcel_Worksheet object, - * typically so that the worksheet object can be unset - * - */ + /** + * Disconnect all cells from this PHPExcel_Worksheet object, + * typically so that the worksheet object can be unset + * + */ public function disconnectCells() { - $this->_cellCollection->unsetWorksheetCells(); - $this->_cellCollection = null; + if ( $this->_cellCollection !== NULL){ + $this->_cellCollection->unsetWorksheetCells(); + $this->_cellCollection = NULL; + } + // detach ourself from the workbook, so that it can then delete this worksheet successfully + $this->_parent = null; + } - // detach ourself from the workbook, so that it can then delete this worksheet successfully - $this->_parent = null; + /** + * Code to execute when this worksheet is unset() + * + */ + function __destruct() { + PHPExcel_Calculation::getInstance($this->_parent) + ->clearCalculationCacheForWorksheet($this->_title); + + $this->disconnectCells(); } - /** - * Return the cache controller for the cell collection - * - * @return PHPExcel_CachedObjectStorage_xxx - */ + /** + * Return the cache controller for the cell collection + * + * @return PHPExcel_CachedObjectStorage_xxx + */ public function getCellCacheController() { - return $this->_cellCollection; - } // function getCellCacheController() + return $this->_cellCollection; + } // function getCellCacheController() - /** - * Get array of invalid characters for sheet title - * - * @return array - */ - public static function getInvalidCharacters() - { - return self::$_invalidCharacters; - } + /** + * Get array of invalid characters for sheet title + * + * @return array + */ + public static function getInvalidCharacters() + { + return self::$_invalidCharacters; + } - /** - * Check sheet title for valid Excel syntax - * - * @param string $pValue The string to check - * @return string The valid string - * @throws Exception - */ - private static function _checkSheetTitle($pValue) - { - // Some of the printable ASCII characters are invalid: * : / \ ? [ ] - if (str_replace(self::$_invalidCharacters, '', $pValue) !== $pValue) { - throw new Exception('Invalid character found in sheet title'); - } + /** + * Check sheet code name for valid Excel syntax + * + * @param string $pValue The string to check + * @return string The valid string + * @throws Exception + */ + private static function _checkSheetCodeName($pValue) + { + $CharCount = PHPExcel_Shared_String::CountCharacters($pValue); + if ($CharCount == 0) { + throw new PHPExcel_Exception('Sheet code name cannot be empty.'); + } + // Some of the printable ASCII characters are invalid: * : / \ ? [ ] and first and last characters cannot be a "'" + if ((str_replace(self::$_invalidCharacters, '', $pValue) !== $pValue) || + (PHPExcel_Shared_String::Substring($pValue,-1,1)=='\'') || + (PHPExcel_Shared_String::Substring($pValue,0,1)=='\'')) { + throw new PHPExcel_Exception('Invalid character found in sheet code name'); + } + + // Maximum 31 characters allowed for sheet title + if ($CharCount > 31) { + throw new PHPExcel_Exception('Maximum 31 characters allowed in sheet code name.'); + } + + return $pValue; + } - // Maximum 31 characters allowed for sheet title - if (PHPExcel_Shared_String::CountCharacters($pValue) > 31) { - throw new Exception('Maximum 31 characters allowed in sheet title.'); - } + /** + * Check sheet title for valid Excel syntax + * + * @param string $pValue The string to check + * @return string The valid string + * @throws PHPExcel_Exception + */ + private static function _checkSheetTitle($pValue) + { + // Some of the printable ASCII characters are invalid: * : / \ ? [ ] + if (str_replace(self::$_invalidCharacters, '', $pValue) !== $pValue) { + throw new PHPExcel_Exception('Invalid character found in sheet title'); + } - return $pValue; - } + // Maximum 31 characters allowed for sheet title + if (PHPExcel_Shared_String::CountCharacters($pValue) > 31) { + throw new PHPExcel_Exception('Maximum 31 characters allowed in sheet title.'); + } - /** - * Get collection of cells - * - * @param boolean $pSorted Also sort the cell collection? - * @return PHPExcel_Cell[] - */ - public function getCellCollection($pSorted = true) - { - if ($pSorted) { - // Re-order cell collection - return $this->sortCellCollection(); - } - if ($this->_cellCollection !== NULL) { - return $this->_cellCollection->getCellList(); - } - return array(); - } + return $pValue; + } - /** - * Sort collection of cells - * - * @return PHPExcel_Worksheet - */ - public function sortCellCollection() - { - if ($this->_cellCollection !== NULL) { - return $this->_cellCollection->getSortedCellList(); - } - return array(); - } + /** + * Get collection of cells + * + * @param boolean $pSorted Also sort the cell collection? + * @return PHPExcel_Cell[] + */ + public function getCellCollection($pSorted = true) + { + if ($pSorted) { + // Re-order cell collection + return $this->sortCellCollection(); + } + if ($this->_cellCollection !== NULL) { + return $this->_cellCollection->getCellList(); + } + return array(); + } - /** - * Get collection of row dimensions - * - * @return PHPExcel_Worksheet_RowDimension[] - */ - public function getRowDimensions() - { - return $this->_rowDimensions; - } + /** + * Sort collection of cells + * + * @return PHPExcel_Worksheet + */ + public function sortCellCollection() + { + if ($this->_cellCollection !== NULL) { + return $this->_cellCollection->getSortedCellList(); + } + return array(); + } - /** - * Get default row dimension - * - * @return PHPExcel_Worksheet_RowDimension - */ - public function getDefaultRowDimension() - { - return $this->_defaultRowDimension; - } + /** + * Get collection of row dimensions + * + * @return PHPExcel_Worksheet_RowDimension[] + */ + public function getRowDimensions() + { + return $this->_rowDimensions; + } - /** - * Get collection of column dimensions - * - * @return PHPExcel_Worksheet_ColumnDimension[] - */ - public function getColumnDimensions() - { - return $this->_columnDimensions; - } + /** + * Get default row dimension + * + * @return PHPExcel_Worksheet_RowDimension + */ + public function getDefaultRowDimension() + { + return $this->_defaultRowDimension; + } - /** - * Get default column dimension - * - * @return PHPExcel_Worksheet_ColumnDimension - */ - public function getDefaultColumnDimension() - { - return $this->_defaultColumnDimension; - } + /** + * Get collection of column dimensions + * + * @return PHPExcel_Worksheet_ColumnDimension[] + */ + public function getColumnDimensions() + { + return $this->_columnDimensions; + } - /** - * Get collection of drawings - * - * @return PHPExcel_Worksheet_BaseDrawing[] - */ - public function getDrawingCollection() - { - return $this->_drawingCollection; - } + /** + * Get default column dimension + * + * @return PHPExcel_Worksheet_ColumnDimension + */ + public function getDefaultColumnDimension() + { + return $this->_defaultColumnDimension; + } - /** - * Get collection of charts - * - * @return PHPExcel_Chart[] - */ - public function getChartCollection() - { - return $this->_chartCollection; - } + /** + * Get collection of drawings + * + * @return PHPExcel_Worksheet_BaseDrawing[] + */ + public function getDrawingCollection() + { + return $this->_drawingCollection; + } - /** - * Add chart - * - * @param PHPExcel_Chart $pChart - * @param int|null $iChartIndex Index where chart should go (0,1,..., or null for last) - * @return PHPExcel_Chart - * @throws Exception - */ - public function addChart(PHPExcel_Chart $pChart = null, $iChartIndex = null) - { - $pChart->setWorksheet($this); - if (is_null($iChartIndex)) { - $this->_chartCollection[] = $pChart; - } else { - // Insert the chart at the requested index - array_splice($this->_chartCollection, $iChartIndex, 0, array($pChart)); - } + /** + * Get collection of charts + * + * @return PHPExcel_Chart[] + */ + public function getChartCollection() + { + return $this->_chartCollection; + } - return $pChart; - } + /** + * Add chart + * + * @param PHPExcel_Chart $pChart + * @param int|null $iChartIndex Index where chart should go (0,1,..., or null for last) + * @return PHPExcel_Chart + */ + public function addChart(PHPExcel_Chart $pChart = null, $iChartIndex = null) + { + $pChart->setWorksheet($this); + if (is_null($iChartIndex)) { + $this->_chartCollection[] = $pChart; + } else { + // Insert the chart at the requested index + array_splice($this->_chartCollection, $iChartIndex, 0, array($pChart)); + } - /** - * Return the count of charts on this worksheet - * - * @return int The number of charts - * @throws Exception - */ - public function getChartCount() - { - return count($this->_chartCollection); - } + return $pChart; + } - /** - * Get a chart by its index position - * - * @param string $index Chart index position - * @return false|PHPExcel_Chart - * @throws Exception - */ - public function getChartByIndex($index = null) - { - $chartCount = count($this->_chartCollection); - if ($chartCount == 0) { - return false; - } - if (is_null($index)) { - $index = --$chartCount; - } - if (!isset($this->_chartCollection[$index])) { - return false; - } + /** + * Return the count of charts on this worksheet + * + * @return int The number of charts + */ + public function getChartCount() + { + return count($this->_chartCollection); + } - return $this->_chartCollection[$index]; - } + /** + * Get a chart by its index position + * + * @param string $index Chart index position + * @return false|PHPExcel_Chart + * @throws PHPExcel_Exception + */ + public function getChartByIndex($index = null) + { + $chartCount = count($this->_chartCollection); + if ($chartCount == 0) { + return false; + } + if (is_null($index)) { + $index = --$chartCount; + } + if (!isset($this->_chartCollection[$index])) { + return false; + } - /** - * Return an array of the names of charts on this worksheet - * - * @return string[] The names of charts - * @throws Exception - */ - public function getChartNames() - { - $chartNames = array(); - foreach($this->_chartCollection as $chart) { - $chartNames[] = $chart->getName(); - } - return $chartNames; - } + return $this->_chartCollection[$index]; + } - /** - * Get a chart by name - * - * @param string $chartName Chart name - * @return false|PHPExcel_Chart - * @throws Exception - */ - public function getChartByName($chartName = '') - { - $chartCount = count($this->_chartCollection); - if ($chartCount == 0) { - return false; - } - foreach($this->_chartCollection as $index => $chart) { - if ($chart->getName() == $chartName) { - return $this->_chartCollection[$index]; - } - } - return false; - } + /** + * Return an array of the names of charts on this worksheet + * + * @return string[] The names of charts + * @throws PHPExcel_Exception + */ + public function getChartNames() + { + $chartNames = array(); + foreach($this->_chartCollection as $chart) { + $chartNames[] = $chart->getName(); + } + return $chartNames; + } - /** - * Refresh column dimensions - * - * @return PHPExcel_Worksheet - */ - public function refreshColumnDimensions() - { - $currentColumnDimensions = $this->getColumnDimensions(); - $newColumnDimensions = array(); + /** + * Get a chart by name + * + * @param string $chartName Chart name + * @return false|PHPExcel_Chart + * @throws PHPExcel_Exception + */ + public function getChartByName($chartName = '') + { + $chartCount = count($this->_chartCollection); + if ($chartCount == 0) { + return false; + } + foreach($this->_chartCollection as $index => $chart) { + if ($chart->getName() == $chartName) { + return $this->_chartCollection[$index]; + } + } + return false; + } - foreach ($currentColumnDimensions as $objColumnDimension) { - $newColumnDimensions[$objColumnDimension->getColumnIndex()] = $objColumnDimension; - } + /** + * Refresh column dimensions + * + * @return PHPExcel_Worksheet + */ + public function refreshColumnDimensions() + { + $currentColumnDimensions = $this->getColumnDimensions(); + $newColumnDimensions = array(); - $this->_columnDimensions = $newColumnDimensions; + foreach ($currentColumnDimensions as $objColumnDimension) { + $newColumnDimensions[$objColumnDimension->getColumnIndex()] = $objColumnDimension; + } - return $this; - } + $this->_columnDimensions = $newColumnDimensions; - /** - * Refresh row dimensions - * - * @return PHPExcel_Worksheet - */ - public function refreshRowDimensions() - { - $currentRowDimensions = $this->getRowDimensions(); - $newRowDimensions = array(); + return $this; + } - foreach ($currentRowDimensions as $objRowDimension) { - $newRowDimensions[$objRowDimension->getRowIndex()] = $objRowDimension; - } + /** + * Refresh row dimensions + * + * @return PHPExcel_Worksheet + */ + public function refreshRowDimensions() + { + $currentRowDimensions = $this->getRowDimensions(); + $newRowDimensions = array(); - $this->_rowDimensions = $newRowDimensions; + foreach ($currentRowDimensions as $objRowDimension) { + $newRowDimensions[$objRowDimension->getRowIndex()] = $objRowDimension; + } - return $this; - } + $this->_rowDimensions = $newRowDimensions; - /** - * Calculate worksheet dimension - * - * @return string String containing the dimension of this worksheet - */ - public function calculateWorksheetDimension() - { - // Return - return 'A1' . ':' . $this->getHighestColumn() . $this->getHighestRow(); - } + return $this; + } - /** - * Calculate worksheet data dimension - * - * @return string String containing the dimension of this worksheet that actually contain data - */ - public function calculateWorksheetDataDimension() - { - // Return - return 'A1' . ':' . $this->getHighestDataColumn() . $this->getHighestDataRow(); - } + /** + * Calculate worksheet dimension + * + * @return string String containing the dimension of this worksheet + */ + public function calculateWorksheetDimension() + { + // Return + return 'A1' . ':' . $this->getHighestColumn() . $this->getHighestRow(); + } - /** - * Calculate widths for auto-size columns - * - * @param boolean $calculateMergeCells Calculate merge cell width - * @return PHPExcel_Worksheet; - */ - public function calculateColumnWidths($calculateMergeCells = false) - { - // initialize $autoSizes array - $autoSizes = array(); - foreach ($this->getColumnDimensions() as $colDimension) { - if ($colDimension->getAutoSize()) { - $autoSizes[$colDimension->getColumnIndex()] = -1; - } - } + /** + * Calculate worksheet data dimension + * + * @return string String containing the dimension of this worksheet that actually contain data + */ + public function calculateWorksheetDataDimension() + { + // Return + return 'A1' . ':' . $this->getHighestDataColumn() . $this->getHighestDataRow(); + } - // There is only something to do if there are some auto-size columns - if (!empty($autoSizes)) { + /** + * Calculate widths for auto-size columns + * + * @param boolean $calculateMergeCells Calculate merge cell width + * @return PHPExcel_Worksheet; + */ + public function calculateColumnWidths($calculateMergeCells = false) + { + // initialize $autoSizes array + $autoSizes = array(); + foreach ($this->getColumnDimensions() as $colDimension) { + if ($colDimension->getAutoSize()) { + $autoSizes[$colDimension->getColumnIndex()] = -1; + } + } - // build list of cells references that participate in a merge - $isMergeCell = array(); - foreach ($this->getMergeCells() as $cells) { - foreach (PHPExcel_Cell::extractAllCellReferencesInRange($cells) as $cellReference) { - $isMergeCell[$cellReference] = true; - } - } + // There is only something to do if there are some auto-size columns + if (!empty($autoSizes)) { - // loop through all cells in the worksheet - foreach ($this->getCellCollection(false) as $cellID) { - $cell = $this->getCell($cellID); - if (isset($autoSizes[$cell->getColumn()])) { - // Determine width if cell does not participate in a merge - if (!isset($isMergeCell[$cell->getCoordinate()])) { - // Calculated value - $cellValue = $cell->getCalculatedValue(); + // build list of cells references that participate in a merge + $isMergeCell = array(); + foreach ($this->getMergeCells() as $cells) { + foreach (PHPExcel_Cell::extractAllCellReferencesInRange($cells) as $cellReference) { + $isMergeCell[$cellReference] = true; + } + } - // To formatted string - $cellValue = PHPExcel_Style_NumberFormat::toFormattedString($cellValue, $this->getParent()->getCellXfByIndex($cell->getXfIndex())->getNumberFormat()->getFormatCode()); - - $autoSizes[$cell->getColumn()] = max( - (float)$autoSizes[$cell->getColumn()], - (float)PHPExcel_Shared_Font::calculateColumnWidth( - $this->getParent()->getCellXfByIndex($cell->getXfIndex())->getFont(), - $cellValue, - $this->getParent()->getCellXfByIndex($cell->getXfIndex())->getAlignment()->getTextRotation(), - $this->getDefaultStyle()->getFont() - ) + // loop through all cells in the worksheet + foreach ($this->getCellCollection(false) as $cellID) { + $cell = $this->getCell($cellID); + if (isset($autoSizes[$this->_cellCollection->getCurrentColumn()])) { + // Determine width if cell does not participate in a merge + if (!isset($isMergeCell[$this->_cellCollection->getCurrentAddress()])) { + // Calculated value + // To formatted string + $cellValue = PHPExcel_Style_NumberFormat::toFormattedString( + $cell->getCalculatedValue(), + $this->getParent()->getCellXfByIndex($cell->getXfIndex())->getNumberFormat()->getFormatCode() ); - } - } - } - // adjust column widths - foreach ($autoSizes as $columnIndex => $width) { - if ($width == -1) $width = $this->getDefaultColumnDimension()->getWidth(); - $this->getColumnDimension($columnIndex)->setWidth($width); - } - } + $autoSizes[$this->_cellCollection->getCurrentColumn()] = max( + (float) $autoSizes[$this->_cellCollection->getCurrentColumn()], + (float)PHPExcel_Shared_Font::calculateColumnWidth( + $this->getParent()->getCellXfByIndex($cell->getXfIndex())->getFont(), + $cellValue, + $this->getParent()->getCellXfByIndex($cell->getXfIndex())->getAlignment()->getTextRotation(), + $this->getDefaultStyle()->getFont() + ) + ); + } + } + } - return $this; - } + // adjust column widths + foreach ($autoSizes as $columnIndex => $width) { + if ($width == -1) $width = $this->getDefaultColumnDimension()->getWidth(); + $this->getColumnDimension($columnIndex)->setWidth($width); + } + } - /** - * Get parent - * - * @return PHPExcel - */ + return $this; + } + + /** + * Get parent + * + * @return PHPExcel + */ public function getParent() { - return $this->_parent; - } + return $this->_parent; + } - /** - * Re-bind parent - * - * @param PHPExcel $parent - * @return PHPExcel_Worksheet - */ + /** + * Re-bind parent + * + * @param PHPExcel $parent + * @return PHPExcel_Worksheet + */ public function rebindParent(PHPExcel $parent) { - $namedRanges = $this->_parent->getNamedRanges(); - foreach ($namedRanges as $namedRange) { - $parent->addNamedRange($namedRange); - } + if ($this->_parent !== null) { + $namedRanges = $this->_parent->getNamedRanges(); + foreach ($namedRanges as $namedRange) { + $parent->addNamedRange($namedRange); + } - $this->_parent->removeSheetByIndex( - $this->_parent->getIndex($this) + $this->_parent->removeSheetByIndex( + $this->_parent->getIndex($this) + ); + } + $this->_parent = $parent; + + return $this; + } + + /** + * Get title + * + * @return string + */ + public function getTitle() + { + return $this->_title; + } + + /** + * Set title + * + * @param string $pValue String containing the dimension of this worksheet + * @param string $updateFormulaCellReferences boolean Flag indicating whether cell references in formulae should + * be updated to reflect the new sheet name. + * This should be left as the default true, unless you are + * certain that no formula cells on any worksheet contain + * references to this worksheet + * @return PHPExcel_Worksheet + */ + public function setTitle($pValue = 'Worksheet', $updateFormulaCellReferences = true) + { + // Is this a 'rename' or not? + if ($this->getTitle() == $pValue) { + return $this; + } + + // Syntax check + self::_checkSheetTitle($pValue); + + // Old title + $oldTitle = $this->getTitle(); + + if ($this->_parent) { + // Is there already such sheet name? + if ($this->_parent->sheetNameExists($pValue)) { + // Use name, but append with lowest possible integer + + if (PHPExcel_Shared_String::CountCharacters($pValue) > 29) { + $pValue = PHPExcel_Shared_String::Substring($pValue,0,29); + } + $i = 1; + while ($this->_parent->sheetNameExists($pValue . ' ' . $i)) { + ++$i; + if ($i == 10) { + if (PHPExcel_Shared_String::CountCharacters($pValue) > 28) { + $pValue = PHPExcel_Shared_String::Substring($pValue,0,28); + } + } elseif ($i == 100) { + if (PHPExcel_Shared_String::CountCharacters($pValue) > 27) { + $pValue = PHPExcel_Shared_String::Substring($pValue,0,27); + } + } + } + + $altTitle = $pValue . ' ' . $i; + return $this->setTitle($altTitle,$updateFormulaCellReferences); + } + } + + // Set title + $this->_title = $pValue; + $this->_dirty = true; + + if ($this->_parent) { + // New title + $newTitle = $this->getTitle(); + PHPExcel_Calculation::getInstance($this->_parent) + ->renameCalculationCacheForWorksheet($oldTitle, $newTitle); + if ($updateFormulaCellReferences) + PHPExcel_ReferenceHelper::getInstance()->updateNamedFormulas($this->_parent, $oldTitle, $newTitle); + } + + return $this; + } + + /** + * Get sheet state + * + * @return string Sheet state (visible, hidden, veryHidden) + */ + public function getSheetState() { + return $this->_sheetState; + } + + /** + * Set sheet state + * + * @param string $value Sheet state (visible, hidden, veryHidden) + * @return PHPExcel_Worksheet + */ + public function setSheetState($value = PHPExcel_Worksheet::SHEETSTATE_VISIBLE) { + $this->_sheetState = $value; + return $this; + } + + /** + * Get page setup + * + * @return PHPExcel_Worksheet_PageSetup + */ + public function getPageSetup() + { + return $this->_pageSetup; + } + + /** + * Set page setup + * + * @param PHPExcel_Worksheet_PageSetup $pValue + * @return PHPExcel_Worksheet + */ + public function setPageSetup(PHPExcel_Worksheet_PageSetup $pValue) + { + $this->_pageSetup = $pValue; + return $this; + } + + /** + * Get page margins + * + * @return PHPExcel_Worksheet_PageMargins + */ + public function getPageMargins() + { + return $this->_pageMargins; + } + + /** + * Set page margins + * + * @param PHPExcel_Worksheet_PageMargins $pValue + * @return PHPExcel_Worksheet + */ + public function setPageMargins(PHPExcel_Worksheet_PageMargins $pValue) + { + $this->_pageMargins = $pValue; + return $this; + } + + /** + * Get page header/footer + * + * @return PHPExcel_Worksheet_HeaderFooter + */ + public function getHeaderFooter() + { + return $this->_headerFooter; + } + + /** + * Set page header/footer + * + * @param PHPExcel_Worksheet_HeaderFooter $pValue + * @return PHPExcel_Worksheet + */ + public function setHeaderFooter(PHPExcel_Worksheet_HeaderFooter $pValue) + { + $this->_headerFooter = $pValue; + return $this; + } + + /** + * Get sheet view + * + * @return PHPExcel_Worksheet_SheetView + */ + public function getSheetView() + { + return $this->_sheetView; + } + + /** + * Set sheet view + * + * @param PHPExcel_Worksheet_SheetView $pValue + * @return PHPExcel_Worksheet + */ + public function setSheetView(PHPExcel_Worksheet_SheetView $pValue) + { + $this->_sheetView = $pValue; + return $this; + } + + /** + * Get Protection + * + * @return PHPExcel_Worksheet_Protection + */ + public function getProtection() + { + return $this->_protection; + } + + /** + * Set Protection + * + * @param PHPExcel_Worksheet_Protection $pValue + * @return PHPExcel_Worksheet + */ + public function setProtection(PHPExcel_Worksheet_Protection $pValue) + { + $this->_protection = $pValue; + $this->_dirty = true; + + return $this; + } + + /** + * Get highest worksheet column + * + * @param string $row Return the data highest column for the specified row, + * or the highest column of any row if no row number is passed + * @return string Highest column name + */ + public function getHighestColumn($row = null) + { + if ($row == null) { + return $this->_cachedHighestColumn; + } + return $this->getHighestDataColumn($row); + } + + /** + * Get highest worksheet column that contains data + * + * @param string $row Return the highest data column for the specified row, + * or the highest data column of any row if no row number is passed + * @return string Highest column name that contains data + */ + public function getHighestDataColumn($row = null) + { + return $this->_cellCollection->getHighestColumn($row); + } + + /** + * Get highest worksheet row + * + * @param string $column Return the highest data row for the specified column, + * or the highest row of any column if no column letter is passed + * @return int Highest row number + */ + public function getHighestRow($column = null) + { + if ($column == null) { + return $this->_cachedHighestRow; + } + return $this->getHighestDataRow($column); + } + + /** + * Get highest worksheet row that contains data + * + * @param string $column Return the highest data row for the specified column, + * or the highest data row of any column if no column letter is passed + * @return string Highest row number that contains data + */ + public function getHighestDataRow($column = null) + { + return $this->_cellCollection->getHighestRow($column); + } + + /** + * Get highest worksheet column and highest row that have cell records + * + * @return array Highest column name and highest row number + */ + public function getHighestRowAndColumn() + { + return $this->_cellCollection->getHighestRowAndColumn(); + } + + /** + * Set a cell value + * + * @param string $pCoordinate Coordinate of the cell + * @param mixed $pValue Value of the cell + * @param bool $returnCell Return the worksheet (false, default) or the cell (true) + * @return PHPExcel_Worksheet|PHPExcel_Cell Depending on the last parameter being specified + */ + public function setCellValue($pCoordinate = 'A1', $pValue = null, $returnCell = false) + { + $cell = $this->getCell($pCoordinate)->setValue($pValue); + return ($returnCell) ? $cell : $this; + } + + /** + * Set a cell value by using numeric cell coordinates + * + * @param string $pColumn Numeric column coordinate of the cell (A = 0) + * @param string $pRow Numeric row coordinate of the cell + * @param mixed $pValue Value of the cell + * @param bool $returnCell Return the worksheet (false, default) or the cell (true) + * @return PHPExcel_Worksheet|PHPExcel_Cell Depending on the last parameter being specified + */ + public function setCellValueByColumnAndRow($pColumn = 0, $pRow = 1, $pValue = null, $returnCell = false) + { + $cell = $this->getCellByColumnAndRow($pColumn, $pRow)->setValue($pValue); + return ($returnCell) ? $cell : $this; + } + + /** + * Set a cell value + * + * @param string $pCoordinate Coordinate of the cell + * @param mixed $pValue Value of the cell + * @param string $pDataType Explicit data type + * @param bool $returnCell Return the worksheet (false, default) or the cell (true) + * @return PHPExcel_Worksheet|PHPExcel_Cell Depending on the last parameter being specified + */ + public function setCellValueExplicit($pCoordinate = 'A1', $pValue = null, $pDataType = PHPExcel_Cell_DataType::TYPE_STRING, $returnCell = false) + { + // Set value + $cell = $this->getCell($pCoordinate)->setValueExplicit($pValue, $pDataType); + return ($returnCell) ? $cell : $this; + } + + /** + * Set a cell value by using numeric cell coordinates + * + * @param string $pColumn Numeric column coordinate of the cell + * @param string $pRow Numeric row coordinate of the cell + * @param mixed $pValue Value of the cell + * @param string $pDataType Explicit data type + * @param bool $returnCell Return the worksheet (false, default) or the cell (true) + * @return PHPExcel_Worksheet|PHPExcel_Cell Depending on the last parameter being specified + */ + public function setCellValueExplicitByColumnAndRow($pColumn = 0, $pRow = 1, $pValue = null, $pDataType = PHPExcel_Cell_DataType::TYPE_STRING, $returnCell = false) + { + $cell = $this->getCellByColumnAndRow($pColumn, $pRow)->setValueExplicit($pValue, $pDataType); + return ($returnCell) ? $cell : $this; + } + + /** + * Get cell at a specific coordinate + * + * @param string $pCoordinate Coordinate of the cell + * @throws PHPExcel_Exception + * @return PHPExcel_Cell Cell that was found + */ + public function getCell($pCoordinate = 'A1') + { + // Check cell collection + if ($this->_cellCollection->isDataSet($pCoordinate)) { + return $this->_cellCollection->getCacheData($pCoordinate); + } + + // Worksheet reference? + if (strpos($pCoordinate, '!') !== false) { + $worksheetReference = PHPExcel_Worksheet::extractSheetTitle($pCoordinate, true); + return $this->_parent->getSheetByName($worksheetReference[0])->getCell($worksheetReference[1]); + } + + // Named range? + if ((!preg_match('/^'.PHPExcel_Calculation::CALCULATION_REGEXP_CELLREF.'$/i', $pCoordinate, $matches)) && + (preg_match('/^'.PHPExcel_Calculation::CALCULATION_REGEXP_NAMEDRANGE.'$/i', $pCoordinate, $matches))) { + $namedRange = PHPExcel_NamedRange::resolveRange($pCoordinate, $this); + if ($namedRange !== NULL) { + $pCoordinate = $namedRange->getRange(); + return $namedRange->getWorksheet()->getCell($pCoordinate); + } + } + + // Uppercase coordinate + $pCoordinate = strtoupper($pCoordinate); + + if (strpos($pCoordinate, ':') !== false || strpos($pCoordinate, ',') !== false) { + throw new PHPExcel_Exception('Cell coordinate can not be a range of cells.'); + } elseif (strpos($pCoordinate, '$') !== false) { + throw new PHPExcel_Exception('Cell coordinate must not be absolute.'); + } + + // Create new cell object + return $this->_createNewCell($pCoordinate); + } + + /** + * Get cell at a specific coordinate by using numeric cell coordinates + * + * @param string $pColumn Numeric column coordinate of the cell + * @param string $pRow Numeric row coordinate of the cell + * @return PHPExcel_Cell Cell that was found + */ + public function getCellByColumnAndRow($pColumn = 0, $pRow = 1) + { + $columnLetter = PHPExcel_Cell::stringFromColumnIndex($pColumn); + $coordinate = $columnLetter . $pRow; + + if ($this->_cellCollection->isDataSet($coordinate)) { + return $this->_cellCollection->getCacheData($coordinate); + } + + return $this->_createNewCell($coordinate); + } + + /** + * Create a new cell at the specified coordinate + * + * @param string $pCoordinate Coordinate of the cell + * @return PHPExcel_Cell Cell that was created + */ + private function _createNewCell($pCoordinate) + { + $cell = $this->_cellCollection->addCacheData( + $pCoordinate, + new PHPExcel_Cell( + NULL, + PHPExcel_Cell_DataType::TYPE_NULL, + $this + ) ); - $this->_parent = $parent; + $this->_cellCollectionIsSorted = false; - return $this; + // Coordinates + $aCoordinates = PHPExcel_Cell::coordinateFromString($pCoordinate); + if (PHPExcel_Cell::columnIndexFromString($this->_cachedHighestColumn) < PHPExcel_Cell::columnIndexFromString($aCoordinates[0])) + $this->_cachedHighestColumn = $aCoordinates[0]; + $this->_cachedHighestRow = max($this->_cachedHighestRow, $aCoordinates[1]); + + // Cell needs appropriate xfIndex from dimensions records + // but don't create dimension records if they don't already exist + $rowDimension = $this->getRowDimension($aCoordinates[1], FALSE); + $columnDimension = $this->getColumnDimension($aCoordinates[0], FALSE); + + if ($rowDimension !== NULL && $rowDimension->getXfIndex() > 0) { + // then there is a row dimension with explicit style, assign it to the cell + $cell->setXfIndex($rowDimension->getXfIndex()); + } elseif ($columnDimension !== NULL && $columnDimension->getXfIndex() > 0) { + // then there is a column dimension, assign it to the cell + $cell->setXfIndex($columnDimension->getXfIndex()); + } + + return $cell; } + + /** + * Does the cell at a specific coordinate exist? + * + * @param string $pCoordinate Coordinate of the cell + * @throws PHPExcel_Exception + * @return boolean + */ + public function cellExists($pCoordinate = 'A1') + { + // Worksheet reference? + if (strpos($pCoordinate, '!') !== false) { + $worksheetReference = PHPExcel_Worksheet::extractSheetTitle($pCoordinate, true); + return $this->_parent->getSheetByName($worksheetReference[0])->cellExists($worksheetReference[1]); + } - /** - * Get title - * - * @return string - */ - public function getTitle() - { - return $this->_title; - } + // Named range? + if ((!preg_match('/^'.PHPExcel_Calculation::CALCULATION_REGEXP_CELLREF.'$/i', $pCoordinate, $matches)) && + (preg_match('/^'.PHPExcel_Calculation::CALCULATION_REGEXP_NAMEDRANGE.'$/i', $pCoordinate, $matches))) { + $namedRange = PHPExcel_NamedRange::resolveRange($pCoordinate, $this); + if ($namedRange !== NULL) { + $pCoordinate = $namedRange->getRange(); + if ($this->getHashCode() != $namedRange->getWorksheet()->getHashCode()) { + if (!$namedRange->getLocalOnly()) { + return $namedRange->getWorksheet()->cellExists($pCoordinate); + } else { + throw new PHPExcel_Exception('Named range ' . $namedRange->getName() . ' is not accessible from within sheet ' . $this->getTitle()); + } + } + } + else { return false; } + } - /** - * Set title + // Uppercase coordinate + $pCoordinate = strtoupper($pCoordinate); + + if (strpos($pCoordinate,':') !== false || strpos($pCoordinate,',') !== false) { + throw new PHPExcel_Exception('Cell coordinate can not be a range of cells.'); + } elseif (strpos($pCoordinate,'$') !== false) { + throw new PHPExcel_Exception('Cell coordinate must not be absolute.'); + } else { + // Coordinates + $aCoordinates = PHPExcel_Cell::coordinateFromString($pCoordinate); + + // Cell exists? + return $this->_cellCollection->isDataSet($pCoordinate); + } + } + + /** + * Cell at a specific coordinate by using numeric cell coordinates exists? + * + * @param string $pColumn Numeric column coordinate of the cell + * @param string $pRow Numeric row coordinate of the cell + * @return boolean + */ + public function cellExistsByColumnAndRow($pColumn = 0, $pRow = 1) + { + return $this->cellExists(PHPExcel_Cell::stringFromColumnIndex($pColumn) . $pRow); + } + + /** + * Get row dimension at a specific row + * + * @param int $pRow Numeric index of the row + * @return PHPExcel_Worksheet_RowDimension + */ + public function getRowDimension($pRow = 1, $create = TRUE) + { + // Found + $found = null; + + // Get row dimension + if (!isset($this->_rowDimensions[$pRow])) { + if (!$create) + return NULL; + $this->_rowDimensions[$pRow] = new PHPExcel_Worksheet_RowDimension($pRow); + + $this->_cachedHighestRow = max($this->_cachedHighestRow,$pRow); + } + return $this->_rowDimensions[$pRow]; + } + + /** + * Get column dimension at a specific column + * + * @param string $pColumn String index of the column + * @return PHPExcel_Worksheet_ColumnDimension + */ + public function getColumnDimension($pColumn = 'A', $create = TRUE) + { + // Uppercase coordinate + $pColumn = strtoupper($pColumn); + + // Fetch dimensions + if (!isset($this->_columnDimensions[$pColumn])) { + if (!$create) + return NULL; + $this->_columnDimensions[$pColumn] = new PHPExcel_Worksheet_ColumnDimension($pColumn); + + if (PHPExcel_Cell::columnIndexFromString($this->_cachedHighestColumn) < PHPExcel_Cell::columnIndexFromString($pColumn)) + $this->_cachedHighestColumn = $pColumn; + } + return $this->_columnDimensions[$pColumn]; + } + + /** + * Get column dimension at a specific column by using numeric cell coordinates + * + * @param string $pColumn Numeric column coordinate of the cell + * @return PHPExcel_Worksheet_ColumnDimension + */ + public function getColumnDimensionByColumn($pColumn = 0) + { + return $this->getColumnDimension(PHPExcel_Cell::stringFromColumnIndex($pColumn)); + } + + /** + * Get styles + * + * @return PHPExcel_Style[] + */ + public function getStyles() + { + return $this->_styles; + } + + /** + * Get default style of workbook. + * + * @deprecated + * @return PHPExcel_Style + * @throws PHPExcel_Exception + */ + public function getDefaultStyle() + { + return $this->_parent->getDefaultStyle(); + } + + /** + * Set default style - should only be used by PHPExcel_IReader implementations! + * + * @deprecated + * @param PHPExcel_Style $pValue + * @throws PHPExcel_Exception + * @return PHPExcel_Worksheet + */ + public function setDefaultStyle(PHPExcel_Style $pValue) + { + $this->_parent->getDefaultStyle()->applyFromArray(array( + 'font' => array( + 'name' => $pValue->getFont()->getName(), + 'size' => $pValue->getFont()->getSize(), + ), + )); + return $this; + } + + /** + * Get style for cell + * + * @param string $pCellCoordinate Cell coordinate to get style for + * @return PHPExcel_Style + * @throws PHPExcel_Exception + */ + public function getStyle($pCellCoordinate = 'A1') + { + // set this sheet as active + $this->_parent->setActiveSheetIndex($this->_parent->getIndex($this)); + + // set cell coordinate as active + $this->setSelectedCells($pCellCoordinate); + + return $this->_parent->getCellXfSupervisor(); + } + + /** + * Get conditional styles for a cell + * + * @param string $pCoordinate + * @return PHPExcel_Style_Conditional[] + */ + public function getConditionalStyles($pCoordinate = 'A1') + { + if (!isset($this->_conditionalStylesCollection[$pCoordinate])) { + $this->_conditionalStylesCollection[$pCoordinate] = array(); + } + return $this->_conditionalStylesCollection[$pCoordinate]; + } + + /** + * Do conditional styles exist for this cell? + * + * @param string $pCoordinate + * @return boolean + */ + public function conditionalStylesExists($pCoordinate = 'A1') + { + if (isset($this->_conditionalStylesCollection[$pCoordinate])) { + return true; + } + return false; + } + + /** + * Removes conditional styles for a cell + * + * @param string $pCoordinate + * @return PHPExcel_Worksheet + */ + public function removeConditionalStyles($pCoordinate = 'A1') + { + unset($this->_conditionalStylesCollection[$pCoordinate]); + return $this; + } + + /** + * Get collection of conditional styles + * + * @return array + */ + public function getConditionalStylesCollection() + { + return $this->_conditionalStylesCollection; + } + + /** + * Set conditional styles + * + * @param $pCoordinate string E.g. 'A1' + * @param $pValue PHPExcel_Style_Conditional[] + * @return PHPExcel_Worksheet + */ + public function setConditionalStyles($pCoordinate = 'A1', $pValue) + { + $this->_conditionalStylesCollection[$pCoordinate] = $pValue; + return $this; + } + + /** + * Get style for cell by using numeric cell coordinates + * + * @param int $pColumn Numeric column coordinate of the cell + * @param int $pRow Numeric row coordinate of the cell + * @return PHPExcel_Style + */ + public function getStyleByColumnAndRow($pColumn = 0, $pRow = 1) + { + return $this->getStyle(PHPExcel_Cell::stringFromColumnIndex($pColumn) . $pRow); + } + + /** + * Set shared cell style to a range of cells + * + * Please note that this will overwrite existing cell styles for cells in range! + * + * @deprecated + * @param PHPExcel_Style $pSharedCellStyle Cell style to share + * @param string $pRange Range of cells (i.e. "A1:B10"), or just one cell (i.e. "A1") + * @throws PHPExcel_Exception + * @return PHPExcel_Worksheet + */ + public function setSharedStyle(PHPExcel_Style $pSharedCellStyle = null, $pRange = '') + { + $this->duplicateStyle($pSharedCellStyle, $pRange); + return $this; + } + + /** + * Duplicate cell style to a range of cells + * + * Please note that this will overwrite existing cell styles for cells in range! + * + * @param PHPExcel_Style $pCellStyle Cell style to duplicate + * @param string $pRange Range of cells (i.e. "A1:B10"), or just one cell (i.e. "A1") + * @throws PHPExcel_Exception + * @return PHPExcel_Worksheet + */ + public function duplicateStyle(PHPExcel_Style $pCellStyle = null, $pRange = '') + { + // make sure we have a real style and not supervisor + $style = $pCellStyle->getIsSupervisor() ? $pCellStyle->getSharedComponent() : $pCellStyle; + + // Add the style to the workbook if necessary + $workbook = $this->_parent; + if ($existingStyle = $this->_parent->getCellXfByHashCode($pCellStyle->getHashCode())) { + // there is already such cell Xf in our collection + $xfIndex = $existingStyle->getIndex(); + } else { + // we don't have such a cell Xf, need to add + $workbook->addCellXf($pCellStyle); + $xfIndex = $pCellStyle->getIndex(); + } + + // Calculate range outer borders + list($rangeStart, $rangeEnd) = PHPExcel_Cell::rangeBoundaries($pRange . ':' . $pRange); + + // Make sure we can loop upwards on rows and columns + if ($rangeStart[0] > $rangeEnd[0] && $rangeStart[1] > $rangeEnd[1]) { + $tmp = $rangeStart; + $rangeStart = $rangeEnd; + $rangeEnd = $tmp; + } + + // Loop through cells and apply styles + for ($col = $rangeStart[0]; $col <= $rangeEnd[0]; ++$col) { + for ($row = $rangeStart[1]; $row <= $rangeEnd[1]; ++$row) { + $this->getCell(PHPExcel_Cell::stringFromColumnIndex($col - 1) . $row)->setXfIndex($xfIndex); + } + } + + return $this; + } + + /** + * Duplicate conditional style to a range of cells + * + * Please note that this will overwrite existing cell styles for cells in range! + * + * @param array of PHPExcel_Style_Conditional $pCellStyle Cell style to duplicate + * @param string $pRange Range of cells (i.e. "A1:B10"), or just one cell (i.e. "A1") + * @throws PHPExcel_Exception + * @return PHPExcel_Worksheet + */ + public function duplicateConditionalStyle(array $pCellStyle = null, $pRange = '') + { + foreach($pCellStyle as $cellStyle) { + if (!($cellStyle instanceof PHPExcel_Style_Conditional)) { + throw new PHPExcel_Exception('Style is not a conditional style'); + } + } + + // Calculate range outer borders + list($rangeStart, $rangeEnd) = PHPExcel_Cell::rangeBoundaries($pRange . ':' . $pRange); + + // Make sure we can loop upwards on rows and columns + if ($rangeStart[0] > $rangeEnd[0] && $rangeStart[1] > $rangeEnd[1]) { + $tmp = $rangeStart; + $rangeStart = $rangeEnd; + $rangeEnd = $tmp; + } + + // Loop through cells and apply styles + for ($col = $rangeStart[0]; $col <= $rangeEnd[0]; ++$col) { + for ($row = $rangeStart[1]; $row <= $rangeEnd[1]; ++$row) { + $this->setConditionalStyles(PHPExcel_Cell::stringFromColumnIndex($col - 1) . $row, $pCellStyle); + } + } + + return $this; + } + + /** + * Duplicate cell style array to a range of cells + * + * Please note that this will overwrite existing cell styles for cells in range, + * if they are in the styles array. For example, if you decide to set a range of + * cells to font bold, only include font bold in the styles array. + * + * @deprecated + * @param array $pStyles Array containing style information + * @param string $pRange Range of cells (i.e. "A1:B10"), or just one cell (i.e. "A1") + * @param boolean $pAdvanced Advanced mode for setting borders. + * @throws PHPExcel_Exception + * @return PHPExcel_Worksheet + */ + public function duplicateStyleArray($pStyles = null, $pRange = '', $pAdvanced = true) + { + $this->getStyle($pRange)->applyFromArray($pStyles, $pAdvanced); + return $this; + } + + /** + * Set break on a cell + * + * @param string $pCell Cell coordinate (e.g. A1) + * @param int $pBreak Break type (type of PHPExcel_Worksheet::BREAK_*) + * @throws PHPExcel_Exception + * @return PHPExcel_Worksheet + */ + public function setBreak($pCell = 'A1', $pBreak = PHPExcel_Worksheet::BREAK_NONE) + { + // Uppercase coordinate + $pCell = strtoupper($pCell); + + if ($pCell != '') { + if ($pBreak == PHPExcel_Worksheet::BREAK_NONE) { + if (isset($this->_breaks[$pCell])) { + unset($this->_breaks[$pCell]); + } + } else { + $this->_breaks[$pCell] = $pBreak; + } + } else { + throw new PHPExcel_Exception('No cell coordinate specified.'); + } + + return $this; + } + + /** + * Set break on a cell by using numeric cell coordinates + * + * @param integer $pColumn Numeric column coordinate of the cell + * @param integer $pRow Numeric row coordinate of the cell + * @param integer $pBreak Break type (type of PHPExcel_Worksheet::BREAK_*) + * @return PHPExcel_Worksheet + */ + public function setBreakByColumnAndRow($pColumn = 0, $pRow = 1, $pBreak = PHPExcel_Worksheet::BREAK_NONE) + { + return $this->setBreak(PHPExcel_Cell::stringFromColumnIndex($pColumn) . $pRow, $pBreak); + } + + /** + * Get breaks + * + * @return array[] + */ + public function getBreaks() + { + return $this->_breaks; + } + + /** + * Set merge on a cell range + * + * @param string $pRange Cell range (e.g. A1:E1) + * @throws PHPExcel_Exception + * @return PHPExcel_Worksheet + */ + public function mergeCells($pRange = 'A1:A1') + { + // Uppercase coordinate + $pRange = strtoupper($pRange); + + if (strpos($pRange,':') !== false) { + $this->_mergeCells[$pRange] = $pRange; + + // make sure cells are created + + // get the cells in the range + $aReferences = PHPExcel_Cell::extractAllCellReferencesInRange($pRange); + + // create upper left cell if it does not already exist + $upperLeft = $aReferences[0]; + if (!$this->cellExists($upperLeft)) { + $this->getCell($upperLeft)->setValueExplicit(null, PHPExcel_Cell_DataType::TYPE_NULL); + } + + // create or blank out the rest of the cells in the range + $count = count($aReferences); + for ($i = 1; $i < $count; $i++) { + $this->getCell($aReferences[$i])->setValueExplicit(null, PHPExcel_Cell_DataType::TYPE_NULL); + } + + } else { + throw new PHPExcel_Exception('Merge must be set on a range of cells.'); + } + + return $this; + } + + /** + * Set merge on a cell range by using numeric cell coordinates + * + * @param int $pColumn1 Numeric column coordinate of the first cell + * @param int $pRow1 Numeric row coordinate of the first cell + * @param int $pColumn2 Numeric column coordinate of the last cell + * @param int $pRow2 Numeric row coordinate of the last cell + * @throws PHPExcel_Exception + * @return PHPExcel_Worksheet + */ + public function mergeCellsByColumnAndRow($pColumn1 = 0, $pRow1 = 1, $pColumn2 = 0, $pRow2 = 1) + { + $cellRange = PHPExcel_Cell::stringFromColumnIndex($pColumn1) . $pRow1 . ':' . PHPExcel_Cell::stringFromColumnIndex($pColumn2) . $pRow2; + return $this->mergeCells($cellRange); + } + + /** + * Remove merge on a cell range + * + * @param string $pRange Cell range (e.g. A1:E1) + * @throws PHPExcel_Exception + * @return PHPExcel_Worksheet + */ + public function unmergeCells($pRange = 'A1:A1') + { + // Uppercase coordinate + $pRange = strtoupper($pRange); + + if (strpos($pRange,':') !== false) { + if (isset($this->_mergeCells[$pRange])) { + unset($this->_mergeCells[$pRange]); + } else { + throw new PHPExcel_Exception('Cell range ' . $pRange . ' not known as merged.'); + } + } else { + throw new PHPExcel_Exception('Merge can only be removed from a range of cells.'); + } + + return $this; + } + + /** + * Remove merge on a cell range by using numeric cell coordinates + * + * @param int $pColumn1 Numeric column coordinate of the first cell + * @param int $pRow1 Numeric row coordinate of the first cell + * @param int $pColumn2 Numeric column coordinate of the last cell + * @param int $pRow2 Numeric row coordinate of the last cell + * @throws PHPExcel_Exception + * @return PHPExcel_Worksheet + */ + public function unmergeCellsByColumnAndRow($pColumn1 = 0, $pRow1 = 1, $pColumn2 = 0, $pRow2 = 1) + { + $cellRange = PHPExcel_Cell::stringFromColumnIndex($pColumn1) . $pRow1 . ':' . PHPExcel_Cell::stringFromColumnIndex($pColumn2) . $pRow2; + return $this->unmergeCells($cellRange); + } + + /** + * Get merge cells array. + * + * @return array[] + */ + public function getMergeCells() + { + return $this->_mergeCells; + } + + /** + * Set merge cells array for the entire sheet. Use instead mergeCells() to merge + * a single cell range. + * + * @param array + */ + public function setMergeCells($pValue = array()) + { + $this->_mergeCells = $pValue; + + return $this; + } + + /** + * Set protection on a cell range + * + * @param string $pRange Cell (e.g. A1) or cell range (e.g. A1:E1) + * @param string $pPassword Password to unlock the protection + * @param boolean $pAlreadyHashed If the password has already been hashed, set this to true + * @throws PHPExcel_Exception + * @return PHPExcel_Worksheet + */ + public function protectCells($pRange = 'A1', $pPassword = '', $pAlreadyHashed = false) + { + // Uppercase coordinate + $pRange = strtoupper($pRange); + + if (!$pAlreadyHashed) { + $pPassword = PHPExcel_Shared_PasswordHasher::hashPassword($pPassword); + } + $this->_protectedCells[$pRange] = $pPassword; + + return $this; + } + + /** + * Set protection on a cell range by using numeric cell coordinates + * + * @param int $pColumn1 Numeric column coordinate of the first cell + * @param int $pRow1 Numeric row coordinate of the first cell + * @param int $pColumn2 Numeric column coordinate of the last cell + * @param int $pRow2 Numeric row coordinate of the last cell + * @param string $pPassword Password to unlock the protection + * @param boolean $pAlreadyHashed If the password has already been hashed, set this to true + * @throws PHPExcel_Exception + * @return PHPExcel_Worksheet + */ + public function protectCellsByColumnAndRow($pColumn1 = 0, $pRow1 = 1, $pColumn2 = 0, $pRow2 = 1, $pPassword = '', $pAlreadyHashed = false) + { + $cellRange = PHPExcel_Cell::stringFromColumnIndex($pColumn1) . $pRow1 . ':' . PHPExcel_Cell::stringFromColumnIndex($pColumn2) . $pRow2; + return $this->protectCells($cellRange, $pPassword, $pAlreadyHashed); + } + + /** + * Remove protection on a cell range + * + * @param string $pRange Cell (e.g. A1) or cell range (e.g. A1:E1) + * @throws PHPExcel_Exception + * @return PHPExcel_Worksheet + */ + public function unprotectCells($pRange = 'A1') + { + // Uppercase coordinate + $pRange = strtoupper($pRange); + + if (isset($this->_protectedCells[$pRange])) { + unset($this->_protectedCells[$pRange]); + } else { + throw new PHPExcel_Exception('Cell range ' . $pRange . ' not known as protected.'); + } + return $this; + } + + /** + * Remove protection on a cell range by using numeric cell coordinates + * + * @param int $pColumn1 Numeric column coordinate of the first cell + * @param int $pRow1 Numeric row coordinate of the first cell + * @param int $pColumn2 Numeric column coordinate of the last cell + * @param int $pRow2 Numeric row coordinate of the last cell + * @param string $pPassword Password to unlock the protection + * @param boolean $pAlreadyHashed If the password has already been hashed, set this to true + * @throws PHPExcel_Exception + * @return PHPExcel_Worksheet + */ + public function unprotectCellsByColumnAndRow($pColumn1 = 0, $pRow1 = 1, $pColumn2 = 0, $pRow2 = 1, $pPassword = '', $pAlreadyHashed = false) + { + $cellRange = PHPExcel_Cell::stringFromColumnIndex($pColumn1) . $pRow1 . ':' . PHPExcel_Cell::stringFromColumnIndex($pColumn2) . $pRow2; + return $this->unprotectCells($cellRange, $pPassword, $pAlreadyHashed); + } + + /** + * Get protected cells + * + * @return array[] + */ + public function getProtectedCells() + { + return $this->_protectedCells; + } + + /** + * Get Autofilter + * + * @return PHPExcel_Worksheet_AutoFilter + */ + public function getAutoFilter() + { + return $this->_autoFilter; + } + + /** + * Set AutoFilter + * + * @param PHPExcel_Worksheet_AutoFilter|string $pValue + * A simple string containing a Cell range like 'A1:E10' is permitted for backward compatibility + * @throws PHPExcel_Exception + * @return PHPExcel_Worksheet + */ + public function setAutoFilter($pValue) + { + if (is_string($pValue)) { + $this->_autoFilter->setRange($pValue); + } elseif(is_object($pValue) && ($pValue instanceof PHPExcel_Worksheet_AutoFilter)) { + $this->_autoFilter = $pValue; + } + return $this; + } + + /** + * Set Autofilter Range by using numeric cell coordinates + * + * @param integer $pColumn1 Numeric column coordinate of the first cell + * @param integer $pRow1 Numeric row coordinate of the first cell + * @param integer $pColumn2 Numeric column coordinate of the second cell + * @param integer $pRow2 Numeric row coordinate of the second cell + * @throws PHPExcel_Exception + * @return PHPExcel_Worksheet + */ + public function setAutoFilterByColumnAndRow($pColumn1 = 0, $pRow1 = 1, $pColumn2 = 0, $pRow2 = 1) + { + return $this->setAutoFilter( + PHPExcel_Cell::stringFromColumnIndex($pColumn1) . $pRow1 + . ':' . + PHPExcel_Cell::stringFromColumnIndex($pColumn2) . $pRow2 + ); + } + + /** + * Remove autofilter + * + * @return PHPExcel_Worksheet + */ + public function removeAutoFilter() + { + $this->_autoFilter->setRange(NULL); + return $this; + } + + /** + * Get Freeze Pane + * + * @return string + */ + public function getFreezePane() + { + return $this->_freezePane; + } + + /** + * Freeze Pane + * + * @param string $pCell Cell (i.e. A2) + * Examples: + * A2 will freeze the rows above cell A2 (i.e row 1) + * B1 will freeze the columns to the left of cell B1 (i.e column A) + * B2 will freeze the rows above and to the left of cell A2 + * (i.e row 1 and column A) + * @throws PHPExcel_Exception + * @return PHPExcel_Worksheet + */ + public function freezePane($pCell = '') + { + // Uppercase coordinate + $pCell = strtoupper($pCell); + + if (strpos($pCell,':') === false && strpos($pCell,',') === false) { + $this->_freezePane = $pCell; + } else { + throw new PHPExcel_Exception('Freeze pane can not be set on a range of cells.'); + } + return $this; + } + + /** + * Freeze Pane by using numeric cell coordinates + * + * @param int $pColumn Numeric column coordinate of the cell + * @param int $pRow Numeric row coordinate of the cell + * @throws PHPExcel_Exception + * @return PHPExcel_Worksheet + */ + public function freezePaneByColumnAndRow($pColumn = 0, $pRow = 1) + { + return $this->freezePane(PHPExcel_Cell::stringFromColumnIndex($pColumn) . $pRow); + } + + /** + * Unfreeze Pane + * + * @return PHPExcel_Worksheet + */ + public function unfreezePane() + { + return $this->freezePane(''); + } + + /** + * Insert a new row, updating all possible related data + * + * @param int $pBefore Insert before this one + * @param int $pNumRows Number of rows to insert + * @throws PHPExcel_Exception + * @return PHPExcel_Worksheet + */ + public function insertNewRowBefore($pBefore = 1, $pNumRows = 1) { + if ($pBefore >= 1) { + $objReferenceHelper = PHPExcel_ReferenceHelper::getInstance(); + $objReferenceHelper->insertNewBefore('A' . $pBefore, 0, $pNumRows, $this); + } else { + throw new PHPExcel_Exception("Rows can only be inserted before at least row 1."); + } + return $this; + } + + /** + * Insert a new column, updating all possible related data + * + * @param int $pBefore Insert before this one + * @param int $pNumCols Number of columns to insert + * @throws PHPExcel_Exception + * @return PHPExcel_Worksheet + */ + public function insertNewColumnBefore($pBefore = 'A', $pNumCols = 1) { + if (!is_numeric($pBefore)) { + $objReferenceHelper = PHPExcel_ReferenceHelper::getInstance(); + $objReferenceHelper->insertNewBefore($pBefore . '1', $pNumCols, 0, $this); + } else { + throw new PHPExcel_Exception("Column references should not be numeric."); + } + return $this; + } + + /** + * Insert a new column, updating all possible related data + * + * @param int $pBefore Insert before this one (numeric column coordinate of the cell) + * @param int $pNumCols Number of columns to insert + * @throws PHPExcel_Exception + * @return PHPExcel_Worksheet + */ + public function insertNewColumnBeforeByIndex($pBefore = 0, $pNumCols = 1) { + if ($pBefore >= 0) { + return $this->insertNewColumnBefore(PHPExcel_Cell::stringFromColumnIndex($pBefore), $pNumCols); + } else { + throw new PHPExcel_Exception("Columns can only be inserted before at least column A (0)."); + } + } + + /** + * Delete a row, updating all possible related data + * + * @param int $pRow Remove starting with this one + * @param int $pNumRows Number of rows to remove + * @throws PHPExcel_Exception + * @return PHPExcel_Worksheet + */ + public function removeRow($pRow = 1, $pNumRows = 1) { + if ($pRow >= 1) { + $objReferenceHelper = PHPExcel_ReferenceHelper::getInstance(); + $objReferenceHelper->insertNewBefore('A' . ($pRow + $pNumRows), 0, -$pNumRows, $this); + } else { + throw new PHPExcel_Exception("Rows to be deleted should at least start from row 1."); + } + return $this; + } + + /** + * Remove a column, updating all possible related data + * + * @param int $pColumn Remove starting with this one + * @param int $pNumCols Number of columns to remove + * @throws PHPExcel_Exception + * @return PHPExcel_Worksheet + */ + public function removeColumn($pColumn = 'A', $pNumCols = 1) { + if (!is_numeric($pColumn)) { + $pColumn = PHPExcel_Cell::stringFromColumnIndex(PHPExcel_Cell::columnIndexFromString($pColumn) - 1 + $pNumCols); + $objReferenceHelper = PHPExcel_ReferenceHelper::getInstance(); + $objReferenceHelper->insertNewBefore($pColumn . '1', -$pNumCols, 0, $this); + } else { + throw new PHPExcel_Exception("Column references should not be numeric."); + } + return $this; + } + + /** + * Remove a column, updating all possible related data + * + * @param int $pColumn Remove starting with this one (numeric column coordinate of the cell) + * @param int $pNumCols Number of columns to remove + * @throws PHPExcel_Exception + * @return PHPExcel_Worksheet + */ + public function removeColumnByIndex($pColumn = 0, $pNumCols = 1) { + if ($pColumn >= 0) { + return $this->removeColumn(PHPExcel_Cell::stringFromColumnIndex($pColumn), $pNumCols); + } else { + throw new PHPExcel_Exception("Columns to be deleted should at least start from column 0"); + } + } + + /** + * Show gridlines? + * + * @return boolean + */ + public function getShowGridlines() { + return $this->_showGridlines; + } + + /** + * Set show gridlines + * + * @param boolean $pValue Show gridlines (true/false) + * @return PHPExcel_Worksheet + */ + public function setShowGridlines($pValue = false) { + $this->_showGridlines = $pValue; + return $this; + } + + /** + * Print gridlines? + * + * @return boolean + */ + public function getPrintGridlines() { + return $this->_printGridlines; + } + + /** + * Set print gridlines + * + * @param boolean $pValue Print gridlines (true/false) + * @return PHPExcel_Worksheet + */ + public function setPrintGridlines($pValue = false) { + $this->_printGridlines = $pValue; + return $this; + } + + /** + * Show row and column headers? + * + * @return boolean + */ + public function getShowRowColHeaders() { + return $this->_showRowColHeaders; + } + + /** + * Set show row and column headers + * + * @param boolean $pValue Show row and column headers (true/false) + * @return PHPExcel_Worksheet + */ + public function setShowRowColHeaders($pValue = false) { + $this->_showRowColHeaders = $pValue; + return $this; + } + + /** + * Show summary below? (Row/Column outlining) + * + * @return boolean + */ + public function getShowSummaryBelow() { + return $this->_showSummaryBelow; + } + + /** + * Set show summary below + * + * @param boolean $pValue Show summary below (true/false) + * @return PHPExcel_Worksheet + */ + public function setShowSummaryBelow($pValue = true) { + $this->_showSummaryBelow = $pValue; + return $this; + } + + /** + * Show summary right? (Row/Column outlining) + * + * @return boolean + */ + public function getShowSummaryRight() { + return $this->_showSummaryRight; + } + + /** + * Set show summary right + * + * @param boolean $pValue Show summary right (true/false) + * @return PHPExcel_Worksheet + */ + public function setShowSummaryRight($pValue = true) { + $this->_showSummaryRight = $pValue; + return $this; + } + + /** + * Get comments + * + * @return PHPExcel_Comment[] + */ + public function getComments() + { + return $this->_comments; + } + + /** + * Set comments array for the entire sheet. + * + * @param array of PHPExcel_Comment + * @return PHPExcel_Worksheet + */ + public function setComments($pValue = array()) + { + $this->_comments = $pValue; + + return $this; + } + + /** + * Get comment for cell + * + * @param string $pCellCoordinate Cell coordinate to get comment for + * @return PHPExcel_Comment + * @throws PHPExcel_Exception + */ + public function getComment($pCellCoordinate = 'A1') + { + // Uppercase coordinate + $pCellCoordinate = strtoupper($pCellCoordinate); + + if (strpos($pCellCoordinate,':') !== false || strpos($pCellCoordinate,',') !== false) { + throw new PHPExcel_Exception('Cell coordinate string can not be a range of cells.'); + } else if (strpos($pCellCoordinate,'$') !== false) { + throw new PHPExcel_Exception('Cell coordinate string must not be absolute.'); + } else if ($pCellCoordinate == '') { + throw new PHPExcel_Exception('Cell coordinate can not be zero-length string.'); + } else { + // Check if we already have a comment for this cell. + // If not, create a new comment. + if (isset($this->_comments[$pCellCoordinate])) { + return $this->_comments[$pCellCoordinate]; + } else { + $newComment = new PHPExcel_Comment(); + $this->_comments[$pCellCoordinate] = $newComment; + return $newComment; + } + } + } + + /** + * Get comment for cell by using numeric cell coordinates + * + * @param int $pColumn Numeric column coordinate of the cell + * @param int $pRow Numeric row coordinate of the cell + * @return PHPExcel_Comment + */ + public function getCommentByColumnAndRow($pColumn = 0, $pRow = 1) + { + return $this->getComment(PHPExcel_Cell::stringFromColumnIndex($pColumn) . $pRow); + } + + /** + * Get selected cell + * + * @deprecated + * @return string + */ + public function getSelectedCell() + { + return $this->getSelectedCells(); + } + + /** + * Get active cell + * + * @return string Example: 'A1' + */ + public function getActiveCell() + { + return $this->_activeCell; + } + + /** + * Get selected cells + * + * @return string + */ + public function getSelectedCells() + { + return $this->_selectedCells; + } + + /** + * Selected cell + * + * @param string $pCoordinate Cell (i.e. A1) + * @return PHPExcel_Worksheet + */ + public function setSelectedCell($pCoordinate = 'A1') + { + return $this->setSelectedCells($pCoordinate); + } + + /** + * Select a range of cells. + * + * @param string $pCoordinate Cell range, examples: 'A1', 'B2:G5', 'A:C', '3:6' + * @throws PHPExcel_Exception + * @return PHPExcel_Worksheet + */ + public function setSelectedCells($pCoordinate = 'A1') + { + // Uppercase coordinate + $pCoordinate = strtoupper($pCoordinate); + + // Convert 'A' to 'A:A' + $pCoordinate = preg_replace('/^([A-Z]+)$/', '${1}:${1}', $pCoordinate); + + // Convert '1' to '1:1' + $pCoordinate = preg_replace('/^([0-9]+)$/', '${1}:${1}', $pCoordinate); + + // Convert 'A:C' to 'A1:C1048576' + $pCoordinate = preg_replace('/^([A-Z]+):([A-Z]+)$/', '${1}1:${2}1048576', $pCoordinate); + + // Convert '1:3' to 'A1:XFD3' + $pCoordinate = preg_replace('/^([0-9]+):([0-9]+)$/', 'A${1}:XFD${2}', $pCoordinate); + + if (strpos($pCoordinate,':') !== false || strpos($pCoordinate,',') !== false) { + list($first, ) = PHPExcel_Cell::splitRange($pCoordinate); + $this->_activeCell = $first[0]; + } else { + $this->_activeCell = $pCoordinate; + } + $this->_selectedCells = $pCoordinate; + return $this; + } + + /** + * Selected cell by using numeric cell coordinates + * + * @param int $pColumn Numeric column coordinate of the cell + * @param int $pRow Numeric row coordinate of the cell + * @throws PHPExcel_Exception + * @return PHPExcel_Worksheet + */ + public function setSelectedCellByColumnAndRow($pColumn = 0, $pRow = 1) + { + return $this->setSelectedCells(PHPExcel_Cell::stringFromColumnIndex($pColumn) . $pRow); + } + + /** + * Get right-to-left + * + * @return boolean + */ + public function getRightToLeft() { + return $this->_rightToLeft; + } + + /** + * Set right-to-left + * + * @param boolean $value Right-to-left true/false + * @return PHPExcel_Worksheet + */ + public function setRightToLeft($value = false) { + $this->_rightToLeft = $value; + return $this; + } + + /** + * Fill worksheet from values in array + * + * @param array $source Source array + * @param mixed $nullValue Value in source array that stands for blank cell + * @param string $startCell Insert array starting from this cell address as the top left coordinate + * @param boolean $strictNullComparison Apply strict comparison when testing for null values in the array + * @throws PHPExcel_Exception + * @return PHPExcel_Worksheet + */ + public function fromArray($source = null, $nullValue = null, $startCell = 'A1', $strictNullComparison = false) { + if (is_array($source)) { + // Convert a 1-D array to 2-D (for ease of looping) + if (!is_array(end($source))) { + $source = array($source); + } + + // start coordinate + list ($startColumn, $startRow) = PHPExcel_Cell::coordinateFromString($startCell); + + // Loop through $source + foreach ($source as $rowData) { + $currentColumn = $startColumn; + foreach($rowData as $cellValue) { + if ($strictNullComparison) { + if ($cellValue !== $nullValue) { + // Set cell value + $this->getCell($currentColumn . $startRow)->setValue($cellValue); + } + } else { + if ($cellValue != $nullValue) { + // Set cell value + $this->getCell($currentColumn . $startRow)->setValue($cellValue); + } + } + ++$currentColumn; + } + ++$startRow; + } + } else { + throw new PHPExcel_Exception("Parameter \$source should be an array."); + } + return $this; + } + + /** + * Create array from a range of cells + * + * @param string $pRange Range of cells (i.e. "A1:B10"), or just one cell (i.e. "A1") + * @param mixed $nullValue Value returned in the array entry if a cell doesn't exist + * @param boolean $calculateFormulas Should formulas be calculated? + * @param boolean $formatData Should formatting be applied to cell values? + * @param boolean $returnCellRef False - Return a simple array of rows and columns indexed by number counting from zero + * True - Return rows and columns indexed by their actual row and column IDs + * @return array + */ + public function rangeToArray($pRange = 'A1', $nullValue = null, $calculateFormulas = true, $formatData = true, $returnCellRef = false) { + // Returnvalue + $returnValue = array(); + // Identify the range that we need to extract from the worksheet + list($rangeStart, $rangeEnd) = PHPExcel_Cell::rangeBoundaries($pRange); + $minCol = PHPExcel_Cell::stringFromColumnIndex($rangeStart[0] -1); + $minRow = $rangeStart[1]; + $maxCol = PHPExcel_Cell::stringFromColumnIndex($rangeEnd[0] -1); + $maxRow = $rangeEnd[1]; + + $maxCol++; + // Loop through rows + $r = -1; + for ($row = $minRow; $row <= $maxRow; ++$row) { + $rRef = ($returnCellRef) ? $row : ++$r; + $c = -1; + // Loop through columns in the current row + for ($col = $minCol; $col != $maxCol; ++$col) { + $cRef = ($returnCellRef) ? $col : ++$c; + // Using getCell() will create a new cell if it doesn't already exist. We don't want that to happen + // so we test and retrieve directly against _cellCollection + if ($this->_cellCollection->isDataSet($col.$row)) { + // Cell exists + $cell = $this->_cellCollection->getCacheData($col.$row); + if ($cell->getValue() !== null) { + if ($cell->getValue() instanceof PHPExcel_RichText) { + $returnValue[$rRef][$cRef] = $cell->getValue()->getPlainText(); + } else { + if ($calculateFormulas) { + $returnValue[$rRef][$cRef] = $cell->getCalculatedValue(); + } else { + $returnValue[$rRef][$cRef] = $cell->getValue(); + } + } + + if ($formatData) { + $style = $this->_parent->getCellXfByIndex($cell->getXfIndex()); + $returnValue[$rRef][$cRef] = PHPExcel_Style_NumberFormat::toFormattedString( + $returnValue[$rRef][$cRef], + ($style && $style->getNumberFormat()) ? + $style->getNumberFormat()->getFormatCode() : + PHPExcel_Style_NumberFormat::FORMAT_GENERAL + ); + } + } else { + // Cell holds a NULL + $returnValue[$rRef][$cRef] = $nullValue; + } + } else { + // Cell doesn't exist + $returnValue[$rRef][$cRef] = $nullValue; + } + } + } + + // Return + return $returnValue; + } + + + /** + * Create array from a range of cells + * + * @param string $pNamedRange Name of the Named Range + * @param mixed $nullValue Value returned in the array entry if a cell doesn't exist + * @param boolean $calculateFormulas Should formulas be calculated? + * @param boolean $formatData Should formatting be applied to cell values? + * @param boolean $returnCellRef False - Return a simple array of rows and columns indexed by number counting from zero + * True - Return rows and columns indexed by their actual row and column IDs + * @return array + * @throws PHPExcel_Exception + */ + public function namedRangeToArray($pNamedRange = '', $nullValue = null, $calculateFormulas = true, $formatData = true, $returnCellRef = false) { + $namedRange = PHPExcel_NamedRange::resolveRange($pNamedRange, $this); + if ($namedRange !== NULL) { + $pWorkSheet = $namedRange->getWorksheet(); + $pCellRange = $namedRange->getRange(); + + return $pWorkSheet->rangeToArray( $pCellRange, + $nullValue, $calculateFormulas, $formatData, $returnCellRef); + } + + throw new PHPExcel_Exception('Named Range '.$pNamedRange.' does not exist.'); + } + + + /** + * Create array from worksheet + * + * @param mixed $nullValue Value returned in the array entry if a cell doesn't exist + * @param boolean $calculateFormulas Should formulas be calculated? + * @param boolean $formatData Should formatting be applied to cell values? + * @param boolean $returnCellRef False - Return a simple array of rows and columns indexed by number counting from zero + * True - Return rows and columns indexed by their actual row and column IDs + * @return array + */ + public function toArray($nullValue = null, $calculateFormulas = true, $formatData = true, $returnCellRef = false) { + // Garbage collect... + $this->garbageCollect(); + + // Identify the range that we need to extract from the worksheet + $maxCol = $this->getHighestColumn(); + $maxRow = $this->getHighestRow(); + // Return + return $this->rangeToArray( 'A1:'.$maxCol.$maxRow, + $nullValue, $calculateFormulas, $formatData, $returnCellRef); + } + + /** + * Get row iterator + * + * @param integer $startRow The row number at which to start iterating + * @return PHPExcel_Worksheet_RowIterator + */ + public function getRowIterator($startRow = 1) { + return new PHPExcel_Worksheet_RowIterator($this,$startRow); + } + + /** + * Run PHPExcel garabage collector. + * + * @return PHPExcel_Worksheet + */ + public function garbageCollect() { + // Flush cache + $this->_cellCollection->getCacheData('A1'); + // Build a reference table from images +// $imageCoordinates = array(); +// $iterator = $this->getDrawingCollection()->getIterator(); +// while ($iterator->valid()) { +// $imageCoordinates[$iterator->current()->getCoordinates()] = true; +// +// $iterator->next(); +// } +// + // Lookup highest column and highest row if cells are cleaned + $colRow = $this->_cellCollection->getHighestRowAndColumn(); + $highestRow = $colRow['row']; + $highestColumn = PHPExcel_Cell::columnIndexFromString($colRow['column']); + + // Loop through column dimensions + foreach ($this->_columnDimensions as $dimension) { + $highestColumn = max($highestColumn,PHPExcel_Cell::columnIndexFromString($dimension->getColumnIndex())); + } + + // Loop through row dimensions + foreach ($this->_rowDimensions as $dimension) { + $highestRow = max($highestRow,$dimension->getRowIndex()); + } + + // Cache values + if ($highestColumn < 0) { + $this->_cachedHighestColumn = 'A'; + } else { + $this->_cachedHighestColumn = PHPExcel_Cell::stringFromColumnIndex(--$highestColumn); + } + $this->_cachedHighestRow = $highestRow; + + // Return + return $this; + } + + /** + * Get hash code + * + * @return string Hash code + */ + public function getHashCode() { + if ($this->_dirty) { + $this->_hash = md5( $this->_title . + $this->_autoFilter . + ($this->_protection->isProtectionEnabled() ? 't' : 'f') . + __CLASS__ + ); + $this->_dirty = false; + } + return $this->_hash; + } + + /** + * Extract worksheet title from range. + * + * Example: extractSheetTitle("testSheet!A1") ==> 'A1' + * Example: extractSheetTitle("'testSheet 1'!A1", true) ==> array('testSheet 1', 'A1'); + * + * @param string $pRange Range to extract title from + * @param bool $returnRange Return range? (see example) + * @return mixed + */ + public static function extractSheetTitle($pRange, $returnRange = false) { + // Sheet title included? + if (($sep = strpos($pRange, '!')) === false) { + return ''; + } + + if ($returnRange) { + return array( trim(substr($pRange, 0, $sep),"'"), + substr($pRange, $sep + 1) + ); + } + + return substr($pRange, $sep + 1); + } + + /** + * Get hyperlink + * + * @param string $pCellCoordinate Cell coordinate to get hyperlink for + */ + public function getHyperlink($pCellCoordinate = 'A1') + { + // return hyperlink if we already have one + if (isset($this->_hyperlinkCollection[$pCellCoordinate])) { + return $this->_hyperlinkCollection[$pCellCoordinate]; + } + + // else create hyperlink + $this->_hyperlinkCollection[$pCellCoordinate] = new PHPExcel_Cell_Hyperlink(); + return $this->_hyperlinkCollection[$pCellCoordinate]; + } + + /** + * Set hyperlnk + * + * @param string $pCellCoordinate Cell coordinate to insert hyperlink + * @param PHPExcel_Cell_Hyperlink $pHyperlink + * @return PHPExcel_Worksheet + */ + public function setHyperlink($pCellCoordinate = 'A1', PHPExcel_Cell_Hyperlink $pHyperlink = null) + { + if ($pHyperlink === null) { + unset($this->_hyperlinkCollection[$pCellCoordinate]); + } else { + $this->_hyperlinkCollection[$pCellCoordinate] = $pHyperlink; + } + return $this; + } + + /** + * Hyperlink at a specific coordinate exists? + * + * @param string $pCoordinate + * @return boolean + */ + public function hyperlinkExists($pCoordinate = 'A1') + { + return isset($this->_hyperlinkCollection[$pCoordinate]); + } + + /** + * Get collection of hyperlinks + * + * @return PHPExcel_Cell_Hyperlink[] + */ + public function getHyperlinkCollection() + { + return $this->_hyperlinkCollection; + } + + /** + * Get data validation + * + * @param string $pCellCoordinate Cell coordinate to get data validation for + */ + public function getDataValidation($pCellCoordinate = 'A1') + { + // return data validation if we already have one + if (isset($this->_dataValidationCollection[$pCellCoordinate])) { + return $this->_dataValidationCollection[$pCellCoordinate]; + } + + // else create data validation + $this->_dataValidationCollection[$pCellCoordinate] = new PHPExcel_Cell_DataValidation(); + return $this->_dataValidationCollection[$pCellCoordinate]; + } + + /** + * Set data validation + * + * @param string $pCellCoordinate Cell coordinate to insert data validation + * @param PHPExcel_Cell_DataValidation $pDataValidation + * @return PHPExcel_Worksheet + */ + public function setDataValidation($pCellCoordinate = 'A1', PHPExcel_Cell_DataValidation $pDataValidation = null) + { + if ($pDataValidation === null) { + unset($this->_dataValidationCollection[$pCellCoordinate]); + } else { + $this->_dataValidationCollection[$pCellCoordinate] = $pDataValidation; + } + return $this; + } + + /** + * Data validation at a specific coordinate exists? + * + * @param string $pCoordinate + * @return boolean + */ + public function dataValidationExists($pCoordinate = 'A1') + { + return isset($this->_dataValidationCollection[$pCoordinate]); + } + + /** + * Get collection of data validations + * + * @return PHPExcel_Cell_DataValidation[] + */ + public function getDataValidationCollection() + { + return $this->_dataValidationCollection; + } + + /** + * Accepts a range, returning it as a range that falls within the current highest row and column of the worksheet + * + * @param string $range + * @return string Adjusted range value + */ + public function shrinkRangeToFit($range) { + $maxCol = $this->getHighestColumn(); + $maxRow = $this->getHighestRow(); + $maxCol = PHPExcel_Cell::columnIndexFromString($maxCol); + + $rangeBlocks = explode(' ',$range); + foreach ($rangeBlocks as &$rangeSet) { + $rangeBoundaries = PHPExcel_Cell::getRangeBoundaries($rangeSet); + + if (PHPExcel_Cell::columnIndexFromString($rangeBoundaries[0][0]) > $maxCol) { $rangeBoundaries[0][0] = PHPExcel_Cell::stringFromColumnIndex($maxCol); } + if ($rangeBoundaries[0][1] > $maxRow) { $rangeBoundaries[0][1] = $maxRow; } + if (PHPExcel_Cell::columnIndexFromString($rangeBoundaries[1][0]) > $maxCol) { $rangeBoundaries[1][0] = PHPExcel_Cell::stringFromColumnIndex($maxCol); } + if ($rangeBoundaries[1][1] > $maxRow) { $rangeBoundaries[1][1] = $maxRow; } + $rangeSet = $rangeBoundaries[0][0].$rangeBoundaries[0][1].':'.$rangeBoundaries[1][0].$rangeBoundaries[1][1]; + } + unset($rangeSet); + $stRange = implode(' ',$rangeBlocks); + + return $stRange; + } + + /** + * Get tab color + * + * @return PHPExcel_Style_Color + */ + public function getTabColor() + { + if ($this->_tabColor === NULL) + $this->_tabColor = new PHPExcel_Style_Color(); + + return $this->_tabColor; + } + + /** + * Reset tab color + * + * @return PHPExcel_Worksheet + */ + public function resetTabColor() + { + $this->_tabColor = null; + unset($this->_tabColor); + + return $this; + } + + /** + * Tab color set? + * + * @return boolean + */ + public function isTabColorSet() + { + return ($this->_tabColor !== NULL); + } + + /** + * Copy worksheet (!= clone!) + * + * @return PHPExcel_Worksheet + */ + public function copy() { + $copied = clone $this; + + return $copied; + } + + /** + * Implement PHP __clone to create a deep clone, not just a shallow copy. + */ + public function __clone() { + foreach ($this as $key => $val) { + if ($key == '_parent') { + continue; + } + + if (is_object($val) || (is_array($val))) { + if ($key == '_cellCollection') { + $newCollection = clone $this->_cellCollection; + $newCollection->copyCellCollection($this); + $this->_cellCollection = $newCollection; + } elseif ($key == '_drawingCollection') { + $newCollection = clone $this->_drawingCollection; + $this->_drawingCollection = $newCollection; + } elseif (($key == '_autoFilter') && ($this->_autoFilter instanceof PHPExcel_Worksheet_AutoFilter)) { + $newAutoFilter = clone $this->_autoFilter; + $this->_autoFilter = $newAutoFilter; + $this->_autoFilter->setParent($this); + } else { + $this->{$key} = unserialize(serialize($val)); + } + } + } + } +/** + * Define the code name of the sheet * - * @param string $pValue String containing the dimension of this worksheet - * @param string $updateFormulaCellReferences boolean Flag indicating whether cell references in formulae should - * be updated to reflect the new sheet name. - * This should be left as the default true, unless you are - * certain that no formula cells on any worksheet contain - * references to this worksheet - * @return PHPExcel_Worksheet - */ - public function setTitle($pValue = 'Worksheet', $updateFormulaCellReferences = true) - { + * @param null|string Same rule as Title minus space not allowed (but, like Excel, change silently space to underscore) + * @return objWorksheet + * @throws PHPExcel_Exception + */ + public function setCodeName($pValue=null){ // Is this a 'rename' or not? - if ($this->getTitle() == $pValue) { + if ($this->getCodeName() == $pValue) { return $this; } - + $pValue = str_replace(' ', '_', $pValue);//Excel does this automatically without flinching, we are doing the same // Syntax check - self::_checkSheetTitle($pValue); - - // Old title - $oldTitle = $this->getTitle(); + // throw an exception if not valid + self::_checkSheetCodeName($pValue); + // We use the same code that setTitle to find a valid codeName else not using a space (Excel don't like) but a '_' + if ($this->getParent()) { // Is there already such sheet name? - if ($this->getParent()->sheetNameExists($pValue)) { + if ($this->getParent()->sheetCodeNameExists($pValue)) { // Use name, but append with lowest possible integer if (PHPExcel_Shared_String::CountCharacters($pValue) > 29) { $pValue = PHPExcel_Shared_String::Substring($pValue,0,29); } $i = 1; - while ($this->getParent()->sheetNameExists($pValue . ' ' . $i)) { + while ($this->getParent()->sheetCodeNameExists($pValue . '_' . $i)) { ++$i; if ($i == 10) { if (PHPExcel_Shared_String::CountCharacters($pValue) > 28) { @@ -815,1981 +2882,28 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable } } - $altTitle = $pValue . ' ' . $i; - return $this->setTitle($altTitle,$updateFormulaCellReferences); + $pValue = $pValue . '_' . $i;// ok, we have a valid name + //codeName is'nt used in formula : no need to call for an update + //return $this->setTitle($altTitle,$updateFormulaCellReferences); } } - // Set title - $this->_title = $pValue; - $this->_dirty = true; - - if ($this->getParent()) { - // New title - $newTitle = $this->getTitle(); - if ($updateFormulaCellReferences) - PHPExcel_ReferenceHelper::getInstance()->updateNamedFormulas($this->getParent(), $oldTitle, $newTitle); - } - + $this->_codeName=$pValue; return $this; } - /** - * Get sheet state + * Return the code name of the sheet * - * @return string Sheet state (visible, hidden, veryHidden) - */ - public function getSheetState() { - return $this->_sheetState; - } - - /** - * Set sheet state - * - * @param string $value Sheet state (visible, hidden, veryHidden) - * @return PHPExcel_Worksheet - */ - public function setSheetState($value = PHPExcel_Worksheet::SHEETSTATE_VISIBLE) { - $this->_sheetState = $value; - return $this; - } - - /** - * Get page setup - * - * @return PHPExcel_Worksheet_PageSetup - */ - public function getPageSetup() - { - return $this->_pageSetup; - } - - /** - * Set page setup - * - * @param PHPExcel_Worksheet_PageSetup $pValue - * @return PHPExcel_Worksheet - */ - public function setPageSetup(PHPExcel_Worksheet_PageSetup $pValue) - { - $this->_pageSetup = $pValue; - return $this; - } - - /** - * Get page margins - * - * @return PHPExcel_Worksheet_PageMargins - */ - public function getPageMargins() - { - return $this->_pageMargins; - } - - /** - * Set page margins - * - * @param PHPExcel_Worksheet_PageMargins $pValue - * @return PHPExcel_Worksheet - */ - public function setPageMargins(PHPExcel_Worksheet_PageMargins $pValue) - { - $this->_pageMargins = $pValue; - return $this; - } - - /** - * Get page header/footer - * - * @return PHPExcel_Worksheet_HeaderFooter - */ - public function getHeaderFooter() - { - return $this->_headerFooter; - } - - /** - * Set page header/footer - * - * @param PHPExcel_Worksheet_HeaderFooter $pValue - * @return PHPExcel_Worksheet - */ - public function setHeaderFooter(PHPExcel_Worksheet_HeaderFooter $pValue) - { - $this->_headerFooter = $pValue; - return $this; - } - - /** - * Get sheet view - * - * @return PHPExcel_Worksheet_HeaderFooter - */ - public function getSheetView() - { - return $this->_sheetView; - } - - /** - * Set sheet view - * - * @param PHPExcel_Worksheet_SheetView $pValue - * @return PHPExcel_Worksheet - */ - public function setSheetView(PHPExcel_Worksheet_SheetView $pValue) - { - $this->_sheetView = $pValue; - return $this; - } - - /** - * Get Protection - * - * @return PHPExcel_Worksheet_Protection - */ - public function getProtection() - { - return $this->_protection; - } - - /** - * Set Protection - * - * @param PHPExcel_Worksheet_Protection $pValue - * @return PHPExcel_Worksheet - */ - public function setProtection(PHPExcel_Worksheet_Protection $pValue) - { - $this->_protection = $pValue; - $this->_dirty = true; - - return $this; - } - - /** - * Get highest worksheet column - * - * @return string Highest column name - */ - public function getHighestColumn() - { - return $this->_cachedHighestColumn; - } - - /** - * Get highest worksheet column that contains data - * - * @return string Highest column name that contains data - */ - public function getHighestDataColumn() - { - return $this->_cellCollection->getHighestColumn(); - } - - /** - * Get highest worksheet row - * - * @return int Highest row number - */ - public function getHighestRow() - { - return $this->_cachedHighestRow; - } - - /** - * Get highest worksheet row that contains data - * - * @return string Highest row number that contains data - */ - public function getHighestDataRow() - { - return $this->_cellCollection->getHighestRow(); - } - - /** - * Get highest worksheet column and highest row that have cell records - * - * @return array Highest column name and highest row number - */ - public function getHighestRowAndColumn() - { - return $this->_cellCollection->getHighestRowAndColumn(); - } - - /** - * Set a cell value - * - * @param string $pCoordinate Coordinate of the cell - * @param mixed $pValue Value of the cell - * @param bool $returnCell Return the worksheet (false, default) or the cell (true) - * @return PHPExcel_Worksheet|PHPExcel_Cell Depending on the last parameter being specified - */ - public function setCellValue($pCoordinate = 'A1', $pValue = null, $returnCell = false) - { - $cell = $this->getCell($pCoordinate)->setValue($pValue); - return ($returnCell) ? $cell : $this; - } - - /** - * Set a cell value by using numeric cell coordinates - * - * @param string $pColumn Numeric column coordinate of the cell - * @param string $pRow Numeric row coordinate of the cell - * @param mixed $pValue Value of the cell - * @param bool $returnCell Return the worksheet (false, default) or the cell (true) - * @return PHPExcel_Worksheet|PHPExcel_Cell Depending on the last parameter being specified - */ - public function setCellValueByColumnAndRow($pColumn = 0, $pRow = 1, $pValue = null, $returnCell = false) - { - $cell = $this->getCell(PHPExcel_Cell::stringFromColumnIndex($pColumn) . $pRow)->setValue($pValue); - return ($returnCell) ? $cell : $this; - } - - /** - * Set a cell value - * - * @param string $pCoordinate Coordinate of the cell - * @param mixed $pValue Value of the cell - * @param string $pDataType Explicit data type - * @param bool $returnCell Return the worksheet (false, default) or the cell (true) - * @return PHPExcel_Worksheet|PHPExcel_Cell Depending on the last parameter being specified - */ - public function setCellValueExplicit($pCoordinate = 'A1', $pValue = null, $pDataType = PHPExcel_Cell_DataType::TYPE_STRING, $returnCell = false) - { - // Set value - $cell = $this->getCell($pCoordinate)->setValueExplicit($pValue, $pDataType); - return ($returnCell) ? $cell : $this; - } - - /** - * Set a cell value by using numeric cell coordinates - * - * @param string $pColumn Numeric column coordinate of the cell - * @param string $pRow Numeric row coordinate of the cell - * @param mixed $pValue Value of the cell - * @param string $pDataType Explicit data type - * @param bool $returnCell Return the worksheet (false, default) or the cell (true) - * @return PHPExcel_Worksheet|PHPExcel_Cell Depending on the last parameter being specified - */ - public function setCellValueExplicitByColumnAndRow($pColumn = 0, $pRow = 1, $pValue = null, $pDataType = PHPExcel_Cell_DataType::TYPE_STRING, $returnCell = false) - { - $cell = $this->getCell(PHPExcel_Cell::stringFromColumnIndex($pColumn) . $pRow)->setValueExplicit($pValue, $pDataType); - return ($returnCell) ? $cell : $this; - } - - /** - * Get cell at a specific coordinate - * - * @param string $pCoordinate Coordinate of the cell - * @throws Exception - * @return PHPExcel_Cell Cell that was found - */ - public function getCell($pCoordinate = 'A1') - { - // Check cell collection - if ($this->_cellCollection->isDataSet($pCoordinate)) { - return $this->_cellCollection->getCacheData($pCoordinate); - } - - // Worksheet reference? - if (strpos($pCoordinate, '!') !== false) { - $worksheetReference = PHPExcel_Worksheet::extractSheetTitle($pCoordinate, true); - return $this->getParent()->getSheetByName($worksheetReference[0])->getCell($worksheetReference[1]); - } - - // Named range? - if ((!preg_match('/^'.PHPExcel_Calculation::CALCULATION_REGEXP_CELLREF.'$/i', $pCoordinate, $matches)) && - (preg_match('/^'.PHPExcel_Calculation::CALCULATION_REGEXP_NAMEDRANGE.'$/i', $pCoordinate, $matches))) { - $namedRange = PHPExcel_NamedRange::resolveRange($pCoordinate, $this); - if ($namedRange !== NULL) { - $pCoordinate = $namedRange->getRange(); - return $namedRange->getWorksheet()->getCell($pCoordinate); - } - } - - // Uppercase coordinate - $pCoordinate = strtoupper($pCoordinate); - - if (strpos($pCoordinate,':') !== false || strpos($pCoordinate,',') !== false) { - throw new Exception('Cell coordinate can not be a range of cells.'); - } elseif (strpos($pCoordinate,'$') !== false) { - throw new Exception('Cell coordinate must not be absolute.'); - } else { - // Create new cell object - - // Coordinates - $aCoordinates = PHPExcel_Cell::coordinateFromString($pCoordinate); - - $cell = $this->_cellCollection->addCacheData($pCoordinate,new PHPExcel_Cell($aCoordinates[0], $aCoordinates[1], null, PHPExcel_Cell_DataType::TYPE_NULL, $this)); - $this->_cellCollectionIsSorted = false; - - if (PHPExcel_Cell::columnIndexFromString($this->_cachedHighestColumn) < PHPExcel_Cell::columnIndexFromString($aCoordinates[0])) - $this->_cachedHighestColumn = $aCoordinates[0]; - - $this->_cachedHighestRow = max($this->_cachedHighestRow,$aCoordinates[1]); - - // Cell needs appropriate xfIndex - $rowDimensions = $this->getRowDimensions(); - $columnDimensions = $this->getColumnDimensions(); - - if ( isset($rowDimensions[$aCoordinates[1]]) && $rowDimensions[$aCoordinates[1]]->getXfIndex() !== null ) { - // then there is a row dimension with explicit style, assign it to the cell - $cell->setXfIndex($rowDimensions[$aCoordinates[1]]->getXfIndex()); - } else if ( isset($columnDimensions[$aCoordinates[0]]) ) { - // then there is a column dimension, assign it to the cell - $cell->setXfIndex($columnDimensions[$aCoordinates[0]]->getXfIndex()); - } else { - // set to default index - $cell->setXfIndex(0); - } - - return $cell; - } - } - - /** - * Get cell at a specific coordinate by using numeric cell coordinates - * - * @param string $pColumn Numeric column coordinate of the cell - * @param string $pRow Numeric row coordinate of the cell - * @return PHPExcel_Cell Cell that was found - */ - public function getCellByColumnAndRow($pColumn = 0, $pRow = 1) - { - $columnLetter = PHPExcel_Cell::stringFromColumnIndex($pColumn); - $coordinate = $columnLetter . $pRow; - - if (!$this->_cellCollection->isDataSet($coordinate)) { - $cell = $this->_cellCollection->addCacheData($coordinate, new PHPExcel_Cell($columnLetter, $pRow, null, PHPExcel_Cell_DataType::TYPE_NULL, $this)); - $this->_cellCollectionIsSorted = false; - - if (PHPExcel_Cell::columnIndexFromString($this->_cachedHighestColumn) < $pColumn) - $this->_cachedHighestColumn = $columnLetter; - - $this->_cachedHighestRow = max($this->_cachedHighestRow,$pRow); - - return $cell; - } - - return $this->_cellCollection->getCacheData($coordinate); - } - - /** - * Cell at a specific coordinate exists? - * - * @param string $pCoordinate Coordinate of the cell - * @throws Exception - * @return boolean - */ - public function cellExists($pCoordinate = 'A1') - { - // Worksheet reference? - if (strpos($pCoordinate, '!') !== false) { - $worksheetReference = PHPExcel_Worksheet::extractSheetTitle($pCoordinate, true); - return $this->getParent()->getSheetByName($worksheetReference[0])->cellExists($worksheetReference[1]); - } - - // Named range? - if ((!preg_match('/^'.PHPExcel_Calculation::CALCULATION_REGEXP_CELLREF.'$/i', $pCoordinate, $matches)) && - (preg_match('/^'.PHPExcel_Calculation::CALCULATION_REGEXP_NAMEDRANGE.'$/i', $pCoordinate, $matches))) { - $namedRange = PHPExcel_NamedRange::resolveRange($pCoordinate, $this); - if ($namedRange !== NULL) { - $pCoordinate = $namedRange->getRange(); - if ($this->getHashCode() != $namedRange->getWorksheet()->getHashCode()) { - if (!$namedRange->getLocalOnly()) { - return $namedRange->getWorksheet()->cellExists($pCoordinate); - } else { - throw new Exception('Named range ' . $namedRange->getName() . ' is not accessible from within sheet ' . $this->getTitle()); - } - } - } - } - - // Uppercase coordinate - $pCoordinate = strtoupper($pCoordinate); - - if (strpos($pCoordinate,':') !== false || strpos($pCoordinate,',') !== false) { - throw new Exception('Cell coordinate can not be a range of cells.'); - } elseif (strpos($pCoordinate,'$') !== false) { - throw new Exception('Cell coordinate must not be absolute.'); - } else { - // Coordinates - $aCoordinates = PHPExcel_Cell::coordinateFromString($pCoordinate); - - // Cell exists? - return $this->_cellCollection->isDataSet($pCoordinate); - } - } - - /** - * Cell at a specific coordinate by using numeric cell coordinates exists? - * - * @param string $pColumn Numeric column coordinate of the cell - * @param string $pRow Numeric row coordinate of the cell - * @return boolean - */ - public function cellExistsByColumnAndRow($pColumn = 0, $pRow = 1) - { - return $this->cellExists(PHPExcel_Cell::stringFromColumnIndex($pColumn) . $pRow); - } - - /** - * Get row dimension at a specific row - * - * @param int $pRow Numeric index of the row - * @return PHPExcel_Worksheet_RowDimension - */ - public function getRowDimension($pRow = 1) - { - // Found - $found = null; - - // Get row dimension - if (!isset($this->_rowDimensions[$pRow])) { - $this->_rowDimensions[$pRow] = new PHPExcel_Worksheet_RowDimension($pRow); - - $this->_cachedHighestRow = max($this->_cachedHighestRow,$pRow); - } - return $this->_rowDimensions[$pRow]; - } - - /** - * Get column dimension at a specific column - * - * @param string $pColumn String index of the column - * @return PHPExcel_Worksheet_ColumnDimension - */ - public function getColumnDimension($pColumn = 'A') - { - // Uppercase coordinate - $pColumn = strtoupper($pColumn); - - // Fetch dimensions - if (!isset($this->_columnDimensions[$pColumn])) { - $this->_columnDimensions[$pColumn] = new PHPExcel_Worksheet_ColumnDimension($pColumn); - - if (PHPExcel_Cell::columnIndexFromString($this->_cachedHighestColumn) < PHPExcel_Cell::columnIndexFromString($pColumn)) - $this->_cachedHighestColumn = $pColumn; - } - return $this->_columnDimensions[$pColumn]; - } - - /** - * Get column dimension at a specific column by using numeric cell coordinates - * - * @param string $pColumn Numeric column coordinate of the cell - * @return PHPExcel_Worksheet_ColumnDimension - */ - public function getColumnDimensionByColumn($pColumn = 0) - { - return $this->getColumnDimension(PHPExcel_Cell::stringFromColumnIndex($pColumn)); - } - - /** - * Get styles - * - * @return PHPExcel_Style[] - */ - public function getStyles() - { - return $this->_styles; - } - - /** - * Get default style of workbork. - * - * @deprecated - * @return PHPExcel_Style - * @throws Exception - */ - public function getDefaultStyle() - { - return $this->_parent->getDefaultStyle(); - } - - /** - * Set default style - should only be used by PHPExcel_IReader implementations! - * - * @deprecated - * @param PHPExcel_Style $pValue - * @throws Exception - * @return PHPExcel_Worksheet - */ - public function setDefaultStyle(PHPExcel_Style $pValue) - { - $this->_parent->getDefaultStyle()->applyFromArray(array( - 'font' => array( - 'name' => $pValue->getFont()->getName(), - 'size' => $pValue->getFont()->getSize(), - ), - )); - return $this; - } - - /** - * Get style for cell - * - * @param string $pCellCoordinate Cell coordinate to get style for - * @return PHPExcel_Style - * @throws Exception - */ - public function getStyle($pCellCoordinate = 'A1') - { - // set this sheet as active - $this->_parent->setActiveSheetIndex($this->_parent->getIndex($this)); - - // set cell coordinate as active - $this->setSelectedCells($pCellCoordinate); - - return $this->_parent->getCellXfSupervisor(); - } - - /** - * Get conditional styles for a cell - * - * @param string $pCoordinate - * @return PHPExcel_Style_Conditional[] - */ - public function getConditionalStyles($pCoordinate = 'A1') - { - if (!isset($this->_conditionalStylesCollection[$pCoordinate])) { - $this->_conditionalStylesCollection[$pCoordinate] = array(); - } - return $this->_conditionalStylesCollection[$pCoordinate]; - } - - /** - * Do conditional styles exist for this cell? - * - * @param string $pCoordinate - * @return boolean - */ - public function conditionalStylesExists($pCoordinate = 'A1') - { - if (isset($this->_conditionalStylesCollection[$pCoordinate])) { - return true; - } - return false; - } - - /** - * Removes conditional styles for a cell - * - * @param string $pCoordinate - * @return PHPExcel_Worksheet - */ - public function removeConditionalStyles($pCoordinate = 'A1') - { - unset($this->_conditionalStylesCollection[$pCoordinate]); - return $this; - } - - /** - * Get collection of conditional styles - * - * @return array - */ - public function getConditionalStylesCollection() - { - return $this->_conditionalStylesCollection; - } - - /** - * Set conditional styles - * - * @param $pCoordinate string E.g. 'A1' - * @param $pValue PHPExcel_Style_Conditional[] - * @return PHPExcel_Worksheet - */ - public function setConditionalStyles($pCoordinate = 'A1', $pValue) - { - $this->_conditionalStylesCollection[$pCoordinate] = $pValue; - return $this; - } - - /** - * Get style for cell by using numeric cell coordinates - * - * @param int $pColumn Numeric column coordinate of the cell - * @param int $pRow Numeric row coordinate of the cell - * @return PHPExcel_Style - */ - public function getStyleByColumnAndRow($pColumn = 0, $pRow = 1) - { - return $this->getStyle(PHPExcel_Cell::stringFromColumnIndex($pColumn) . $pRow); - } - - /** - * Set shared cell style to a range of cells - * - * Please note that this will overwrite existing cell styles for cells in range! - * - * @deprecated - * @param PHPExcel_Style $pSharedCellStyle Cell style to share - * @param string $pRange Range of cells (i.e. "A1:B10"), or just one cell (i.e. "A1") - * @throws Exception - * @return PHPExcel_Worksheet - */ - public function setSharedStyle(PHPExcel_Style $pSharedCellStyle = null, $pRange = '') - { - $this->duplicateStyle($pSharedCellStyle, $pRange); - return $this; - } - - /** - * Duplicate cell style to a range of cells - * - * Please note that this will overwrite existing cell styles for cells in range! - * - * @param PHPExcel_Style $pCellStyle Cell style to duplicate - * @param string $pRange Range of cells (i.e. "A1:B10"), or just one cell (i.e. "A1") - * @throws Exception - * @return PHPExcel_Worksheet - */ - public function duplicateStyle(PHPExcel_Style $pCellStyle = null, $pRange = '') - { - // make sure we have a real style and not supervisor - $style = $pCellStyle->getIsSupervisor() ? $pCellStyle->getSharedComponent() : $pCellStyle; - - // Add the style to the workbook if necessary - $workbook = $this->_parent; - if ($existingStyle = $this->_parent->getCellXfByHashCode($pCellStyle->getHashCode())) { - // there is already such cell Xf in our collection - $xfIndex = $existingStyle->getIndex(); - } else { - // we don't have such a cell Xf, need to add - $workbook->addCellXf($pCellStyle); - $xfIndex = $pCellStyle->getIndex(); - } - - // Uppercase coordinate - $pRange = strtoupper($pRange); - - // Is it a cell range or a single cell? - $rangeA = ''; - $rangeB = ''; - if (strpos($pRange, ':') === false) { - $rangeA = $pRange; - $rangeB = $pRange; - } else { - list($rangeA, $rangeB) = explode(':', $pRange); - } - - // Calculate range outer borders - $rangeStart = PHPExcel_Cell::coordinateFromString($rangeA); - $rangeEnd = PHPExcel_Cell::coordinateFromString($rangeB); - - // Translate column into index - $rangeStart[0] = PHPExcel_Cell::columnIndexFromString($rangeStart[0]) - 1; - $rangeEnd[0] = PHPExcel_Cell::columnIndexFromString($rangeEnd[0]) - 1; - - // Make sure we can loop upwards on rows and columns - if ($rangeStart[0] > $rangeEnd[0] && $rangeStart[1] > $rangeEnd[1]) { - $tmp = $rangeStart; - $rangeStart = $rangeEnd; - $rangeEnd = $tmp; - } - - // Loop through cells and apply styles - for ($col = $rangeStart[0]; $col <= $rangeEnd[0]; ++$col) { - for ($row = $rangeStart[1]; $row <= $rangeEnd[1]; ++$row) { - $this->getCell(PHPExcel_Cell::stringFromColumnIndex($col) . $row)->setXfIndex($xfIndex); - } - } - - return $this; - } - - /** - * Duplicate conditional style to a range of cells - * - * Please note that this will overwrite existing cell styles for cells in range! - * - * @param array of PHPExcel_Style_Conditional $pCellStyle Cell style to duplicate - * @param string $pRange Range of cells (i.e. "A1:B10"), or just one cell (i.e. "A1") - * @throws Exception - * @return PHPExcel_Worksheet - */ - public function duplicateConditionalStyle(array $pCellStyle = null, $pRange = '') - { - foreach($pCellStyle as $cellStyle) { - if (!is_a($cellStyle,'PHPExcel_Style_Conditional')) { - throw new Exception('Style is not a conditional style'); - } - } - - // Uppercase coordinate - $pRange = strtoupper($pRange); - - // Is it a cell range or a single cell? - $rangeA = ''; - $rangeB = ''; - if (strpos($pRange, ':') === false) { - $rangeA = $pRange; - $rangeB = $pRange; - } else { - list($rangeA, $rangeB) = explode(':', $pRange); - } - - // Calculate range outer borders - $rangeStart = PHPExcel_Cell::coordinateFromString($rangeA); - $rangeEnd = PHPExcel_Cell::coordinateFromString($rangeB); - - // Translate column into index - $rangeStart[0] = PHPExcel_Cell::columnIndexFromString($rangeStart[0]) - 1; - $rangeEnd[0] = PHPExcel_Cell::columnIndexFromString($rangeEnd[0]) - 1; - - // Make sure we can loop upwards on rows and columns - if ($rangeStart[0] > $rangeEnd[0] && $rangeStart[1] > $rangeEnd[1]) { - $tmp = $rangeStart; - $rangeStart = $rangeEnd; - $rangeEnd = $tmp; - } - - // Loop through cells and apply styles - for ($col = $rangeStart[0]; $col <= $rangeEnd[0]; ++$col) { - for ($row = $rangeStart[1]; $row <= $rangeEnd[1]; ++$row) { - $this->setConditionalStyles(PHPExcel_Cell::stringFromColumnIndex($col) . $row, $pCellStyle); - } - } - - return $this; - } - - /** - * Duplicate cell style array to a range of cells - * - * Please note that this will overwrite existing cell styles for cells in range, - * if they are in the styles array. For example, if you decide to set a range of - * cells to font bold, only include font bold in the styles array. - * - * @deprecated - * @param array $pStyles Array containing style information - * @param string $pRange Range of cells (i.e. "A1:B10"), or just one cell (i.e. "A1") - * @param boolean $pAdvanced Advanced mode for setting borders. - * @throws Exception - * @return PHPExcel_Worksheet - */ - public function duplicateStyleArray($pStyles = null, $pRange = '', $pAdvanced = true) - { - $this->getStyle($pRange)->applyFromArray($pStyles, $pAdvanced); - return $this; - } - - /** - * Set break on a cell - * - * @param string $pCell Cell coordinate (e.g. A1) - * @param int $pBreak Break type (type of PHPExcel_Worksheet::BREAK_*) - * @throws Exception - * @return PHPExcel_Worksheet - */ - public function setBreak($pCell = 'A1', $pBreak = PHPExcel_Worksheet::BREAK_NONE) - { - // Uppercase coordinate - $pCell = strtoupper($pCell); - - if ($pCell != '') { - $this->_breaks[$pCell] = $pBreak; - } else { - throw new Exception('No cell coordinate specified.'); - } - - return $this; - } - - /** - * Set break on a cell by using numeric cell coordinates - * - * @param integer $pColumn Numeric column coordinate of the cell - * @param integer $pRow Numeric row coordinate of the cell - * @param integer $pBreak Break type (type of PHPExcel_Worksheet::BREAK_*) - * @throws Exception - * @return PHPExcel_Worksheet - */ - public function setBreakByColumnAndRow($pColumn = 0, $pRow = 1, $pBreak = PHPExcel_Worksheet::BREAK_NONE) - { - return $this->setBreak(PHPExcel_Cell::stringFromColumnIndex($pColumn) . $pRow, $pBreak); - } - - /** - * Get breaks - * - * @return array[] - */ - public function getBreaks() - { - return $this->_breaks; - } - - /** - * Set merge on a cell range - * - * @param string $pRange Cell range (e.g. A1:E1) - * @throws Exception - * @return PHPExcel_Worksheet - */ - public function mergeCells($pRange = 'A1:A1') - { - // Uppercase coordinate - $pRange = strtoupper($pRange); - - if (strpos($pRange,':') !== false) { - $this->_mergeCells[$pRange] = $pRange; - - // make sure cells are created - - // get the cells in the range - $aReferences = PHPExcel_Cell::extractAllCellReferencesInRange($pRange); - - // create upper left cell if it does not already exist - $upperLeft = $aReferences[0]; - if (!$this->cellExists($upperLeft)) { - $this->getCell($upperLeft)->setValueExplicit(null, PHPExcel_Cell_DataType::TYPE_NULL); - } - - // create or blank out the rest of the cells in the range - $count = count($aReferences); - for ($i = 1; $i < $count; $i++) { - $this->getCell($aReferences[$i])->setValueExplicit(null, PHPExcel_Cell_DataType::TYPE_NULL); - } - - } else { - throw new Exception('Merge must be set on a range of cells.'); - } - - return $this; - } - - /** - * Set merge on a cell range by using numeric cell coordinates - * - * @param int $pColumn1 Numeric column coordinate of the first cell - * @param int $pRow1 Numeric row coordinate of the first cell - * @param int $pColumn2 Numeric column coordinate of the last cell - * @param int $pRow2 Numeric row coordinate of the last cell - * @throws Exception - * @return PHPExcel_Worksheet - */ - public function mergeCellsByColumnAndRow($pColumn1 = 0, $pRow1 = 1, $pColumn2 = 0, $pRow2 = 1) - { - $cellRange = PHPExcel_Cell::stringFromColumnIndex($pColumn1) . $pRow1 . ':' . PHPExcel_Cell::stringFromColumnIndex($pColumn2) . $pRow2; - return $this->mergeCells($cellRange); - } - - /** - * Remove merge on a cell range - * - * @param string $pRange Cell range (e.g. A1:E1) - * @throws Exception - * @return PHPExcel_Worksheet - */ - public function unmergeCells($pRange = 'A1:A1') - { - // Uppercase coordinate - $pRange = strtoupper($pRange); - - if (strpos($pRange,':') !== false) { - if (isset($this->_mergeCells[$pRange])) { - unset($this->_mergeCells[$pRange]); - } else { - throw new Exception('Cell range ' . $pRange . ' not known as merged.'); - } - } else { - throw new Exception('Merge can only be removed from a range of cells.'); - } - - return $this; - } - - /** - * Remove merge on a cell range by using numeric cell coordinates - * - * @param int $pColumn1 Numeric column coordinate of the first cell - * @param int $pRow1 Numeric row coordinate of the first cell - * @param int $pColumn2 Numeric column coordinate of the last cell - * @param int $pRow2 Numeric row coordinate of the last cell - * @throws Exception - * @return PHPExcel_Worksheet - */ - public function unmergeCellsByColumnAndRow($pColumn1 = 0, $pRow1 = 1, $pColumn2 = 0, $pRow2 = 1) - { - $cellRange = PHPExcel_Cell::stringFromColumnIndex($pColumn1) . $pRow1 . ':' . PHPExcel_Cell::stringFromColumnIndex($pColumn2) . $pRow2; - return $this->unmergeCells($cellRange); - } - - /** - * Get merge cells array. - * - * @return array[] - */ - public function getMergeCells() - { - return $this->_mergeCells; - } - - /** - * Set merge cells array for the entire sheet. Use instead mergeCells() to merge - * a single cell range. - * - * @param array - */ - public function setMergeCells($pValue = array()) - { - $this->_mergeCells = $pValue; - - return $this; - } - - /** - * Set protection on a cell range - * - * @param string $pRange Cell (e.g. A1) or cell range (e.g. A1:E1) - * @param string $pPassword Password to unlock the protection - * @param boolean $pAlreadyHashed If the password has already been hashed, set this to true - * @throws Exception - * @return PHPExcel_Worksheet - */ - public function protectCells($pRange = 'A1', $pPassword = '', $pAlreadyHashed = false) - { - // Uppercase coordinate - $pRange = strtoupper($pRange); - - if (!$pAlreadyHashed) { - $pPassword = PHPExcel_Shared_PasswordHasher::hashPassword($pPassword); - } - $this->_protectedCells[$pRange] = $pPassword; - - return $this; - } - - /** - * Set protection on a cell range by using numeric cell coordinates - * - * @param int $pColumn1 Numeric column coordinate of the first cell - * @param int $pRow1 Numeric row coordinate of the first cell - * @param int $pColumn2 Numeric column coordinate of the last cell - * @param int $pRow2 Numeric row coordinate of the last cell - * @param string $pPassword Password to unlock the protection - * @param boolean $pAlreadyHashed If the password has already been hashed, set this to true - * @throws Exception - * @return PHPExcel_Worksheet - */ - public function protectCellsByColumnAndRow($pColumn1 = 0, $pRow1 = 1, $pColumn2 = 0, $pRow2 = 1, $pPassword = '', $pAlreadyHashed = false) - { - $cellRange = PHPExcel_Cell::stringFromColumnIndex($pColumn1) . $pRow1 . ':' . PHPExcel_Cell::stringFromColumnIndex($pColumn2) . $pRow2; - return $this->protectCells($cellRange, $pPassword, $pAlreadyHashed); - } - - /** - * Remove protection on a cell range - * - * @param string $pRange Cell (e.g. A1) or cell range (e.g. A1:E1) - * @throws Exception - * @return PHPExcel_Worksheet - */ - public function unprotectCells($pRange = 'A1') - { - // Uppercase coordinate - $pRange = strtoupper($pRange); - - if (isset($this->_protectedCells[$pRange])) { - unset($this->_protectedCells[$pRange]); - } else { - throw new Exception('Cell range ' . $pRange . ' not known as protected.'); - } - return $this; - } - - /** - * Remove protection on a cell range by using numeric cell coordinates - * - * @param int $pColumn1 Numeric column coordinate of the first cell - * @param int $pRow1 Numeric row coordinate of the first cell - * @param int $pColumn2 Numeric column coordinate of the last cell - * @param int $pRow2 Numeric row coordinate of the last cell - * @param string $pPassword Password to unlock the protection - * @param boolean $pAlreadyHashed If the password has already been hashed, set this to true - * @throws Exception - * @return PHPExcel_Worksheet - */ - public function unprotectCellsByColumnAndRow($pColumn1 = 0, $pRow1 = 1, $pColumn2 = 0, $pRow2 = 1, $pPassword = '', $pAlreadyHashed = false) - { - $cellRange = PHPExcel_Cell::stringFromColumnIndex($pColumn1) . $pRow1 . ':' . PHPExcel_Cell::stringFromColumnIndex($pColumn2) . $pRow2; - return $this->unprotectCells($cellRange, $pPassword, $pAlreadyHashed); - } - - /** - * Get protected cells - * - * @return array[] - */ - public function getProtectedCells() - { - return $this->_protectedCells; - } - - /** - * Get Autofilter - * - * @return PHPExcel_Worksheet_AutoFilter - */ - public function getAutoFilter() - { - return $this->_autoFilter; - } - - /** - * Set AutoFilter - * - * @param PHPExcel_Worksheet_AutoFilter|string $pValue - * A simple string containing a Cell range like 'A1:E10' is permitted for backward compatibility - * @throws Exception - * @return PHPExcel_Worksheet - */ - public function setAutoFilter($pValue) - { - if (is_string($pValue)) { - $this->_autoFilter->setRange($pValue); - } elseif(is_object($pValue) && ($pValue instanceof PHPExcel_Worksheet_AutoFilter)) { - $this->_autoFilter = $pValue; - } - return $this; - } - - /** - * Set Autofilter Range by using numeric cell coordinates - * - * @param int $pColumn1 Numeric column coordinate of the first cell - * @param int $pRow1 Numeric row coordinate of the first cell - * @param int $pColumn2 Numeric column coordinate of the second cell - * @param int $pRow2 Numeric row coordinate of the second cell - * @throws Exception - * @return PHPExcel_Worksheet - */ - public function setAutoFilterByColumnAndRow($pColumn1 = 0, $pRow1 = 1, $pColumn2 = 0, $pRow2 = 1) - { - return $this->setAutoFilter( - PHPExcel_Cell::stringFromColumnIndex($pColumn1) . $pRow1 - . ':' . - PHPExcel_Cell::stringFromColumnIndex($pColumn2) . $pRow2 - ); - } - - /** - * Remove autofilter - * - * @return PHPExcel_Worksheet - */ - public function removeAutoFilter() - { - $this->_autoFilter->setRange(NULL); - return $this; - } - - /** - * Get Freeze Pane - * - * @return string - */ - public function getFreezePane() - { - return $this->_freezePane; - } - - /** - * Freeze Pane - * - * @param string $pCell Cell (i.e. A2) - * Examples: - * A2 will freeze the rows above cell A2 (i.e row 1) - * B1 will freeze the columns to the left of cell B1 (i.e column A) - * B2 will freeze the rows above and to the left of cell A2 - * (i.e row 1 and column A) - * @throws Exception - * @return PHPExcel_Worksheet - */ - public function freezePane($pCell = '') - { - // Uppercase coordinate - $pCell = strtoupper($pCell); - - if (strpos($pCell,':') === false && strpos($pCell,',') === false) { - $this->_freezePane = $pCell; - } else { - throw new Exception('Freeze pane can not be set on a range of cells.'); - } - return $this; - } - - /** - * Freeze Pane by using numeric cell coordinates - * - * @param int $pColumn Numeric column coordinate of the cell - * @param int $pRow Numeric row coordinate of the cell - * @throws Exception - * @return PHPExcel_Worksheet - */ - public function freezePaneByColumnAndRow($pColumn = 0, $pRow = 1) - { - return $this->freezePane(PHPExcel_Cell::stringFromColumnIndex($pColumn) . $pRow); - } - - /** - * Unfreeze Pane - * - * @return PHPExcel_Worksheet - */ - public function unfreezePane() - { - return $this->freezePane(''); - } - - /** - * Insert a new row, updating all possible related data - * - * @param int $pBefore Insert before this one - * @param int $pNumRows Number of rows to insert - * @throws Exception - * @return PHPExcel_Worksheet - */ - public function insertNewRowBefore($pBefore = 1, $pNumRows = 1) { - if ($pBefore >= 1) { - $objReferenceHelper = PHPExcel_ReferenceHelper::getInstance(); - $objReferenceHelper->insertNewBefore('A' . $pBefore, 0, $pNumRows, $this); - } else { - throw new Exception("Rows can only be inserted before at least row 1."); - } - return $this; - } - - /** - * Insert a new column, updating all possible related data - * - * @param int $pBefore Insert before this one - * @param int $pNumCols Number of columns to insert - * @throws Exception - * @return PHPExcel_Worksheet - */ - public function insertNewColumnBefore($pBefore = 'A', $pNumCols = 1) { - if (!is_numeric($pBefore)) { - $objReferenceHelper = PHPExcel_ReferenceHelper::getInstance(); - $objReferenceHelper->insertNewBefore($pBefore . '1', $pNumCols, 0, $this); - } else { - throw new Exception("Column references should not be numeric."); - } - return $this; - } - - /** - * Insert a new column, updating all possible related data - * - * @param int $pBefore Insert before this one (numeric column coordinate of the cell) - * @param int $pNumCols Number of columns to insert - * @throws Exception - * @return PHPExcel_Worksheet - */ - public function insertNewColumnBeforeByIndex($pBefore = 0, $pNumCols = 1) { - if ($pBefore >= 0) { - return $this->insertNewColumnBefore(PHPExcel_Cell::stringFromColumnIndex($pBefore), $pNumCols); - } else { - throw new Exception("Columns can only be inserted before at least column A (0)."); - } - } - - /** - * Delete a row, updating all possible related data - * - * @param int $pRow Remove starting with this one - * @param int $pNumRows Number of rows to remove - * @throws Exception - * @return PHPExcel_Worksheet - */ - public function removeRow($pRow = 1, $pNumRows = 1) { - if ($pRow >= 1) { - $objReferenceHelper = PHPExcel_ReferenceHelper::getInstance(); - $objReferenceHelper->insertNewBefore('A' . ($pRow + $pNumRows), 0, -$pNumRows, $this); - } else { - throw new Exception("Rows to be deleted should at least start from row 1."); - } - return $this; - } - - /** - * Remove a column, updating all possible related data - * - * @param int $pColumn Remove starting with this one - * @param int $pNumCols Number of columns to remove - * @throws Exception - * @return PHPExcel_Worksheet - */ - public function removeColumn($pColumn = 'A', $pNumCols = 1) { - if (!is_numeric($pColumn)) { - $pColumn = PHPExcel_Cell::stringFromColumnIndex(PHPExcel_Cell::columnIndexFromString($pColumn) - 1 + $pNumCols); - $objReferenceHelper = PHPExcel_ReferenceHelper::getInstance(); - $objReferenceHelper->insertNewBefore($pColumn . '1', -$pNumCols, 0, $this); - } else { - throw new Exception("Column references should not be numeric."); - } - return $this; - } - - /** - * Remove a column, updating all possible related data - * - * @param int $pColumn Remove starting with this one (numeric column coordinate of the cell) - * @param int $pNumCols Number of columns to remove - * @throws Exception - * @return PHPExcel_Worksheet - */ - public function removeColumnByIndex($pColumn = 0, $pNumCols = 1) { - if ($pColumn >= 0) { - return $this->removeColumn(PHPExcel_Cell::stringFromColumnIndex($pColumn), $pNumCols); - } else { - throw new Exception("Columns to be deleted should at least start from column 0"); - } - } - - /** - * Show gridlines? - * - * @return boolean - */ - public function getShowGridlines() { - return $this->_showGridlines; - } - - /** - * Set show gridlines - * - * @param boolean $pValue Show gridlines (true/false) - * @return PHPExcel_Worksheet - */ - public function setShowGridlines($pValue = false) { - $this->_showGridlines = $pValue; - return $this; - } - - /** - * Print gridlines? - * - * @return boolean + * @return null|string */ - public function getPrintGridlines() { - return $this->_printGridlines; + public function getCodeName(){ + return $this->_codeName; } - /** - * Set print gridlines - * - * @param boolean $pValue Print gridlines (true/false) - * @return PHPExcel_Worksheet + * Sheet has a code name ? + * @return boolean */ - public function setPrintGridlines($pValue = false) { - $this->_printGridlines = $pValue; - return $this; - } - - /** - * Show row and column headers? - * - * @return boolean - */ - public function getShowRowColHeaders() { - return $this->_showRowColHeaders; - } - - /** - * Set show row and column headers - * - * @param boolean $pValue Show row and column headers (true/false) - * @return PHPExcel_Worksheet - */ - public function setShowRowColHeaders($pValue = false) { - $this->_showRowColHeaders = $pValue; - return $this; - } - - /** - * Show summary below? (Row/Column outlining) - * - * @return boolean - */ - public function getShowSummaryBelow() { - return $this->_showSummaryBelow; - } - - /** - * Set show summary below - * - * @param boolean $pValue Show summary below (true/false) - * @return PHPExcel_Worksheet - */ - public function setShowSummaryBelow($pValue = true) { - $this->_showSummaryBelow = $pValue; - return $this; - } - - /** - * Show summary right? (Row/Column outlining) - * - * @return boolean - */ - public function getShowSummaryRight() { - return $this->_showSummaryRight; - } - - /** - * Set show summary right - * - * @param boolean $pValue Show summary right (true/false) - * @return PHPExcel_Worksheet - */ - public function setShowSummaryRight($pValue = true) { - $this->_showSummaryRight = $pValue; - return $this; - } - - /** - * Get comments - * - * @return PHPExcel_Comment[] - */ - public function getComments() - { - return $this->_comments; - } - - /** - * Set comments array for the entire sheet. - * - * @param array of PHPExcel_Comment - * @return PHPExcel_Worksheet - */ - public function setComments($pValue = array()) - { - $this->_comments = $pValue; - - return $this; - } - - /** - * Get comment for cell - * - * @param string $pCellCoordinate Cell coordinate to get comment for - * @return PHPExcel_Comment - * @throws Exception - */ - public function getComment($pCellCoordinate = 'A1') - { - // Uppercase coordinate - $pCellCoordinate = strtoupper($pCellCoordinate); - - if (strpos($pCellCoordinate,':') !== false || strpos($pCellCoordinate,',') !== false) { - throw new Exception('Cell coordinate string can not be a range of cells.'); - } else if (strpos($pCellCoordinate,'$') !== false) { - throw new Exception('Cell coordinate string must not be absolute.'); - } else if ($pCellCoordinate == '') { - throw new Exception('Cell coordinate can not be zero-length string.'); - } else { - // Check if we already have a comment for this cell. - // If not, create a new comment. - if (isset($this->_comments[$pCellCoordinate])) { - return $this->_comments[$pCellCoordinate]; - } else { - $newComment = new PHPExcel_Comment(); - $this->_comments[$pCellCoordinate] = $newComment; - return $newComment; - } - } - } - - /** - * Get comment for cell by using numeric cell coordinates - * - * @param int $pColumn Numeric column coordinate of the cell - * @param int $pRow Numeric row coordinate of the cell - * @return PHPExcel_Comment - */ - public function getCommentByColumnAndRow($pColumn = 0, $pRow = 1) - { - return $this->getComment(PHPExcel_Cell::stringFromColumnIndex($pColumn) . $pRow); - } - - /** - * Get selected cell - * - * @deprecated - * @return string - */ - public function getSelectedCell() - { - return $this->getSelectedCells(); - } - - /** - * Get active cell - * - * @return string Example: 'A1' - */ - public function getActiveCell() - { - return $this->_activeCell; - } - - /** - * Get selected cells - * - * @return string - */ - public function getSelectedCells() - { - return $this->_selectedCells; - } - - /** - * Selected cell - * - * @param string $pCoordinate Cell (i.e. A1) - * @return PHPExcel_Worksheet - */ - public function setSelectedCell($pCoordinate = 'A1') - { - return $this->setSelectedCells($pCoordinate); - } - - /** - * Select a range of cells. - * - * @param string $pCoordinate Cell range, examples: 'A1', 'B2:G5', 'A:C', '3:6' - * @throws Exception - * @return PHPExcel_Worksheet - */ - public function setSelectedCells($pCoordinate = 'A1') - { - // Uppercase coordinate - $pCoordinate = strtoupper($pCoordinate); - - // Convert 'A' to 'A:A' - $pCoordinate = preg_replace('/^([A-Z]+)$/', '${1}:${1}', $pCoordinate); - - // Convert '1' to '1:1' - $pCoordinate = preg_replace('/^([0-9]+)$/', '${1}:${1}', $pCoordinate); - - // Convert 'A:C' to 'A1:C1048576' - $pCoordinate = preg_replace('/^([A-Z]+):([A-Z]+)$/', '${1}1:${2}1048576', $pCoordinate); - - // Convert '1:3' to 'A1:XFD3' - $pCoordinate = preg_replace('/^([0-9]+):([0-9]+)$/', 'A${1}:XFD${2}', $pCoordinate); - - if (strpos($pCoordinate,':') !== false || strpos($pCoordinate,',') !== false) { - list($first, ) = PHPExcel_Cell::splitRange($pCoordinate); - $this->_activeCell = $first[0]; - } else { - $this->_activeCell = $pCoordinate; - } - $this->_selectedCells = $pCoordinate; - return $this; - } - - /** - * Selected cell by using numeric cell coordinates - * - * @param int $pColumn Numeric column coordinate of the cell - * @param int $pRow Numeric row coordinate of the cell - * @throws Exception - * @return PHPExcel_Worksheet - */ - public function setSelectedCellByColumnAndRow($pColumn = 0, $pRow = 1) - { - return $this->setSelectedCells(PHPExcel_Cell::stringFromColumnIndex($pColumn) . $pRow); - } - - /** - * Get right-to-left - * - * @return boolean - */ - public function getRightToLeft() { - return $this->_rightToLeft; - } - - /** - * Set right-to-left - * - * @param boolean $value Right-to-left true/false - * @return PHPExcel_Worksheet - */ - public function setRightToLeft($value = false) { - $this->_rightToLeft = $value; - return $this; - } - - /** - * Fill worksheet from values in array - * - * @param array $source Source array - * @param mixed $nullValue Value in source array that stands for blank cell - * @param string $startCell Insert array starting from this cell address as the top left coordinate - * @param boolean $strictNullComparison Apply strict comparison when testing for null values in the array - * @throws Exception - * @return PHPExcel_Worksheet - */ - public function fromArray($source = null, $nullValue = null, $startCell = 'A1', $strictNullComparison = false) { - if (is_array($source)) { - // Convert a 1-D array to 2-D (for ease of looping) - if (!is_array(end($source))) { - $source = array($source); - } - - // start coordinate - list ($startColumn, $startRow) = PHPExcel_Cell::coordinateFromString($startCell); - - // Loop through $source - foreach ($source as $rowData) { - $currentColumn = $startColumn; - foreach($rowData as $cellValue) { - if ($strictNullComparison) { - if ($cellValue !== $nullValue) { - // Set cell value - $this->getCell($currentColumn . $startRow)->setValue($cellValue); - } - } else { - if ($cellValue != $nullValue) { - // Set cell value - $this->getCell($currentColumn . $startRow)->setValue($cellValue); - } - } - ++$currentColumn; - } - ++$startRow; - } - } else { - throw new Exception("Parameter \$source should be an array."); - } - return $this; - } - - /** - * Create array from a range of cells - * - * @param string $pRange Range of cells (i.e. "A1:B10"), or just one cell (i.e. "A1") - * @param mixed $nullValue Value returned in the array entry if a cell doesn't exist - * @param boolean $calculateFormulas Should formulas be calculated? - * @param boolean $formatData Should formatting be applied to cell values? - * @param boolean $returnCellRef False - Return a simple array of rows and columns indexed by number counting from zero - * True - Return rows and columns indexed by their actual row and column IDs - * @return array - */ - public function rangeToArray($pRange = 'A1', $nullValue = null, $calculateFormulas = true, $formatData = true, $returnCellRef = false) { - // Returnvalue - $returnValue = array(); - - // Identify the range that we need to extract from the worksheet - list($rangeStart, $rangeEnd) = PHPExcel_Cell::rangeBoundaries($pRange); - $minCol = PHPExcel_Cell::stringFromColumnIndex($rangeStart[0] -1); - $minRow = $rangeStart[1]; - $maxCol = PHPExcel_Cell::stringFromColumnIndex($rangeEnd[0] -1); - $maxRow = $rangeEnd[1]; - - $maxCol++; - - // Loop through rows - $r = -1; - for ($row = $minRow; $row <= $maxRow; ++$row) { - $rRef = ($returnCellRef) ? $row : ++$r; - $c = -1; - // Loop through columns in the current row - for ($col = $minCol; $col != $maxCol; ++$col) { - $cRef = ($returnCellRef) ? $col : ++$c; - // Using getCell() will create a new cell if it doesn't already exist. We don't want that to happen - // so we test and retrieve directly against _cellCollection - if ($this->_cellCollection->isDataSet($col.$row)) { - // Cell exists - $cell = $this->_cellCollection->getCacheData($col.$row); - if ($cell->getValue() !== null) { - if ($cell->getValue() instanceof PHPExcel_RichText) { - $returnValue[$rRef][$cRef] = $cell->getValue()->getPlainText(); - } else { - if ($calculateFormulas) { - $returnValue[$rRef][$cRef] = $cell->getCalculatedValue(); - } else { - $returnValue[$rRef][$cRef] = $cell->getValue(); - } - } - - if ($formatData) { - $style = $this->_parent->getCellXfByIndex($cell->getXfIndex()); - $returnValue[$rRef][$cRef] = PHPExcel_Style_NumberFormat::toFormattedString($returnValue[$rRef][$cRef], $style->getNumberFormat()->getFormatCode()); - } - } else { - // Cell holds a NULL - $returnValue[$rRef][$cRef] = $nullValue; - } - } else { - // Cell doesn't exist - $returnValue[$rRef][$cRef] = $nullValue; - } - } - } - - // Return - return $returnValue; - } - - - /** - * Create array from a range of cells - * - * @param string $pNamedRange Name of the Named Range - * @param mixed $nullValue Value returned in the array entry if a cell doesn't exist - * @param boolean $calculateFormulas Should formulas be calculated? - * @param boolean $formatData Should formatting be applied to cell values? - * @param boolean $returnCellRef False - Return a simple array of rows and columns indexed by number counting from zero - * True - Return rows and columns indexed by their actual row and column IDs - * @return array - * @throws Exception - */ - public function namedRangeToArray($pNamedRange = '', $nullValue = null, $calculateFormulas = true, $formatData = true, $returnCellRef = false) { - $namedRange = PHPExcel_NamedRange::resolveRange($pNamedRange, $this); - if ($namedRange !== NULL) { - $pWorkSheet = $namedRange->getWorksheet(); - $pCellRange = $namedRange->getRange(); - - return $pWorkSheet->rangeToArray( $pCellRange, - $nullValue, $calculateFormulas, $formatData, $returnCellRef); - } - - throw new Exception('Named Range '.$pNamedRange.' does not exist.'); - } - - - /** - * Create array from worksheet - * - * @param mixed $nullValue Value returned in the array entry if a cell doesn't exist - * @param boolean $calculateFormulas Should formulas be calculated? - * @param boolean $formatData Should formatting be applied to cell values? - * @param boolean $returnCellRef False - Return a simple array of rows and columns indexed by number counting from zero - * True - Return rows and columns indexed by their actual row and column IDs - * @return array - */ - public function toArray($nullValue = null, $calculateFormulas = true, $formatData = true, $returnCellRef = false) { - // Garbage collect... - $this->garbageCollect(); - - // Identify the range that we need to extract from the worksheet - $maxCol = $this->getHighestColumn(); - $maxRow = $this->getHighestRow(); - // Return - return $this->rangeToArray( 'A1:'.$maxCol.$maxRow, - $nullValue, $calculateFormulas, $formatData, $returnCellRef); - } - - /** - * Get row iterator - * - * @param integer $startRow The row number at which to start iterating - * @return PHPExcel_Worksheet_RowIterator - */ - public function getRowIterator($startRow = 1) { - return new PHPExcel_Worksheet_RowIterator($this,$startRow); - } - - /** - * Run PHPExcel garabage collector. - * - * @return PHPExcel_Worksheet - */ - public function garbageCollect() { - // Build a reference table from images -// $imageCoordinates = array(); -// $iterator = $this->getDrawingCollection()->getIterator(); -// while ($iterator->valid()) { -// $imageCoordinates[$iterator->current()->getCoordinates()] = true; -// -// $iterator->next(); -// } -// - // Lookup highest column and highest row if cells are cleaned - $colRow = $this->_cellCollection->getHighestRowAndColumn(); - $highestRow = $colRow['row']; - $highestColumn = PHPExcel_Cell::columnIndexFromString($colRow['column']); - - // Loop through column dimensions - foreach ($this->_columnDimensions as $dimension) { - $highestColumn = max($highestColumn,PHPExcel_Cell::columnIndexFromString($dimension->getColumnIndex())); - } - - // Loop through row dimensions - foreach ($this->_rowDimensions as $dimension) { - $highestRow = max($highestRow,$dimension->getRowIndex()); - } - - // Cache values - if ($highestColumn < 0) { - $this->_cachedHighestColumn = 'A'; - } else { - $this->_cachedHighestColumn = PHPExcel_Cell::stringFromColumnIndex(--$highestColumn); - } - $this->_cachedHighestRow = $highestRow; - - // Return - return $this; - } - - /** - * Get hash code - * - * @return string Hash code - */ - public function getHashCode() { - if ($this->_dirty) { - $this->_hash = md5( $this->_title . - $this->_autoFilter . - ($this->_protection->isProtectionEnabled() ? 't' : 'f') . - __CLASS__ - ); - $this->_dirty = false; - } - return $this->_hash; - } - - /** - * Extract worksheet title from range. - * - * Example: extractSheetTitle("testSheet!A1") ==> 'A1' - * Example: extractSheetTitle("'testSheet 1'!A1", true) ==> array('testSheet 1', 'A1'); - * - * @param string $pRange Range to extract title from - * @param bool $returnRange Return range? (see example) - * @return mixed - */ - public static function extractSheetTitle($pRange, $returnRange = false) { - // Sheet title included? - if (($sep = strpos($pRange, '!')) === false) { - return ''; - } - - if ($returnRange) { - return array( trim(substr($pRange, 0, $sep),"'"), - substr($pRange, $sep + 1) - ); - } - - return substr($pRange, $sep + 1); - } - - /** - * Get hyperlink - * - * @param string $pCellCoordinate Cell coordinate to get hyperlink for - */ - public function getHyperlink($pCellCoordinate = 'A1') - { - // return hyperlink if we already have one - if (isset($this->_hyperlinkCollection[$pCellCoordinate])) { - return $this->_hyperlinkCollection[$pCellCoordinate]; - } - - // else create hyperlink - $this->_hyperlinkCollection[$pCellCoordinate] = new PHPExcel_Cell_Hyperlink(); - return $this->_hyperlinkCollection[$pCellCoordinate]; - } - - /** - * Set hyperlnk - * - * @param string $pCellCoordinate Cell coordinate to insert hyperlink - * @param PHPExcel_Cell_Hyperlink $pHyperlink - * @return PHPExcel_Worksheet - */ - public function setHyperlink($pCellCoordinate = 'A1', PHPExcel_Cell_Hyperlink $pHyperlink = null) - { - if ($pHyperlink === null) { - unset($this->_hyperlinkCollection[$pCellCoordinate]); - } else { - $this->_hyperlinkCollection[$pCellCoordinate] = $pHyperlink; - } - return $this; - } - - /** - * Hyperlink at a specific coordinate exists? - * - * @param string $pCoordinate - * @return boolean - */ - public function hyperlinkExists($pCoordinate = 'A1') - { - return isset($this->_hyperlinkCollection[$pCoordinate]); - } - - /** - * Get collection of hyperlinks - * - * @return PHPExcel_Cell_Hyperlink[] - */ - public function getHyperlinkCollection() - { - return $this->_hyperlinkCollection; - } - - /** - * Get data validation - * - * @param string $pCellCoordinate Cell coordinate to get data validation for - */ - public function getDataValidation($pCellCoordinate = 'A1') - { - // return data validation if we already have one - if (isset($this->_dataValidationCollection[$pCellCoordinate])) { - return $this->_dataValidationCollection[$pCellCoordinate]; - } - - // else create data validation - $this->_dataValidationCollection[$pCellCoordinate] = new PHPExcel_Cell_DataValidation(); - return $this->_dataValidationCollection[$pCellCoordinate]; - } - - /** - * Set data validation - * - * @param string $pCellCoordinate Cell coordinate to insert data validation - * @param PHPExcel_Cell_DataValidation $pDataValidation - * @return PHPExcel_Worksheet - */ - public function setDataValidation($pCellCoordinate = 'A1', PHPExcel_Cell_DataValidation $pDataValidation = null) - { - if ($pDataValidation === null) { - unset($this->_dataValidationCollection[$pCellCoordinate]); - } else { - $this->_dataValidationCollection[$pCellCoordinate] = $pDataValidation; - } - return $this; - } - - /** - * Data validation at a specific coordinate exists? - * - * @param string $pCoordinate - * @return boolean - */ - public function dataValidationExists($pCoordinate = 'A1') - { - return isset($this->_dataValidationCollection[$pCoordinate]); - } - - /** - * Get collection of data validations - * - * @return PHPExcel_Cell_DataValidation[] - */ - public function getDataValidationCollection() - { - return $this->_dataValidationCollection; - } - - /** - * Accepts a range, returning it as a range that falls within the current highest row and column of the worksheet - * - * @param string $range - * @return string Adjusted range value - */ - public function shrinkRangeToFit($range) { - $maxCol = $this->getHighestColumn(); - $maxRow = $this->getHighestRow(); - $maxCol = PHPExcel_Cell::columnIndexFromString($maxCol); - - $rangeBlocks = explode(' ',$range); - foreach ($rangeBlocks as &$rangeSet) { - $rangeBoundaries = PHPExcel_Cell::getRangeBoundaries($rangeSet); - - if (PHPExcel_Cell::columnIndexFromString($rangeBoundaries[0][0]) > $maxCol) { $rangeBoundaries[0][0] = PHPExcel_Cell::stringFromColumnIndex($maxCol); } - if ($rangeBoundaries[0][1] > $maxRow) { $rangeBoundaries[0][1] = $maxRow; } - if (PHPExcel_Cell::columnIndexFromString($rangeBoundaries[1][0]) > $maxCol) { $rangeBoundaries[1][0] = PHPExcel_Cell::stringFromColumnIndex($maxCol); } - if ($rangeBoundaries[1][1] > $maxRow) { $rangeBoundaries[1][1] = $maxRow; } - $rangeSet = $rangeBoundaries[0][0].$rangeBoundaries[0][1].':'.$rangeBoundaries[1][0].$rangeBoundaries[1][1]; - } - unset($rangeSet); - $stRange = implode(' ',$rangeBlocks); - - return $stRange; - } - - - /** - * Get tab color - * - * @return PHPExcel_Style_Color - */ - public function getTabColor() - { - if ($this->_tabColor === NULL) - $this->_tabColor = new PHPExcel_Style_Color(); - - return $this->_tabColor; - } - - /** - * Reset tab color - * - * @return PHPExcel_Worksheet - */ - public function resetTabColor() - { - $this->_tabColor = null; - unset($this->_tabColor); - - return $this; - } - - /** - * Tab color set? - * - * @return boolean - */ - public function isTabColorSet() - { - return ($this->_tabColor !== NULL); - } - - /** - * Copy worksheet (!= clone!) - * - * @return PHPExcel_Worksheet - */ - public function copy() { - $copied = clone $this; - - return $copied; - } - - /** - * Implement PHP __clone to create a deep clone, not just a shallow copy. - */ - public function __clone() { - foreach ($this as $key => $val) { - if ($key == '_parent') { - continue; - } - - if (is_object($val) || (is_array($val))) { - if ($key == '_cellCollection') { - $newCollection = clone $this->_cellCollection; - $newCollection->copyCellCollection($this); - $this->_cellCollection = $newCollection; - } elseif ($key == '_drawingCollection') { - $newCollection = clone $this->_drawingCollection; - $this->_drawingCollection = $newCollection; - } elseif (($key == '_autoFilter') && (is_a($this->_autoFilter,'PHPExcel_Worksheet_AutoFilter'))) { - $newAutoFilter = clone $this->_autoFilter; - $this->_autoFilter = $newAutoFilter; - $this->_autoFilter->setParent($this); - } else { - $this->{$key} = unserialize(serialize($val)); - } - } - } + public function hasCodeName(){ + return !(is_null($this->_codeName)); } } diff --git a/htdocs/includes/phpexcel/PHPExcel/Worksheet/AutoFilter.php b/htdocs/includes/phpexcel/PHPExcel/Worksheet/AutoFilter.php index e6ea6f207a7..03055e10b99 100644 --- a/htdocs/includes/phpexcel/PHPExcel/Worksheet/AutoFilter.php +++ b/htdocs/includes/phpexcel/PHPExcel/Worksheet/AutoFilter.php @@ -2,7 +2,7 @@ /** * PHPExcel * - * Copyright (c) 2006 - 2012 PHPExcel + * Copyright (c) 2006 - 2014 PHPExcel * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,9 +20,9 @@ * * @category PHPExcel * @package PHPExcel_Worksheet - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version 1.7.8, 2012-10-12 + * @version 1.8.0, 2014-03-02 */ @@ -31,7 +31,7 @@ * * @category PHPExcel * @package PHPExcel_Worksheet - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) */ class PHPExcel_Worksheet_AutoFilter { @@ -61,6 +61,9 @@ class PHPExcel_Worksheet_AutoFilter /** * Create a new PHPExcel_Worksheet_AutoFilter + * + * @param string $pRange Cell range (i.e. A1:E10) + * @param PHPExcel_Worksheet $pSheet */ public function __construct($pRange = '', PHPExcel_Worksheet $pSheet = NULL) { @@ -80,7 +83,7 @@ class PHPExcel_Worksheet_AutoFilter /** * Set AutoFilter Parent Worksheet * - * @param PHPExcel_Worksheet + * @param PHPExcel_Worksheet $pSheet * @return PHPExcel_Worksheet_AutoFilter */ public function setParent(PHPExcel_Worksheet $pSheet = NULL) { @@ -243,7 +246,7 @@ class PHPExcel_Worksheet_AutoFilter /** * Clear a specified AutoFilter Column * - * @param string $pColumn Column name (e.g. A) + * @param string $pColumn Column name (e.g. A) * @throws PHPExcel_Exception * @return PHPExcel_Worksheet_AutoFilter */ @@ -347,10 +350,10 @@ class PHPExcel_Worksheet_AutoFilter * Test if cell value is within a set of values defined by a ruleset * * @param mixed $cellValue - * @param mixed[] $dataSet + * @param mixed[] $ruleSet * @return boolean */ - private static function _filterTestInCustomDataSet($cellValue,$ruleSet) + private static function _filterTestInCustomDataSet($cellValue, $ruleSet) { $dataSet = $ruleSet['filterRules']; $join = $ruleSet['join']; @@ -424,10 +427,10 @@ class PHPExcel_Worksheet_AutoFilter * Test if cell date value is matches a set of values defined by a set of months * * @param mixed $cellValue - * @param mixed[] $dataSet + * @param mixed[] $monthSet * @return boolean */ - private static function _filterTestInPeriodDateSet($cellValue,$monthSet) + private static function _filterTestInPeriodDateSet($cellValue, $monthSet) { // Blank cells are always ignored, so return a FALSE if (($cellValue == '') || ($cellValue === NULL)) { @@ -457,7 +460,7 @@ class PHPExcel_Worksheet_AutoFilter * Convert a dynamic rule daterange to a custom filter range expression for ease of calculation * * @param string $dynamicRuleType - * @param PHPExcel_Worksheet_AutoFilter_Column $filterColumn + * @param PHPExcel_Worksheet_AutoFilter_Column &$filterColumn * @return mixed[] */ private function _dynamicFilterDateRange($dynamicRuleType, &$filterColumn) @@ -725,7 +728,7 @@ class PHPExcel_Worksheet_AutoFilter // Date based if ($dynamicRuleType{0} == 'M' || $dynamicRuleType{0} == 'Q') { // Month or Quarter - list($periodType,$period) = sscanf($dynamicRuleType,'%[A-Z]%d'); + sscanf($dynamicRuleType,'%[A-Z]%d', $periodType, $period); if ($periodType == 'M') { $ruleValues = array($period); } else { @@ -826,20 +829,20 @@ class PHPExcel_Worksheet_AutoFilter if (is_object($value)) { if ($key == '_workSheet') { // Detach from worksheet - $this->$key = NULL; + $this->{$key} = NULL; } else { - $this->$key = clone $value; + $this->{$key} = clone $value; } } elseif ((is_array($value)) && ($key == '_columns')) { // The columns array of PHPExcel_Worksheet_AutoFilter objects - $this->$key = array(); + $this->{$key} = array(); foreach ($value as $k => $v) { - $this->$key[$k] = clone $v; + $this->{$key}[$k] = clone $v; // attach the new cloned Column to this new cloned Autofilter object - $this->$key[$k]->setParent($this); + $this->{$key}[$k]->setParent($this); } } else { - $this->$key = $value; + $this->{$key} = $value; } } } diff --git a/htdocs/includes/phpexcel/PHPExcel/Worksheet/AutoFilter/Column.php b/htdocs/includes/phpexcel/PHPExcel/Worksheet/AutoFilter/Column.php index bb70ec672fe..12043d5a0a1 100644 --- a/htdocs/includes/phpexcel/PHPExcel/Worksheet/AutoFilter/Column.php +++ b/htdocs/includes/phpexcel/PHPExcel/Worksheet/AutoFilter/Column.php @@ -2,7 +2,7 @@ /** * PHPExcel * - * Copyright (c) 2006 - 2012 PHPExcel + * Copyright (c) 2006 - 2014 PHPExcel * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,9 +20,9 @@ * * @category PHPExcel * @package PHPExcel_Worksheet - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version 1.7.8, 2012-10-12 + * @version 1.8.0, 2014-03-02 */ @@ -31,7 +31,7 @@ * * @category PHPExcel * @package PHPExcel_Worksheet - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) */ class PHPExcel_Worksheet_AutoFilter_Column { @@ -44,6 +44,11 @@ class PHPExcel_Worksheet_AutoFilter_Column // e.g. filtered by date = TODAY const AUTOFILTER_FILTERTYPE_TOPTENFILTER = 'top10'; + /** + * Types of autofilter rules + * + * @var string[] + */ private static $_filterTypes = array( // Currently we're not handling // colorFilter @@ -59,6 +64,11 @@ class PHPExcel_Worksheet_AutoFilter_Column const AUTOFILTER_COLUMN_JOIN_AND = 'and'; const AUTOFILTER_COLUMN_JOIN_OR = 'or'; + /** + * Join options for autofilter rules + * + * @var string[] + */ private static $_ruleJoins = array( self::AUTOFILTER_COLUMN_JOIN_AND, self::AUTOFILTER_COLUMN_JOIN_OR, @@ -114,6 +124,9 @@ class PHPExcel_Worksheet_AutoFilter_Column /** * Create a new PHPExcel_Worksheet_AutoFilter_Column + * + * @param string $pColumn Column (e.g. A) + * @param PHPExcel_Worksheet_AutoFilter $pParent Autofilter for this column */ public function __construct($pColumn, PHPExcel_Worksheet_AutoFilter $pParent = NULL) { @@ -134,7 +147,7 @@ class PHPExcel_Worksheet_AutoFilter_Column * Set AutoFilter Column Index * * @param string $pColumn Column (e.g. A) - * @throws Exception + * @throws PHPExcel_Exception * @return PHPExcel_Worksheet_AutoFilter_Column */ public function setColumnIndex($pColumn) { @@ -183,7 +196,7 @@ class PHPExcel_Worksheet_AutoFilter_Column * Set AutoFilter Type * * @param string $pFilterType - * @throws Exception + * @throws PHPExcel_Exception * @return PHPExcel_Worksheet_AutoFilter_Column */ public function setFilterType($pFilterType = self::AUTOFILTER_FILTERTYPE_FILTER) { @@ -209,7 +222,7 @@ class PHPExcel_Worksheet_AutoFilter_Column * Set AutoFilter Multiple Rules And/Or * * @param string $pJoin And/Or - * @throws Exception + * @throws PHPExcel_Exception * @return PHPExcel_Worksheet_AutoFilter_Column */ public function setJoin($pJoin = self::AUTOFILTER_COLUMN_JOIN_OR) { @@ -228,7 +241,7 @@ class PHPExcel_Worksheet_AutoFilter_Column * Set AutoFilter Attributes * * @param string[] $pAttributes - * @throws Exception + * @throws PHPExcel_Exception * @return PHPExcel_Worksheet_AutoFilter_Column */ public function setAttributes($pAttributes = array()) { @@ -242,7 +255,7 @@ class PHPExcel_Worksheet_AutoFilter_Column * * @param string $pName Attribute Name * @param string $pValue Attribute Value - * @throws Exception + * @throws PHPExcel_Exception * @return PHPExcel_Worksheet_AutoFilter_Column */ public function setAttribute($pName, $pValue) { diff --git a/htdocs/includes/phpexcel/PHPExcel/Worksheet/AutoFilter/Column/Rule.php b/htdocs/includes/phpexcel/PHPExcel/Worksheet/AutoFilter/Column/Rule.php index 209012ce180..ae33683f708 100644 --- a/htdocs/includes/phpexcel/PHPExcel/Worksheet/AutoFilter/Column/Rule.php +++ b/htdocs/includes/phpexcel/PHPExcel/Worksheet/AutoFilter/Column/Rule.php @@ -2,7 +2,7 @@ /** * PHPExcel * - * Copyright (c) 2006 - 2012 PHPExcel + * Copyright (c) 2006 - 2014 PHPExcel * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,9 +20,9 @@ * * @category PHPExcel * @package PHPExcel_Worksheet - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version 1.7.8, 2012-10-12 + * @version 1.8.0, 2014-03-02 */ @@ -31,7 +31,7 @@ * * @category PHPExcel * @package PHPExcel_Worksheet - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) */ class PHPExcel_Worksheet_AutoFilter_Column_Rule { @@ -269,6 +269,8 @@ class PHPExcel_Worksheet_AutoFilter_Column_Rule /** * Create a new PHPExcel_Worksheet_AutoFilter_Column_Rule + * + * @param PHPExcel_Worksheet_AutoFilter_Column $pParent */ public function __construct(PHPExcel_Worksheet_AutoFilter_Column $pParent = NULL) { @@ -288,7 +290,7 @@ class PHPExcel_Worksheet_AutoFilter_Column_Rule * Set AutoFilter Rule Type * * @param string $pRuleType - * @throws Exception + * @throws PHPExcel_Exception * @return PHPExcel_Worksheet_AutoFilter_Column */ public function setRuleType($pRuleType = self::AUTOFILTER_RULETYPE_FILTER) { @@ -314,7 +316,7 @@ class PHPExcel_Worksheet_AutoFilter_Column_Rule * Set AutoFilter Rule Value * * @param string|string[] $pValue - * @throws Exception + * @throws PHPExcel_Exception * @return PHPExcel_Worksheet_AutoFilter_Column_Rule */ public function setValue($pValue = '') { @@ -354,7 +356,7 @@ class PHPExcel_Worksheet_AutoFilter_Column_Rule * Set AutoFilter Rule Operator * * @param string $pOperator - * @throws Exception + * @throws PHPExcel_Exception * @return PHPExcel_Worksheet_AutoFilter_Column_Rule */ public function setOperator($pOperator = self::AUTOFILTER_COLUMN_RULE_EQUAL) { @@ -382,7 +384,7 @@ class PHPExcel_Worksheet_AutoFilter_Column_Rule * Set AutoFilter Rule Grouping * * @param string $pGrouping - * @throws Exception + * @throws PHPExcel_Exception * @return PHPExcel_Worksheet_AutoFilter_Column_Rule */ public function setGrouping($pGrouping = NULL) { @@ -404,7 +406,7 @@ class PHPExcel_Worksheet_AutoFilter_Column_Rule * @param string $pOperator * @param string|string[] $pValue * @param string $pGrouping - * @throws Exception + * @throws PHPExcel_Exception * @return PHPExcel_Worksheet_AutoFilter_Column_Rule */ public function setRule($pOperator = self::AUTOFILTER_COLUMN_RULE_EQUAL, $pValue = '', $pGrouping = NULL) { diff --git a/htdocs/includes/phpexcel/PHPExcel/Worksheet/BaseDrawing.php b/htdocs/includes/phpexcel/PHPExcel/Worksheet/BaseDrawing.php index 1e6725a38ad..4db0f8825a9 100644 --- a/htdocs/includes/phpexcel/PHPExcel/Worksheet/BaseDrawing.php +++ b/htdocs/includes/phpexcel/PHPExcel/Worksheet/BaseDrawing.php @@ -2,7 +2,7 @@ /** * PHPExcel * - * Copyright (c) 2006 - 2012 PHPExcel + * Copyright (c) 2006 - 2014 PHPExcel * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,9 +20,9 @@ * * @category PHPExcel * @package PHPExcel_Worksheet - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version 1.7.8, 2012-10-12 + * @version 1.8.0, 2014-03-02 */ @@ -31,7 +31,7 @@ * * @category PHPExcel * @package PHPExcel_Worksheet - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) */ class PHPExcel_Worksheet_BaseDrawing implements PHPExcel_IComparable { @@ -212,7 +212,7 @@ class PHPExcel_Worksheet_BaseDrawing implements PHPExcel_IComparable * * @param PHPExcel_Worksheet $pValue * @param bool $pOverrideOld If a Worksheet has already been assigned, overwrite it and remove image from old Worksheet? - * @throws Exception + * @throws PHPExcel_Exception * @return PHPExcel_Worksheet_BaseDrawing */ public function setWorksheet(PHPExcel_Worksheet $pValue = null, $pOverrideOld = false) { @@ -237,7 +237,7 @@ class PHPExcel_Worksheet_BaseDrawing implements PHPExcel_IComparable // Set new PHPExcel_Worksheet $this->setWorksheet($pValue); } else { - throw new Exception("A PHPExcel_Worksheet has already been assigned. Drawings can only exist on one PHPExcel_Worksheet."); + throw new PHPExcel_Exception("A PHPExcel_Worksheet has already been assigned. Drawings can only exist on one PHPExcel_Worksheet."); } } return $this; @@ -440,7 +440,7 @@ class PHPExcel_Worksheet_BaseDrawing implements PHPExcel_IComparable * Set Shadow * * @param PHPExcel_Worksheet_Drawing_Shadow $pValue - * @throws Exception + * @throws PHPExcel_Exception * @return PHPExcel_Worksheet_BaseDrawing */ public function setShadow(PHPExcel_Worksheet_Drawing_Shadow $pValue = null) { diff --git a/htdocs/includes/phpexcel/PHPExcel/Worksheet/CellIterator.php b/htdocs/includes/phpexcel/PHPExcel/Worksheet/CellIterator.php index a612d550c62..4b968167a8d 100644 --- a/htdocs/includes/phpexcel/PHPExcel/Worksheet/CellIterator.php +++ b/htdocs/includes/phpexcel/PHPExcel/Worksheet/CellIterator.php @@ -2,7 +2,7 @@ /** * PHPExcel * - * Copyright (c) 2006 - 2012 PHPExcel + * Copyright (c) 2006 - 2014 PHPExcel * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,9 +20,9 @@ * * @category PHPExcel * @package PHPExcel_Worksheet - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version 1.7.8, 2012-10-12 + * @version 1.8.0, 2014-03-02 */ @@ -33,7 +33,7 @@ * * @category PHPExcel * @package PHPExcel_Worksheet - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) */ class PHPExcel_Worksheet_CellIterator implements Iterator { diff --git a/htdocs/includes/phpexcel/PHPExcel/Worksheet/ColumnDimension.php b/htdocs/includes/phpexcel/PHPExcel/Worksheet/ColumnDimension.php index 0915a359961..79db1c58ffa 100644 --- a/htdocs/includes/phpexcel/PHPExcel/Worksheet/ColumnDimension.php +++ b/htdocs/includes/phpexcel/PHPExcel/Worksheet/ColumnDimension.php @@ -2,7 +2,7 @@ /** * PHPExcel * - * Copyright (c) 2006 - 2012 PHPExcel + * Copyright (c) 2006 - 2014 PHPExcel * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,9 +20,9 @@ * * @category PHPExcel * @package PHPExcel_Worksheet - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version 1.7.8, 2012-10-12 + * @version 1.8.0, 2014-03-02 */ @@ -31,7 +31,7 @@ * * @category PHPExcel * @package PHPExcel_Worksheet - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) */ class PHPExcel_Worksheet_ColumnDimension { @@ -195,12 +195,12 @@ class PHPExcel_Worksheet_ColumnDimension * Value must be between 0 and 7 * * @param int $pValue - * @throws Exception + * @throws PHPExcel_Exception * @return PHPExcel_Worksheet_ColumnDimension */ public function setOutlineLevel($pValue) { if ($pValue < 0 || $pValue > 7) { - throw new Exception("Outline level must range between 0 and 7."); + throw new PHPExcel_Exception("Outline level must range between 0 and 7."); } $this->_outlineLevel = $pValue; diff --git a/htdocs/includes/phpexcel/PHPExcel/Worksheet/Drawing.php b/htdocs/includes/phpexcel/PHPExcel/Worksheet/Drawing.php index 1d4e4b53fb0..56f0cfde13e 100644 --- a/htdocs/includes/phpexcel/PHPExcel/Worksheet/Drawing.php +++ b/htdocs/includes/phpexcel/PHPExcel/Worksheet/Drawing.php @@ -2,7 +2,7 @@ /** * PHPExcel * - * Copyright (c) 2006 - 2012 PHPExcel + * Copyright (c) 2006 - 2014 PHPExcel * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,9 +20,9 @@ * * @category PHPExcel * @package PHPExcel_Worksheet_Drawing - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version 1.7.8, 2012-10-12 + * @version 1.8.0, 2014-03-02 */ @@ -31,7 +31,7 @@ * * @category PHPExcel * @package PHPExcel_Worksheet_Drawing - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) */ class PHPExcel_Worksheet_Drawing extends PHPExcel_Worksheet_BaseDrawing implements PHPExcel_IComparable { @@ -98,7 +98,7 @@ class PHPExcel_Worksheet_Drawing extends PHPExcel_Worksheet_BaseDrawing implemen * * @param string $pValue File path * @param boolean $pVerifyFile Verify file - * @throws Exception + * @throws PHPExcel_Exception * @return PHPExcel_Worksheet_Drawing */ public function setPath($pValue = '', $pVerifyFile = true) { @@ -111,7 +111,7 @@ class PHPExcel_Worksheet_Drawing extends PHPExcel_Worksheet_BaseDrawing implemen list($this->_width, $this->_height) = getimagesize($pValue); } } else { - throw new Exception("File $pValue not found!"); + throw new PHPExcel_Exception("File $pValue not found!"); } } else { $this->_path = $pValue; diff --git a/htdocs/includes/phpexcel/PHPExcel/Worksheet/Drawing/Shadow.php b/htdocs/includes/phpexcel/PHPExcel/Worksheet/Drawing/Shadow.php index d4a53733dc3..5df448964b0 100644 --- a/htdocs/includes/phpexcel/PHPExcel/Worksheet/Drawing/Shadow.php +++ b/htdocs/includes/phpexcel/PHPExcel/Worksheet/Drawing/Shadow.php @@ -2,7 +2,7 @@ /** * PHPExcel * - * Copyright (c) 2006 - 2012 PHPExcel + * Copyright (c) 2006 - 2014 PHPExcel * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,9 +20,9 @@ * * @category PHPExcel * @package PHPExcel_Worksheet_Drawing - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version 1.7.8, 2012-10-12 + * @version 1.8.0, 2014-03-02 */ @@ -31,7 +31,7 @@ * * @category PHPExcel * @package PHPExcel_Worksheet_Drawing - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) */ class PHPExcel_Worksheet_Drawing_Shadow implements PHPExcel_IComparable { @@ -226,7 +226,7 @@ class PHPExcel_Worksheet_Drawing_Shadow implements PHPExcel_IComparable * Set Color * * @param PHPExcel_Style_Color $pValue - * @throws Exception + * @throws PHPExcel_Exception * @return PHPExcel_Worksheet_Drawing_Shadow */ public function setColor(PHPExcel_Style_Color $pValue = null) { diff --git a/htdocs/includes/phpexcel/PHPExcel/Worksheet/HeaderFooter.php b/htdocs/includes/phpexcel/PHPExcel/Worksheet/HeaderFooter.php index e2524e1f951..82d7faf6d4e 100644 --- a/htdocs/includes/phpexcel/PHPExcel/Worksheet/HeaderFooter.php +++ b/htdocs/includes/phpexcel/PHPExcel/Worksheet/HeaderFooter.php @@ -2,7 +2,7 @@ /** * PHPExcel * - * Copyright (c) 2006 - 2012 PHPExcel + * Copyright (c) 2006 - 2014 PHPExcel * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,9 +20,9 @@ * * @category PHPExcel * @package PHPExcel_Worksheet - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version 1.7.8, 2012-10-12 + * @version 1.8.0, 2014-03-02 */ @@ -91,7 +91,7 @@ * * @category PHPExcel * @package PHPExcel_Worksheet - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) */ class PHPExcel_Worksheet_HeaderFooter { @@ -392,7 +392,7 @@ class PHPExcel_Worksheet_HeaderFooter * * @param PHPExcel_Worksheet_HeaderFooterDrawing $image * @param string $location - * @throws Exception + * @throws PHPExcel_Exception * @return PHPExcel_Worksheet_HeaderFooter */ public function addImage(PHPExcel_Worksheet_HeaderFooterDrawing $image = null, $location = self::IMAGE_HEADER_LEFT) { @@ -404,7 +404,7 @@ class PHPExcel_Worksheet_HeaderFooter * Remove header/footer image * * @param string $location - * @throws Exception + * @throws PHPExcel_Exception * @return PHPExcel_Worksheet_HeaderFooter */ public function removeImage($location = self::IMAGE_HEADER_LEFT) { @@ -418,12 +418,12 @@ class PHPExcel_Worksheet_HeaderFooter * Set header/footer images * * @param PHPExcel_Worksheet_HeaderFooterDrawing[] $images - * @throws Exception + * @throws PHPExcel_Exception * @return PHPExcel_Worksheet_HeaderFooter */ public function setImages($images) { if (!is_array($images)) { - throw new Exception('Invalid parameter!'); + throw new PHPExcel_Exception('Invalid parameter!'); } $this->_headerFooterImages = $images; diff --git a/htdocs/includes/phpexcel/PHPExcel/Worksheet/HeaderFooterDrawing.php b/htdocs/includes/phpexcel/PHPExcel/Worksheet/HeaderFooterDrawing.php index 94672da4722..1c6f4e19087 100644 --- a/htdocs/includes/phpexcel/PHPExcel/Worksheet/HeaderFooterDrawing.php +++ b/htdocs/includes/phpexcel/PHPExcel/Worksheet/HeaderFooterDrawing.php @@ -2,7 +2,7 @@ /** * PHPExcel * - * Copyright (c) 2006 - 2012 PHPExcel + * Copyright (c) 2006 - 2014 PHPExcel * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,9 +20,9 @@ * * @category PHPExcel * @package PHPExcel_Worksheet - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version 1.7.8, 2012-10-12 + * @version 1.8.0, 2014-03-02 */ @@ -31,7 +31,7 @@ * * @category PHPExcel * @package PHPExcel_Worksheet - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) */ class PHPExcel_Worksheet_HeaderFooterDrawing extends PHPExcel_Worksheet_Drawing implements PHPExcel_IComparable { @@ -296,7 +296,7 @@ class PHPExcel_Worksheet_HeaderFooterDrawing extends PHPExcel_Worksheet_Drawing * * @param string $pValue File path * @param boolean $pVerifyFile Verify file - * @throws Exception + * @throws PHPExcel_Exception * @return PHPExcel_Worksheet_HeaderFooterDrawing */ public function setPath($pValue = '', $pVerifyFile = true) { @@ -309,7 +309,7 @@ class PHPExcel_Worksheet_HeaderFooterDrawing extends PHPExcel_Worksheet_Drawing list($this->_width, $this->_height) = getimagesize($pValue); } } else { - throw new Exception("File $pValue not found!"); + throw new PHPExcel_Exception("File $pValue not found!"); } } else { $this->_path = $pValue; diff --git a/htdocs/includes/phpexcel/PHPExcel/Worksheet/MemoryDrawing.php b/htdocs/includes/phpexcel/PHPExcel/Worksheet/MemoryDrawing.php index 223a29f06b0..93266d210c9 100644 --- a/htdocs/includes/phpexcel/PHPExcel/Worksheet/MemoryDrawing.php +++ b/htdocs/includes/phpexcel/PHPExcel/Worksheet/MemoryDrawing.php @@ -2,7 +2,7 @@ /** * PHPExcel * - * Copyright (c) 2006 - 2012 PHPExcel + * Copyright (c) 2006 - 2014 PHPExcel * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,9 +20,9 @@ * * @category PHPExcel * @package PHPExcel_Worksheet - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version 1.7.8, 2012-10-12 + * @version 1.8.0, 2014-03-02 */ @@ -31,7 +31,7 @@ * * @category PHPExcel * @package PHPExcel_Worksheet - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) */ class PHPExcel_Worksheet_MemoryDrawing extends PHPExcel_Worksheet_BaseDrawing implements PHPExcel_IComparable { diff --git a/htdocs/includes/phpexcel/PHPExcel/Worksheet/PageMargins.php b/htdocs/includes/phpexcel/PHPExcel/Worksheet/PageMargins.php index 7d31a5f6291..671711ff50e 100644 --- a/htdocs/includes/phpexcel/PHPExcel/Worksheet/PageMargins.php +++ b/htdocs/includes/phpexcel/PHPExcel/Worksheet/PageMargins.php @@ -2,7 +2,7 @@ /** * PHPExcel * - * Copyright (c) 2006 - 2012 PHPExcel + * Copyright (c) 2006 - 2014 PHPExcel * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,9 +20,9 @@ * * @category PHPExcel * @package PHPExcel_Worksheet - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version 1.7.8, 2012-10-12 + * @version 1.8.0, 2014-03-02 */ @@ -31,7 +31,7 @@ * * @category PHPExcel * @package PHPExcel_Worksheet - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) */ class PHPExcel_Worksheet_PageMargins { diff --git a/htdocs/includes/phpexcel/PHPExcel/Worksheet/PageSetup.php b/htdocs/includes/phpexcel/PHPExcel/Worksheet/PageSetup.php index 693f1c6a83f..9512dbe48df 100644 --- a/htdocs/includes/phpexcel/PHPExcel/Worksheet/PageSetup.php +++ b/htdocs/includes/phpexcel/PHPExcel/Worksheet/PageSetup.php @@ -2,7 +2,7 @@ /** * PHPExcel * - * Copyright (c) 2006 - 2012 PHPExcel + * Copyright (c) 2006 - 2014 PHPExcel * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,9 +20,9 @@ * * @category PHPExcel * @package PHPExcel_Worksheet - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version 1.7.8, 2012-10-12 + * @version 1.8.0, 2014-03-02 */ @@ -102,7 +102,7 @@ * * @category PHPExcel * @package PHPExcel_Worksheet - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) */ class PHPExcel_Worksheet_PageSetup { @@ -339,7 +339,7 @@ class PHPExcel_Worksheet_PageSetup * @param int? $pValue * @param boolean $pUpdate Update fitToPage so scaling applies rather than fitToHeight / fitToWidth * @return PHPExcel_Worksheet_PageSetup - * @throws Exception + * @throws PHPExcel_Exception */ public function setScale($pValue = 100, $pUpdate = true) { // Microsoft Office Excel 2007 only allows setting a scale between 10 and 400 via the user interface, @@ -350,7 +350,7 @@ class PHPExcel_Worksheet_PageSetup $this->_fitToPage = false; } } else { - throw new Exception("Scale must not be negative"); + throw new PHPExcel_Exception("Scale must not be negative"); } return $this; } @@ -568,7 +568,7 @@ class PHPExcel_Worksheet_PageSetup * Default behaviour, or a index value of 0, will return all ranges as a comma-separated string * Otherwise, the specific range identified by the value of $index will be returned * Print areas are numbered from 1 - * @throws Exception + * @throws PHPExcel_Exception * @return string */ public function getPrintArea($index = 0) { @@ -579,7 +579,7 @@ class PHPExcel_Worksheet_PageSetup if (isset($printAreas[$index-1])) { return $printAreas[$index-1]; } - throw new Exception("Requested Print Area does not exist"); + throw new PHPExcel_Exception("Requested Print Area does not exist"); } /** @@ -640,15 +640,15 @@ class PHPExcel_Worksheet_PageSetup * Default behaviour, or the "O" method, overwrites existing print area * The "I" method, inserts the new print area before any specified index, or at the end of the list * @return PHPExcel_Worksheet_PageSetup - * @throws Exception + * @throws PHPExcel_Exception */ public function setPrintArea($value, $index = 0, $method = self::SETPRINTRANGE_OVERWRITE) { if (strpos($value,'!') !== false) { - throw new Exception('Cell coordinate must not specify a worksheet.'); + throw new PHPExcel_Exception('Cell coordinate must not specify a worksheet.'); } elseif (strpos($value,':') === false) { - throw new Exception('Cell coordinate must be a range of cells.'); + throw new PHPExcel_Exception('Cell coordinate must be a range of cells.'); } elseif (strpos($value,'$') !== false) { - throw new Exception('Cell coordinate must not be absolute.'); + throw new PHPExcel_Exception('Cell coordinate must not be absolute.'); } $value = strtoupper($value); @@ -661,7 +661,7 @@ class PHPExcel_Worksheet_PageSetup $index = count($printAreas) - abs($index) + 1; } if (($index <= 0) || ($index > count($printAreas))) { - throw new Exception('Invalid index for setting print range.'); + throw new PHPExcel_Exception('Invalid index for setting print range.'); } $printAreas[$index-1] = $value; $this->_printArea = implode(',',$printAreas); @@ -675,13 +675,13 @@ class PHPExcel_Worksheet_PageSetup $index = abs($index) - 1; } if ($index > count($printAreas)) { - throw new Exception('Invalid index for setting print range.'); + throw new PHPExcel_Exception('Invalid index for setting print range.'); } $printAreas = array_merge(array_slice($printAreas,0,$index),array($value),array_slice($printAreas,$index)); $this->_printArea = implode(',',$printAreas); } } else { - throw new Exception('Invalid method for setting print range.'); + throw new PHPExcel_Exception('Invalid method for setting print range.'); } return $this; @@ -698,7 +698,7 @@ class PHPExcel_Worksheet_PageSetup * list. * Print areas are numbered from 1 * @return PHPExcel_Worksheet_PageSetup - * @throws Exception + * @throws PHPExcel_Exception */ public function addPrintArea($value, $index = -1) { return $this->setPrintArea($value, $index, self::SETPRINTRANGE_INSERT); @@ -725,7 +725,7 @@ class PHPExcel_Worksheet_PageSetup * Default behaviour, or the "O" method, overwrites existing print area * The "I" method, inserts the new print area before any specified index, or at the end of the list * @return PHPExcel_Worksheet_PageSetup - * @throws Exception + * @throws PHPExcel_Exception */ public function setPrintAreaByColumnAndRow($column1, $row1, $column2, $row2, $index = 0, $method = self::SETPRINTRANGE_OVERWRITE) { @@ -746,7 +746,7 @@ class PHPExcel_Worksheet_PageSetup * list. * Print areas are numbered from 1 * @return PHPExcel_Worksheet_PageSetup - * @throws Exception + * @throws PHPExcel_Exception */ public function addPrintAreaByColumnAndRow($column1, $row1, $column2, $row2, $index = -1) { diff --git a/htdocs/includes/phpexcel/PHPExcel/Worksheet/Protection.php b/htdocs/includes/phpexcel/PHPExcel/Worksheet/Protection.php index e7c3436f179..f41dd53a2a0 100644 --- a/htdocs/includes/phpexcel/PHPExcel/Worksheet/Protection.php +++ b/htdocs/includes/phpexcel/PHPExcel/Worksheet/Protection.php @@ -2,7 +2,7 @@ /** * PHPExcel * - * Copyright (c) 2006 - 2012 PHPExcel + * Copyright (c) 2006 - 2014 PHPExcel * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,9 +20,9 @@ * * @category PHPExcel * @package PHPExcel_Worksheet - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version 1.7.8, 2012-10-12 + * @version 1.8.0, 2014-03-02 */ @@ -31,7 +31,7 @@ * * @category PHPExcel * @package PHPExcel_Worksheet - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) */ class PHPExcel_Worksheet_Protection { diff --git a/htdocs/includes/phpexcel/PHPExcel/Worksheet/Row.php b/htdocs/includes/phpexcel/PHPExcel/Worksheet/Row.php index ba9d8530b48..2e9bd132867 100644 --- a/htdocs/includes/phpexcel/PHPExcel/Worksheet/Row.php +++ b/htdocs/includes/phpexcel/PHPExcel/Worksheet/Row.php @@ -2,7 +2,7 @@ /** * PHPExcel * - * Copyright (c) 2006 - 2012 PHPExcel + * Copyright (c) 2006 - 2014 PHPExcel * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,9 +20,9 @@ * * @category PHPExcel * @package PHPExcel_Worksheet - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version 1.7.8, 2012-10-12 + * @version 1.8.0, 2014-03-02 */ @@ -33,7 +33,7 @@ * * @category PHPExcel * @package PHPExcel_Worksheet - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) */ class PHPExcel_Worksheet_Row { diff --git a/htdocs/includes/phpexcel/PHPExcel/Worksheet/RowDimension.php b/htdocs/includes/phpexcel/PHPExcel/Worksheet/RowDimension.php index 7bacabd2378..69b7ba813eb 100644 --- a/htdocs/includes/phpexcel/PHPExcel/Worksheet/RowDimension.php +++ b/htdocs/includes/phpexcel/PHPExcel/Worksheet/RowDimension.php @@ -2,7 +2,7 @@ /** * PHPExcel * - * Copyright (c) 2006 - 2012 PHPExcel + * Copyright (c) 2006 - 2014 PHPExcel * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,9 +20,9 @@ * * @category PHPExcel * @package PHPExcel_Worksheet - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version 1.7.8, 2012-10-12 + * @version 1.8.0, 2014-03-02 */ @@ -31,7 +31,7 @@ * * @category PHPExcel * @package PHPExcel_Worksheet - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) */ class PHPExcel_Worksheet_RowDimension { @@ -195,12 +195,12 @@ class PHPExcel_Worksheet_RowDimension * Value must be between 0 and 7 * * @param int $pValue - * @throws Exception + * @throws PHPExcel_Exception * @return PHPExcel_Worksheet_RowDimension */ public function setOutlineLevel($pValue) { if ($pValue < 0 || $pValue > 7) { - throw new Exception("Outline level must range between 0 and 7."); + throw new PHPExcel_Exception("Outline level must range between 0 and 7."); } $this->_outlineLevel = $pValue; diff --git a/htdocs/includes/phpexcel/PHPExcel/Worksheet/RowIterator.php b/htdocs/includes/phpexcel/PHPExcel/Worksheet/RowIterator.php index c8e832ed72c..f2d962f5741 100644 --- a/htdocs/includes/phpexcel/PHPExcel/Worksheet/RowIterator.php +++ b/htdocs/includes/phpexcel/PHPExcel/Worksheet/RowIterator.php @@ -2,7 +2,7 @@ /** * PHPExcel * - * Copyright (c) 2006 - 2012 PHPExcel + * Copyright (c) 2006 - 2014 PHPExcel * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,9 +20,9 @@ * * @category PHPExcel * @package PHPExcel_Worksheet - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version 1.7.8, 2012-10-12 + * @version 1.8.0, 2014-03-02 */ @@ -33,7 +33,7 @@ * * @category PHPExcel * @package PHPExcel_Worksheet - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) */ class PHPExcel_Worksheet_RowIterator implements Iterator { diff --git a/htdocs/includes/phpexcel/PHPExcel/Worksheet/SheetView.php b/htdocs/includes/phpexcel/PHPExcel/Worksheet/SheetView.php index bdaf323b264..05fbf286b06 100644 --- a/htdocs/includes/phpexcel/PHPExcel/Worksheet/SheetView.php +++ b/htdocs/includes/phpexcel/PHPExcel/Worksheet/SheetView.php @@ -2,7 +2,7 @@ /** * PHPExcel * - * Copyright (c) 2006 - 2012 PHPExcel + * Copyright (c) 2006 - 2014 PHPExcel * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,9 +20,9 @@ * * @category PHPExcel * @package PHPExcel_Worksheet - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version 1.7.8, 2012-10-12 + * @version 1.8.0, 2014-03-02 */ @@ -31,7 +31,7 @@ * * @category PHPExcel * @package PHPExcel_Worksheet - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) */ class PHPExcel_Worksheet_SheetView { @@ -96,7 +96,7 @@ class PHPExcel_Worksheet_SheetView * Valid values range from 10 to 400. * * @param int $pValue - * @throws Exception + * @throws PHPExcel_Exception * @return PHPExcel_Worksheet_SheetView */ public function setZoomScale($pValue = 100) { @@ -105,7 +105,7 @@ class PHPExcel_Worksheet_SheetView if (($pValue >= 1) || is_null($pValue)) { $this->_zoomScale = $pValue; } else { - throw new Exception("Scale must be greater than or equal to 1."); + throw new PHPExcel_Exception("Scale must be greater than or equal to 1."); } return $this; } @@ -125,14 +125,14 @@ class PHPExcel_Worksheet_SheetView * Valid values range from 10 to 400. * * @param int $pValue - * @throws Exception + * @throws PHPExcel_Exception * @return PHPExcel_Worksheet_SheetView */ public function setZoomScaleNormal($pValue = 100) { if (($pValue >= 1) || is_null($pValue)) { $this->_zoomScaleNormal = $pValue; } else { - throw new Exception("Scale must be greater than or equal to 1."); + throw new PHPExcel_Exception("Scale must be greater than or equal to 1."); } return $this; } @@ -155,7 +155,7 @@ class PHPExcel_Worksheet_SheetView * 'pageBreakPreview' self::SHEETVIEW_PAGE_BREAK_PREVIEW * * @param string $pValue - * @throws Exception + * @throws PHPExcel_Exception * @return PHPExcel_Worksheet_SheetView */ public function setView($pValue = NULL) { @@ -166,7 +166,7 @@ class PHPExcel_Worksheet_SheetView if (in_array($pValue, self::$_sheetViewTypes)) { $this->_sheetviewType = $pValue; } else { - throw new Exception("Invalid sheetview layout type."); + throw new PHPExcel_Exception("Invalid sheetview layout type."); } return $this; diff --git a/htdocs/includes/phpexcel/PHPExcel/WorksheetIterator.php b/htdocs/includes/phpexcel/PHPExcel/WorksheetIterator.php index 9eff5382dd9..624b49b6208 100644 --- a/htdocs/includes/phpexcel/PHPExcel/WorksheetIterator.php +++ b/htdocs/includes/phpexcel/PHPExcel/WorksheetIterator.php @@ -2,7 +2,7 @@ /** * PHPExcel * - * Copyright (c) 2006 - 2012 PHPExcel + * Copyright (c) 2006 - 2014 PHPExcel * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,9 +20,9 @@ * * @category PHPExcel * @package PHPExcel - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version 1.7.8, 2012-10-12 + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) + * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @version 1.8.0, 2014-03-02 */ @@ -33,45 +33,48 @@ * * @category PHPExcel * @package PHPExcel - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) */ class PHPExcel_WorksheetIterator implements Iterator { - /** - * Spreadsheet to iterate - * - * @var PHPExcel - */ - private $_subject; + /** + * Spreadsheet to iterate + * + * @var PHPExcel + */ + private $_subject; - /** - * Current iterator position - * - * @var int - */ - private $_position = 0; + /** + * Current iterator position + * + * @var int + */ + private $_position = 0; - /** - * Create a new worksheet iterator - * - * @param PHPExcel $subject - */ - public function __construct(PHPExcel $subject = null) { - // Set subject - $this->_subject = $subject; - } + /** + * Create a new worksheet iterator + * + * @param PHPExcel $subject + */ + public function __construct(PHPExcel $subject = null) + { + // Set subject + $this->_subject = $subject; + } - /** - * Destructor - */ - public function __destruct() { - unset($this->_subject); - } + /** + * Destructor + */ + public function __destruct() + { + unset($this->_subject); + } - /** - * Rewind iterator - */ - public function rewind() { + /** + * Rewind iterator + */ + public function rewind() + { $this->_position = 0; } @@ -80,8 +83,9 @@ class PHPExcel_WorksheetIterator implements Iterator * * @return PHPExcel_Worksheet */ - public function current() { - return $this->_subject->getSheet($this->_position); + public function current() + { + return $this->_subject->getSheet($this->_position); } /** @@ -89,14 +93,16 @@ class PHPExcel_WorksheetIterator implements Iterator * * @return int */ - public function key() { + public function key() + { return $this->_position; } /** * Next value */ - public function next() { + public function next() + { ++$this->_position; } @@ -105,7 +111,8 @@ class PHPExcel_WorksheetIterator implements Iterator * * @return boolean */ - public function valid() { + public function valid() + { return $this->_position < $this->_subject->getSheetCount(); } } diff --git a/htdocs/includes/phpexcel/PHPExcel/Writer/Abstract.php b/htdocs/includes/phpexcel/PHPExcel/Writer/Abstract.php new file mode 100644 index 00000000000..7e09ef83a08 --- /dev/null +++ b/htdocs/includes/phpexcel/PHPExcel/Writer/Abstract.php @@ -0,0 +1,158 @@ +_includeCharts; + } + + /** + * Set write charts in workbook + * Set to true, to advise the Writer to include any charts that exist in the PHPExcel object. + * Set to false (the default) to ignore charts. + * + * @param boolean $pValue + * @return PHPExcel_Writer_IWriter + */ + public function setIncludeCharts($pValue = FALSE) { + $this->_includeCharts = (boolean) $pValue; + return $this; + } + + /** + * Get Pre-Calculate Formulas flag + * If this is true (the default), then the writer will recalculate all formulae in a workbook when saving, + * so that the pre-calculated values are immediately available to MS Excel or other office spreadsheet + * viewer when opening the file + * If false, then formulae are not calculated on save. This is faster for saving in PHPExcel, but slower + * when opening the resulting file in MS Excel, because Excel has to recalculate the formulae itself + * + * @return boolean + */ + public function getPreCalculateFormulas() { + return $this->_preCalculateFormulas; + } + + /** + * Set Pre-Calculate Formulas + * Set to true (the default) to advise the Writer to calculate all formulae on save + * Set to false to prevent precalculation of formulae on save. + * + * @param boolean $pValue Pre-Calculate Formulas? + * @return PHPExcel_Writer_IWriter + */ + public function setPreCalculateFormulas($pValue = TRUE) { + $this->_preCalculateFormulas = (boolean) $pValue; + return $this; + } + + /** + * Get use disk caching where possible? + * + * @return boolean + */ + public function getUseDiskCaching() { + return $this->_useDiskCaching; + } + + /** + * Set use disk caching where possible? + * + * @param boolean $pValue + * @param string $pDirectory Disk caching directory + * @throws PHPExcel_Writer_Exception when directory does not exist + * @return PHPExcel_Writer_Excel2007 + */ + public function setUseDiskCaching($pValue = FALSE, $pDirectory = NULL) { + $this->_useDiskCaching = $pValue; + + if ($pDirectory !== NULL) { + if (is_dir($pDirectory)) { + $this->_diskCachingDirectory = $pDirectory; + } else { + throw new PHPExcel_Writer_Exception("Directory does not exist: $pDirectory"); + } + } + return $this; + } + + /** + * Get disk caching directory + * + * @return string + */ + public function getDiskCachingDirectory() { + return $this->_diskCachingDirectory; + } +} diff --git a/htdocs/includes/phpexcel/PHPExcel/Writer/CSV.php b/htdocs/includes/phpexcel/PHPExcel/Writer/CSV.php index 11a399e3b22..521874f25ed 100644 --- a/htdocs/includes/phpexcel/PHPExcel/Writer/CSV.php +++ b/htdocs/includes/phpexcel/PHPExcel/Writer/CSV.php @@ -2,7 +2,7 @@ /** * PHPExcel * - * Copyright (c) 2006 - 2012 PHPExcel + * Copyright (c) 2006 - 2014 PHPExcel * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -19,10 +19,10 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * @category PHPExcel - * @package PHPExcel_Writer - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @package PHPExcel_Writer_CSV + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version 1.7.8, 2012-10-12 + * @version 1.8.0, 2014-03-02 */ @@ -30,10 +30,10 @@ * PHPExcel_Writer_CSV * * @category PHPExcel - * @package PHPExcel_Writer - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @package PHPExcel_Writer_CSV + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) */ -class PHPExcel_Writer_CSV implements PHPExcel_Writer_IWriter { +class PHPExcel_Writer_CSV extends PHPExcel_Writer_Abstract implements PHPExcel_Writer_IWriter { /** * PHPExcel object * @@ -69,13 +69,6 @@ class PHPExcel_Writer_CSV implements PHPExcel_Writer_IWriter { */ private $_sheetIndex = 0; - /** - * Pre-calculate formulas - * - * @var boolean - */ - private $_preCalculateFormulas = true; - /** * Whether to write a BOM (for UTF8). * @@ -103,36 +96,37 @@ class PHPExcel_Writer_CSV implements PHPExcel_Writer_IWriter { * Save PHPExcel to file * * @param string $pFilename - * @throws Exception + * @throws PHPExcel_Writer_Exception */ public function save($pFilename = null) { // Fetch sheet $sheet = $this->_phpExcel->getSheet($this->_sheetIndex); - $saveDebugLog = PHPExcel_Calculation::getInstance()->writeDebugLog; - PHPExcel_Calculation::getInstance()->writeDebugLog = false; + $saveDebugLog = PHPExcel_Calculation::getInstance($this->_phpExcel)->getDebugLog()->getWriteDebugLog(); + PHPExcel_Calculation::getInstance($this->_phpExcel)->getDebugLog()->setWriteDebugLog(FALSE); $saveArrayReturnType = PHPExcel_Calculation::getArrayReturnType(); PHPExcel_Calculation::setArrayReturnType(PHPExcel_Calculation::RETURN_ARRAY_AS_VALUE); // Open file $fileHandle = fopen($pFilename, 'wb+'); if ($fileHandle === false) { - throw new Exception("Could not open file $pFilename for writing."); + throw new PHPExcel_Writer_Exception("Could not open file $pFilename for writing."); } if ($this->_excelCompatibility) { - // Write the UTF-16LE BOM code - fwrite($fileHandle, "\xFF\xFE"); // Excel uses UTF-16LE encoding - $this->setEnclosure(); // Default enclosure is " - $this->setDelimiter("\t"); // Excel delimiter is a TAB + fwrite($fileHandle, "\xEF\xBB\xBF"); // Enforce UTF-8 BOM Header + $this->setEnclosure('"'); // Set enclosure to " + $this->setDelimiter(";"); // Set delimiter to a semi-colon + $this->setLineEnding("\r\n"); + fwrite($fileHandle, 'sep=' . $this->getDelimiter() . $this->_lineEnding); } elseif ($this->_useBOM) { - // Write the UTF-8 BOM code + // Write the UTF-8 BOM code if required fwrite($fileHandle, "\xEF\xBB\xBF"); } // Identify the range that we need to extract from the worksheet - $maxCol = $sheet->getHighestColumn(); - $maxRow = $sheet->getHighestRow(); + $maxCol = $sheet->getHighestDataColumn(); + $maxRow = $sheet->getHighestDataRow(); // Write rows to file for($row = 1; $row <= $maxRow; ++$row) { @@ -146,7 +140,7 @@ class PHPExcel_Writer_CSV implements PHPExcel_Writer_IWriter { fclose($fileHandle); PHPExcel_Calculation::setArrayReturnType($saveArrayReturnType); - PHPExcel_Calculation::getInstance()->writeDebugLog = $saveDebugLog; + PHPExcel_Calculation::getInstance($this->_phpExcel)->getDebugLog()->setWriteDebugLog($saveDebugLog); } /** @@ -278,7 +272,7 @@ class PHPExcel_Writer_CSV implements PHPExcel_Writer_IWriter { * * @param mixed $pFileHandle PHP filehandle * @param array $pValues Array containing values in a row - * @throws Exception + * @throws PHPExcel_Writer_Exception */ private function _writeLine($pFileHandle = null, $pValues = null) { if (is_array($pValues)) { @@ -307,33 +301,10 @@ class PHPExcel_Writer_CSV implements PHPExcel_Writer_IWriter { $line .= $this->_lineEnding; // Write to file - if ($this->_excelCompatibility) { - fwrite($pFileHandle, mb_convert_encoding($line,"UTF-16LE","UTF-8")); - } else { - fwrite($pFileHandle, $line); - } + fwrite($pFileHandle, $line); } else { - throw new Exception("Invalid data row passed to CSV writer."); + throw new PHPExcel_Writer_Exception("Invalid data row passed to CSV writer."); } } - /** - * Get Pre-Calculate Formulas - * - * @return boolean - */ - public function getPreCalculateFormulas() { - return $this->_preCalculateFormulas; - } - - /** - * Set Pre-Calculate Formulas - * - * @param boolean $pValue Pre-Calculate Formulas? - * @return PHPExcel_Writer_CSV - */ - public function setPreCalculateFormulas($pValue = true) { - $this->_preCalculateFormulas = $pValue; - return $this; - } } diff --git a/htdocs/includes/phpexcel/PHPExcel/Writer/Excel2007.php b/htdocs/includes/phpexcel/PHPExcel/Writer/Excel2007.php index 6a1b9887d52..a8f7593c106 100644 --- a/htdocs/includes/phpexcel/PHPExcel/Writer/Excel2007.php +++ b/htdocs/includes/phpexcel/PHPExcel/Writer/Excel2007.php @@ -2,7 +2,7 @@ /** * PHPExcel * - * Copyright (c) 2006 - 2012 PHPExcel + * Copyright (c) 2006 - 2014 PHPExcel * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,9 +20,9 @@ * * @category PHPExcel * @package PHPExcel_Writer_Excel2007 - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version 1.7.8, 2012-10-12 + * @version 1.8.0, 2014-03-02 */ @@ -30,25 +30,21 @@ * PHPExcel_Writer_Excel2007 * * @category PHPExcel - * @package PHPExcel_Writer_Excel2007 - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @package PHPExcel_Writer_2007 + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) */ -class PHPExcel_Writer_Excel2007 implements PHPExcel_Writer_IWriter +class PHPExcel_Writer_Excel2007 extends PHPExcel_Writer_Abstract implements PHPExcel_Writer_IWriter { - /** - * Write charts that are defined in the workbook? - * Identifies whether the Writer should write definitions for any charts that exist in the PHPExcel object; - * - * @var boolean - */ - private $_includeCharts = false; - /** * Pre-calculate formulas + * Forces PHPExcel to recalculate all formulae in a workbook when saving, so that the pre-calculated values are + * immediately available to MS Excel or other office spreadsheet viewer when opening the file * + * Overrides the default TRUE for this specific writer for performance reasons + * * @var boolean */ - private $_preCalculateFormulas = true; + protected $_preCalculateFormulas = FALSE; /** * Office2003 compatibility @@ -85,6 +81,13 @@ class PHPExcel_Writer_Excel2007 implements PHPExcel_Writer_IWriter */ private $_stylesConditionalHashTable; + /** + * Private unique PHPExcel_Style HashTable + * + * @var PHPExcel_HashTable + */ + private $_styleHashTable; + /** * Private unique PHPExcel_Style_Fill HashTable * @@ -120,20 +123,6 @@ class PHPExcel_Writer_Excel2007 implements PHPExcel_Writer_IWriter */ private $_drawingHashTable; - /** - * Use disk caching where possible? - * - * @var boolean - */ - private $_useDiskCaching = false; - - /** - * Disk caching directory - * - * @var string - */ - private $_diskCachingDirectory = './'; - /** * Create a new PHPExcel_Writer_Excel2007 * @@ -155,6 +144,8 @@ class PHPExcel_Writer_Excel2007 implements PHPExcel_Writer_IWriter 'drawing' => 'PHPExcel_Writer_Excel2007_Drawing', 'comments' => 'PHPExcel_Writer_Excel2007_Comments', 'chart' => 'PHPExcel_Writer_Excel2007_Chart', + 'relsvba' => 'PHPExcel_Writer_Excel2007_RelsVBA', + 'relsribbonobjects' => 'PHPExcel_Writer_Excel2007_RelsRibbon' ); // Initialise writer parts @@ -164,7 +155,8 @@ class PHPExcel_Writer_Excel2007 implements PHPExcel_Writer_IWriter } $hashTablesArray = array( '_stylesConditionalHashTable', '_fillHashTable', '_fontHashTable', - '_bordersHashTable', '_numFmtHashTable', '_drawingHashTable' + '_bordersHashTable', '_numFmtHashTable', '_drawingHashTable', + '_styleHashTable' ); // Set HashTable variables @@ -191,7 +183,7 @@ class PHPExcel_Writer_Excel2007 implements PHPExcel_Writer_IWriter * Save PHPExcel to file * * @param string $pFilename - * @throws Exception + * @throws PHPExcel_Writer_Exception */ public function save($pFilename = null) { @@ -208,8 +200,8 @@ class PHPExcel_Writer_Excel2007 implements PHPExcel_Writer_IWriter } } - $saveDebugLog = PHPExcel_Calculation::getInstance()->writeDebugLog; - PHPExcel_Calculation::getInstance()->writeDebugLog = false; + $saveDebugLog = PHPExcel_Calculation::getInstance($this->_spreadSheet)->getDebugLog()->getWriteDebugLog(); + PHPExcel_Calculation::getInstance($this->_spreadSheet)->getDebugLog()->setWriteDebugLog(FALSE); $saveDateReturnType = PHPExcel_Calculation_Functions::getReturnDateType(); PHPExcel_Calculation_Functions::setReturnDateType(PHPExcel_Calculation_Functions::RETURNDATE_EXCEL); @@ -220,6 +212,7 @@ class PHPExcel_Writer_Excel2007 implements PHPExcel_Writer_IWriter } // Create styles dictionaries + $this->_styleHashTable->addFromSource( $this->getWriterPart('Style')->allStyles($this->_spreadSheet) ); $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) ); @@ -245,13 +238,42 @@ class PHPExcel_Writer_Excel2007 implements PHPExcel_Writer_IWriter // Try opening the ZIP file if ($objZip->open($pFilename, $zipOverWrite) !== true) { if ($objZip->open($pFilename, $zipCreate) !== true) { - throw new Exception("Could not open " . $pFilename . " for writing."); + throw new PHPExcel_Writer_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, $this->_includeCharts)); + //if hasMacros, add the vbaProject.bin file, Certificate file(if exists) + if($this->_spreadSheet->hasMacros()){ + $macrosCode=$this->_spreadSheet->getMacrosCode(); + if(!is_null($macrosCode)){// we have the code ? + $objZip->addFromString('xl/vbaProject.bin', $macrosCode);//allways in 'xl', allways named vbaProject.bin + if($this->_spreadSheet->hasMacrosCertificate()){//signed macros ? + // Yes : add the certificate file and the related rels file + $objZip->addFromString('xl/vbaProjectSignature.bin', $this->_spreadSheet->getMacrosCertificate()); + $objZip->addFromString('xl/_rels/vbaProject.bin.rels', + $this->getWriterPart('RelsVBA')->writeVBARelationships($this->_spreadSheet)); + } + } + } + //a custom UI in this workbook ? add it ("base" xml and additional objects (pictures) and rels) + if($this->_spreadSheet->hasRibbon()){ + $tmpRibbonTarget=$this->_spreadSheet->getRibbonXMLData('target'); + $objZip->addFromString($tmpRibbonTarget, $this->_spreadSheet->getRibbonXMLData('data')); + if($this->_spreadSheet->hasRibbonBinObjects()){ + $tmpRootPath=dirname($tmpRibbonTarget).'/'; + $ribbonBinObjects=$this->_spreadSheet->getRibbonBinObjects('data');//the files to write + foreach($ribbonBinObjects as $aPath=>$aContent){ + $objZip->addFromString($tmpRootPath.$aPath, $aContent); + } + //the rels for files + $objZip->addFromString($tmpRootPath.'_rels/'.basename($tmpRibbonTarget).'.rels', + $this->getWriterPart('RelsRibbonObjects')->writeRibbonRelationships($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)); @@ -342,7 +364,6 @@ class PHPExcel_Writer_Excel2007 implements PHPExcel_Writer_IWriter 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); @@ -371,22 +392,22 @@ class PHPExcel_Writer_Excel2007 implements PHPExcel_Writer_IWriter } PHPExcel_Calculation_Functions::setReturnDateType($saveDateReturnType); - PHPExcel_Calculation::getInstance()->writeDebugLog = $saveDebugLog; + PHPExcel_Calculation::getInstance($this->_spreadSheet)->getDebugLog()->setWriteDebugLog($saveDebugLog); // Close file if ($objZip->close() === false) { - throw new Exception("Could not close zip file $pFilename."); + throw new PHPExcel_Writer_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."); + throw new PHPExcel_Writer_Exception("Could not copy temporary zip file $pFilename to $originalFilename."); } @unlink($pFilename); } } else { - throw new Exception("PHPExcel object unassigned."); + throw new PHPExcel_Writer_Exception("PHPExcel object unassigned."); } } @@ -394,13 +415,13 @@ class PHPExcel_Writer_Excel2007 implements PHPExcel_Writer_IWriter * Get PHPExcel object * * @return PHPExcel - * @throws Exception + * @throws PHPExcel_Writer_Exception */ public function getPHPExcel() { if ($this->_spreadSheet !== null) { return $this->_spreadSheet; } else { - throw new Exception("No PHPExcel assigned."); + throw new PHPExcel_Writer_Exception("No PHPExcel assigned."); } } @@ -408,7 +429,7 @@ class PHPExcel_Writer_Excel2007 implements PHPExcel_Writer_IWriter * Set PHPExcel object * * @param PHPExcel $pPHPExcel PHPExcel object - * @throws Exception + * @throws PHPExcel_Writer_Exception * @return PHPExcel_Writer_Excel2007 */ public function setPHPExcel(PHPExcel $pPHPExcel = null) { @@ -425,6 +446,15 @@ class PHPExcel_Writer_Excel2007 implements PHPExcel_Writer_IWriter return $this->_stringTable; } + /** + * Get PHPExcel_Style HashTable + * + * @return PHPExcel_HashTable + */ + public function getStyleHashTable() { + return $this->_styleHashTable; + } + /** * Get PHPExcel_Style_Conditional HashTable * @@ -479,49 +509,6 @@ class PHPExcel_Writer_Excel2007 implements PHPExcel_Writer_IWriter return $this->_drawingHashTable; } - /** - * Write charts in workbook? - * If this is true, then the Writer will write definitions for any charts that exist in the PHPExcel object. - * If false (the default) it will ignore any charts defined in the PHPExcel object. - * - * @return boolean - */ - public function getIncludeCharts() { - return $this->_includeCharts; - } - - /** - * Set write charts in workbook - * Set to true, to advise the Writer to include any charts that exist in the PHPExcel object. - * Set to false (the default) to ignore charts. - * - * @param boolean $pValue - * - * @return PHPExcel_Writer_Excel2007 - */ - public function setIncludeCharts($pValue = false) { - $this->_includeCharts = (boolean) $pValue; - return $this; - } - - /** - * Get Pre-Calculate Formulas - * - * @return boolean - */ - public function getPreCalculateFormulas() { - return $this->_preCalculateFormulas; - } - - /** - * Set Pre-Calculate Formulas - * - * @param boolean $pValue Pre-Calculate Formulas? - */ - public function setPreCalculateFormulas($pValue = true) { - $this->_preCalculateFormulas = $pValue; - } - /** * Get Office2003 compatibility * @@ -532,7 +519,7 @@ class PHPExcel_Writer_Excel2007 implements PHPExcel_Writer_IWriter } /** - * Set Pre-Calculate Formulas + * Set Office2003 compatibility * * @param boolean $pValue Office2003 compatibility? * @return PHPExcel_Writer_Excel2007 @@ -542,42 +529,4 @@ class PHPExcel_Writer_Excel2007 implements PHPExcel_Writer_IWriter return $this; } - /** - * Get use disk caching where possible? - * - * @return boolean - */ - public function getUseDiskCaching() { - return $this->_useDiskCaching; - } - - /** - * Set use disk caching where possible? - * - * @param boolean $pValue - * @param string $pDirectory Disk caching directory - * @throws Exception Exception when directory does not exist - * @return PHPExcel_Writer_Excel2007 - */ - public function setUseDiskCaching($pValue = false, $pDirectory = null) { - $this->_useDiskCaching = $pValue; - - if ($pDirectory !== NULL) { - if (is_dir($pDirectory)) { - $this->_diskCachingDirectory = $pDirectory; - } else { - throw new Exception("Directory does not exist: $pDirectory"); - } - } - return $this; - } - - /** - * Get disk caching directory - * - * @return string - */ - public function getDiskCachingDirectory() { - return $this->_diskCachingDirectory; - } } diff --git a/htdocs/includes/phpexcel/PHPExcel/Writer/Excel2007/Chart.php b/htdocs/includes/phpexcel/PHPExcel/Writer/Excel2007/Chart.php index d181d517b94..526daa92d94 100644 --- a/htdocs/includes/phpexcel/PHPExcel/Writer/Excel2007/Chart.php +++ b/htdocs/includes/phpexcel/PHPExcel/Writer/Excel2007/Chart.php @@ -2,7 +2,7 @@ /** * PHPExcel * - * Copyright (c) 2006 - 2012 PHPExcel + * Copyright (c) 2006 - 2014 PHPExcel * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,9 +20,9 @@ * * @category PHPExcel * @package PHPExcel_Writer_Excel2007 - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version 1.7.8, 2012-10-12 + * @version 1.8.0, 2014-03-02 */ @@ -31,7 +31,7 @@ * * @category PHPExcel * @package PHPExcel_Writer_Excel2007 - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) */ class PHPExcel_Writer_Excel2007_Chart extends PHPExcel_Writer_Excel2007_WriterPart { @@ -40,7 +40,7 @@ class PHPExcel_Writer_Excel2007_Chart extends PHPExcel_Writer_Excel2007_WriterPa * * @param PHPExcel_Chart $pChart * @return string XML Output - * @throws Exception + * @throws PHPExcel_Writer_Exception */ public function writeChart(PHPExcel_Chart $pChart = null) { @@ -120,7 +120,7 @@ class PHPExcel_Writer_Excel2007_Chart extends PHPExcel_Writer_Excel2007_WriterPa * * @param PHPExcel_Chart_Title $title * @param PHPExcel_Shared_XMLWriter $objWriter XML Writer - * @throws Exception + * @throws PHPExcel_Writer_Exception */ private function _writeTitle(PHPExcel_Chart_Title $title = null, $objWriter) { @@ -164,7 +164,7 @@ class PHPExcel_Writer_Excel2007_Chart extends PHPExcel_Writer_Excel2007_WriterPa * * @param PHPExcel_Chart_Legend $legend * @param PHPExcel_Shared_XMLWriter $objWriter XML Writer - * @throws Exception + * @throws PHPExcel_Writer_Exception */ private function _writeLegend(PHPExcel_Chart_Legend $legend = null, $objWriter) { @@ -217,7 +217,7 @@ class PHPExcel_Writer_Excel2007_Chart extends PHPExcel_Writer_Excel2007_WriterPa * @param PHPExcel_Chart_Title $xAxisLabel * @param PHPExcel_Chart_Title $yAxisLabel * @param PHPExcel_Shared_XMLWriter $objWriter XML Writer - * @throws Exception + * @throws PHPExcel_Writer_Exception */ private function _writePlotArea(PHPExcel_Chart_PlotArea $plotArea, PHPExcel_Chart_Title $xAxisLabel = NULL, @@ -230,6 +230,7 @@ class PHPExcel_Writer_Excel2007_Chart extends PHPExcel_Writer_Excel2007_WriterPa } $id1 = $id2 = 0; + $this->_seriesIndex = 0; $objWriter->startElement('c:plotArea'); $layout = $plotArea->getLayout(); @@ -298,6 +299,20 @@ class PHPExcel_Writer_Excel2007_Chart extends PHPExcel_Writer_Excel2007_WriterPa $objWriter->startElement('c:hiLowLines'); $objWriter->endElement(); + + $objWriter->startElement( 'c:upDownBars' ); + + $objWriter->startElement( 'c:gapWidth' ); + $objWriter->writeAttribute('val', 300); + $objWriter->endElement(); + + $objWriter->startElement( 'c:upBars' ); + $objWriter->endElement(); + + $objWriter->startElement( 'c:downBars' ); + $objWriter->endElement(); + + $objWriter->endElement(); } // Generate 2 unique numbers to use for axId values @@ -355,7 +370,7 @@ class PHPExcel_Writer_Excel2007_Chart extends PHPExcel_Writer_Excel2007_WriterPa * * @param PHPExcel_Shared_XMLWriter $objWriter XML Writer * @param PHPExcel_Chart_Layout $chartLayout Chart layout - * @throws Exception + * @throws PHPExcel_Writer_Exception */ private function _writeDataLbls($objWriter, $chartLayout) { @@ -410,7 +425,7 @@ class PHPExcel_Writer_Excel2007_Chart extends PHPExcel_Writer_Excel2007_WriterPa * @param string $id1 * @param string $id2 * @param boolean $isMultiLevelSeries - * @throws Exception + * @throws PHPExcel_Writer_Exception */ private function _writeCatAx($objWriter, PHPExcel_Chart_PlotArea $plotArea, $xAxisLabel, $groupType, $id1, $id2, $isMultiLevelSeries) { @@ -463,13 +478,13 @@ class PHPExcel_Writer_Excel2007_Chart extends PHPExcel_Writer_Excel2007_WriterPa $objWriter->endElement(); $objWriter->endElement(); + $layout = $xAxisLabel->getLayout(); + $this->_writeLayout($layout, $objWriter); + $objWriter->startElement('c:overlay'); $objWriter->writeAttribute('val', 0); $objWriter->endElement(); - $layout = $xAxisLabel->getLayout(); - $this->_writeLayout($layout, $objWriter); - $objWriter->endElement(); } @@ -533,7 +548,7 @@ class PHPExcel_Writer_Excel2007_Chart extends PHPExcel_Writer_Excel2007_WriterPa * @param string $id1 * @param string $id2 * @param boolean $isMultiLevelSeries - * @throws Exception + * @throws PHPExcel_Writer_Exception */ private function _writeValAx($objWriter, PHPExcel_Chart_PlotArea $plotArea, $yAxisLabel, $groupType, $id1, $id2, $isMultiLevelSeries) { @@ -589,15 +604,15 @@ class PHPExcel_Writer_Excel2007_Chart extends PHPExcel_Writer_Excel2007_WriterPa $objWriter->endElement(); $objWriter->endElement(); - $objWriter->startElement('c:overlay'); - $objWriter->writeAttribute('val', 0); - $objWriter->endElement(); - if ($groupType !== PHPExcel_Chart_DataSeries::TYPE_BUBBLECHART) { $layout = $yAxisLabel->getLayout(); $this->_writeLayout($layout, $objWriter); } + $objWriter->startElement('c:overlay'); + $objWriter->writeAttribute('val', 0); + $objWriter->endElement(); + $objWriter->endElement(); } @@ -649,7 +664,7 @@ class PHPExcel_Writer_Excel2007_Chart extends PHPExcel_Writer_Excel2007_WriterPa * * @param PHPExcel_Chart_PlotArea $plotArea * @return string|array - * @throws Exception + * @throws PHPExcel_Writer_Exception */ private static function _getChartType($plotArea) { @@ -664,7 +679,7 @@ class PHPExcel_Writer_Excel2007_Chart extends PHPExcel_Writer_Excel2007_WriterPa } $chartType = array_unique($chartTypes); if (count($chartTypes) == 0) { - throw new Exception('Chart is not yet implemented'); + throw new PHPExcel_Writer_Exception('Chart is not yet implemented'); } } @@ -681,7 +696,7 @@ class PHPExcel_Writer_Excel2007_Chart extends PHPExcel_Writer_Excel2007_WriterPa * @param boolean &$valIsMultiLevelSeries Is value set a multi-series set * @param string &$plotGroupingType Type of grouping for multi-series values * @param PHPExcel_Worksheet $pSheet - * @throws Exception + * @throws PHPExcel_Writer_Exception */ private function _writePlotGroup( $plotGroup, $groupType, @@ -737,11 +752,11 @@ class PHPExcel_Writer_Excel2007_Chart extends PHPExcel_Writer_Excel2007_WriterPa $objWriter->startElement('c:ser'); $objWriter->startElement('c:idx'); - $objWriter->writeAttribute('val', $plotSeriesIdx); + $objWriter->writeAttribute('val', $this->_seriesIndex + $plotSeriesIdx); $objWriter->endElement(); $objWriter->startElement('c:order'); - $objWriter->writeAttribute('val', $plotSeriesRef); + $objWriter->writeAttribute('val', $this->_seriesIndex + $plotSeriesRef); $objWriter->endElement(); if (($groupType == PHPExcel_Chart_DataSeries::TYPE_PIECHART) || @@ -778,10 +793,15 @@ class PHPExcel_Writer_Excel2007_Chart extends PHPExcel_Writer_Excel2007_WriterPa } // Formatting for the points - if ($groupType == PHPExcel_Chart_DataSeries::TYPE_LINECHART) { + if (($groupType == PHPExcel_Chart_DataSeries::TYPE_LINECHART) || + ($groupType == PHPExcel_Chart_DataSeries::TYPE_STOCKCHART)) { $objWriter->startElement('c:spPr'); $objWriter->startElement('a:ln'); $objWriter->writeAttribute('w', 12700); + if ($groupType == PHPExcel_Chart_DataSeries::TYPE_STOCKCHART) { + $objWriter->startElement('a:noFill'); + $objWriter->endElement(); + } $objWriter->endElement(); $objWriter->endElement(); } @@ -865,6 +885,8 @@ class PHPExcel_Writer_Excel2007_Chart extends PHPExcel_Writer_Excel2007_WriterPa $objWriter->endElement(); } + + $this->_seriesIndex += $plotSeriesIdx + 1; } /** @@ -872,7 +894,7 @@ class PHPExcel_Writer_Excel2007_Chart extends PHPExcel_Writer_Excel2007_WriterPa * * @param PHPExcel_Chart_DataSeriesValues $plotSeriesLabel * @param PHPExcel_Shared_XMLWriter $objWriter XML Writer - * @throws Exception + * @throws PHPExcel_Writer_Exception */ private function _writePlotSeriesLabel($plotSeriesLabel, $objWriter) { @@ -910,7 +932,7 @@ class PHPExcel_Writer_Excel2007_Chart extends PHPExcel_Writer_Excel2007_WriterPa * @param string $groupType Type of plot for dataseries * @param string $dataType Datatype of series values * @param PHPExcel_Worksheet $pSheet - * @throws Exception + * @throws PHPExcel_Writer_Exception */ private function _writePlotSeriesValues( $plotSeriesValues, $objWriter, @@ -1010,7 +1032,7 @@ class PHPExcel_Writer_Excel2007_Chart extends PHPExcel_Writer_Excel2007_WriterPa * * @param PHPExcel_Chart_DataSeriesValues $plotSeriesValues * @param PHPExcel_Shared_XMLWriter $objWriter XML Writer - * @throws Exception + * @throws PHPExcel_Writer_Exception */ private function _writeBubbles($plotSeriesValues, $objWriter, PHPExcel_Worksheet $pSheet) { @@ -1056,7 +1078,7 @@ class PHPExcel_Writer_Excel2007_Chart extends PHPExcel_Writer_Excel2007_WriterPa * * @param PHPExcel_Chart_Layout $layout * @param PHPExcel_Shared_XMLWriter $objWriter XML Writer - * @throws Exception + * @throws PHPExcel_Writer_Exception */ private function _writeLayout(PHPExcel_Chart_Layout $layout = NULL, $objWriter) { @@ -1124,7 +1146,7 @@ class PHPExcel_Writer_Excel2007_Chart extends PHPExcel_Writer_Excel2007_WriterPa * Write Alternate Content block * * @param PHPExcel_Shared_XMLWriter $objWriter XML Writer - * @throws Exception + * @throws PHPExcel_Writer_Exception */ private function _writeAlternateContent($objWriter) { @@ -1153,7 +1175,7 @@ class PHPExcel_Writer_Excel2007_Chart extends PHPExcel_Writer_Excel2007_WriterPa * Write Printer Settings * * @param PHPExcel_Shared_XMLWriter $objWriter XML Writer - * @throws Exception + * @throws PHPExcel_Writer_Exception */ private function _writePrintSettings($objWriter) { diff --git a/htdocs/includes/phpexcel/PHPExcel/Writer/Excel2007/Comments.php b/htdocs/includes/phpexcel/PHPExcel/Writer/Excel2007/Comments.php index ec8a2704258..436219c6e90 100644 --- a/htdocs/includes/phpexcel/PHPExcel/Writer/Excel2007/Comments.php +++ b/htdocs/includes/phpexcel/PHPExcel/Writer/Excel2007/Comments.php @@ -2,7 +2,7 @@ /** * PHPExcel * - * Copyright (c) 2006 - 2012 PHPExcel + * Copyright (c) 2006 - 2014 PHPExcel * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,9 +20,9 @@ * * @category PHPExcel * @package PHPExcel_Writer_Excel2007 - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version 1.7.8, 2012-10-12 + * @version 1.8.0, 2014-03-02 */ @@ -31,7 +31,7 @@ * * @category PHPExcel * @package PHPExcel_Writer_Excel2007 - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) */ class PHPExcel_Writer_Excel2007_Comments extends PHPExcel_Writer_Excel2007_WriterPart { @@ -40,7 +40,7 @@ class PHPExcel_Writer_Excel2007_Comments extends PHPExcel_Writer_Excel2007_Write * * @param PHPExcel_Worksheet $pWorksheet * @return string XML Output - * @throws Exception + * @throws PHPExcel_Writer_Exception */ public function writeComments(PHPExcel_Worksheet $pWorksheet = null) { @@ -98,7 +98,7 @@ class PHPExcel_Writer_Excel2007_Comments extends PHPExcel_Writer_Excel2007_Write * @param string $pCellReference Cell reference * @param PHPExcel_Comment $pComment Comment * @param array $pAuthors Array of authors - * @throws Exception + * @throws PHPExcel_Writer_Exception */ public function _writeComment(PHPExcel_Shared_XMLWriter $objWriter = null, $pCellReference = 'A1', PHPExcel_Comment $pComment = null, $pAuthors = null) { @@ -120,7 +120,7 @@ class PHPExcel_Writer_Excel2007_Comments extends PHPExcel_Writer_Excel2007_Write * * @param PHPExcel_Worksheet $pWorksheet * @return string XML Output - * @throws Exception + * @throws PHPExcel_Writer_Exception */ public function writeVMLComments(PHPExcel_Worksheet $pWorksheet = null) { @@ -193,7 +193,7 @@ class PHPExcel_Writer_Excel2007_Comments extends PHPExcel_Writer_Excel2007_Write * @param PHPExcel_Shared_XMLWriter $objWriter XML Writer * @param string $pCellReference Cell reference * @param PHPExcel_Comment $pComment Comment - * @throws Exception + * @throws PHPExcel_Writer_Exception */ public function _writeVMLComment(PHPExcel_Shared_XMLWriter $objWriter = null, $pCellReference = 'A1', PHPExcel_Comment $pComment = null) { diff --git a/htdocs/includes/phpexcel/PHPExcel/Writer/Excel2007/ContentTypes.php b/htdocs/includes/phpexcel/PHPExcel/Writer/Excel2007/ContentTypes.php index a6ee53c6d02..3c17a169271 100644 --- a/htdocs/includes/phpexcel/PHPExcel/Writer/Excel2007/ContentTypes.php +++ b/htdocs/includes/phpexcel/PHPExcel/Writer/Excel2007/ContentTypes.php @@ -2,7 +2,7 @@ /** * PHPExcel * - * Copyright (c) 2006 - 2012 PHPExcel + * Copyright (c) 2006 - 2014 PHPExcel * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,9 +20,9 @@ * * @category PHPExcel * @package PHPExcel_Writer_Excel2007 - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version 1.7.8, 2012-10-12 + * @version 1.8.0, 2014-03-02 */ @@ -31,7 +31,7 @@ * * @category PHPExcel * @package PHPExcel_Writer_Excel2007 - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) */ class PHPExcel_Writer_Excel2007_ContentTypes extends PHPExcel_Writer_Excel2007_WriterPart { @@ -41,7 +41,7 @@ class PHPExcel_Writer_Excel2007_ContentTypes extends PHPExcel_Writer_Excel2007_W * @param PHPExcel $pPHPExcel * @param boolean $includeCharts Flag indicating if we should include drawing details for charts * @return string XML Output - * @throws Exception + * @throws PHPExcel_Writer_Exception */ public function writeContentTypes(PHPExcel $pPHPExcel = null, $includeCharts = FALSE) { @@ -86,9 +86,26 @@ class PHPExcel_Writer_Excel2007_ContentTypes extends PHPExcel_Writer_Excel2007_W ); // Workbook - $this->_writeOverrideContentType( - $objWriter, '/xl/workbook.xml', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml' - ); + if($pPHPExcel->hasMacros()){ //Macros in workbook ? + // Yes : not standard content but "macroEnabled" + $this->_writeOverrideContentType( + $objWriter, '/xl/workbook.xml', 'application/vnd.ms-excel.sheet.macroEnabled.main+xml' + ); + //... and define a new type for the VBA project + $this->_writeDefaultContentType( + $objWriter, 'bin', 'application/vnd.ms-office.vbaProject' + ); + if($pPHPExcel->hasMacrosCertificate()){// signed macros ? + // Yes : add needed information + $this->_writeOverrideContentType( + $objWriter, '/xl/vbaProjectSignature.bin', 'application/vnd.ms-office.vbaProjectSignature' + ); + } + }else{// no macros in workbook, so standard type + $this->_writeOverrideContentType( + $objWriter, '/xl/workbook.xml', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml' + ); + } // DocProps $this->_writeOverrideContentType( @@ -178,7 +195,16 @@ class PHPExcel_Writer_Excel2007_ContentTypes extends PHPExcel_Writer_Excel2007_W ); } } - + if($pPHPExcel->hasRibbonBinObjects()){//Some additional objects in the ribbon ? + //we need to write "Extension" but not already write for media content + $tabRibbonTypes=array_diff($pPHPExcel->getRibbonBinObjects('types'), array_keys($aMediaContentTypes)); + foreach($tabRibbonTypes as $aRibbonType){ + $mimeType='image/.'.$aRibbonType;//we wrote $mimeType like customUI Editor + $this->_writeDefaultContentType( + $objWriter, $aRibbonType, $mimeType + ); + } + } $sheetCount = $pPHPExcel->getSheetCount(); for ($i = 0; $i < $sheetCount; ++$i) { if (count($pPHPExcel->getSheet()->getHeaderFooter()->getImages()) > 0) { @@ -205,7 +231,7 @@ class PHPExcel_Writer_Excel2007_ContentTypes extends PHPExcel_Writer_Excel2007_W * * @param string $pFile Filename * @return string Mime Type - * @throws Exception + * @throws PHPExcel_Writer_Exception */ private function _getImageMimeType($pFile = '') { @@ -213,7 +239,7 @@ class PHPExcel_Writer_Excel2007_ContentTypes extends PHPExcel_Writer_Excel2007_W $image = getimagesize($pFile); return image_type_to_mime_type($image[2]); } else { - throw new Exception("File $pFile does not exist"); + throw new PHPExcel_Writer_Exception("File $pFile does not exist"); } } @@ -223,7 +249,7 @@ class PHPExcel_Writer_Excel2007_ContentTypes extends PHPExcel_Writer_Excel2007_W * @param PHPExcel_Shared_XMLWriter $objWriter XML Writer * @param string $pPartname Part name * @param string $pContentType Content type - * @throws Exception + * @throws PHPExcel_Writer_Exception */ private function _writeDefaultContentType(PHPExcel_Shared_XMLWriter $objWriter = null, $pPartname = '', $pContentType = '') { @@ -234,7 +260,7 @@ class PHPExcel_Writer_Excel2007_ContentTypes extends PHPExcel_Writer_Excel2007_W $objWriter->writeAttribute('ContentType', $pContentType); $objWriter->endElement(); } else { - throw new Exception("Invalid parameters passed."); + throw new PHPExcel_Writer_Exception("Invalid parameters passed."); } } @@ -244,7 +270,7 @@ class PHPExcel_Writer_Excel2007_ContentTypes extends PHPExcel_Writer_Excel2007_W * @param PHPExcel_Shared_XMLWriter $objWriter XML Writer * @param string $pPartname Part name * @param string $pContentType Content type - * @throws Exception + * @throws PHPExcel_Writer_Exception */ private function _writeOverrideContentType(PHPExcel_Shared_XMLWriter $objWriter = null, $pPartname = '', $pContentType = '') { @@ -255,7 +281,7 @@ class PHPExcel_Writer_Excel2007_ContentTypes extends PHPExcel_Writer_Excel2007_W $objWriter->writeAttribute('ContentType', $pContentType); $objWriter->endElement(); } else { - throw new Exception("Invalid parameters passed."); + throw new PHPExcel_Writer_Exception("Invalid parameters passed."); } } } diff --git a/htdocs/includes/phpexcel/PHPExcel/Writer/Excel2007/DocProps.php b/htdocs/includes/phpexcel/PHPExcel/Writer/Excel2007/DocProps.php index 84dd06bc1f2..cfc308909f0 100644 --- a/htdocs/includes/phpexcel/PHPExcel/Writer/Excel2007/DocProps.php +++ b/htdocs/includes/phpexcel/PHPExcel/Writer/Excel2007/DocProps.php @@ -2,7 +2,7 @@ /** * PHPExcel * - * Copyright (c) 2006 - 2012 PHPExcel + * Copyright (c) 2006 - 2014 PHPExcel * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,9 +20,9 @@ * * @category PHPExcel * @package PHPExcel_Writer_Excel2007 - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version 1.7.8, 2012-10-12 + * @version 1.8.0, 2014-03-02 */ @@ -31,7 +31,7 @@ * * @category PHPExcel * @package PHPExcel_Writer_Excel2007 - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) */ class PHPExcel_Writer_Excel2007_DocProps extends PHPExcel_Writer_Excel2007_WriterPart { @@ -40,7 +40,7 @@ class PHPExcel_Writer_Excel2007_DocProps extends PHPExcel_Writer_Excel2007_Write * * @param PHPExcel $pPHPExcel * @return string XML Output - * @throws Exception + * @throws PHPExcel_Writer_Exception */ public function writeDocPropsApp(PHPExcel $pPHPExcel = null) { @@ -137,7 +137,7 @@ class PHPExcel_Writer_Excel2007_DocProps extends PHPExcel_Writer_Excel2007_Write * * @param PHPExcel $pPHPExcel * @return string XML Output - * @throws Exception + * @throws PHPExcel_Writer_Exception */ public function writeDocPropsCore(PHPExcel $pPHPExcel = null) { @@ -204,7 +204,7 @@ class PHPExcel_Writer_Excel2007_DocProps extends PHPExcel_Writer_Excel2007_Write * * @param PHPExcel $pPHPExcel * @return string XML Output - * @throws Exception + * @throws PHPExcel_Writer_Exception */ public function writeDocPropsCustom(PHPExcel $pPHPExcel = null) { diff --git a/htdocs/includes/phpexcel/PHPExcel/Writer/Excel2007/Drawing.php b/htdocs/includes/phpexcel/PHPExcel/Writer/Excel2007/Drawing.php index 9b618c56301..3c52723a41c 100644 --- a/htdocs/includes/phpexcel/PHPExcel/Writer/Excel2007/Drawing.php +++ b/htdocs/includes/phpexcel/PHPExcel/Writer/Excel2007/Drawing.php @@ -2,7 +2,7 @@ /** * PHPExcel * - * Copyright (c) 2006 - 2012 PHPExcel + * Copyright (c) 2006 - 2014 PHPExcel * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,9 +20,9 @@ * * @category PHPExcel * @package PHPExcel_Writer_Excel2007 - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version 1.7.8, 2012-10-12 + * @version 1.8.0, 2014-03-02 */ @@ -31,7 +31,7 @@ * * @category PHPExcel * @package PHPExcel_Writer_Excel2007 - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) */ class PHPExcel_Writer_Excel2007_Drawing extends PHPExcel_Writer_Excel2007_WriterPart { @@ -42,7 +42,7 @@ class PHPExcel_Writer_Excel2007_Drawing extends PHPExcel_Writer_Excel2007_Writer * @param int &$chartRef Chart ID * @param boolean $includeCharts Flag indicating if we should include drawing details for charts * @return string XML Output - * @throws Exception + * @throws PHPExcel_Writer_Exception */ public function writeDrawings(PHPExcel_Worksheet $pWorksheet = null, &$chartRef, $includeCharts = FALSE) { @@ -95,7 +95,7 @@ class PHPExcel_Writer_Excel2007_Drawing extends PHPExcel_Writer_Excel2007_Writer * @param PHPExcel_Shared_XMLWriter $objWriter XML Writer * @param PHPExcel_Chart $pChart * @param int $pRelationId - * @throws Exception + * @throws PHPExcel_Writer_Exception */ public function _writeChart(PHPExcel_Shared_XMLWriter $objWriter = null, PHPExcel_Chart $pChart = null, $pRelationId = -1) { @@ -167,7 +167,7 @@ class PHPExcel_Writer_Excel2007_Drawing extends PHPExcel_Writer_Excel2007_Writer * @param PHPExcel_Shared_XMLWriter $objWriter XML Writer * @param PHPExcel_Worksheet_BaseDrawing $pDrawing * @param int $pRelationId - * @throws Exception + * @throws PHPExcel_Writer_Exception */ public function _writeDrawing(PHPExcel_Shared_XMLWriter $objWriter = null, PHPExcel_Worksheet_BaseDrawing $pDrawing = null, $pRelationId = -1) { @@ -375,7 +375,7 @@ class PHPExcel_Writer_Excel2007_Drawing extends PHPExcel_Writer_Excel2007_Writer $objWriter->endElement(); } else { - throw new Exception("Invalid parameters passed."); + throw new PHPExcel_Writer_Exception("Invalid parameters passed."); } } @@ -384,7 +384,7 @@ class PHPExcel_Writer_Excel2007_Drawing extends PHPExcel_Writer_Excel2007_Writer * * @param PHPExcel_Worksheet $pWorksheet * @return string XML Output - * @throws Exception + * @throws PHPExcel_Writer_Exception */ public function writeVMLHeaderFooterImages(PHPExcel_Worksheet $pWorksheet = null) { @@ -532,7 +532,7 @@ class PHPExcel_Writer_Excel2007_Drawing extends PHPExcel_Writer_Excel2007_Writer * @param PHPExcel_Shared_XMLWriter $objWriter XML Writer * @param string $pReference Reference * @param PHPExcel_Worksheet_HeaderFooterDrawing $pImage Image - * @throws Exception + * @throws PHPExcel_Writer_Exception */ public function _writeVMLHeaderFooterImage(PHPExcel_Shared_XMLWriter $objWriter = null, $pReference = '', PHPExcel_Worksheet_HeaderFooterDrawing $pImage = null) { @@ -574,7 +574,7 @@ class PHPExcel_Writer_Excel2007_Drawing extends PHPExcel_Writer_Excel2007_Writer * * @param PHPExcel $pPHPExcel * @return PHPExcel_Worksheet_Drawing[] All drawings in PHPExcel - * @throws Exception + * @throws PHPExcel_Writer_Exception */ public function allDrawings(PHPExcel $pPHPExcel = null) { diff --git a/htdocs/includes/phpexcel/PHPExcel/Writer/Excel2007/Rels.php b/htdocs/includes/phpexcel/PHPExcel/Writer/Excel2007/Rels.php index ff550a673db..0bdb667c991 100644 --- a/htdocs/includes/phpexcel/PHPExcel/Writer/Excel2007/Rels.php +++ b/htdocs/includes/phpexcel/PHPExcel/Writer/Excel2007/Rels.php @@ -2,7 +2,7 @@ /** * PHPExcel * - * Copyright (c) 2006 - 2012 PHPExcel + * Copyright (c) 2006 - 2014 PHPExcel * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,9 +20,9 @@ * * @category PHPExcel * @package PHPExcel_Writer_Excel2007 - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version 1.7.8, 2012-10-12 + * @version 1.8.0, 2014-03-02 */ @@ -31,7 +31,7 @@ * * @category PHPExcel * @package PHPExcel_Writer_Excel2007 - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) */ class PHPExcel_Writer_Excel2007_Rels extends PHPExcel_Writer_Excel2007_WriterPart { @@ -40,7 +40,7 @@ class PHPExcel_Writer_Excel2007_Rels extends PHPExcel_Writer_Excel2007_WriterPar * * @param PHPExcel $pPHPExcel * @return string XML Output - * @throws Exception + * @throws PHPExcel_Writer_Exception */ public function writeRelationships(PHPExcel $pPHPExcel = null) { @@ -94,6 +94,15 @@ class PHPExcel_Writer_Excel2007_Rels extends PHPExcel_Writer_Excel2007_WriterPar 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument', 'xl/workbook.xml' ); + // a custom UI in workbook ? + if($pPHPExcel->hasRibbon()){ + $this->_writeRelationShip( + $objWriter, + 5, + 'http://schemas.microsoft.com/office/2006/relationships/ui/extensibility', + $pPHPExcel->getRibbonXMLData('target') + ); + } $objWriter->endElement(); @@ -106,7 +115,7 @@ class PHPExcel_Writer_Excel2007_Rels extends PHPExcel_Writer_Excel2007_WriterPar * * @param PHPExcel $pPHPExcel * @return string XML Output - * @throws Exception + * @throws PHPExcel_Writer_Exception */ public function writeWorkbookRelationships(PHPExcel $pPHPExcel = null) { @@ -159,6 +168,17 @@ class PHPExcel_Writer_Excel2007_Rels extends PHPExcel_Writer_Excel2007_WriterPar 'worksheets/sheet' . ($i + 1) . '.xml' ); } + // Relationships for vbaProject if needed + // id : just after the last sheet + if($pPHPExcel->hasMacros()){ + $this->_writeRelationShip( + $objWriter, + ($i + 1 + 3), + 'http://schemas.microsoft.com/office/2006/relationships/vbaProject', + 'vbaProject.bin' + ); + ++$i;//increment i if needed for an another relation + } $objWriter->endElement(); @@ -177,7 +197,7 @@ class PHPExcel_Writer_Excel2007_Rels extends PHPExcel_Writer_Excel2007_WriterPar * @param int $pWorksheetId * @param boolean $includeCharts Flag indicating if we should write charts * @return string XML Output - * @throws Exception + * @throws PHPExcel_Writer_Exception */ public function writeWorksheetRelationships(PHPExcel_Worksheet $pWorksheet = null, $pWorksheetId = 1, $includeCharts = FALSE) { @@ -286,7 +306,7 @@ class PHPExcel_Writer_Excel2007_Rels extends PHPExcel_Writer_Excel2007_WriterPar * @param int &$chartRef Chart ID * @param boolean $includeCharts Flag indicating if we should write charts * @return string XML Output - * @throws Exception + * @throws PHPExcel_Writer_Exception */ public function writeDrawingRelationships(PHPExcel_Worksheet $pWorksheet = null, &$chartRef, $includeCharts = FALSE) { @@ -350,7 +370,7 @@ class PHPExcel_Writer_Excel2007_Rels extends PHPExcel_Writer_Excel2007_WriterPar * * @param PHPExcel_Worksheet $pWorksheet * @return string XML Output - * @throws Exception + * @throws PHPExcel_Writer_Exception */ public function writeHeaderFooterDrawingRelationships(PHPExcel_Worksheet $pWorksheet = null) { @@ -394,7 +414,7 @@ class PHPExcel_Writer_Excel2007_Rels extends PHPExcel_Writer_Excel2007_WriterPar * @param string $pType Relationship type * @param string $pTarget Relationship target * @param string $pTargetMode Relationship target mode - * @throws Exception + * @throws PHPExcel_Writer_Exception */ private function _writeRelationship(PHPExcel_Shared_XMLWriter $objWriter = null, $pId = 1, $pType = '', $pTarget = '', $pTargetMode = '') { @@ -411,7 +431,7 @@ class PHPExcel_Writer_Excel2007_Rels extends PHPExcel_Writer_Excel2007_WriterPar $objWriter->endElement(); } else { - throw new Exception("Invalid parameters passed."); + throw new PHPExcel_Writer_Exception("Invalid parameters passed."); } } } diff --git a/htdocs/includes/phpexcel/PHPExcel/Writer/Excel2007/RelsRibbon.php b/htdocs/includes/phpexcel/PHPExcel/Writer/Excel2007/RelsRibbon.php new file mode 100644 index 00000000000..f924a1d43d1 --- /dev/null +++ b/htdocs/includes/phpexcel/PHPExcel/Writer/Excel2007/RelsRibbon.php @@ -0,0 +1,77 @@ +getParentWriter()->getUseDiskCaching()) { + $objWriter = new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); + } else { + $objWriter = new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_MEMORY); + } + + // XML header + $objWriter->startDocument('1.0','UTF-8','yes'); + + // Relationships + $objWriter->startElement('Relationships'); + $objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships'); + $localRels=$pPHPExcel->getRibbonBinObjects('names'); + if(is_array($localRels)){ + foreach($localRels as $aId=>$aTarget){ + $objWriter->startElement('Relationship'); + $objWriter->writeAttribute('Id', $aId); + $objWriter->writeAttribute('Type', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/image'); + $objWriter->writeAttribute('Target', $aTarget); + $objWriter->endElement();//Relationship + } + } + $objWriter->endElement();//Relationships + + // Return + return $objWriter->getData(); + + } + +} diff --git a/htdocs/includes/phpexcel/PHPExcel/Writer/Excel2007/RelsVBA.php b/htdocs/includes/phpexcel/PHPExcel/Writer/Excel2007/RelsVBA.php new file mode 100644 index 00000000000..aecb0b8da3b --- /dev/null +++ b/htdocs/includes/phpexcel/PHPExcel/Writer/Excel2007/RelsVBA.php @@ -0,0 +1,72 @@ +getParentWriter()->getUseDiskCaching()) { + $objWriter = new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); + } else { + $objWriter = new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_MEMORY); + } + + // XML header + $objWriter->startDocument('1.0','UTF-8','yes'); + + // Relationships + $objWriter->startElement('Relationships'); + $objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships'); + $objWriter->startElement('Relationship'); + $objWriter->writeAttribute('Id', 'rId1'); + $objWriter->writeAttribute('Type', 'http://schemas.microsoft.com/office/2006/relationships/vbaProjectSignature'); + $objWriter->writeAttribute('Target', 'vbaProjectSignature.bin'); + $objWriter->endElement();//Relationship + $objWriter->endElement();//Relationships + + // Return + return $objWriter->getData(); + + } + +} diff --git a/htdocs/includes/phpexcel/PHPExcel/Writer/Excel2007/StringTable.php b/htdocs/includes/phpexcel/PHPExcel/Writer/Excel2007/StringTable.php index e9fb6600cd8..0e8a259b1b9 100644 --- a/htdocs/includes/phpexcel/PHPExcel/Writer/Excel2007/StringTable.php +++ b/htdocs/includes/phpexcel/PHPExcel/Writer/Excel2007/StringTable.php @@ -2,7 +2,7 @@ /** * PHPExcel * - * Copyright (c) 2006 - 2012 PHPExcel + * Copyright (c) 2006 - 2014 PHPExcel * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,9 +20,9 @@ * * @category PHPExcel * @package PHPExcel_Writer_Excel2007 - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version 1.7.8, 2012-10-12 + * @version 1.8.0, 2014-03-02 */ @@ -31,7 +31,7 @@ * * @category PHPExcel * @package PHPExcel_Writer_Excel2007 - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) */ class PHPExcel_Writer_Excel2007_StringTable extends PHPExcel_Writer_Excel2007_WriterPart { @@ -41,7 +41,7 @@ class PHPExcel_Writer_Excel2007_StringTable extends PHPExcel_Writer_Excel2007_Wr * @param PHPExcel_Worksheet $pSheet Worksheet * @param string[] $pExistingTable Existing table to eventually merge with * @return string[] String table for worksheet - * @throws Exception + * @throws PHPExcel_Writer_Exception */ public function createStringTable($pSheet = null, $pExistingTable = null) { @@ -81,7 +81,7 @@ class PHPExcel_Writer_Excel2007_StringTable extends PHPExcel_Writer_Excel2007_Wr // Return return $aStringTable; } else { - throw new Exception("Invalid PHPExcel_Worksheet object passed."); + throw new PHPExcel_Writer_Exception("Invalid PHPExcel_Worksheet object passed."); } } @@ -90,7 +90,7 @@ class PHPExcel_Writer_Excel2007_StringTable extends PHPExcel_Writer_Excel2007_Wr * * @param string[] $pStringTable * @return string XML Output - * @throws Exception + * @throws PHPExcel_Writer_Exception */ public function writeStringTable($pStringTable = null) { @@ -135,7 +135,7 @@ class PHPExcel_Writer_Excel2007_StringTable extends PHPExcel_Writer_Excel2007_Wr // Return return $objWriter->getData(); } else { - throw new Exception("Invalid string table array passed."); + throw new PHPExcel_Writer_Exception("Invalid string table array passed."); } } @@ -145,7 +145,7 @@ class PHPExcel_Writer_Excel2007_StringTable extends PHPExcel_Writer_Excel2007_Wr * @param PHPExcel_Shared_XMLWriter $objWriter XML Writer * @param PHPExcel_RichText $pRichText Rich text * @param string $prefix Optional Namespace prefix - * @throws Exception + * @throws PHPExcel_Writer_Exception */ public function writeRichText(PHPExcel_Shared_XMLWriter $objWriter = null, PHPExcel_RichText $pRichText = null, $prefix=NULL) { @@ -227,7 +227,7 @@ class PHPExcel_Writer_Excel2007_StringTable extends PHPExcel_Writer_Excel2007_Wr * @param PHPExcel_Shared_XMLWriter $objWriter XML Writer * @param string|PHPExcel_RichText $pRichText text string or Rich text * @param string $prefix Optional Namespace prefix - * @throws Exception + * @throws PHPExcel_Writer_Exception */ public function writeRichTextForCharts(PHPExcel_Shared_XMLWriter $objWriter = null, $pRichText = null, $prefix=NULL) { diff --git a/htdocs/includes/phpexcel/PHPExcel/Writer/Excel2007/Style.php b/htdocs/includes/phpexcel/PHPExcel/Writer/Excel2007/Style.php index b24deba9a67..849ad127f58 100644 --- a/htdocs/includes/phpexcel/PHPExcel/Writer/Excel2007/Style.php +++ b/htdocs/includes/phpexcel/PHPExcel/Writer/Excel2007/Style.php @@ -2,7 +2,7 @@ /** * PHPExcel * - * Copyright (c) 2006 - 2012 PHPExcel + * Copyright (c) 2006 - 2014 PHPExcel * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,9 +20,9 @@ * * @category PHPExcel * @package PHPExcel_Writer_Excel2007 - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version 1.7.8, 2012-10-12 + * @version 1.8.0, 2014-03-02 */ @@ -31,7 +31,7 @@ * * @category PHPExcel * @package PHPExcel_Writer_Excel2007 - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) */ class PHPExcel_Writer_Excel2007_Style extends PHPExcel_Writer_Excel2007_WriterPart { @@ -40,7 +40,7 @@ class PHPExcel_Writer_Excel2007_Style extends PHPExcel_Writer_Excel2007_WriterPa * * @param PHPExcel $pPHPExcel * @return string XML Output - * @throws Exception + * @throws PHPExcel_Writer_Exception */ public function writeStyles(PHPExcel $pPHPExcel = null) { @@ -170,7 +170,7 @@ class PHPExcel_Writer_Excel2007_Style extends PHPExcel_Writer_Excel2007_WriterPa * * @param PHPExcel_Shared_XMLWriter $objWriter XML Writer * @param PHPExcel_Style_Fill $pFill Fill style - * @throws Exception + * @throws PHPExcel_Writer_Exception */ private function _writeFill(PHPExcel_Shared_XMLWriter $objWriter = null, PHPExcel_Style_Fill $pFill = null) { @@ -190,7 +190,7 @@ class PHPExcel_Writer_Excel2007_Style extends PHPExcel_Writer_Excel2007_WriterPa * * @param PHPExcel_Shared_XMLWriter $objWriter XML Writer * @param PHPExcel_Style_Fill $pFill Fill style - * @throws Exception + * @throws PHPExcel_Writer_Exception */ private function _writeGradientFill(PHPExcel_Shared_XMLWriter $objWriter = null, PHPExcel_Style_Fill $pFill = null) { @@ -234,7 +234,7 @@ class PHPExcel_Writer_Excel2007_Style extends PHPExcel_Writer_Excel2007_WriterPa * * @param PHPExcel_Shared_XMLWriter $objWriter XML Writer * @param PHPExcel_Style_Fill $pFill Fill style - * @throws Exception + * @throws PHPExcel_Writer_Exception */ private function _writePatternFill(PHPExcel_Shared_XMLWriter $objWriter = null, PHPExcel_Style_Fill $pFill = null) { @@ -272,7 +272,7 @@ class PHPExcel_Writer_Excel2007_Style extends PHPExcel_Writer_Excel2007_WriterPa * * @param PHPExcel_Shared_XMLWriter $objWriter XML Writer * @param PHPExcel_Style_Font $pFont Font style - * @throws Exception + * @throws PHPExcel_Writer_Exception */ private function _writeFont(PHPExcel_Shared_XMLWriter $objWriter = null, PHPExcel_Style_Font $pFont = null) { @@ -352,7 +352,7 @@ class PHPExcel_Writer_Excel2007_Style extends PHPExcel_Writer_Excel2007_WriterPa * * @param PHPExcel_Shared_XMLWriter $objWriter XML Writer * @param PHPExcel_Style_Borders $pBorders Borders style - * @throws Exception + * @throws PHPExcel_Writer_Exception */ private function _writeBorder(PHPExcel_Shared_XMLWriter $objWriter = null, PHPExcel_Style_Borders $pBorders = null) { @@ -389,7 +389,7 @@ class PHPExcel_Writer_Excel2007_Style extends PHPExcel_Writer_Excel2007_WriterPa * @param PHPExcel_Shared_XMLWriter $objWriter XML Writer * @param PHPExcel_Style $pStyle Style * @param PHPExcel $pPHPExcel Workbook - * @throws Exception + * @throws PHPExcel_Writer_Exception */ private function _writeCellStyleXf(PHPExcel_Shared_XMLWriter $objWriter = null, PHPExcel_Style $pStyle = null, PHPExcel $pPHPExcel = null) { @@ -397,6 +397,9 @@ class PHPExcel_Writer_Excel2007_Style extends PHPExcel_Writer_Excel2007_WriterPa $objWriter->startElement('xf'); $objWriter->writeAttribute('xfId', 0); $objWriter->writeAttribute('fontId', (int)$this->getParentWriter()->getFontHashTable()->getIndexForHashCode($pStyle->getFont()->getHashCode())); + if ($pStyle->getQuotePrefix()) { + $objWriter->writeAttribute('quotePrefix', 1); + } if ($pStyle->getNumberFormat()->getBuiltInFormatCode() === false) { $objWriter->writeAttribute('numFmtId', (int)($this->getParentWriter()->getNumFmtHashTable()->getIndexForHashCode($pStyle->getNumberFormat()->getHashCode()) + 164) ); @@ -458,7 +461,7 @@ class PHPExcel_Writer_Excel2007_Style extends PHPExcel_Writer_Excel2007_WriterPa * * @param PHPExcel_Shared_XMLWriter $objWriter XML Writer * @param PHPExcel_Style $pStyle Style - * @throws Exception + * @throws PHPExcel_Writer_Exception */ private function _writeCellStyleDxf(PHPExcel_Shared_XMLWriter $objWriter = null, PHPExcel_Style $pStyle = null) { @@ -524,7 +527,7 @@ class PHPExcel_Writer_Excel2007_Style extends PHPExcel_Writer_Excel2007_WriterPa * @param PHPExcel_Shared_XMLWriter $objWriter XML Writer * @param string $pName Element name * @param PHPExcel_Style_Border $pBorder Border style - * @throws Exception + * @throws PHPExcel_Writer_Exception */ private function _writeBorderPr(PHPExcel_Shared_XMLWriter $objWriter = null, $pName = 'left', PHPExcel_Style_Border $pBorder = null) { @@ -548,7 +551,7 @@ class PHPExcel_Writer_Excel2007_Style extends PHPExcel_Writer_Excel2007_WriterPa * @param PHPExcel_Shared_XMLWriter $objWriter XML Writer * @param PHPExcel_Style_NumberFormat $pNumberFormat Number Format * @param int $pId Number Format identifier - * @throws Exception + * @throws PHPExcel_Writer_Exception */ private function _writeNumFmt(PHPExcel_Shared_XMLWriter $objWriter = null, PHPExcel_Style_NumberFormat $pNumberFormat = null, $pId = 0) { @@ -569,7 +572,7 @@ class PHPExcel_Writer_Excel2007_Style extends PHPExcel_Writer_Excel2007_WriterPa * * @param PHPExcel $pPHPExcel * @return PHPExcel_Style[] All styles in PHPExcel - * @throws Exception + * @throws PHPExcel_Writer_Exception */ public function allStyles(PHPExcel $pPHPExcel = null) { @@ -583,7 +586,7 @@ class PHPExcel_Writer_Excel2007_Style extends PHPExcel_Writer_Excel2007_WriterPa * * @param PHPExcel $pPHPExcel * @return PHPExcel_Style_Conditional[] All conditional styles in PHPExcel - * @throws Exception + * @throws PHPExcel_Writer_Exception */ public function allConditionalStyles(PHPExcel $pPHPExcel = null) { @@ -607,7 +610,7 @@ class PHPExcel_Writer_Excel2007_Style extends PHPExcel_Writer_Excel2007_WriterPa * * @param PHPExcel $pPHPExcel * @return PHPExcel_Style_Fill[] All fills in PHPExcel - * @throws Exception + * @throws PHPExcel_Writer_Exception */ public function allFills(PHPExcel $pPHPExcel = null) { @@ -638,7 +641,7 @@ class PHPExcel_Writer_Excel2007_Style extends PHPExcel_Writer_Excel2007_WriterPa * * @param PHPExcel $pPHPExcel * @return PHPExcel_Style_Font[] All fonts in PHPExcel - * @throws Exception + * @throws PHPExcel_Writer_Exception */ public function allFonts(PHPExcel $pPHPExcel = null) { @@ -660,7 +663,7 @@ class PHPExcel_Writer_Excel2007_Style extends PHPExcel_Writer_Excel2007_WriterPa * * @param PHPExcel $pPHPExcel * @return PHPExcel_Style_Borders[] All borders in PHPExcel - * @throws Exception + * @throws PHPExcel_Writer_Exception */ public function allBorders(PHPExcel $pPHPExcel = null) { @@ -682,7 +685,7 @@ class PHPExcel_Writer_Excel2007_Style extends PHPExcel_Writer_Excel2007_WriterPa * * @param PHPExcel $pPHPExcel * @return PHPExcel_Style_NumberFormat[] All number formats in PHPExcel - * @throws Exception + * @throws PHPExcel_Writer_Exception */ public function allNumberFormats(PHPExcel $pPHPExcel = null) { diff --git a/htdocs/includes/phpexcel/PHPExcel/Writer/Excel2007/Theme.php b/htdocs/includes/phpexcel/PHPExcel/Writer/Excel2007/Theme.php index e067efe357e..064c3edcb7a 100644 --- a/htdocs/includes/phpexcel/PHPExcel/Writer/Excel2007/Theme.php +++ b/htdocs/includes/phpexcel/PHPExcel/Writer/Excel2007/Theme.php @@ -2,7 +2,7 @@ /** * PHPExcel * - * Copyright (c) 2006 - 2012 PHPExcel + * Copyright (c) 2006 - 2014 PHPExcel * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,18 +20,18 @@ * * @category PHPExcel * @package PHPExcel_Writer_Excel2007 - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version 1.7.8, 2012-10-12 + * @version 1.8.0, 2014-03-02 */ /** - * PHPExcel_Writer_Excel2007_DocProps + * PHPExcel_Writer_Excel2007_Theme * * @category PHPExcel * @package PHPExcel_Writer_Excel2007 - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) */ class PHPExcel_Writer_Excel2007_Theme extends PHPExcel_Writer_Excel2007_WriterPart { @@ -134,7 +134,7 @@ class PHPExcel_Writer_Excel2007_Theme extends PHPExcel_Writer_Excel2007_WriterPa * * @param PHPExcel $pPHPExcel * @return string XML Output - * @throws Exception + * @throws PHPExcel_Writer_Exception */ public function writeTheme(PHPExcel $pPHPExcel = null) { @@ -820,7 +820,7 @@ class PHPExcel_Writer_Excel2007_Theme extends PHPExcel_Writer_Excel2007_WriterPa * @param string $latinFont * @param array of string $fontSet * @return string XML Output - * @throws Exception + * @throws PHPExcel_Writer_Exception */ private function _writeFonts($objWriter, $latinFont, $fontSet) { @@ -853,7 +853,7 @@ class PHPExcel_Writer_Excel2007_Theme extends PHPExcel_Writer_Excel2007_WriterPa * * @param PHPExcel_Shared_XMLWriter $objWriter * @return string XML Output - * @throws Exception + * @throws PHPExcel_Writer_Exception */ private function _writeColourScheme($objWriter) { diff --git a/htdocs/includes/phpexcel/PHPExcel/Writer/Excel2007/Workbook.php b/htdocs/includes/phpexcel/PHPExcel/Writer/Excel2007/Workbook.php index bbd2f927e9e..d1fe666e84f 100644 --- a/htdocs/includes/phpexcel/PHPExcel/Writer/Excel2007/Workbook.php +++ b/htdocs/includes/phpexcel/PHPExcel/Writer/Excel2007/Workbook.php @@ -2,7 +2,7 @@ /** * PHPExcel * - * Copyright (c) 2006 - 2012 PHPExcel + * Copyright (c) 2006 - 2014 PHPExcel * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,9 +20,9 @@ * * @category PHPExcel * @package PHPExcel_Writer_Excel2007 - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version 1.7.8, 2012-10-12 + * @version 1.8.0, 2014-03-02 */ @@ -31,7 +31,7 @@ * * @category PHPExcel * @package PHPExcel_Writer_Excel2007 - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) */ class PHPExcel_Writer_Excel2007_Workbook extends PHPExcel_Writer_Excel2007_WriterPart { @@ -41,7 +41,7 @@ class PHPExcel_Writer_Excel2007_Workbook extends PHPExcel_Writer_Excel2007_Write * @param PHPExcel $pPHPExcel * @param boolean $recalcRequired Indicate whether formulas should be recalculated before writing * @return string XML Output - * @throws Exception + * @throws PHPExcel_Writer_Exception */ public function writeWorkbook(PHPExcel $pPHPExcel = null, $recalcRequired = FALSE) { @@ -95,7 +95,7 @@ class PHPExcel_Writer_Excel2007_Workbook extends PHPExcel_Writer_Excel2007_Write * Write file version * * @param PHPExcel_Shared_XMLWriter $objWriter XML Writer - * @throws Exception + * @throws PHPExcel_Writer_Exception */ private function _writeFileVersion(PHPExcel_Shared_XMLWriter $objWriter = null) { @@ -111,7 +111,7 @@ class PHPExcel_Writer_Excel2007_Workbook extends PHPExcel_Writer_Excel2007_Write * Write WorkbookPr * * @param PHPExcel_Shared_XMLWriter $objWriter XML Writer - * @throws Exception + * @throws PHPExcel_Writer_Exception */ private function _writeWorkbookPr(PHPExcel_Shared_XMLWriter $objWriter = null) { @@ -131,7 +131,7 @@ class PHPExcel_Writer_Excel2007_Workbook extends PHPExcel_Writer_Excel2007_Write * * @param PHPExcel_Shared_XMLWriter $objWriter XML Writer * @param PHPExcel $pPHPExcel - * @throws Exception + * @throws PHPExcel_Writer_Exception */ private function _writeBookViews(PHPExcel_Shared_XMLWriter $objWriter = null, PHPExcel $pPHPExcel = null) { @@ -161,7 +161,7 @@ class PHPExcel_Writer_Excel2007_Workbook extends PHPExcel_Writer_Excel2007_Write * * @param PHPExcel_Shared_XMLWriter $objWriter XML Writer * @param PHPExcel $pPHPExcel - * @throws Exception + * @throws PHPExcel_Writer_Exception */ private function _writeWorkbookProtection(PHPExcel_Shared_XMLWriter $objWriter = null, PHPExcel $pPHPExcel = null) { @@ -188,16 +188,20 @@ class PHPExcel_Writer_Excel2007_Workbook extends PHPExcel_Writer_Excel2007_Write * * @param PHPExcel_Shared_XMLWriter $objWriter XML Writer * @param boolean $recalcRequired Indicate whether formulas should be recalculated before writing - * @throws Exception + * @throws PHPExcel_Writer_Exception */ private function _writeCalcPr(PHPExcel_Shared_XMLWriter $objWriter = null, $recalcRequired = TRUE) { $objWriter->startElement('calcPr'); - $objWriter->writeAttribute('calcId', '124519'); + // Set the calcid to a higher value than Excel itself will use, otherwise Excel will always recalc + // If MS Excel does do a recalc, then users opening a file in MS Excel will be prompted to save on exit + // because the file has changed + $objWriter->writeAttribute('calcId', '999999'); $objWriter->writeAttribute('calcMode', 'auto'); // fullCalcOnLoad isn't needed if we've recalculating for the save - $objWriter->writeAttribute('fullCalcOnLoad', ($recalcRequired) ? '0' : '1'); + $objWriter->writeAttribute('calcCompleted', ($recalcRequired) ? 1 : 0); + $objWriter->writeAttribute('fullCalcOnLoad', ($recalcRequired) ? 0 : 1); $objWriter->endElement(); } @@ -207,7 +211,7 @@ class PHPExcel_Writer_Excel2007_Workbook extends PHPExcel_Writer_Excel2007_Write * * @param PHPExcel_Shared_XMLWriter $objWriter XML Writer * @param PHPExcel $pPHPExcel - * @throws Exception + * @throws PHPExcel_Writer_Exception */ private function _writeSheets(PHPExcel_Shared_XMLWriter $objWriter = null, PHPExcel $pPHPExcel = null) { @@ -236,7 +240,7 @@ class PHPExcel_Writer_Excel2007_Workbook extends PHPExcel_Writer_Excel2007_Write * @param int $pSheetId Sheet id * @param int $pRelId Relationship ID * @param string $sheetState Sheet state (visible, hidden, veryHidden) - * @throws Exception + * @throws PHPExcel_Writer_Exception */ private function _writeSheet(PHPExcel_Shared_XMLWriter $objWriter = null, $pSheetname = '', $pSheetId = 1, $pRelId = 1, $sheetState = 'visible') { @@ -251,7 +255,7 @@ class PHPExcel_Writer_Excel2007_Workbook extends PHPExcel_Writer_Excel2007_Write $objWriter->writeAttribute('r:id', 'rId' . $pRelId); $objWriter->endElement(); } else { - throw new Exception("Invalid parameters passed."); + throw new PHPExcel_Writer_Exception("Invalid parameters passed."); } } @@ -260,7 +264,7 @@ class PHPExcel_Writer_Excel2007_Workbook extends PHPExcel_Writer_Excel2007_Write * * @param PHPExcel_Shared_XMLWriter $objWriter XML Writer * @param PHPExcel $pPHPExcel - * @throws Exception + * @throws PHPExcel_Writer_Exception */ private function _writeDefinedNames(PHPExcel_Shared_XMLWriter $objWriter = null, PHPExcel $pPHPExcel = null) { @@ -294,7 +298,7 @@ class PHPExcel_Writer_Excel2007_Workbook extends PHPExcel_Writer_Excel2007_Write * * @param PHPExcel_Shared_XMLWriter $objWriter XML Writer * @param PHPExcel $pPHPExcel - * @throws Exception + * @throws PHPExcel_Writer_Exception */ private function _writeNamedRanges(PHPExcel_Shared_XMLWriter $objWriter = null, PHPExcel $pPHPExcel) { @@ -310,7 +314,7 @@ class PHPExcel_Writer_Excel2007_Workbook extends PHPExcel_Writer_Excel2007_Write * * @param PHPExcel_Shared_XMLWriter $objWriter XML Writer * @param PHPExcel_NamedRange $pNamedRange - * @throws Exception + * @throws PHPExcel_Writer_Exception */ private function _writeDefinedNameForNamedRange(PHPExcel_Shared_XMLWriter $objWriter = null, PHPExcel_NamedRange $pNamedRange) { @@ -342,7 +346,7 @@ class PHPExcel_Writer_Excel2007_Workbook extends PHPExcel_Writer_Excel2007_Write * @param PHPExcel_Shared_XMLWriter $objWriter XML Writer * @param PHPExcel_Worksheet $pSheet * @param int $pSheetId - * @throws Exception + * @throws PHPExcel_Writer_Exception */ private function _writeDefinedNameForAutofilter(PHPExcel_Shared_XMLWriter $objWriter = null, PHPExcel_Worksheet $pSheet = null, $pSheetId = 0) { @@ -378,7 +382,7 @@ class PHPExcel_Writer_Excel2007_Workbook extends PHPExcel_Writer_Excel2007_Write * @param PHPExcel_Shared_XMLWriter $objWriter XML Writer * @param PHPExcel_Worksheet $pSheet * @param int $pSheetId - * @throws Exception + * @throws PHPExcel_Writer_Exception */ private function _writeDefinedNameForPrintTitles(PHPExcel_Shared_XMLWriter $objWriter = null, PHPExcel_Worksheet $pSheet = null, $pSheetId = 0) { @@ -421,7 +425,7 @@ class PHPExcel_Writer_Excel2007_Workbook extends PHPExcel_Writer_Excel2007_Write * @param PHPExcel_Shared_XMLWriter $objWriter XML Writer * @param PHPExcel_Worksheet $pSheet * @param int $pSheetId - * @throws Exception + * @throws PHPExcel_Writer_Exception */ private function _writeDefinedNameForPrintArea(PHPExcel_Shared_XMLWriter $objWriter = null, PHPExcel_Worksheet $pSheet = null, $pSheetId = 0) { diff --git a/htdocs/includes/phpexcel/PHPExcel/Writer/Excel2007/Worksheet.php b/htdocs/includes/phpexcel/PHPExcel/Writer/Excel2007/Worksheet.php index f720af338bf..7d93f5a4e00 100644 --- a/htdocs/includes/phpexcel/PHPExcel/Writer/Excel2007/Worksheet.php +++ b/htdocs/includes/phpexcel/PHPExcel/Writer/Excel2007/Worksheet.php @@ -2,7 +2,7 @@ /** * PHPExcel * - * Copyright (c) 2006 - 2012 PHPExcel + * Copyright (c) 2006 - 2014 PHPExcel * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,9 +20,9 @@ * * @category PHPExcel * @package PHPExcel_Writer_Excel2007 - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version 1.7.8, 2012-10-12 + * @version 1.8.0, 2014-03-02 */ @@ -31,7 +31,7 @@ * * @category PHPExcel * @package PHPExcel_Writer_Excel2007 - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) */ class PHPExcel_Writer_Excel2007_Worksheet extends PHPExcel_Writer_Excel2007_WriterPart { @@ -42,7 +42,7 @@ class PHPExcel_Writer_Excel2007_Worksheet extends PHPExcel_Writer_Excel2007_Writ * @param string[] $pStringTable * @param boolean $includeCharts Flag indicating if we should write charts * @return string XML Output - * @throws Exception + * @throws PHPExcel_Writer_Exception */ public function writeWorksheet($pSheet = null, $pStringTable = null, $includeCharts = FALSE) { @@ -132,7 +132,7 @@ class PHPExcel_Writer_Excel2007_Worksheet extends PHPExcel_Writer_Excel2007_Writ // Return return $objWriter->getData(); } else { - throw new Exception("Invalid PHPExcel_Worksheet object passed."); + throw new PHPExcel_Writer_Exception("Invalid PHPExcel_Worksheet object passed."); } } @@ -141,13 +141,19 @@ class PHPExcel_Writer_Excel2007_Worksheet extends PHPExcel_Writer_Excel2007_Writ * * @param PHPExcel_Shared_XMLWriter $objWriter XML Writer * @param PHPExcel_Worksheet $pSheet Worksheet - * @throws Exception + * @throws PHPExcel_Writer_Exception */ private function _writeSheetPr(PHPExcel_Shared_XMLWriter $objWriter = null, PHPExcel_Worksheet $pSheet = null) { // sheetPr $objWriter->startElement('sheetPr'); //$objWriter->writeAttribute('codeName', $pSheet->getTitle()); + if($pSheet->getParent()->hasMacros()){//if the workbook have macros, we need to have codeName for the sheet + if($pSheet->hasCodeName()==false){ + $pSheet->setCodeName($pSheet->getTitle()); + } + $objWriter->writeAttribute('codeName', $pSheet->getCodeName()); + } $autoFilterRange = $pSheet->getAutoFilter()->getRange(); if (!empty($autoFilterRange)) { $objWriter->writeAttribute('filterMode', 1); @@ -182,7 +188,7 @@ class PHPExcel_Writer_Excel2007_Worksheet extends PHPExcel_Writer_Excel2007_Writ * * @param PHPExcel_Shared_XMLWriter $objWriter XML Writer * @param PHPExcel_Worksheet $pSheet Worksheet - * @throws Exception + * @throws PHPExcel_Writer_Exception */ private function _writeDimension(PHPExcel_Shared_XMLWriter $objWriter = null, PHPExcel_Worksheet $pSheet = null) { @@ -197,7 +203,7 @@ class PHPExcel_Writer_Excel2007_Worksheet extends PHPExcel_Writer_Excel2007_Writ * * @param PHPExcel_Shared_XMLWriter $objWriter XML Writer * @param PHPExcel_Worksheet $pSheet Worksheet - * @throws Exception + * @throws PHPExcel_Writer_Exception */ private function _writeSheetViews(PHPExcel_Shared_XMLWriter $objWriter = NULL, PHPExcel_Worksheet $pSheet = NULL) { @@ -304,7 +310,7 @@ class PHPExcel_Writer_Excel2007_Worksheet extends PHPExcel_Writer_Excel2007_Writ * * @param PHPExcel_Shared_XMLWriter $objWriter XML Writer * @param PHPExcel_Worksheet $pSheet Worksheet - * @throws Exception + * @throws PHPExcel_Writer_Exception */ private function _writeSheetFormatPr(PHPExcel_Shared_XMLWriter $objWriter = null, PHPExcel_Worksheet $pSheet = null) { @@ -356,7 +362,7 @@ class PHPExcel_Writer_Excel2007_Worksheet extends PHPExcel_Writer_Excel2007_Writ * * @param PHPExcel_Shared_XMLWriter $objWriter XML Writer * @param PHPExcel_Worksheet $pSheet Worksheet - * @throws Exception + * @throws PHPExcel_Writer_Exception */ private function _writeCols(PHPExcel_Shared_XMLWriter $objWriter = null, PHPExcel_Worksheet $pSheet = null) { @@ -421,7 +427,7 @@ class PHPExcel_Writer_Excel2007_Worksheet extends PHPExcel_Writer_Excel2007_Writ * * @param PHPExcel_Shared_XMLWriter $objWriter XML Writer * @param PHPExcel_Worksheet $pSheet Worksheet - * @throws Exception + * @throws PHPExcel_Writer_Exception */ private function _writeSheetProtection(PHPExcel_Shared_XMLWriter $objWriter = null, PHPExcel_Worksheet $pSheet = null) { @@ -456,7 +462,7 @@ class PHPExcel_Writer_Excel2007_Worksheet extends PHPExcel_Writer_Excel2007_Writ * * @param PHPExcel_Shared_XMLWriter $objWriter XML Writer * @param PHPExcel_Worksheet $pSheet Worksheet - * @throws Exception + * @throws PHPExcel_Writer_Exception */ private function _writeConditionalFormatting(PHPExcel_Shared_XMLWriter $objWriter = null, PHPExcel_Worksheet $pSheet = null) { @@ -531,7 +537,7 @@ class PHPExcel_Writer_Excel2007_Worksheet extends PHPExcel_Writer_Excel2007_Writ * * @param PHPExcel_Shared_XMLWriter $objWriter XML Writer * @param PHPExcel_Worksheet $pSheet Worksheet - * @throws Exception + * @throws PHPExcel_Writer_Exception */ private function _writeDataValidations(PHPExcel_Shared_XMLWriter $objWriter = null, PHPExcel_Worksheet $pSheet = null) { @@ -597,7 +603,7 @@ class PHPExcel_Writer_Excel2007_Worksheet extends PHPExcel_Writer_Excel2007_Writ * * @param PHPExcel_Shared_XMLWriter $objWriter XML Writer * @param PHPExcel_Worksheet $pSheet Worksheet - * @throws Exception + * @throws PHPExcel_Writer_Exception */ private function _writeHyperlinks(PHPExcel_Shared_XMLWriter $objWriter = null, PHPExcel_Worksheet $pSheet = null) { @@ -638,7 +644,7 @@ class PHPExcel_Writer_Excel2007_Worksheet extends PHPExcel_Writer_Excel2007_Writ * * @param PHPExcel_Shared_XMLWriter $objWriter XML Writer * @param PHPExcel_Worksheet $pSheet Worksheet - * @throws Exception + * @throws PHPExcel_Writer_Exception */ private function _writeProtectedRanges(PHPExcel_Shared_XMLWriter $objWriter = null, PHPExcel_Worksheet $pSheet = null) { @@ -652,7 +658,9 @@ class PHPExcel_Writer_Excel2007_Worksheet extends PHPExcel_Writer_Excel2007_Writ $objWriter->startElement('protectedRange'); $objWriter->writeAttribute('name', 'p' . md5($protectedCell)); $objWriter->writeAttribute('sqref', $protectedCell); - $objWriter->writeAttribute('password', $passwordHash); + if (!empty($passwordHash)) { + $objWriter->writeAttribute('password', $passwordHash); + } $objWriter->endElement(); } @@ -665,7 +673,7 @@ class PHPExcel_Writer_Excel2007_Worksheet extends PHPExcel_Writer_Excel2007_Writ * * @param PHPExcel_Shared_XMLWriter $objWriter XML Writer * @param PHPExcel_Worksheet $pSheet Worksheet - * @throws Exception + * @throws PHPExcel_Writer_Exception */ private function _writeMergeCells(PHPExcel_Shared_XMLWriter $objWriter = null, PHPExcel_Worksheet $pSheet = null) { @@ -690,7 +698,7 @@ class PHPExcel_Writer_Excel2007_Worksheet extends PHPExcel_Writer_Excel2007_Writ * * @param PHPExcel_Shared_XMLWriter $objWriter XML Writer * @param PHPExcel_Worksheet $pSheet Worksheet - * @throws Exception + * @throws PHPExcel_Writer_Exception */ private function _writePrintOptions(PHPExcel_Shared_XMLWriter $objWriter = null, PHPExcel_Worksheet $pSheet = null) { @@ -716,7 +724,7 @@ class PHPExcel_Writer_Excel2007_Worksheet extends PHPExcel_Writer_Excel2007_Writ * * @param PHPExcel_Shared_XMLWriter $objWriter XML Writer * @param PHPExcel_Worksheet $pSheet Worksheet - * @throws Exception + * @throws PHPExcel_Writer_Exception */ private function _writePageMargins(PHPExcel_Shared_XMLWriter $objWriter = null, PHPExcel_Worksheet $pSheet = null) { @@ -736,7 +744,7 @@ class PHPExcel_Writer_Excel2007_Worksheet extends PHPExcel_Writer_Excel2007_Writ * * @param PHPExcel_Shared_XMLWriter $objWriter XML Writer * @param PHPExcel_Worksheet $pSheet Worksheet - * @throws Exception + * @throws PHPExcel_Writer_Exception */ private function _writeAutoFilter(PHPExcel_Shared_XMLWriter $objWriter = null, PHPExcel_Worksheet $pSheet = null) { @@ -828,7 +836,7 @@ class PHPExcel_Writer_Excel2007_Worksheet extends PHPExcel_Writer_Excel2007_Writ * * @param PHPExcel_Shared_XMLWriter $objWriter XML Writer * @param PHPExcel_Worksheet $pSheet Worksheet - * @throws Exception + * @throws PHPExcel_Writer_Exception */ private function _writePageSetup(PHPExcel_Shared_XMLWriter $objWriter = null, PHPExcel_Worksheet $pSheet = null) { @@ -863,7 +871,7 @@ class PHPExcel_Writer_Excel2007_Worksheet extends PHPExcel_Writer_Excel2007_Writ * * @param PHPExcel_Shared_XMLWriter $objWriter XML Writer * @param PHPExcel_Worksheet $pSheet Worksheet - * @throws Exception + * @throws PHPExcel_Writer_Exception */ private function _writeHeaderFooter(PHPExcel_Shared_XMLWriter $objWriter = null, PHPExcel_Worksheet $pSheet = null) { @@ -888,7 +896,7 @@ class PHPExcel_Writer_Excel2007_Worksheet extends PHPExcel_Writer_Excel2007_Writ * * @param PHPExcel_Shared_XMLWriter $objWriter XML Writer * @param PHPExcel_Worksheet $pSheet Worksheet - * @throws Exception + * @throws PHPExcel_Writer_Exception */ private function _writeBreaks(PHPExcel_Shared_XMLWriter $objWriter = null, PHPExcel_Worksheet $pSheet = null) { @@ -946,7 +954,7 @@ class PHPExcel_Writer_Excel2007_Worksheet extends PHPExcel_Writer_Excel2007_Writ * @param PHPExcel_Shared_XMLWriter $objWriter XML Writer * @param PHPExcel_Worksheet $pSheet Worksheet * @param string[] $pStringTable String table - * @throws Exception + * @throws PHPExcel_Writer_Exception */ private function _writeSheetData(PHPExcel_Shared_XMLWriter $objWriter = null, PHPExcel_Worksheet $pSheet = null, $pStringTable = null) { @@ -1031,7 +1039,7 @@ class PHPExcel_Writer_Excel2007_Worksheet extends PHPExcel_Writer_Excel2007_Writ $objWriter->endElement(); } else { - throw new Exception("Invalid parameters passed."); + throw new PHPExcel_Writer_Exception("Invalid parameters passed."); } } @@ -1043,7 +1051,7 @@ class PHPExcel_Writer_Excel2007_Worksheet extends PHPExcel_Writer_Excel2007_Writ * @param PHPExcel_Cell $pCellAddress Cell Address * @param string[] $pStringTable String table * @param string[] $pFlippedStringTable String table (flipped), for faster index searching - * @throws Exception + * @throws PHPExcel_Writer_Exception */ private function _writeCell(PHPExcel_Shared_XMLWriter $objWriter = null, PHPExcel_Worksheet $pSheet = null, $pCellAddress = null, $pStringTable = null, $pFlippedStringTable = null) { @@ -1072,12 +1080,9 @@ class PHPExcel_Writer_Excel2007_Worksheet extends PHPExcel_Writer_Excel2007_Writ $objWriter->writeAttribute('t', $mappedType); break; case 'f': // Formula - $calculatedValue = null; - if ($this->getParentWriter()->getPreCalculateFormulas()) { - $calculatedValue = $pCell->getCalculatedValue(); - } else { - $calculatedValue = $cellValue; - } + $calculatedValue = ($this->getParentWriter()->getPreCalculateFormulas()) ? + $pCell->getCalculatedValue() : + $cellValue; if (is_string($calculatedValue)) { $objWriter->writeAttribute('t', 'str'); } @@ -1123,7 +1128,7 @@ class PHPExcel_Writer_Excel2007_Worksheet extends PHPExcel_Writer_Excel2007_Writ } if ($this->getParentWriter()->getOffice2003Compatibility() === false) { if ($this->getParentWriter()->getPreCalculateFormulas()) { - $calculatedValue = $pCell->getCalculatedValue(); +// $calculatedValue = $pCell->getCalculatedValue(); if (!is_array($calculatedValue) && substr($calculatedValue, 0, 1) != '#') { $objWriter->writeElement('v', PHPExcel_Shared_String::FormatNumber($calculatedValue)); } else { @@ -1155,7 +1160,7 @@ class PHPExcel_Writer_Excel2007_Worksheet extends PHPExcel_Writer_Excel2007_Writ $objWriter->endElement(); } else { - throw new Exception("Invalid parameters passed."); + throw new PHPExcel_Writer_Exception("Invalid parameters passed."); } } @@ -1165,7 +1170,7 @@ class PHPExcel_Writer_Excel2007_Worksheet extends PHPExcel_Writer_Excel2007_Writ * @param PHPExcel_Shared_XMLWriter $objWriter XML Writer * @param PHPExcel_Worksheet $pSheet Worksheet * @param boolean $includeCharts Flag indicating if we should include drawing details for charts - * @throws Exception + * @throws PHPExcel_Writer_Exception */ private function _writeDrawings(PHPExcel_Shared_XMLWriter $objWriter = null, PHPExcel_Worksheet $pSheet = null, $includeCharts = FALSE) { @@ -1184,7 +1189,7 @@ class PHPExcel_Writer_Excel2007_Worksheet extends PHPExcel_Writer_Excel2007_Writ * * @param PHPExcel_Shared_XMLWriter $objWriter XML Writer * @param PHPExcel_Worksheet $pSheet Worksheet - * @throws Exception + * @throws PHPExcel_Writer_Exception */ private function _writeLegacyDrawing(PHPExcel_Shared_XMLWriter $objWriter = null, PHPExcel_Worksheet $pSheet = null) { @@ -1201,7 +1206,7 @@ class PHPExcel_Writer_Excel2007_Worksheet extends PHPExcel_Writer_Excel2007_Writ * * @param PHPExcel_Shared_XMLWriter $objWriter XML Writer * @param PHPExcel_Worksheet $pSheet Worksheet - * @throws Exception + * @throws PHPExcel_Writer_Exception */ private function _writeLegacyDrawingHF(PHPExcel_Shared_XMLWriter $objWriter = null, PHPExcel_Worksheet $pSheet = null) { diff --git a/htdocs/includes/phpexcel/PHPExcel/Writer/Excel2007/WriterPart.php b/htdocs/includes/phpexcel/PHPExcel/Writer/Excel2007/WriterPart.php index 3f5069182e2..982117bcf6f 100644 --- a/htdocs/includes/phpexcel/PHPExcel/Writer/Excel2007/WriterPart.php +++ b/htdocs/includes/phpexcel/PHPExcel/Writer/Excel2007/WriterPart.php @@ -2,7 +2,7 @@ /** * PHPExcel * - * Copyright (c) 2006 - 2012 PHPExcel + * Copyright (c) 2006 - 2014 PHPExcel * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,9 +20,9 @@ * * @category PHPExcel * @package PHPExcel_Writer_Excel2007 - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version 1.7.8, 2012-10-12 + * @version 1.8.0, 2014-03-02 */ @@ -31,7 +31,7 @@ * * @category PHPExcel * @package PHPExcel_Writer_Excel2007 - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) */ abstract class PHPExcel_Writer_Excel2007_WriterPart { @@ -46,7 +46,7 @@ abstract class PHPExcel_Writer_Excel2007_WriterPart * Set parent IWriter object * * @param PHPExcel_Writer_IWriter $pWriter - * @throws Exception + * @throws PHPExcel_Writer_Exception */ public function setParentWriter(PHPExcel_Writer_IWriter $pWriter = null) { $this->_parentWriter = $pWriter; @@ -56,13 +56,13 @@ abstract class PHPExcel_Writer_Excel2007_WriterPart * Get parent IWriter object * * @return PHPExcel_Writer_IWriter - * @throws Exception + * @throws PHPExcel_Writer_Exception */ public function getParentWriter() { if (!is_null($this->_parentWriter)) { return $this->_parentWriter; } else { - throw new Exception("No parent PHPExcel_Writer_IWriter assigned."); + throw new PHPExcel_Writer_Exception("No parent PHPExcel_Writer_IWriter assigned."); } } @@ -70,7 +70,7 @@ abstract class PHPExcel_Writer_Excel2007_WriterPart * Set parent IWriter object * * @param PHPExcel_Writer_IWriter $pWriter - * @throws Exception + * @throws PHPExcel_Writer_Exception */ public function __construct(PHPExcel_Writer_IWriter $pWriter = null) { if (!is_null($pWriter)) { diff --git a/htdocs/includes/phpexcel/PHPExcel/Writer/Excel5.php b/htdocs/includes/phpexcel/PHPExcel/Writer/Excel5.php index 9297c78baed..3f816fa1f87 100644 --- a/htdocs/includes/phpexcel/PHPExcel/Writer/Excel5.php +++ b/htdocs/includes/phpexcel/PHPExcel/Writer/Excel5.php @@ -2,7 +2,7 @@ /** * PHPExcel * - * Copyright (c) 2006 - 2012 PHPExcel + * Copyright (c) 2006 - 2014 PHPExcel * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,9 +20,9 @@ * * @category PHPExcel * @package PHPExcel_Writer_Excel5 - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version 1.7.8, 2012-10-12 + * @version 1.8.0, 2014-03-02 */ @@ -31,17 +31,10 @@ * * @category PHPExcel * @package PHPExcel_Writer_Excel5 - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) */ -class PHPExcel_Writer_Excel5 implements PHPExcel_Writer_IWriter +class PHPExcel_Writer_Excel5 extends PHPExcel_Writer_Abstract implements PHPExcel_Writer_IWriter { - /** - * Pre-calculate formulas - * - * @var boolean - */ - private $_preCalculateFormulas = true; - /** * PHPExcel object * @@ -120,15 +113,15 @@ class PHPExcel_Writer_Excel5 implements PHPExcel_Writer_IWriter * Save PHPExcel to file * * @param string $pFilename - * @throws Exception + * @throws PHPExcel_Writer_Exception */ public function save($pFilename = null) { // garbage collect $this->_phpExcel->garbageCollect(); - $saveDebugLog = PHPExcel_Calculation::getInstance()->writeDebugLog; - PHPExcel_Calculation::getInstance()->writeDebugLog = false; + $saveDebugLog = PHPExcel_Calculation::getInstance($this->_phpExcel)->getDebugLog()->getWriteDebugLog(); + PHPExcel_Calculation::getInstance($this->_phpExcel)->getDebugLog()->setWriteDebugLog(FALSE); $saveDateReturnType = PHPExcel_Calculation_Functions::getReturnDateType(); PHPExcel_Calculation_Functions::setReturnDateType(PHPExcel_Calculation_Functions::RETURNDATE_EXCEL); @@ -196,7 +189,7 @@ class PHPExcel_Writer_Excel5 implements PHPExcel_Writer_IWriter } // add binary data for global workbook stream - $OLE->append( $this->_writerWorkbook->writeWorkbook($worksheetSizes) ); + $OLE->append($this->_writerWorkbook->writeWorkbook($worksheetSizes)); // add binary data for sheet streams for ($i = 0; $i < $countSheets; ++$i) { @@ -233,7 +226,7 @@ class PHPExcel_Writer_Excel5 implements PHPExcel_Writer_IWriter $res = $root->save($pFilename); PHPExcel_Calculation_Functions::setReturnDateType($saveDateReturnType); - PHPExcel_Calculation::getInstance()->writeDebugLog = $saveDebugLog; + PHPExcel_Calculation::getInstance($this->_phpExcel)->getDebugLog()->setWriteDebugLog($saveDebugLog); } /** @@ -241,31 +234,13 @@ class PHPExcel_Writer_Excel5 implements PHPExcel_Writer_IWriter * * @deprecated * @param string $pValue Temporary storage directory - * @throws Exception Exception when directory does not exist + * @throws PHPExcel_Writer_Exception when directory does not exist * @return PHPExcel_Writer_Excel5 */ public function setTempDir($pValue = '') { return $this; } - /** - * Get Pre-Calculate Formulas - * - * @return boolean - */ - public function getPreCalculateFormulas() { - return $this->_preCalculateFormulas; - } - - /** - * Set Pre-Calculate Formulas - * - * @param boolean $pValue Pre-Calculate Formulas? - */ - public function setPreCalculateFormulas($pValue = true) { - $this->_preCalculateFormulas = $pValue; - } - /** * Build the Worksheet Escher objects * @@ -621,7 +596,6 @@ class PHPExcel_Writer_Excel5 implements PHPExcel_Writer_IWriter // GKPIDDSI_CATEGORY : Category if($this->_phpExcel->getProperties()->getCategory()){ $dataProp = $this->_phpExcel->getProperties()->getCategory(); - $dataProp = 'Test result file'; $dataSection[] = array('summary'=> array('pack' => 'V', 'data' => 0x02), 'offset' => array('pack' => 'V'), 'type' => array('pack' => 'V', 'data' => 0x1E), @@ -958,4 +932,4 @@ class PHPExcel_Writer_Excel5 implements PHPExcel_Writer_IWriter return $data; } -} \ No newline at end of file +} diff --git a/htdocs/includes/phpexcel/PHPExcel/Writer/Excel5/BIFFwriter.php b/htdocs/includes/phpexcel/PHPExcel/Writer/Excel5/BIFFwriter.php index b6782255047..b3e48bc33d5 100644 --- a/htdocs/includes/phpexcel/PHPExcel/Writer/Excel5/BIFFwriter.php +++ b/htdocs/includes/phpexcel/PHPExcel/Writer/Excel5/BIFFwriter.php @@ -2,7 +2,7 @@ /** * PHPExcel * - * Copyright (c) 2006 - 2012 PHPExcel + * Copyright (c) 2006 - 2014 PHPExcel * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,9 +20,9 @@ * * @category PHPExcel * @package PHPExcel_Writer_Excel5 - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version 1.7.8, 2012-10-12 + * @version 1.8.0, 2014-03-02 */ // Original file header of PEAR::Spreadsheet_Excel_Writer_BIFFwriter (used as the base for this class): @@ -65,7 +65,7 @@ * * @category PHPExcel * @package PHPExcel_Writer_Excel5 - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) */ class PHPExcel_Writer_Excel5_BIFFwriter { @@ -122,7 +122,7 @@ class PHPExcel_Writer_Excel5_BIFFwriter $byte_order = 1; // Big Endian } else { // Give up. I'll fix this in a later version. - throw new Exception("Required floating point format not supported on this platform."); + throw new PHPExcel_Writer_Exception("Required floating point format not supported on this platform."); } self::$_byte_order = $byte_order; } diff --git a/htdocs/includes/phpexcel/PHPExcel/Writer/Excel5/Escher.php b/htdocs/includes/phpexcel/PHPExcel/Writer/Excel5/Escher.php index 94b769ab92b..7e9b73a3d1b 100644 --- a/htdocs/includes/phpexcel/PHPExcel/Writer/Excel5/Escher.php +++ b/htdocs/includes/phpexcel/PHPExcel/Writer/Excel5/Escher.php @@ -2,7 +2,7 @@ /** * PHPExcel * - * Copyright (c) 2006 - 2012 PHPExcel + * Copyright (c) 2006 - 2014 PHPExcel * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,9 +20,9 @@ * * @category PHPExcel * @package PHPExcel_Writer_Excel5 - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version 1.7.8, 2012-10-12 + * @version 1.8.0, 2014-03-02 */ @@ -31,7 +31,7 @@ * * @category PHPExcel * @package PHPExcel_Writer_Excel5 - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) */ class PHPExcel_Writer_Excel5_Escher { diff --git a/htdocs/includes/phpexcel/PHPExcel/Writer/Excel5/Font.php b/htdocs/includes/phpexcel/PHPExcel/Writer/Excel5/Font.php index f67dd11f048..f2dbab2015b 100644 --- a/htdocs/includes/phpexcel/PHPExcel/Writer/Excel5/Font.php +++ b/htdocs/includes/phpexcel/PHPExcel/Writer/Excel5/Font.php @@ -2,7 +2,7 @@ /** * PHPExcel * - * Copyright (c) 2006 - 2012 PHPExcel + * Copyright (c) 2006 - 2014 PHPExcel * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,9 +20,9 @@ * * @category PHPExcel * @package PHPExcel_Writer_Excel5 - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version 1.7.8, 2012-10-12 + * @version 1.8.0, 2014-03-02 */ @@ -31,7 +31,7 @@ * * @category PHPExcel * @package PHPExcel_Writer_Excel5 - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) */ class PHPExcel_Writer_Excel5_Font { diff --git a/htdocs/includes/phpexcel/PHPExcel/Writer/Excel5/Parser.php b/htdocs/includes/phpexcel/PHPExcel/Writer/Excel5/Parser.php index 88b777e0032..04e674a21a2 100644 --- a/htdocs/includes/phpexcel/PHPExcel/Writer/Excel5/Parser.php +++ b/htdocs/includes/phpexcel/PHPExcel/Writer/Excel5/Parser.php @@ -2,7 +2,7 @@ /** * PHPExcel * - * Copyright (c) 2006 - 2012 PHPExcel + * Copyright (c) 2006 - 2014 PHPExcel * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,9 +20,9 @@ * * @category PHPExcel * @package PHPExcel_Writer_Excel5 - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version 1.7.8, 2012-10-12 + * @version 1.8.0, 2014-03-02 */ // Original file header of PEAR::Spreadsheet_Excel_Writer_Parser (used as the base for this class): @@ -55,7 +55,7 @@ * * @category PHPExcel * @package PHPExcel_Writer_Excel5 - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) */ class PHPExcel_Writer_Excel5_Parser { @@ -564,7 +564,7 @@ class PHPExcel_Writer_Excel5_Parser } // TODO: use real error codes - throw new Exception("Unknown token $token"); + throw new PHPExcel_Writer_Exception("Unknown token $token"); } /** @@ -598,7 +598,7 @@ class PHPExcel_Writer_Excel5_Parser // chop away beggining and ending quotes $string = substr($string, 1, strlen($string) - 2); if (strlen($string) > 255) { - throw new Exception("String is too long"); + throw new PHPExcel_Writer_Exception("String is too long"); } return pack('C', $this->ptg['ptgStr']) . PHPExcel_Shared_String::UTF8toBIFF8UnicodeShort($string); @@ -644,7 +644,7 @@ class PHPExcel_Writer_Excel5_Parser list($cell1, $cell2) = explode(':', $range); } else { // TODO: use real error codes - throw new Exception("Unknown range separator"); + throw new PHPExcel_Writer_Exception("Unknown range separator"); } // Convert the cell references @@ -660,7 +660,7 @@ class PHPExcel_Writer_Excel5_Parser $ptgArea = pack("C", $this->ptg['ptgAreaA']); } else { // TODO: use real error codes - throw new Exception("Unknown class $class"); + throw new PHPExcel_Writer_Exception("Unknown class $class"); } return $ptgArea . $row1 . $row2 . $col1. $col2; } @@ -702,7 +702,7 @@ class PHPExcel_Writer_Excel5_Parser // } elseif ($class == 2) { // $ptgArea = pack("C", $this->ptg['ptgArea3dA']); // } else { -// throw new Exception("Unknown class $class"); +// throw new PHPExcel_Writer_Exception("Unknown class $class"); // } return $ptgArea . $ext_ref . $row1 . $row2 . $col1. $col2; @@ -732,7 +732,7 @@ class PHPExcel_Writer_Excel5_Parser $ptgRef = pack("C", $this->ptg['ptgRefA']); // } else { // // TODO: use real error codes -// throw new Exception("Unknown class $class"); +// throw new PHPExcel_Writer_Exception("Unknown class $class"); // } return $ptgRef.$row.$col; } @@ -766,7 +766,7 @@ class PHPExcel_Writer_Excel5_Parser // } elseif ($class == 2) { $ptgRef = pack("C", $this->ptg['ptgRef3dA']); // } else { -// throw new Exception("Unknown class $class"); +// throw new PHPExcel_Writer_Exception("Unknown class $class"); // } return $ptgRef . $ext_ref. $row . $col; @@ -812,11 +812,11 @@ class PHPExcel_Writer_Excel5_Parser $sheet1 = $this->_getSheetIndex($sheet_name1); if ($sheet1 == -1) { - throw new Exception("Unknown sheet name $sheet_name1 in formula"); + throw new PHPExcel_Writer_Exception("Unknown sheet name $sheet_name1 in formula"); } $sheet2 = $this->_getSheetIndex($sheet_name2); if ($sheet2 == -1) { - throw new Exception("Unknown sheet name $sheet_name2 in formula"); + throw new PHPExcel_Writer_Exception("Unknown sheet name $sheet_name2 in formula"); } // Reverse max and min sheet numbers if necessary @@ -826,7 +826,7 @@ class PHPExcel_Writer_Excel5_Parser } else { // Single sheet name only. $sheet1 = $this->_getSheetIndex($ext_ref); if ($sheet1 == -1) { - throw new Exception("Unknown sheet name $ext_ref in formula"); + throw new PHPExcel_Writer_Exception("Unknown sheet name $ext_ref in formula"); } $sheet2 = $sheet1; } @@ -858,11 +858,11 @@ class PHPExcel_Writer_Excel5_Parser $sheet1 = $this->_getSheetIndex($sheet_name1); if ($sheet1 == -1) { - throw new Exception("Unknown sheet name $sheet_name1 in formula"); + throw new PHPExcel_Writer_Exception("Unknown sheet name $sheet_name1 in formula"); } $sheet2 = $this->_getSheetIndex($sheet_name2); if ($sheet2 == -1) { - throw new Exception("Unknown sheet name $sheet_name2 in formula"); + throw new PHPExcel_Writer_Exception("Unknown sheet name $sheet_name2 in formula"); } // Reverse max and min sheet numbers if necessary @@ -872,7 +872,7 @@ class PHPExcel_Writer_Excel5_Parser } else { // Single sheet name only. $sheet1 = $this->_getSheetIndex($ext_ref); if ($sheet1 == -1) { - throw new Exception("Unknown sheet name $ext_ref in formula"); + throw new PHPExcel_Writer_Exception("Unknown sheet name $ext_ref in formula"); } $sheet2 = $sheet1; } @@ -942,11 +942,10 @@ class PHPExcel_Writer_Excel5_Parser $cell = strtoupper($cell); list($row, $col, $row_rel, $col_rel) = $this->_cellToRowcol($cell); if ($col >= 256) { - throw new Exception("Column in: $cell greater than 255"); + throw new PHPExcel_Writer_Exception("Column in: $cell greater than 255"); } - // FIXME: change for BIFF8 - if ($row >= 16384) { - throw new Exception("Row in: $cell greater than 16384 "); + if ($row >= 65536) { + throw new PHPExcel_Writer_Exception("Row in: $cell greater than 65536 "); } // Set the high bits to indicate if row or col are relative. @@ -980,11 +979,11 @@ class PHPExcel_Writer_Excel5_Parser --$row2; // Trick poor inocent Excel $col1 = 0; - $col2 = 16383; // FIXME: maximum possible value for Excel 5 (change this!!!) + $col2 = 65535; // FIXME: maximum possible value for Excel 5 (change this!!!) // FIXME: this changes for BIFF8 - if (($row1 >= 16384) or ($row2 >= 16384)) { - throw new Exception("Row in: $range greater than 16384 "); + if (($row1 >= 65536) or ($row2 >= 65536)) { + throw new PHPExcel_Writer_Exception("Row in: $range greater than 65536 "); } // Set the high bits to indicate if rows are relative. @@ -1373,7 +1372,7 @@ class PHPExcel_Writer_Excel5_Parser $this->_advance(); // eat the "(" $result = $this->_parenthesizedExpression(); if ($this->_current_token != ")") { - throw new Exception("')' token expected."); + throw new PHPExcel_Writer_Exception("')' token expected."); } $this->_advance(); // eat the ")" return $result; @@ -1443,7 +1442,7 @@ class PHPExcel_Writer_Excel5_Parser $result = $this->_func(); return $result; } - throw new Exception("Syntax error: ".$this->_current_token. + throw new PHPExcel_Writer_Exception("Syntax error: ".$this->_current_token. ", lookahead: ".$this->_lookahead. ", current char: ".$this->_current_char); } @@ -1470,7 +1469,7 @@ class PHPExcel_Writer_Excel5_Parser { $this->_advance(); // eat the "," or ";" } else { - throw new Exception("Syntax error: comma expected in ". + throw new PHPExcel_Writer_Exception("Syntax error: comma expected in ". "function $function, arg #{$num_args}"); } $result2 = $this->_condition(); @@ -1482,12 +1481,12 @@ class PHPExcel_Writer_Excel5_Parser ++$num_args; } if (!isset($this->_functions[$function])) { - throw new Exception("Function $function() doesn't exist"); + throw new PHPExcel_Writer_Exception("Function $function() doesn't exist"); } $args = $this->_functions[$function][1]; // If fixed number of args eg. TIME($i,$j,$k). Check that the number of args is valid. if (($args >= 0) and ($args != $num_args)) { - throw new Exception("Incorrect number of arguments in function $function() "); + throw new PHPExcel_Writer_Exception("Incorrect number of arguments in function $function() "); } $result = $this->_createTree($function, $result, $num_args); diff --git a/htdocs/includes/phpexcel/PHPExcel/Writer/Excel5/Workbook.php b/htdocs/includes/phpexcel/PHPExcel/Writer/Excel5/Workbook.php index 2e177ceff90..e14bcba4d37 100644 --- a/htdocs/includes/phpexcel/PHPExcel/Writer/Excel5/Workbook.php +++ b/htdocs/includes/phpexcel/PHPExcel/Writer/Excel5/Workbook.php @@ -2,7 +2,7 @@ /** * PHPExcel * - * Copyright (c) 2006 - 2012 PHPExcel + * Copyright (c) 2006 - 2014 PHPExcel * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,9 +20,9 @@ * * @category PHPExcel * @package PHPExcel_Writer_Excel5 - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version 1.7.8, 2012-10-12 + * @version 1.8.0, 2014-03-02 */ // Original file header of PEAR::Spreadsheet_Excel_Writer_Workbook (used as the base for this class): @@ -66,7 +66,7 @@ * * @category PHPExcel * @package PHPExcel_Writer_Excel5 - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) */ class PHPExcel_Writer_Excel5_Workbook extends PHPExcel_Writer_Excel5_BIFFwriter { @@ -317,6 +317,7 @@ class PHPExcel_Writer_Excel5_Workbook extends PHPExcel_Writer_Excel5_BIFFwriter } return $fontIndex; } + /** * Alter color palette adding a custom color * @@ -629,7 +630,7 @@ class PHPExcel_Writer_Excel5_Workbook extends PHPExcel_Writer_Excel5_BIFFwriter $rowmax = $repeat[1] - 1; } else { $rowmin = 0; - $rowmax = 16383; + $rowmax = 65535; } $this->_writeNameShort( @@ -687,7 +688,7 @@ class PHPExcel_Writer_Excel5_Workbook extends PHPExcel_Writer_Excel5_BIFFwriter } $chunk .= $this->writeData($this->_writeDefinedNameBiff8($namedRange->getName(), $formulaData, $scope, false)); - } catch(Exception $e) { + } catch(PHPExcel_Exception $e) { // do nothing } } @@ -835,10 +836,10 @@ class PHPExcel_Writer_Excel5_Workbook extends PHPExcel_Writer_Excel5_BIFFwriter /** * Write a short NAME record * - * @param string $name - * @param string $sheetIndex 1-based sheet index the defined name applies to. 0 = global - * @param int[][] $range rangeboundaries - * @param bool $isHidden + * @param string $name + * @param string $sheetIndex 1-based sheet index the defined name applies to. 0 = global + * @param integer[][] $rangeBounds range boundaries + * @param boolean $isHidden * @return string Complete binary record data * */ private function _writeShortNameBiff8($name, $sheetIndex = 0, $rangeBounds, $isHidden = false){ @@ -1446,5 +1447,4 @@ class PHPExcel_Writer_Excel5_Workbook extends PHPExcel_Writer_Excel5_BIFFwriter { $this->_escher = $pValue; } - } diff --git a/htdocs/includes/phpexcel/PHPExcel/Writer/Excel5/Worksheet.php b/htdocs/includes/phpexcel/PHPExcel/Writer/Excel5/Worksheet.php index 9aa5083d915..55da26f3282 100644 --- a/htdocs/includes/phpexcel/PHPExcel/Writer/Excel5/Worksheet.php +++ b/htdocs/includes/phpexcel/PHPExcel/Writer/Excel5/Worksheet.php @@ -2,7 +2,7 @@ /** * PHPExcel * - * Copyright (c) 2006 - 2012 PHPExcel + * Copyright (c) 2006 - 2014 PHPExcel * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,9 +20,9 @@ * * @category PHPExcel * @package PHPExcel_Writer_Excel5 - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version 1.7.8, 2012-10-12 + * @version 1.8.0, 2014-03-02 */ // Original file header of PEAR::Spreadsheet_Excel_Writer_Worksheet (used as the base for this class): @@ -66,7 +66,7 @@ * * @category PHPExcel * @package PHPExcel_Writer_Excel5 - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) */ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter { @@ -424,7 +424,7 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter if ($cVal instanceof PHPExcel_RichText) { // $this->_writeString($row, $column, $cVal->getPlainText(), $xfIndex); $arrcRun = array(); - $str_len = strlen($cVal->getPlainText()); + $str_len = PHPExcel_Shared_String::CountCharacters($cVal->getPlainText(), 'UTF-8'); $str_pos = 0; $elements = $cVal->getRichTextElements(); foreach ($elements as $element) { @@ -437,7 +437,7 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter } $arrcRun[] = array('strlen' => $str_pos, 'fontidx' => $str_fontidx); // Position FROM - $str_pos += strlen($element->getText()); + $str_pos += PHPExcel_Shared_String::CountCharacters($element->getText(), 'UTF-8'); } $this->_writeRichTextString($row, $column, $cVal->getPlainText(), $xfIndex, $arrcRun); } else { @@ -476,12 +476,22 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter // Append $this->_writeMsoDrawing(); + // Write WINDOW2 record $this->_writeWindow2(); + + // Write PLV record + $this->_writePageLayoutView(); + + // Write ZOOM record $this->_writeZoom(); if ($_phpSheet->getFreezePane()) { $this->_writePanes(); } + + // Write SELECTION record $this->_writeSelection(); + + // Write MergedCellsTable Record $this->_writeMergedCells(); // Hyperlinks @@ -508,9 +518,32 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter $this->_writeDataValidity(); $this->_writeSheetLayout(); + + // Write SHEETPROTECTION record $this->_writeSheetProtection(); $this->_writeRangeProtection(); + $arrConditionalStyles = $_phpSheet->getConditionalStylesCollection(); + if(!empty($arrConditionalStyles)){ + $arrConditional = array(); + // @todo CFRule & CFHeader + // Write CFHEADER record + $this->_writeCFHeader(); + // Write ConditionalFormattingTable records + foreach ($arrConditionalStyles as $cellCoordinate => $conditionalStyles) { + foreach ($conditionalStyles as $conditional) { + if($conditional->getConditionType() == PHPExcel_Style_Conditional::CONDITION_EXPRESSION + || $conditional->getConditionType() == PHPExcel_Style_Conditional::CONDITION_CELLIS){ + if(!in_array($conditional->getHashCode(), $arrConditional)){ + $arrConditional[] = $conditional->getHashCode(); + // Write CFRULE record + $this->_writeCFRule($conditional); + } + } + } + } + } + $this->_storeEof(); } @@ -642,6 +675,7 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter { $this->_writeLabelSst($row, $col, $str, $xfIndex); } + /** * Write a LABELSST record or a LABEL record. Which one depends on BIFF version * It differs from _writeString by the writing of rich text strings. @@ -654,7 +688,6 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter private function _writeRichTextString($row, $col, $str, $xfIndex, $arrcRun){ $record = 0x00FD; // Record identifier $length = 0x000A; // Bytes to follow - $str = PHPExcel_Shared_String::UTF8toBIFF8UnicodeShort($str, $arrcRun); /* check if string is already present */ @@ -901,7 +934,7 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter return 0; - } catch (Exception $e) { + } catch (PHPExcel_Exception $e) { // do nothing } @@ -1276,26 +1309,29 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter // no support in PHPExcel for selected sheet, therefore sheet is only selected if it is the active sheet $fSelected = ($this->_phpSheet === $this->_phpSheet->getParent()->getActiveSheet()) ? 1 : 0; $fPaged = 1; // 2 + $fPageBreakPreview = $this->_phpSheet->getSheetView()->getView() === PHPExcel_Worksheet_SheetView::SHEETVIEW_PAGE_BREAK_PREVIEW; $grbit = $fDspFmla; $grbit |= $fDspGrid << 1; - $grbit |= $fDspRwCol << 2; - $grbit |= $fFrozen << 3; - $grbit |= $fDspZeros << 4; - $grbit |= $fDefaultHdr << 5; - $grbit |= $fArabic << 6; + $grbit |= $fDspRwCol << 2; + $grbit |= $fFrozen << 3; + $grbit |= $fDspZeros << 4; + $grbit |= $fDefaultHdr << 5; + $grbit |= $fArabic << 6; $grbit |= $fDspGuts << 7; $grbit |= $fFrozenNoSplit << 8; - $grbit |= $fSelected << 9; - $grbit |= $fPaged << 10; + $grbit |= $fSelected << 9; + $grbit |= $fPaged << 10; + $grbit |= $fPageBreakPreview << 11; $header = pack("vv", $record, $length); $data = pack("vvv", $grbit, $rwTop, $colLeft); // FIXME !!! $rgbHdr = 0x0040; // Row/column heading and gridline color index - $zoom_factor_page_break = 0x0000; - $zoom_factor_normal = 0x0000; + $zoom_factor_page_break = ($fPageBreakPreview? $this->_phpSheet->getSheetView()->getZoomScale() : 0x0000); + $zoom_factor_normal = $this->_phpSheet->getSheetView()->getZoomScaleNormal(); + $data .= pack("vvvvV", $rgbHdr, 0x0000, $zoom_factor_page_break, $zoom_factor_normal, 0x00000000); $this->_append($header.$data); @@ -2238,10 +2274,10 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter $record = 0x0012; // Record identifier $length = 0x0002; // Bytes to follow - $fLock = 1; // Worksheet is protected + $fLock = 1; // Worksheet is protected $header = pack("vv", $record, $length); - $data = pack("v", $fLock); + $data = pack("v", $fLock); $this->_append($header.$data); } @@ -2579,7 +2615,7 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter // Open file. $bmp_fd = @fopen($bitmap,"rb"); if (!$bmp_fd) { - throw new Exception("Couldn't import $bitmap"); + throw new PHPExcel_Writer_Exception("Couldn't import $bitmap"); } // Slurp the file into a string. @@ -2587,13 +2623,13 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter // Check that the file is big enough to be a bitmap. if (strlen($data) <= 0x36) { - throw new Exception("$bitmap doesn't contain enough data.\n"); + throw new PHPExcel_Writer_Exception("$bitmap doesn't contain enough data.\n"); } // The first 2 bytes are used to identify the bitmap. $identity = unpack("A2ident", $data); if ($identity['ident'] != "BM") { - throw new Exception("$bitmap doesn't appear to be a valid bitmap image.\n"); + throw new PHPExcel_Writer_Exception("$bitmap doesn't appear to be a valid bitmap image.\n"); } // Remove bitmap data: ID. @@ -2617,20 +2653,20 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter $height = $width_and_height[2]; $data = substr($data, 8); if ($width > 0xFFFF) { - throw new Exception("$bitmap: largest image width supported is 65k.\n"); + throw new PHPExcel_Writer_Exception("$bitmap: largest image width supported is 65k.\n"); } if ($height > 0xFFFF) { - throw new Exception("$bitmap: largest image height supported is 65k.\n"); + throw new PHPExcel_Writer_Exception("$bitmap: largest image height supported is 65k.\n"); } // Read and remove the bitmap planes and bpp data. Verify them. $planes_and_bitcount = unpack("v2", substr($data, 0, 4)); $data = substr($data, 4); if ($planes_and_bitcount[2] != 24) { // Bitcount - throw new Exception("$bitmap isn't a 24bit true color bitmap.\n"); + throw new PHPExcel_Writer_Exception("$bitmap isn't a 24bit true color bitmap.\n"); } if ($planes_and_bitcount[1] != 1) { - throw new Exception("$bitmap: only 1 plane supported in bitmap image.\n"); + throw new PHPExcel_Writer_Exception("$bitmap: only 1 plane supported in bitmap image.\n"); } // Read and remove the bitmap compression. Verify compression. @@ -2639,7 +2675,7 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter //$compression = 0; if ($compression['comp'] != 0) { - throw new Exception("$bitmap: compression not supported in bitmap image.\n"); + throw new PHPExcel_Writer_Exception("$bitmap: compression not supported in bitmap image.\n"); } // Remove bitmap data: data size, hres, vres, colours, imp. colours. @@ -2895,7 +2931,7 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter $formula1 = $this->_parser->toReversePolish(); $sz1 = strlen($formula1); - } catch(Exception $e) { + } catch(PHPExcel_Exception $e) { $sz1 = 0; $formula1 = ''; } @@ -2906,13 +2942,13 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter try { $formula2 = $dataValidation->getFormula2(); if ($formula2 === '') { - throw new Exception('No formula2'); + throw new PHPExcel_Writer_Exception('No formula2'); } $this->_parser->parse($formula2); $formula2 = $this->_parser->toReversePolish(); $sz2 = strlen($formula2); - } catch(Exception $e) { + } catch(PHPExcel_Exception $e) { $sz2 = 0; $formula2 = ''; } @@ -2951,4 +2987,695 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter return 0; } + /** + * Write PLV Record + */ + private function _writePageLayoutView(){ + $record = 0x088B; // Record identifier + $length = 0x0010; // Bytes to follow + + $rt = 0x088B; // 2 + $grbitFrt = 0x0000; // 2 + $reserved = 0x0000000000000000; // 8 + $wScalvePLV = $this->_phpSheet->getSheetView()->getZoomScale(); // 2 + + // The options flags that comprise $grbit + if($this->_phpSheet->getSheetView()->getView() == PHPExcel_Worksheet_SheetView::SHEETVIEW_PAGE_LAYOUT){ + $fPageLayoutView = 1; + } else { + $fPageLayoutView = 0; + } + $fRulerVisible = 0; + $fWhitespaceHidden = 0; + + $grbit = $fPageLayoutView; // 2 + $grbit |= $fRulerVisible << 1; + $grbit |= $fWhitespaceHidden << 3; + + $header = pack("vv", $record, $length); + $data = pack("vvVVvv", $rt, $grbitFrt, 0x00000000, 0x00000000, $wScalvePLV, $grbit); + $this->_append($header . $data); + } + + /** + * Write CFRule Record + * @param PHPExcel_Style_Conditional $conditional + */ + private function _writeCFRule(PHPExcel_Style_Conditional $conditional){ + $record = 0x01B1; // Record identifier + + // $type : Type of the CF + // $operatorType : Comparison operator + if($conditional->getConditionType() == PHPExcel_Style_Conditional::CONDITION_EXPRESSION){ + $type = 0x02; + $operatorType = 0x00; + } else if($conditional->getConditionType() == PHPExcel_Style_Conditional::CONDITION_CELLIS){ + $type = 0x01; + + switch ($conditional->getOperatorType()){ + case PHPExcel_Style_Conditional::OPERATOR_NONE: + $operatorType = 0x00; + break; + case PHPExcel_Style_Conditional::OPERATOR_EQUAL: + $operatorType = 0x03; + break; + case PHPExcel_Style_Conditional::OPERATOR_GREATERTHAN: + $operatorType = 0x05; + break; + case PHPExcel_Style_Conditional::OPERATOR_GREATERTHANOREQUAL: + $operatorType = 0x07; + break; + case PHPExcel_Style_Conditional::OPERATOR_LESSTHAN: + $operatorType = 0x06; + break; + case PHPExcel_Style_Conditional::OPERATOR_LESSTHANOREQUAL: + $operatorType = 0x08; + break; + case PHPExcel_Style_Conditional::OPERATOR_NOTEQUAL: + $operatorType = 0x04; + break; + case PHPExcel_Style_Conditional::OPERATOR_BETWEEN: + $operatorType = 0x01; + break; + // not OPERATOR_NOTBETWEEN 0x02 + } + } + + // $szValue1 : size of the formula data for first value or formula + // $szValue2 : size of the formula data for second value or formula + $arrConditions = $conditional->getConditions(); + $numConditions = sizeof($arrConditions); + if($numConditions == 1){ + $szValue1 = ($arrConditions[0] <= 65535 ? 3 : 0x0000); + $szValue2 = 0x0000; + $operand1 = pack('Cv', 0x1E, $arrConditions[0]); + $operand2 = null; + } else if($numConditions == 2 && ($conditional->getOperatorType() == PHPExcel_Style_Conditional::OPERATOR_BETWEEN)){ + $szValue1 = ($arrConditions[0] <= 65535 ? 3 : 0x0000); + $szValue2 = ($arrConditions[1] <= 65535 ? 3 : 0x0000); + $operand1 = pack('Cv', 0x1E, $arrConditions[0]); + $operand2 = pack('Cv', 0x1E, $arrConditions[1]); + } else { + $szValue1 = 0x0000; + $szValue2 = 0x0000; + $operand1 = null; + $operand2 = null; + } + + // $flags : Option flags + // Alignment + $bAlignHz = ($conditional->getStyle()->getAlignment()->getHorizontal() == null ? 1 : 0); + $bAlignVt = ($conditional->getStyle()->getAlignment()->getVertical() == null ? 1 : 0); + $bAlignWrapTx = ($conditional->getStyle()->getAlignment()->getWrapText() == false ? 1 : 0); + $bTxRotation = ($conditional->getStyle()->getAlignment()->getTextRotation() == null ? 1 : 0); + $bIndent = ($conditional->getStyle()->getAlignment()->getIndent() == 0 ? 1 : 0); + $bShrinkToFit = ($conditional->getStyle()->getAlignment()->getShrinkToFit() == false ? 1 : 0); + if($bAlignHz == 0 || $bAlignVt == 0 || $bAlignWrapTx == 0 || $bTxRotation == 0 || $bIndent == 0 || $bShrinkToFit == 0){ + $bFormatAlign = 1; + } else { + $bFormatAlign = 0; + } + // Protection + $bProtLocked = ($conditional->getStyle()->getProtection()->getLocked() == null ? 1 : 0); + $bProtHidden = ($conditional->getStyle()->getProtection()->getHidden() == null ? 1 : 0); + if($bProtLocked == 0 || $bProtHidden == 0){ + $bFormatProt = 1; + } else { + $bFormatProt = 0; + } + // Border + $bBorderLeft = ($conditional->getStyle()->getBorders()->getLeft()->getColor()->getARGB() == PHPExcel_Style_Color::COLOR_BLACK + && $conditional->getStyle()->getBorders()->getLeft()->getBorderStyle() == PHPExcel_Style_Border::BORDER_NONE ? 1 : 0); + $bBorderRight = ($conditional->getStyle()->getBorders()->getRight()->getColor()->getARGB() == PHPExcel_Style_Color::COLOR_BLACK + && $conditional->getStyle()->getBorders()->getRight()->getBorderStyle() == PHPExcel_Style_Border::BORDER_NONE ? 1 : 0); + $bBorderTop = ($conditional->getStyle()->getBorders()->getTop()->getColor()->getARGB() == PHPExcel_Style_Color::COLOR_BLACK + && $conditional->getStyle()->getBorders()->getTop()->getBorderStyle() == PHPExcel_Style_Border::BORDER_NONE ? 1 : 0); + $bBorderBottom = ($conditional->getStyle()->getBorders()->getBottom()->getColor()->getARGB() == PHPExcel_Style_Color::COLOR_BLACK + && $conditional->getStyle()->getBorders()->getBottom()->getBorderStyle() == PHPExcel_Style_Border::BORDER_NONE ? 1 : 0); + if($bBorderLeft == 0 || $bBorderRight == 0 || $bBorderTop == 0 || $bBorderBottom == 0){ + $bFormatBorder = 1; + } else { + $bFormatBorder = 0; + } + // Pattern + $bFillStyle = ($conditional->getStyle()->getFill()->getFillType() == null ? 0 : 1); + $bFillColor = ($conditional->getStyle()->getFill()->getStartColor()->getARGB() == null ? 0 : 1); + $bFillColorBg = ($conditional->getStyle()->getFill()->getEndColor()->getARGB() == null ? 0 : 1); + if($bFillStyle == 0 || $bFillColor == 0 || $bFillColorBg == 0){ + $bFormatFill = 1; + } else { + $bFormatFill = 0; + } + // Font + if($conditional->getStyle()->getFont()->getName() != null + || $conditional->getStyle()->getFont()->getSize() != null + || $conditional->getStyle()->getFont()->getBold() != null + || $conditional->getStyle()->getFont()->getItalic() != null + || $conditional->getStyle()->getFont()->getSuperScript() != null + || $conditional->getStyle()->getFont()->getSubScript() != null + || $conditional->getStyle()->getFont()->getUnderline() != null + || $conditional->getStyle()->getFont()->getStrikethrough() != null + || $conditional->getStyle()->getFont()->getColor()->getARGB() != null){ + $bFormatFont = 1; + } else { + $bFormatFont = 0; + } + // Alignment + $flags = 0; + $flags |= (1 == $bAlignHz ? 0x00000001 : 0); + $flags |= (1 == $bAlignVt ? 0x00000002 : 0); + $flags |= (1 == $bAlignWrapTx ? 0x00000004 : 0); + $flags |= (1 == $bTxRotation ? 0x00000008 : 0); + // Justify last line flag + $flags |= (1 == 1 ? 0x00000010 : 0); + $flags |= (1 == $bIndent ? 0x00000020 : 0); + $flags |= (1 == $bShrinkToFit ? 0x00000040 : 0); + // Default + $flags |= (1 == 1 ? 0x00000080 : 0); + // Protection + $flags |= (1 == $bProtLocked ? 0x00000100 : 0); + $flags |= (1 == $bProtHidden ? 0x00000200 : 0); + // Border + $flags |= (1 == $bBorderLeft ? 0x00000400 : 0); + $flags |= (1 == $bBorderRight ? 0x00000800 : 0); + $flags |= (1 == $bBorderTop ? 0x00001000 : 0); + $flags |= (1 == $bBorderBottom ? 0x00002000 : 0); + $flags |= (1 == 1 ? 0x00004000 : 0); // Top left to Bottom right border + $flags |= (1 == 1 ? 0x00008000 : 0); // Bottom left to Top right border + // Pattern + $flags |= (1 == $bFillStyle ? 0x00010000 : 0); + $flags |= (1 == $bFillColor ? 0x00020000 : 0); + $flags |= (1 == $bFillColorBg ? 0x00040000 : 0); + $flags |= (1 == 1 ? 0x00380000 : 0); + // Font + $flags |= (1 == $bFormatFont ? 0x04000000 : 0); + // Alignment : + $flags |= (1 == $bFormatAlign ? 0x08000000 : 0); + // Border + $flags |= (1 == $bFormatBorder ? 0x10000000 : 0); + // Pattern + $flags |= (1 == $bFormatFill ? 0x20000000 : 0); + // Protection + $flags |= (1 == $bFormatProt ? 0x40000000 : 0); + // Text direction + $flags |= (1 == 0 ? 0x80000000 : 0); + + // Data Blocks + if($bFormatFont == 1){ + // Font Name + if($conditional->getStyle()->getFont()->getName() == null){ + $dataBlockFont = pack('VVVVVVVV', 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000); + $dataBlockFont .= pack('VVVVVVVV', 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000); + } else { + $dataBlockFont = PHPExcel_Shared_String::UTF8toBIFF8UnicodeLong($conditional->getStyle()->getFont()->getName()); + } + // Font Size + if($conditional->getStyle()->getFont()->getSize() == null){ + $dataBlockFont .= pack('V', 20 * 11); + } else { + $dataBlockFont .= pack('V', 20 * $conditional->getStyle()->getFont()->getSize()); + } + // Font Options + $dataBlockFont .= pack('V', 0); + // Font weight + if($conditional->getStyle()->getFont()->getBold() == true){ + $dataBlockFont .= pack('v', 0x02BC); + } else { + $dataBlockFont .= pack('v', 0x0190); + } + // Escapement type + if($conditional->getStyle()->getFont()->getSubScript() == true){ + $dataBlockFont .= pack('v', 0x02); + $fontEscapement = 0; + } else if($conditional->getStyle()->getFont()->getSuperScript() == true){ + $dataBlockFont .= pack('v', 0x01); + $fontEscapement = 0; + } else { + $dataBlockFont .= pack('v', 0x00); + $fontEscapement = 1; + } + // Underline type + switch ($conditional->getStyle()->getFont()->getUnderline()){ + case PHPExcel_Style_Font::UNDERLINE_NONE : $dataBlockFont .= pack('C', 0x00); $fontUnderline = 0; break; + case PHPExcel_Style_Font::UNDERLINE_DOUBLE : $dataBlockFont .= pack('C', 0x02); $fontUnderline = 0; break; + case PHPExcel_Style_Font::UNDERLINE_DOUBLEACCOUNTING : $dataBlockFont .= pack('C', 0x22); $fontUnderline = 0; break; + case PHPExcel_Style_Font::UNDERLINE_SINGLE : $dataBlockFont .= pack('C', 0x01); $fontUnderline = 0; break; + case PHPExcel_Style_Font::UNDERLINE_SINGLEACCOUNTING : $dataBlockFont .= pack('C', 0x21); $fontUnderline = 0; break; + default : $dataBlockFont .= pack('C', 0x00); $fontUnderline = 1; break; + } + // Not used (3) + $dataBlockFont .= pack('vC', 0x0000, 0x00); + // Font color index + switch ($conditional->getStyle()->getFont()->getColor()->getRGB()) { + case '000000': $colorIdx = 0x08; break; + case 'FFFFFF': $colorIdx = 0x09; break; + case 'FF0000': $colorIdx = 0x0A; break; + case '00FF00': $colorIdx = 0x0B; break; + case '0000FF': $colorIdx = 0x0C; break; + case 'FFFF00': $colorIdx = 0x0D; break; + case 'FF00FF': $colorIdx = 0x0E; break; + case '00FFFF': $colorIdx = 0x0F; break; + case '800000': $colorIdx = 0x10; break; + case '008000': $colorIdx = 0x11; break; + case '000080': $colorIdx = 0x12; break; + case '808000': $colorIdx = 0x13; break; + case '800080': $colorIdx = 0x14; break; + case '008080': $colorIdx = 0x15; break; + case 'C0C0C0': $colorIdx = 0x16; break; + case '808080': $colorIdx = 0x17; break; + case '9999FF': $colorIdx = 0x18; break; + case '993366': $colorIdx = 0x19; break; + case 'FFFFCC': $colorIdx = 0x1A; break; + case 'CCFFFF': $colorIdx = 0x1B; break; + case '660066': $colorIdx = 0x1C; break; + case 'FF8080': $colorIdx = 0x1D; break; + case '0066CC': $colorIdx = 0x1E; break; + case 'CCCCFF': $colorIdx = 0x1F; break; + case '000080': $colorIdx = 0x20; break; + case 'FF00FF': $colorIdx = 0x21; break; + case 'FFFF00': $colorIdx = 0x22; break; + case '00FFFF': $colorIdx = 0x23; break; + case '800080': $colorIdx = 0x24; break; + case '800000': $colorIdx = 0x25; break; + case '008080': $colorIdx = 0x26; break; + case '0000FF': $colorIdx = 0x27; break; + case '00CCFF': $colorIdx = 0x28; break; + case 'CCFFFF': $colorIdx = 0x29; break; + case 'CCFFCC': $colorIdx = 0x2A; break; + case 'FFFF99': $colorIdx = 0x2B; break; + case '99CCFF': $colorIdx = 0x2C; break; + case 'FF99CC': $colorIdx = 0x2D; break; + case 'CC99FF': $colorIdx = 0x2E; break; + case 'FFCC99': $colorIdx = 0x2F; break; + case '3366FF': $colorIdx = 0x30; break; + case '33CCCC': $colorIdx = 0x31; break; + case '99CC00': $colorIdx = 0x32; break; + case 'FFCC00': $colorIdx = 0x33; break; + case 'FF9900': $colorIdx = 0x34; break; + case 'FF6600': $colorIdx = 0x35; break; + case '666699': $colorIdx = 0x36; break; + case '969696': $colorIdx = 0x37; break; + case '003366': $colorIdx = 0x38; break; + case '339966': $colorIdx = 0x39; break; + case '003300': $colorIdx = 0x3A; break; + case '333300': $colorIdx = 0x3B; break; + case '993300': $colorIdx = 0x3C; break; + case '993366': $colorIdx = 0x3D; break; + case '333399': $colorIdx = 0x3E; break; + case '333333': $colorIdx = 0x3F; break; + default: $colorIdx = 0x00; break; + } + $dataBlockFont .= pack('V', $colorIdx); + // Not used (4) + $dataBlockFont .= pack('V', 0x00000000); + // Options flags for modified font attributes + $optionsFlags = 0; + $optionsFlagsBold = ($conditional->getStyle()->getFont()->getBold() == null ? 1 : 0); + $optionsFlags |= (1 == $optionsFlagsBold ? 0x00000002 : 0); + $optionsFlags |= (1 == 1 ? 0x00000008 : 0); + $optionsFlags |= (1 == 1 ? 0x00000010 : 0); + $optionsFlags |= (1 == 0 ? 0x00000020 : 0); + $optionsFlags |= (1 == 1 ? 0x00000080 : 0); + $dataBlockFont .= pack('V', $optionsFlags); + // Escapement type + $dataBlockFont .= pack('V', $fontEscapement); + // Underline type + $dataBlockFont .= pack('V', $fontUnderline); + // Always + $dataBlockFont .= pack('V', 0x00000000); + // Always + $dataBlockFont .= pack('V', 0x00000000); + // Not used (8) + $dataBlockFont .= pack('VV', 0x00000000, 0x00000000); + // Always + $dataBlockFont .= pack('v', 0x0001); + } + if($bFormatAlign == 1){ + $blockAlign = 0; + // Alignment and text break + switch ($conditional->getStyle()->getAlignment()->getHorizontal()){ + case PHPExcel_Style_Alignment::HORIZONTAL_GENERAL : $blockAlign = 0; break; + case PHPExcel_Style_Alignment::HORIZONTAL_LEFT : $blockAlign = 1; break; + case PHPExcel_Style_Alignment::HORIZONTAL_RIGHT : $blockAlign = 3; break; + case PHPExcel_Style_Alignment::HORIZONTAL_CENTER : $blockAlign = 2; break; + case PHPExcel_Style_Alignment::HORIZONTAL_CENTER_CONTINUOUS : $blockAlign = 6; break; + case PHPExcel_Style_Alignment::HORIZONTAL_JUSTIFY : $blockAlign = 5; break; + } + if($conditional->getStyle()->getAlignment()->getWrapText() == true){ + $blockAlign |= 1 << 3; + } else { + $blockAlign |= 0 << 3; + } + switch ($conditional->getStyle()->getAlignment()->getVertical()){ + case PHPExcel_Style_Alignment::VERTICAL_BOTTOM : $blockAlign = 2 << 4; break; + case PHPExcel_Style_Alignment::VERTICAL_TOP : $blockAlign = 0 << 4; break; + case PHPExcel_Style_Alignment::VERTICAL_CENTER : $blockAlign = 1 << 4; break; + case PHPExcel_Style_Alignment::VERTICAL_JUSTIFY : $blockAlign = 3 << 4; break; + } + $blockAlign |= 0 << 7; + + // Text rotation angle + $blockRotation = $conditional->getStyle()->getAlignment()->getTextRotation(); + + // Indentation + $blockIndent = $conditional->getStyle()->getAlignment()->getIndent(); + if($conditional->getStyle()->getAlignment()->getShrinkToFit() == true){ + $blockIndent |= 1 << 4; + } else { + $blockIndent |= 0 << 4; + } + $blockIndent |= 0 << 6; + + // Relative indentation + $blockIndentRelative = 255; + + $dataBlockAlign = pack('CCvvv', $blockAlign, $blockRotation, $blockIndent, $blockIndentRelative, 0x0000); + } + if($bFormatBorder == 1){ + $blockLineStyle = 0; + switch ($conditional->getStyle()->getBorders()->getLeft()->getBorderStyle()){ + case PHPExcel_Style_Border::BORDER_NONE : $blockLineStyle |= 0x00; break; + case PHPExcel_Style_Border::BORDER_THIN : $blockLineStyle |= 0x01; break; + case PHPExcel_Style_Border::BORDER_MEDIUM : $blockLineStyle |= 0x02; break; + case PHPExcel_Style_Border::BORDER_DASHED : $blockLineStyle |= 0x03; break; + case PHPExcel_Style_Border::BORDER_DOTTED : $blockLineStyle |= 0x04; break; + case PHPExcel_Style_Border::BORDER_THICK : $blockLineStyle |= 0x05; break; + case PHPExcel_Style_Border::BORDER_DOUBLE : $blockLineStyle |= 0x06; break; + case PHPExcel_Style_Border::BORDER_HAIR : $blockLineStyle |= 0x07; break; + case PHPExcel_Style_Border::BORDER_MEDIUMDASHED : $blockLineStyle |= 0x08; break; + case PHPExcel_Style_Border::BORDER_DASHDOT : $blockLineStyle |= 0x09; break; + case PHPExcel_Style_Border::BORDER_MEDIUMDASHDOT : $blockLineStyle |= 0x0A; break; + case PHPExcel_Style_Border::BORDER_DASHDOTDOT : $blockLineStyle |= 0x0B; break; + case PHPExcel_Style_Border::BORDER_MEDIUMDASHDOTDOT : $blockLineStyle |= 0x0C; break; + case PHPExcel_Style_Border::BORDER_SLANTDASHDOT : $blockLineStyle |= 0x0D; break; + } + switch ($conditional->getStyle()->getBorders()->getRight()->getBorderStyle()){ + case PHPExcel_Style_Border::BORDER_NONE : $blockLineStyle |= 0x00 << 4; break; + case PHPExcel_Style_Border::BORDER_THIN : $blockLineStyle |= 0x01 << 4; break; + case PHPExcel_Style_Border::BORDER_MEDIUM : $blockLineStyle |= 0x02 << 4; break; + case PHPExcel_Style_Border::BORDER_DASHED : $blockLineStyle |= 0x03 << 4; break; + case PHPExcel_Style_Border::BORDER_DOTTED : $blockLineStyle |= 0x04 << 4; break; + case PHPExcel_Style_Border::BORDER_THICK : $blockLineStyle |= 0x05 << 4; break; + case PHPExcel_Style_Border::BORDER_DOUBLE : $blockLineStyle |= 0x06 << 4; break; + case PHPExcel_Style_Border::BORDER_HAIR : $blockLineStyle |= 0x07 << 4; break; + case PHPExcel_Style_Border::BORDER_MEDIUMDASHED : $blockLineStyle |= 0x08 << 4; break; + case PHPExcel_Style_Border::BORDER_DASHDOT : $blockLineStyle |= 0x09 << 4; break; + case PHPExcel_Style_Border::BORDER_MEDIUMDASHDOT : $blockLineStyle |= 0x0A << 4; break; + case PHPExcel_Style_Border::BORDER_DASHDOTDOT : $blockLineStyle |= 0x0B << 4; break; + case PHPExcel_Style_Border::BORDER_MEDIUMDASHDOTDOT : $blockLineStyle |= 0x0C << 4; break; + case PHPExcel_Style_Border::BORDER_SLANTDASHDOT : $blockLineStyle |= 0x0D << 4; break; + } + switch ($conditional->getStyle()->getBorders()->getTop()->getBorderStyle()){ + case PHPExcel_Style_Border::BORDER_NONE : $blockLineStyle |= 0x00 << 8; break; + case PHPExcel_Style_Border::BORDER_THIN : $blockLineStyle |= 0x01 << 8; break; + case PHPExcel_Style_Border::BORDER_MEDIUM : $blockLineStyle |= 0x02 << 8; break; + case PHPExcel_Style_Border::BORDER_DASHED : $blockLineStyle |= 0x03 << 8; break; + case PHPExcel_Style_Border::BORDER_DOTTED : $blockLineStyle |= 0x04 << 8; break; + case PHPExcel_Style_Border::BORDER_THICK : $blockLineStyle |= 0x05 << 8; break; + case PHPExcel_Style_Border::BORDER_DOUBLE : $blockLineStyle |= 0x06 << 8; break; + case PHPExcel_Style_Border::BORDER_HAIR : $blockLineStyle |= 0x07 << 8; break; + case PHPExcel_Style_Border::BORDER_MEDIUMDASHED : $blockLineStyle |= 0x08 << 8; break; + case PHPExcel_Style_Border::BORDER_DASHDOT : $blockLineStyle |= 0x09 << 8; break; + case PHPExcel_Style_Border::BORDER_MEDIUMDASHDOT : $blockLineStyle |= 0x0A << 8; break; + case PHPExcel_Style_Border::BORDER_DASHDOTDOT : $blockLineStyle |= 0x0B << 8; break; + case PHPExcel_Style_Border::BORDER_MEDIUMDASHDOTDOT : $blockLineStyle |= 0x0C << 8; break; + case PHPExcel_Style_Border::BORDER_SLANTDASHDOT : $blockLineStyle |= 0x0D << 8; break; + } + switch ($conditional->getStyle()->getBorders()->getBottom()->getBorderStyle()){ + case PHPExcel_Style_Border::BORDER_NONE : $blockLineStyle |= 0x00 << 12; break; + case PHPExcel_Style_Border::BORDER_THIN : $blockLineStyle |= 0x01 << 12; break; + case PHPExcel_Style_Border::BORDER_MEDIUM : $blockLineStyle |= 0x02 << 12; break; + case PHPExcel_Style_Border::BORDER_DASHED : $blockLineStyle |= 0x03 << 12; break; + case PHPExcel_Style_Border::BORDER_DOTTED : $blockLineStyle |= 0x04 << 12; break; + case PHPExcel_Style_Border::BORDER_THICK : $blockLineStyle |= 0x05 << 12; break; + case PHPExcel_Style_Border::BORDER_DOUBLE : $blockLineStyle |= 0x06 << 12; break; + case PHPExcel_Style_Border::BORDER_HAIR : $blockLineStyle |= 0x07 << 12; break; + case PHPExcel_Style_Border::BORDER_MEDIUMDASHED : $blockLineStyle |= 0x08 << 12; break; + case PHPExcel_Style_Border::BORDER_DASHDOT : $blockLineStyle |= 0x09 << 12; break; + case PHPExcel_Style_Border::BORDER_MEDIUMDASHDOT : $blockLineStyle |= 0x0A << 12; break; + case PHPExcel_Style_Border::BORDER_DASHDOTDOT : $blockLineStyle |= 0x0B << 12; break; + case PHPExcel_Style_Border::BORDER_MEDIUMDASHDOTDOT : $blockLineStyle |= 0x0C << 12; break; + case PHPExcel_Style_Border::BORDER_SLANTDASHDOT : $blockLineStyle |= 0x0D << 12; break; + } + //@todo _writeCFRule() => $blockLineStyle => Index Color for left line + //@todo _writeCFRule() => $blockLineStyle => Index Color for right line + //@todo _writeCFRule() => $blockLineStyle => Top-left to bottom-right on/off + //@todo _writeCFRule() => $blockLineStyle => Bottom-left to top-right on/off + $blockColor = 0; + //@todo _writeCFRule() => $blockColor => Index Color for top line + //@todo _writeCFRule() => $blockColor => Index Color for bottom line + //@todo _writeCFRule() => $blockColor => Index Color for diagonal line + switch ($conditional->getStyle()->getBorders()->getDiagonal()->getBorderStyle()){ + case PHPExcel_Style_Border::BORDER_NONE : $blockColor |= 0x00 << 21; break; + case PHPExcel_Style_Border::BORDER_THIN : $blockColor |= 0x01 << 21; break; + case PHPExcel_Style_Border::BORDER_MEDIUM : $blockColor |= 0x02 << 21; break; + case PHPExcel_Style_Border::BORDER_DASHED : $blockColor |= 0x03 << 21; break; + case PHPExcel_Style_Border::BORDER_DOTTED : $blockColor |= 0x04 << 21; break; + case PHPExcel_Style_Border::BORDER_THICK : $blockColor |= 0x05 << 21; break; + case PHPExcel_Style_Border::BORDER_DOUBLE : $blockColor |= 0x06 << 21; break; + case PHPExcel_Style_Border::BORDER_HAIR : $blockColor |= 0x07 << 21; break; + case PHPExcel_Style_Border::BORDER_MEDIUMDASHED : $blockColor |= 0x08 << 21; break; + case PHPExcel_Style_Border::BORDER_DASHDOT : $blockColor |= 0x09 << 21; break; + case PHPExcel_Style_Border::BORDER_MEDIUMDASHDOT : $blockColor |= 0x0A << 21; break; + case PHPExcel_Style_Border::BORDER_DASHDOTDOT : $blockColor |= 0x0B << 21; break; + case PHPExcel_Style_Border::BORDER_MEDIUMDASHDOTDOT : $blockColor |= 0x0C << 21; break; + case PHPExcel_Style_Border::BORDER_SLANTDASHDOT : $blockColor |= 0x0D << 21; break; + } + $dataBlockBorder = pack('vv', $blockLineStyle, $blockColor); + } + if($bFormatFill == 1){ + // Fill Patern Style + $blockFillPatternStyle = 0; + switch ($conditional->getStyle()->getFill()->getFillType()){ + case PHPExcel_Style_Fill::FILL_NONE : $blockFillPatternStyle = 0x00; break; + case PHPExcel_Style_Fill::FILL_SOLID : $blockFillPatternStyle = 0x01; break; + case PHPExcel_Style_Fill::FILL_PATTERN_MEDIUMGRAY : $blockFillPatternStyle = 0x02; break; + case PHPExcel_Style_Fill::FILL_PATTERN_DARKGRAY : $blockFillPatternStyle = 0x03; break; + case PHPExcel_Style_Fill::FILL_PATTERN_LIGHTGRAY : $blockFillPatternStyle = 0x04; break; + case PHPExcel_Style_Fill::FILL_PATTERN_DARKHORIZONTAL : $blockFillPatternStyle = 0x05; break; + case PHPExcel_Style_Fill::FILL_PATTERN_DARKVERTICAL : $blockFillPatternStyle = 0x06; break; + case PHPExcel_Style_Fill::FILL_PATTERN_DARKDOWN : $blockFillPatternStyle = 0x07; break; + case PHPExcel_Style_Fill::FILL_PATTERN_DARKUP : $blockFillPatternStyle = 0x08; break; + case PHPExcel_Style_Fill::FILL_PATTERN_DARKGRID : $blockFillPatternStyle = 0x09; break; + case PHPExcel_Style_Fill::FILL_PATTERN_DARKTRELLIS : $blockFillPatternStyle = 0x0A; break; + case PHPExcel_Style_Fill::FILL_PATTERN_LIGHTHORIZONTAL : $blockFillPatternStyle = 0x0B; break; + case PHPExcel_Style_Fill::FILL_PATTERN_LIGHTVERTICAL : $blockFillPatternStyle = 0x0C; break; + case PHPExcel_Style_Fill::FILL_PATTERN_LIGHTDOWN : $blockFillPatternStyle = 0x0D; break; + case PHPExcel_Style_Fill::FILL_PATTERN_LIGHTUP : $blockFillPatternStyle = 0x0E; break; + case PHPExcel_Style_Fill::FILL_PATTERN_LIGHTGRID : $blockFillPatternStyle = 0x0F; break; + case PHPExcel_Style_Fill::FILL_PATTERN_LIGHTTRELLIS : $blockFillPatternStyle = 0x10; break; + case PHPExcel_Style_Fill::FILL_PATTERN_GRAY125 : $blockFillPatternStyle = 0x11; break; + case PHPExcel_Style_Fill::FILL_PATTERN_GRAY0625 : $blockFillPatternStyle = 0x12; break; + case PHPExcel_Style_Fill::FILL_GRADIENT_LINEAR : $blockFillPatternStyle = 0x00; break; // does not exist in BIFF8 + case PHPExcel_Style_Fill::FILL_GRADIENT_PATH : $blockFillPatternStyle = 0x00; break; // does not exist in BIFF8 + default : $blockFillPatternStyle = 0x00; break; + } + // Color + switch ($conditional->getStyle()->getFill()->getStartColor()->getRGB()) { + case '000000': $colorIdxBg = 0x08; break; + case 'FFFFFF': $colorIdxBg = 0x09; break; + case 'FF0000': $colorIdxBg = 0x0A; break; + case '00FF00': $colorIdxBg = 0x0B; break; + case '0000FF': $colorIdxBg = 0x0C; break; + case 'FFFF00': $colorIdxBg = 0x0D; break; + case 'FF00FF': $colorIdxBg = 0x0E; break; + case '00FFFF': $colorIdxBg = 0x0F; break; + case '800000': $colorIdxBg = 0x10; break; + case '008000': $colorIdxBg = 0x11; break; + case '000080': $colorIdxBg = 0x12; break; + case '808000': $colorIdxBg = 0x13; break; + case '800080': $colorIdxBg = 0x14; break; + case '008080': $colorIdxBg = 0x15; break; + case 'C0C0C0': $colorIdxBg = 0x16; break; + case '808080': $colorIdxBg = 0x17; break; + case '9999FF': $colorIdxBg = 0x18; break; + case '993366': $colorIdxBg = 0x19; break; + case 'FFFFCC': $colorIdxBg = 0x1A; break; + case 'CCFFFF': $colorIdxBg = 0x1B; break; + case '660066': $colorIdxBg = 0x1C; break; + case 'FF8080': $colorIdxBg = 0x1D; break; + case '0066CC': $colorIdxBg = 0x1E; break; + case 'CCCCFF': $colorIdxBg = 0x1F; break; + case '000080': $colorIdxBg = 0x20; break; + case 'FF00FF': $colorIdxBg = 0x21; break; + case 'FFFF00': $colorIdxBg = 0x22; break; + case '00FFFF': $colorIdxBg = 0x23; break; + case '800080': $colorIdxBg = 0x24; break; + case '800000': $colorIdxBg = 0x25; break; + case '008080': $colorIdxBg = 0x26; break; + case '0000FF': $colorIdxBg = 0x27; break; + case '00CCFF': $colorIdxBg = 0x28; break; + case 'CCFFFF': $colorIdxBg = 0x29; break; + case 'CCFFCC': $colorIdxBg = 0x2A; break; + case 'FFFF99': $colorIdxBg = 0x2B; break; + case '99CCFF': $colorIdxBg = 0x2C; break; + case 'FF99CC': $colorIdxBg = 0x2D; break; + case 'CC99FF': $colorIdxBg = 0x2E; break; + case 'FFCC99': $colorIdxBg = 0x2F; break; + case '3366FF': $colorIdxBg = 0x30; break; + case '33CCCC': $colorIdxBg = 0x31; break; + case '99CC00': $colorIdxBg = 0x32; break; + case 'FFCC00': $colorIdxBg = 0x33; break; + case 'FF9900': $colorIdxBg = 0x34; break; + case 'FF6600': $colorIdxBg = 0x35; break; + case '666699': $colorIdxBg = 0x36; break; + case '969696': $colorIdxBg = 0x37; break; + case '003366': $colorIdxBg = 0x38; break; + case '339966': $colorIdxBg = 0x39; break; + case '003300': $colorIdxBg = 0x3A; break; + case '333300': $colorIdxBg = 0x3B; break; + case '993300': $colorIdxBg = 0x3C; break; + case '993366': $colorIdxBg = 0x3D; break; + case '333399': $colorIdxBg = 0x3E; break; + case '333333': $colorIdxBg = 0x3F; break; + default: $colorIdxBg = 0x41; break; + } + // Fg Color + switch ($conditional->getStyle()->getFill()->getEndColor()->getRGB()) { + case '000000': $colorIdxFg = 0x08; break; + case 'FFFFFF': $colorIdxFg = 0x09; break; + case 'FF0000': $colorIdxFg = 0x0A; break; + case '00FF00': $colorIdxFg = 0x0B; break; + case '0000FF': $colorIdxFg = 0x0C; break; + case 'FFFF00': $colorIdxFg = 0x0D; break; + case 'FF00FF': $colorIdxFg = 0x0E; break; + case '00FFFF': $colorIdxFg = 0x0F; break; + case '800000': $colorIdxFg = 0x10; break; + case '008000': $colorIdxFg = 0x11; break; + case '000080': $colorIdxFg = 0x12; break; + case '808000': $colorIdxFg = 0x13; break; + case '800080': $colorIdxFg = 0x14; break; + case '008080': $colorIdxFg = 0x15; break; + case 'C0C0C0': $colorIdxFg = 0x16; break; + case '808080': $colorIdxFg = 0x17; break; + case '9999FF': $colorIdxFg = 0x18; break; + case '993366': $colorIdxFg = 0x19; break; + case 'FFFFCC': $colorIdxFg = 0x1A; break; + case 'CCFFFF': $colorIdxFg = 0x1B; break; + case '660066': $colorIdxFg = 0x1C; break; + case 'FF8080': $colorIdxFg = 0x1D; break; + case '0066CC': $colorIdxFg = 0x1E; break; + case 'CCCCFF': $colorIdxFg = 0x1F; break; + case '000080': $colorIdxFg = 0x20; break; + case 'FF00FF': $colorIdxFg = 0x21; break; + case 'FFFF00': $colorIdxFg = 0x22; break; + case '00FFFF': $colorIdxFg = 0x23; break; + case '800080': $colorIdxFg = 0x24; break; + case '800000': $colorIdxFg = 0x25; break; + case '008080': $colorIdxFg = 0x26; break; + case '0000FF': $colorIdxFg = 0x27; break; + case '00CCFF': $colorIdxFg = 0x28; break; + case 'CCFFFF': $colorIdxFg = 0x29; break; + case 'CCFFCC': $colorIdxFg = 0x2A; break; + case 'FFFF99': $colorIdxFg = 0x2B; break; + case '99CCFF': $colorIdxFg = 0x2C; break; + case 'FF99CC': $colorIdxFg = 0x2D; break; + case 'CC99FF': $colorIdxFg = 0x2E; break; + case 'FFCC99': $colorIdxFg = 0x2F; break; + case '3366FF': $colorIdxFg = 0x30; break; + case '33CCCC': $colorIdxFg = 0x31; break; + case '99CC00': $colorIdxFg = 0x32; break; + case 'FFCC00': $colorIdxFg = 0x33; break; + case 'FF9900': $colorIdxFg = 0x34; break; + case 'FF6600': $colorIdxFg = 0x35; break; + case '666699': $colorIdxFg = 0x36; break; + case '969696': $colorIdxFg = 0x37; break; + case '003366': $colorIdxFg = 0x38; break; + case '339966': $colorIdxFg = 0x39; break; + case '003300': $colorIdxFg = 0x3A; break; + case '333300': $colorIdxFg = 0x3B; break; + case '993300': $colorIdxFg = 0x3C; break; + case '993366': $colorIdxFg = 0x3D; break; + case '333399': $colorIdxFg = 0x3E; break; + case '333333': $colorIdxFg = 0x3F; break; + default: $colorIdxFg = 0x40; break; + } + $dataBlockFill = pack('v', $blockFillPatternStyle); + $dataBlockFill .= pack('v', $colorIdxFg | ($colorIdxBg << 7)); + } + if($bFormatProt == 1){ + $dataBlockProtection = 0; + if($conditional->getStyle()->getProtection()->getLocked() == PHPExcel_Style_Protection::PROTECTION_PROTECTED){ + $dataBlockProtection = 1; + } + if($conditional->getStyle()->getProtection()->getHidden() == PHPExcel_Style_Protection::PROTECTION_PROTECTED){ + $dataBlockProtection = 1 << 1; + } + } + + $data = pack('CCvvVv', $type, $operatorType, $szValue1, $szValue2, $flags, 0x0000); + if($bFormatFont == 1){ // Block Formatting : OK + $data .= $dataBlockFont; + } + if($bFormatAlign == 1){ + $data .= $dataBlockAlign; + } + if($bFormatBorder == 1){ + $data .= $dataBlockBorder; + } + if($bFormatFill == 1){ // Block Formatting : OK + $data .= $dataBlockFill; + } + if($bFormatProt == 1){ + $data .= $dataBlockProtection; + } + if(!is_null($operand1)){ + $data .= $operand1; + } + if(!is_null($operand2)){ + $data .= $operand2; + } + $header = pack('vv', $record, strlen($data)); + $this->_append($header . $data); + } + + /** + * Write CFHeader record + */ + private function _writeCFHeader(){ + $record = 0x01B0; // Record identifier + $length = 0x0016; // Bytes to follow + + $numColumnMin = null; + $numColumnMax = null; + $numRowMin = null; + $numRowMax = null; + $arrConditional = array(); + foreach ($this->_phpSheet->getConditionalStylesCollection() as $cellCoordinate => $conditionalStyles) { + foreach ($conditionalStyles as $conditional) { + if($conditional->getConditionType() == PHPExcel_Style_Conditional::CONDITION_EXPRESSION + || $conditional->getConditionType() == PHPExcel_Style_Conditional::CONDITION_CELLIS){ + if(!in_array($conditional->getHashCode(), $arrConditional)){ + $arrConditional[] = $conditional->getHashCode(); + } + // Cells + $arrCoord = PHPExcel_Cell::coordinateFromString($cellCoordinate); + if(!is_numeric($arrCoord[0])){ + $arrCoord[0] = PHPExcel_Cell::columnIndexFromString($arrCoord[0]); + } + if(is_null($numColumnMin) || ($numColumnMin > $arrCoord[0])){ + $numColumnMin = $arrCoord[0]; + } + if(is_null($numColumnMax) || ($numColumnMax < $arrCoord[0])){ + $numColumnMax = $arrCoord[0]; + } + if(is_null($numRowMin) || ($numRowMin > $arrCoord[1])){ + $numRowMin = $arrCoord[1]; + } + if(is_null($numRowMax) || ($numRowMax < $arrCoord[1])){ + $numRowMax = $arrCoord[1]; + } + } + } + } + $needRedraw = 1; + $cellRange = pack('vvvv', $numRowMin-1, $numRowMax-1, $numColumnMin-1, $numColumnMax-1); + + $header = pack('vv', $record, $length); + $data = pack('vv', count($arrConditional), $needRedraw); + $data .= $cellRange; + $data .= pack('v', 0x0001); + $data .= $cellRange; + $this->_append($header . $data); + } } \ No newline at end of file diff --git a/htdocs/includes/phpexcel/PHPExcel/Writer/Excel5/Xf.php b/htdocs/includes/phpexcel/PHPExcel/Writer/Excel5/Xf.php index 06fb1d9d8cf..f803f68346b 100644 --- a/htdocs/includes/phpexcel/PHPExcel/Writer/Excel5/Xf.php +++ b/htdocs/includes/phpexcel/PHPExcel/Writer/Excel5/Xf.php @@ -2,7 +2,7 @@ /** * PHPExcel * - * Copyright (c) 2006 - 2012 PHPExcel + * Copyright (c) 2006 - 2014 PHPExcel * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,9 +20,9 @@ * * @category PHPExcel * @package PHPExcel_Writer_Excel5 - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version 1.7.8, 2012-10-12 + * @version 1.8.0, 2014-03-02 */ // Original file header of PEAR::Spreadsheet_Excel_Writer_Format (used as the base for this class): @@ -66,7 +66,7 @@ * * @category PHPExcel * @package PHPExcel_Writer_Excel5 - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) */ class PHPExcel_Writer_Excel5_Xf { @@ -179,7 +179,7 @@ class PHPExcel_Writer_Excel5_Xf // Flags to indicate if attributes have been set. $atr_num = ($this->_numberFormatIndex != 0)?1:0; $atr_fnt = ($this->_fontIndex != 0)?1:0; - $atr_alc = ((int) $this->_style->getAlignment()->getWrapText())?1:0; + $atr_alc = ((int) $this->_style->getAlignment()->getWrapText()) ? 1 : 0; $atr_bdr = (self::_mapBorderStyle($this->_style->getBorders()->getBottom()->getBorderStyle()) || self::_mapBorderStyle($this->_style->getBorders()->getTop()->getBorderStyle()) || self::_mapBorderStyle($this->_style->getBorders()->getLeft()->getBorderStyle()) || @@ -457,6 +457,7 @@ class PHPExcel_Writer_Excel5_Xf PHPExcel_Style_Alignment::HORIZONTAL_LEFT => 1, PHPExcel_Style_Alignment::HORIZONTAL_CENTER => 2, PHPExcel_Style_Alignment::HORIZONTAL_RIGHT => 3, + PHPExcel_Style_Alignment::HORIZONTAL_FILL => 4, PHPExcel_Style_Alignment::HORIZONTAL_JUSTIFY => 5, PHPExcel_Style_Alignment::HORIZONTAL_CENTER_CONTINUOUS => 6, ); diff --git a/htdocs/includes/phpexcel/PHPExcel/Writer/Exception.php b/htdocs/includes/phpexcel/PHPExcel/Writer/Exception.php new file mode 100644 index 00000000000..e8fe9be783d --- /dev/null +++ b/htdocs/includes/phpexcel/PHPExcel/Writer/Exception.php @@ -0,0 +1,52 @@ +line = $line; + $e->file = $file; + throw $e; + } +} diff --git a/htdocs/includes/phpexcel/PHPExcel/Writer/HTML.php b/htdocs/includes/phpexcel/PHPExcel/Writer/HTML.php index f0aafafed34..0f2cc089f6b 100644 --- a/htdocs/includes/phpexcel/PHPExcel/Writer/HTML.php +++ b/htdocs/includes/phpexcel/PHPExcel/Writer/HTML.php @@ -2,7 +2,7 @@ /** * PHPExcel * - * Copyright (c) 2006 - 2012 PHPExcel + * Copyright (c) 2006 - 2014 PHPExcel * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -19,10 +19,10 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * @category PHPExcel - * @package PHPExcel_Writer - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @package PHPExcel_Writer_HTML + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version 1.7.8, 2012-10-12 + * @version 1.8.0, 2014-03-02 */ @@ -30,10 +30,10 @@ * PHPExcel_Writer_HTML * * @category PHPExcel - * @package PHPExcel_Writer - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @package PHPExcel_Writer_HTML + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) */ -class PHPExcel_Writer_HTML implements PHPExcel_Writer_IWriter { +class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_Writer_IWriter { /** * PHPExcel object * @@ -48,13 +48,6 @@ class PHPExcel_Writer_HTML implements PHPExcel_Writer_IWriter { */ private $_sheetIndex = 0; - /** - * Pre-calculate formulas - * - * @var boolean - */ - private $_preCalculateFormulas = true; - /** * Images root * @@ -62,6 +55,13 @@ class PHPExcel_Writer_HTML implements PHPExcel_Writer_IWriter { */ private $_imagesRoot = '.'; + /** + * embed images, or link to images + * + * @var boolean + */ + private $_embedImages = FALSE; + /** * Use inline CSS? * @@ -146,14 +146,14 @@ class PHPExcel_Writer_HTML implements PHPExcel_Writer_IWriter { * Save PHPExcel to file * * @param string $pFilename - * @throws Exception + * @throws PHPExcel_Writer_Exception */ public function save($pFilename = null) { // garbage collect $this->_phpExcel->garbageCollect(); - $saveDebugLog = PHPExcel_Calculation::getInstance()->writeDebugLog; - PHPExcel_Calculation::getInstance()->writeDebugLog = false; + $saveDebugLog = PHPExcel_Calculation::getInstance($this->_phpExcel)->getDebugLog()->getWriteDebugLog(); + PHPExcel_Calculation::getInstance($this->_phpExcel)->getDebugLog()->setWriteDebugLog(FALSE); $saveArrayReturnType = PHPExcel_Calculation::getArrayReturnType(); PHPExcel_Calculation::setArrayReturnType(PHPExcel_Calculation::RETURN_ARRAY_AS_VALUE); @@ -163,7 +163,7 @@ class PHPExcel_Writer_HTML implements PHPExcel_Writer_IWriter { // Open file $fileHandle = fopen($pFilename, 'wb+'); if ($fileHandle === false) { - throw new Exception("Could not open file $pFilename for writing."); + throw new PHPExcel_Writer_Exception("Could not open file $pFilename for writing."); } // Write headers @@ -184,7 +184,7 @@ class PHPExcel_Writer_HTML implements PHPExcel_Writer_IWriter { fclose($fileHandle); PHPExcel_Calculation::setArrayReturnType($saveArrayReturnType); - PHPExcel_Calculation::getInstance()->writeDebugLog = $saveDebugLog; + PHPExcel_Calculation::getInstance($this->_phpExcel)->getDebugLog()->setWriteDebugLog($saveDebugLog); } /** @@ -300,12 +300,12 @@ class PHPExcel_Writer_HTML implements PHPExcel_Writer_IWriter { * * @param boolean $pIncludeStyles Include styles? * @return string - * @throws Exception + * @throws PHPExcel_Writer_Exception */ public function generateHTMLHeader($pIncludeStyles = false) { // PHPExcel object known? if (is_null($this->_phpExcel)) { - throw new Exception('Internal PHPExcel object not set to an instance of an object.'); + throw new PHPExcel_Writer_Exception('Internal PHPExcel object not set to an instance of an object.'); } // Construct HTML @@ -351,12 +351,12 @@ class PHPExcel_Writer_HTML implements PHPExcel_Writer_IWriter { * Generate sheet data * * @return string - * @throws Exception + * @throws PHPExcel_Writer_Exception */ public function generateSheetData() { // PHPExcel object known? if (is_null($this->_phpExcel)) { - throw new Exception('Internal PHPExcel object not set to an instance of an object.'); + throw new PHPExcel_Writer_Exception('Internal PHPExcel object not set to an instance of an object.'); } // Ensure that Spans have been calculated? @@ -394,7 +394,6 @@ class PHPExcel_Writer_HTML implements PHPExcel_Writer_IWriter { // calculate start of , $tbodyStart = $rowMin; - $tbodyEnd = $rowMax; $theadStart = $theadEnd = 0; // default: no no if ($sheet->getPageSetup()->isRowsToRepeatAtTopSet()) { $rowsToRepeatAtTop = $sheet->getPageSetup()->getRowsToRepeatAtTop(); @@ -429,7 +428,7 @@ class PHPExcel_Writer_HTML implements PHPExcel_Writer_IWriter { while($column++ < $dimension[1][0]) { // Cell exists? if ($sheet->cellExistsByColumnAndRow($column, $row)) { - $rowData[$column] = $sheet->getCellByColumnAndRow($column, $row); + $rowData[$column] = PHPExcel_Cell::stringFromColumnIndex($column) . $row; } else { $rowData[$column] = ''; } @@ -441,12 +440,11 @@ class PHPExcel_Writer_HTML implements PHPExcel_Writer_IWriter { if ($row == $theadEnd) { $html .= ' ' . PHP_EOL; } - - // ? - if ($row == $tbodyEnd) { - $html .= ' ' . PHP_EOL; - } } + $html .= $this->_extendRowsForChartsAndImages($sheet, $row); + + // Close table body. + $html .= ' ' . PHP_EOL; // Write table footer $html .= $this->_generateTableFooter(); @@ -470,13 +468,13 @@ class PHPExcel_Writer_HTML implements PHPExcel_Writer_IWriter { * Generate sheet tabs * * @return string - * @throws Exception + * @throws PHPExcel_Writer_Exception */ public function generateNavigation() { // PHPExcel object known? if (is_null($this->_phpExcel)) { - throw new Exception('Internal PHPExcel object not set to an instance of an object.'); + throw new PHPExcel_Writer_Exception('Internal PHPExcel object not set to an instance of an object.'); } // Fetch sheets @@ -508,15 +506,65 @@ class PHPExcel_Writer_HTML implements PHPExcel_Writer_IWriter { return $html; } + private function _extendRowsForChartsAndImages(PHPExcel_Worksheet $pSheet, $row) { + $rowMax = $row; + $colMax = 'A'; + if ($this->_includeCharts) { + foreach ($pSheet->getChartCollection() as $chart) { + if ($chart instanceof PHPExcel_Chart) { + $chartCoordinates = $chart->getTopLeftPosition(); + $chartTL = PHPExcel_Cell::coordinateFromString($chartCoordinates['cell']); + $chartCol = PHPExcel_Cell::columnIndexFromString($chartTL[0]); + if ($chartTL[1] > $rowMax) { + $rowMax = $chartTL[1]; + if ($chartCol > PHPExcel_Cell::columnIndexFromString($colMax)) { + $colMax = $chartTL[0]; + } + } + } + } + } + + foreach ($pSheet->getDrawingCollection() as $drawing) { + if ($drawing instanceof PHPExcel_Worksheet_Drawing) { + $imageTL = PHPExcel_Cell::coordinateFromString($drawing->getCoordinates()); + $imageCol = PHPExcel_Cell::columnIndexFromString($imageTL[0]); + if ($imageTL[1] > $rowMax) { + $rowMax = $imageTL[1]; + if ($imageCol > PHPExcel_Cell::columnIndexFromString($colMax)) { + $colMax = $imageTL[0]; + } + } + } + } + $html = ''; + $colMax++; + while ($row < $rowMax) { + $html .= ''; + for ($col = 'A'; $col != $colMax; ++$col) { + $html .= ''; + $html .= $this->_writeImageInCell($pSheet, $col.$row); + if ($this->_includeCharts) { + $html .= $this->_writeChartInCell($pSheet, $col.$row); + } + $html .= ''; + } + ++$row; + $html .= ''; + } + return $html; + } + + /** * Generate image tag in cell * * @param PHPExcel_Worksheet $pSheet PHPExcel_Worksheet * @param string $coordinates Cell coordinates * @return string - * @throws Exception + * @throws PHPExcel_Writer_Exception */ - private function _writeImageTagInCell(PHPExcel_Worksheet $pSheet, $coordinates) { + private function _writeImageInCell(PHPExcel_Worksheet $pSheet, $coordinates) { // Construct HTML $html = ''; @@ -543,7 +591,74 @@ class PHPExcel_Writer_HTML implements PHPExcel_Writer_IWriter { $filename = htmlspecialchars($filename); $html .= PHP_EOL; - $html .= ' ' . PHP_EOL; + if ((!$this->_embedImages) || ($this->_isPdf)) { + $imageData = $filename; + } else { + $imageDetails = getimagesize($filename); + if ($fp = fopen($filename,"rb", 0)) { + $picture = fread($fp,filesize($filename)); + fclose($fp); + // base64 encode the binary data, then break it + // into chunks according to RFC 2045 semantics + $base64 = chunk_split(base64_encode($picture)); + $imageData = 'data:'.$imageDetails['mime'].';base64,' . $base64; + } else { + $imageData = $filename; + } + } + + $html .= '

'; + $html .= ''; + $html .= '
'; + } + } + } + + // Return + return $html; + } + + /** + * Generate chart tag in cell + * + * @param PHPExcel_Worksheet $pSheet PHPExcel_Worksheet + * @param string $coordinates Cell coordinates + * @return string + * @throws PHPExcel_Writer_Exception + */ + private function _writeChartInCell(PHPExcel_Worksheet $pSheet, $coordinates) { + // Construct HTML + $html = ''; + + // Write charts + foreach ($pSheet->getChartCollection() as $chart) { + if ($chart instanceof PHPExcel_Chart) { + $chartCoordinates = $chart->getTopLeftPosition(); + if ($chartCoordinates['cell'] == $coordinates) { + $chartFileName = PHPExcel_Shared_File::sys_get_temp_dir().'/'.uniqid().'.png'; + if (!$chart->render($chartFileName)) { + return; + } + + $html .= PHP_EOL; + $imageDetails = getimagesize($chartFileName); + if ($fp = fopen($chartFileName,"rb", 0)) { + $picture = fread($fp,filesize($chartFileName)); + fclose($fp); + // base64 encode the binary data, then break it + // into chunks according to RFC 2045 semantics + $base64 = chunk_split(base64_encode($picture)); + $imageData = 'data:'.$imageDetails['mime'].';base64,' . $base64; + + $html .= '
'; + $html .= '' . PHP_EOL; + $html .= '
'; + + unlink($chartFileName); + } } } } @@ -557,12 +672,12 @@ class PHPExcel_Writer_HTML implements PHPExcel_Writer_IWriter { * * @param boolean $generateSurroundingHTML Generate surrounding HTML tags? () * @return string - * @throws Exception + * @throws PHPExcel_Writer_Exception */ public function generateStyles($generateSurroundingHTML = true) { // PHPExcel object known? if (is_null($this->_phpExcel)) { - throw new Exception('Internal PHPExcel object not set to an instance of an object.'); + throw new PHPExcel_Writer_Exception('Internal PHPExcel object not set to an instance of an object.'); } // Build CSS @@ -598,12 +713,12 @@ class PHPExcel_Writer_HTML implements PHPExcel_Writer_IWriter { * * @param boolean $generateSurroundingHTML Generate surrounding HTML style? (html { }) * @return array - * @throws Exception + * @throws PHPExcel_Writer_Exception */ public function buildCSS($generateSurroundingHTML = true) { // PHPExcel object known? if (is_null($this->_phpExcel)) { - throw new Exception('Internal PHPExcel object not set to an instance of an object.'); + throw new PHPExcel_Writer_Exception('Internal PHPExcel object not set to an instance of an object.'); } // Cached? @@ -851,7 +966,10 @@ class PHPExcel_Writer_HTML implements PHPExcel_Writer_IWriter { */ private function _createCSSStyleBorder(PHPExcel_Style_Border $pStyle) { // Create CSS - $css = $this->_mapBorderStyle($pStyle->getBorderStyle()) . ' #' . $pStyle->getColor()->getRGB(); +// $css = $this->_mapBorderStyle($pStyle->getBorderStyle()) . ' #' . $pStyle->getColor()->getRGB(); + // Create CSS - add !important to non-none border styles for merged cells + $borderStyle = $this->_mapBorderStyle($pStyle->getBorderStyle()); + $css = $borderStyle . ' #' . $pStyle->getColor()->getRGB() . (($borderStyle == 'none') ? '' : ' !important'); // Return return $css; @@ -894,25 +1012,26 @@ class PHPExcel_Writer_HTML implements PHPExcel_Writer_IWriter { * * @param PHPExcel_Worksheet $pSheet The worksheet for the table we are writing * @return string - * @throws Exception + * @throws PHPExcel_Writer_Exception */ private function _generateTableHeader($pSheet) { $sheetIndex = $pSheet->getParent()->getIndex($pSheet); // Construct HTML $html = ''; - + $html .= $this->_setMargins($pSheet); + if (!$this->_useInlineCss) { - $gridlines = $pSheet->getShowGridLines() ? ' gridlines' : ''; + $gridlines = $pSheet->getShowGridlines() ? ' gridlines' : ''; $html .= ' ' . PHP_EOL; } else { $style = isset($this->_cssStyles['table']) ? $this->_assembleCSS($this->_cssStyles['table']) : ''; - if ($this->_isPdf && $pSheet->getShowGridLines()) { - $html .= '
' . PHP_EOL; + if ($this->_isPdf && $pSheet->getShowGridlines()) { + $html .= '
' . PHP_EOL; } else { - $html .= '
' . PHP_EOL; + $html .= '
' . PHP_EOL; } } @@ -938,7 +1057,7 @@ class PHPExcel_Writer_HTML implements PHPExcel_Writer_IWriter { /** * Generate table footer * - * @throws Exception + * @throws PHPExcel_Writer_Exception */ private function _generateTableFooter() { // Construct HTML @@ -956,7 +1075,7 @@ class PHPExcel_Writer_HTML implements PHPExcel_Writer_IWriter { * @param array $pValues Array containing cells in a row * @param int $pRow Row number (0-based) * @return string - * @throws Exception + * @throws PHPExcel_Writer_Exception */ private function _generateRow(PHPExcel_Worksheet $pSheet, $pValues = null, $pRow = 0) { if (is_array($pValues)) { @@ -995,9 +1114,9 @@ class PHPExcel_Writer_HTML implements PHPExcel_Writer_IWriter { // Write cells $colNum = 0; - foreach ($pValues as $cell) { + foreach ($pValues as $cellAddress) { + $cell = ($cellAddress > '') ? $pSheet->getCell($cellAddress) : ''; $coordinate = PHPExcel_Cell::stringFromColumnIndex($colNum) . ($pRow + 1); - if (!$this->_useInlineCss) { $cssClass = ''; $cssClass = 'column' . $colNum; @@ -1011,10 +1130,11 @@ class PHPExcel_Writer_HTML implements PHPExcel_Writer_IWriter { $rowSpan = 1; // initialize - $cellData = ''; + $cellData = ' '; // PHPExcel_Cell if ($cell instanceof PHPExcel_Cell) { + $cellData = ''; if (is_null($cell->getParent())) { $cell->attach($pSheet); } @@ -1112,6 +1232,13 @@ class PHPExcel_Writer_HTML implements PHPExcel_Writer_IWriter { $spans = $this->_isBaseCell[$pSheet->getParent()->getIndex($pSheet)][$pRow + 1][$colNum]; $rowSpan = $spans['rowspan']; $colSpan = $spans['colspan']; + + // Also apply style from last cell in merge to fix borders - + // relies on !important for non-none border declarations in _createCSSStyleBorder + $endCellCoord = PHPExcel_Cell::stringFromColumnIndex($colNum + $colSpan - 1) . ($pRow + $rowSpan); + if (!$this->_useInlineCss) { + $cssClass .= ' style' . $pSheet->getCell($endCellCoord)->getXfIndex(); + } } // Write @@ -1153,7 +1280,12 @@ class PHPExcel_Writer_HTML implements PHPExcel_Writer_IWriter { $html .= '>'; // Image? - $html .= $this->_writeImageTagInCell($pSheet, $coordinate); + $html .= $this->_writeImageInCell($pSheet, $coordinate); + + // Chart? + if ($this->_includeCharts) { + $html .= $this->_writeChartInCell($pSheet, $coordinate); + } // Cell data $html .= $cellData; @@ -1172,7 +1304,7 @@ class PHPExcel_Writer_HTML implements PHPExcel_Writer_IWriter { // Return return $html; } else { - throw new Exception("Invalid parameters passed."); + throw new PHPExcel_Writer_Exception("Invalid parameters passed."); } } @@ -1193,26 +1325,6 @@ class PHPExcel_Writer_HTML implements PHPExcel_Writer_IWriter { return $string; } - /** - * Get Pre-Calculate Formulas - * - * @return boolean - */ - public function getPreCalculateFormulas() { - return $this->_preCalculateFormulas; - } - - /** - * Set Pre-Calculate Formulas - * - * @param boolean $pValue Pre-Calculate Formulas? - * @return PHPExcel_Writer_HTML - */ - public function setPreCalculateFormulas($pValue = true) { - $this->_preCalculateFormulas = $pValue; - return $this; - } - /** * Get images root * @@ -1233,6 +1345,26 @@ class PHPExcel_Writer_HTML implements PHPExcel_Writer_IWriter { return $this; } + /** + * Get embed images + * + * @return boolean + */ + public function getEmbedImages() { + return $this->_embedImages; + } + + /** + * Set embed images + * + * @param boolean $pValue + * @return PHPExcel_Writer_HTML + */ + public function setEmbedImages($pValue = '.') { + $this->_embedImages = $pValue; + return $this; + } + /** * Get use inline CSS? * @@ -1374,4 +1506,27 @@ class PHPExcel_Writer_HTML implements PHPExcel_Writer_IWriter { $this->_spansAreCalculated = true; } + private function _setMargins(PHPExcel_Worksheet $pSheet) { + $htmlPage = '@page { '; + $htmlBody = 'body { '; + + $left = PHPExcel_Shared_String::FormatNumber($pSheet->getPageMargins()->getLeft()) . 'in; '; + $htmlPage .= 'left-margin: ' . $left; + $htmlBody .= 'left-margin: ' . $left; + $right = PHPExcel_Shared_String::FormatNumber($pSheet->getPageMargins()->getRight()) . 'in; '; + $htmlPage .= 'right-margin: ' . $right; + $htmlBody .= 'right-margin: ' . $right; + $top = PHPExcel_Shared_String::FormatNumber($pSheet->getPageMargins()->getTop()) . 'in; '; + $htmlPage .= 'top-margin: ' . $top; + $htmlBody .= 'top-margin: ' . $top; + $bottom = PHPExcel_Shared_String::FormatNumber($pSheet->getPageMargins()->getBottom()) . 'in; '; + $htmlPage .= 'bottom-margin: ' . $bottom; + $htmlBody .= 'bottom-margin: ' . $bottom; + + $htmlPage .= "}\n"; + $htmlBody .= "}\n"; + + return "\n"; + } + } diff --git a/htdocs/includes/phpexcel/PHPExcel/Writer/IWriter.php b/htdocs/includes/phpexcel/PHPExcel/Writer/IWriter.php index af97f0778ce..6974c93c875 100644 --- a/htdocs/includes/phpexcel/PHPExcel/Writer/IWriter.php +++ b/htdocs/includes/phpexcel/PHPExcel/Writer/IWriter.php @@ -1,45 +1,46 @@ _renderer = new $rendererName($phpExcel); - } + $rendererName = 'PHPExcel_Writer_PDF_' . $pdfLibraryName; + $this->_renderer = new $rendererName($phpExcel); + } + /** + * Magic method to handle direct calls to the configured PDF renderer wrapper class. + * + * @param string $name Renderer library method name + * @param mixed[] $arguments Array of arguments to pass to the renderer method + * @return mixed Returned data from the PDF renderer wrapper method + */ public function __call($name, $arguments) { if ($this->_renderer === NULL) { - throw new Exception("PDF Renderer has not been defined."); + throw new PHPExcel_Writer_Exception("PDF Rendering library has not been defined."); } - return call_user_func_array(array($this->_renderer,$name),$arguments); + return call_user_func_array(array($this->_renderer, $name), $arguments); } } diff --git a/htdocs/includes/phpexcel/PHPExcel/Writer/PDF/Core.php b/htdocs/includes/phpexcel/PHPExcel/Writer/PDF/Core.php index b9154ac6bee..3b281f4e582 100644 --- a/htdocs/includes/phpexcel/PHPExcel/Writer/PDF/Core.php +++ b/htdocs/includes/phpexcel/PHPExcel/Writer/PDF/Core.php @@ -1,239 +1,364 @@ 'LETTER', // (8.5 in. by 11 in.) - PHPExcel_Worksheet_PageSetup::PAPERSIZE_LETTER_SMALL => 'LETTER', // (8.5 in. by 11 in.) - PHPExcel_Worksheet_PageSetup::PAPERSIZE_TABLOID => array(792.00,1224.00), // (11 in. by 17 in.) - PHPExcel_Worksheet_PageSetup::PAPERSIZE_LEDGER => array(1224.00,792.00), // (17 in. by 11 in.) - PHPExcel_Worksheet_PageSetup::PAPERSIZE_LEGAL => 'LEGAL', // (8.5 in. by 14 in.) - PHPExcel_Worksheet_PageSetup::PAPERSIZE_STATEMENT => array(396.00,612.00), // (5.5 in. by 8.5 in.) - PHPExcel_Worksheet_PageSetup::PAPERSIZE_EXECUTIVE => 'EXECUTIVE', // (7.25 in. by 10.5 in.) - PHPExcel_Worksheet_PageSetup::PAPERSIZE_A3 => 'A3', // (297 mm by 420 mm) - PHPExcel_Worksheet_PageSetup::PAPERSIZE_A4 => 'A4', // (210 mm by 297 mm) - PHPExcel_Worksheet_PageSetup::PAPERSIZE_A4_SMALL => 'A4', // (210 mm by 297 mm) - PHPExcel_Worksheet_PageSetup::PAPERSIZE_A5 => 'A5', // (148 mm by 210 mm) - PHPExcel_Worksheet_PageSetup::PAPERSIZE_B4 => 'B4', // (250 mm by 353 mm) - PHPExcel_Worksheet_PageSetup::PAPERSIZE_B5 => 'B5', // (176 mm by 250 mm) - PHPExcel_Worksheet_PageSetup::PAPERSIZE_FOLIO => 'FOLIO', // (8.5 in. by 13 in.) - PHPExcel_Worksheet_PageSetup::PAPERSIZE_QUARTO => array(609.45,779.53), // (215 mm by 275 mm) - PHPExcel_Worksheet_PageSetup::PAPERSIZE_STANDARD_1 => array(720.00,1008.00), // (10 in. by 14 in.) - PHPExcel_Worksheet_PageSetup::PAPERSIZE_STANDARD_2 => array(792.00,1224.00), // (11 in. by 17 in.) - PHPExcel_Worksheet_PageSetup::PAPERSIZE_NOTE => 'LETTER', // (8.5 in. by 11 in.) - PHPExcel_Worksheet_PageSetup::PAPERSIZE_NO9_ENVELOPE => array(279.00,639.00), // (3.875 in. by 8.875 in.) - PHPExcel_Worksheet_PageSetup::PAPERSIZE_NO10_ENVELOPE => array(297.00,684.00), // (4.125 in. by 9.5 in.) - PHPExcel_Worksheet_PageSetup::PAPERSIZE_NO11_ENVELOPE => array(324.00,747.00), // (4.5 in. by 10.375 in.) - PHPExcel_Worksheet_PageSetup::PAPERSIZE_NO12_ENVELOPE => array(342.00,792.00), // (4.75 in. by 11 in.) - PHPExcel_Worksheet_PageSetup::PAPERSIZE_NO14_ENVELOPE => array(360.00,828.00), // (5 in. by 11.5 in.) - PHPExcel_Worksheet_PageSetup::PAPERSIZE_C => array(1224.00,1584.00), // (17 in. by 22 in.) - PHPExcel_Worksheet_PageSetup::PAPERSIZE_D => array(1584.00,2448.00), // (22 in. by 34 in.) - PHPExcel_Worksheet_PageSetup::PAPERSIZE_E => array(2448.00,3168.00), // (34 in. by 44 in.) - PHPExcel_Worksheet_PageSetup::PAPERSIZE_DL_ENVELOPE => array(311.81,623.62), // (110 mm by 220 mm) - PHPExcel_Worksheet_PageSetup::PAPERSIZE_C5_ENVELOPE => 'C5', // (162 mm by 229 mm) - PHPExcel_Worksheet_PageSetup::PAPERSIZE_C3_ENVELOPE => 'C3', // (324 mm by 458 mm) - PHPExcel_Worksheet_PageSetup::PAPERSIZE_C4_ENVELOPE => 'C4', // (229 mm by 324 mm) - PHPExcel_Worksheet_PageSetup::PAPERSIZE_C6_ENVELOPE => 'C6', // (114 mm by 162 mm) - PHPExcel_Worksheet_PageSetup::PAPERSIZE_C65_ENVELOPE => array(323.15,649.13), // (114 mm by 229 mm) - PHPExcel_Worksheet_PageSetup::PAPERSIZE_B4_ENVELOPE => 'B4', // (250 mm by 353 mm) - PHPExcel_Worksheet_PageSetup::PAPERSIZE_B5_ENVELOPE => 'B5', // (176 mm by 250 mm) - PHPExcel_Worksheet_PageSetup::PAPERSIZE_B6_ENVELOPE => array(498.90,354.33), // (176 mm by 125 mm) - PHPExcel_Worksheet_PageSetup::PAPERSIZE_ITALY_ENVELOPE => array(311.81,651.97), // (110 mm by 230 mm) - PHPExcel_Worksheet_PageSetup::PAPERSIZE_MONARCH_ENVELOPE => array(279.00,540.00), // (3.875 in. by 7.5 in.) - PHPExcel_Worksheet_PageSetup::PAPERSIZE_6_3_4_ENVELOPE => array(261.00,468.00), // (3.625 in. by 6.5 in.) - PHPExcel_Worksheet_PageSetup::PAPERSIZE_US_STANDARD_FANFOLD => array(1071.00,792.00), // (14.875 in. by 11 in.) - PHPExcel_Worksheet_PageSetup::PAPERSIZE_GERMAN_STANDARD_FANFOLD => array(612.00,864.00), // (8.5 in. by 12 in.) - PHPExcel_Worksheet_PageSetup::PAPERSIZE_GERMAN_LEGAL_FANFOLD => 'FOLIO', // (8.5 in. by 13 in.) - PHPExcel_Worksheet_PageSetup::PAPERSIZE_ISO_B4 => 'B4', // (250 mm by 353 mm) - PHPExcel_Worksheet_PageSetup::PAPERSIZE_JAPANESE_DOUBLE_POSTCARD => array(566.93,419.53), // (200 mm by 148 mm) - PHPExcel_Worksheet_PageSetup::PAPERSIZE_STANDARD_PAPER_1 => array(648.00,792.00), // (9 in. by 11 in.) - PHPExcel_Worksheet_PageSetup::PAPERSIZE_STANDARD_PAPER_2 => array(720.00,792.00), // (10 in. by 11 in.) - PHPExcel_Worksheet_PageSetup::PAPERSIZE_STANDARD_PAPER_3 => array(1080.00,792.00), // (15 in. by 11 in.) - PHPExcel_Worksheet_PageSetup::PAPERSIZE_INVITE_ENVELOPE => array(623.62,623.62), // (220 mm by 220 mm) - PHPExcel_Worksheet_PageSetup::PAPERSIZE_LETTER_EXTRA_PAPER => array(667.80,864.00), // (9.275 in. by 12 in.) - PHPExcel_Worksheet_PageSetup::PAPERSIZE_LEGAL_EXTRA_PAPER => array(667.80,1080.00), // (9.275 in. by 15 in.) - PHPExcel_Worksheet_PageSetup::PAPERSIZE_TABLOID_EXTRA_PAPER => array(841.68,1296.00), // (11.69 in. by 18 in.) - PHPExcel_Worksheet_PageSetup::PAPERSIZE_A4_EXTRA_PAPER => array(668.98,912.76), // (236 mm by 322 mm) - PHPExcel_Worksheet_PageSetup::PAPERSIZE_LETTER_TRANSVERSE_PAPER => array(595.80,792.00), // (8.275 in. by 11 in.) - PHPExcel_Worksheet_PageSetup::PAPERSIZE_A4_TRANSVERSE_PAPER => 'A4', // (210 mm by 297 mm) - PHPExcel_Worksheet_PageSetup::PAPERSIZE_LETTER_EXTRA_TRANSVERSE_PAPER => array(667.80,864.00), // (9.275 in. by 12 in.) - PHPExcel_Worksheet_PageSetup::PAPERSIZE_SUPERA_SUPERA_A4_PAPER => array(643.46,1009.13), // (227 mm by 356 mm) - PHPExcel_Worksheet_PageSetup::PAPERSIZE_SUPERB_SUPERB_A3_PAPER => array(864.57,1380.47), // (305 mm by 487 mm) - PHPExcel_Worksheet_PageSetup::PAPERSIZE_LETTER_PLUS_PAPER => array(612.00,913.68), // (8.5 in. by 12.69 in.) - PHPExcel_Worksheet_PageSetup::PAPERSIZE_A4_PLUS_PAPER => array(595.28,935.43), // (210 mm by 330 mm) - PHPExcel_Worksheet_PageSetup::PAPERSIZE_A5_TRANSVERSE_PAPER => 'A5', // (148 mm by 210 mm) - PHPExcel_Worksheet_PageSetup::PAPERSIZE_JIS_B5_TRANSVERSE_PAPER => array(515.91,728.50), // (182 mm by 257 mm) - PHPExcel_Worksheet_PageSetup::PAPERSIZE_A3_EXTRA_PAPER => array(912.76,1261.42), // (322 mm by 445 mm) - PHPExcel_Worksheet_PageSetup::PAPERSIZE_A5_EXTRA_PAPER => array(493.23,666.14), // (174 mm by 235 mm) - PHPExcel_Worksheet_PageSetup::PAPERSIZE_ISO_B5_EXTRA_PAPER => array(569.76,782.36), // (201 mm by 276 mm) - PHPExcel_Worksheet_PageSetup::PAPERSIZE_A2_PAPER => 'A2', // (420 mm by 594 mm) - PHPExcel_Worksheet_PageSetup::PAPERSIZE_A3_TRANSVERSE_PAPER => 'A3', // (297 mm by 420 mm) - PHPExcel_Worksheet_PageSetup::PAPERSIZE_A3_EXTRA_TRANSVERSE_PAPER => array(912.76,1261.42) // (322 mm by 445 mm) - ); - - /** - * Create a new PHPExcel_Writer_PDF - * - * @param PHPExcel $phpExcel PHPExcel object - */ - public function __construct(PHPExcel $phpExcel) { - parent::__construct($phpExcel); - $this->setUseInlineCss(true); - $this->_tempDir = PHPExcel_Shared_File::sys_get_temp_dir(); - } +abstract class PHPExcel_Writer_PDF_Core extends PHPExcel_Writer_HTML +{ + /** + * Temporary storage directory + * + * @var string + */ + protected $_tempDir = ''; /** - * Get Font + * Font * - * @return string + * @var string */ - public function getFont() { - return $this->_font; - } - - /** - * Set font. Examples: - * 'arialunicid0-chinese-simplified' - * 'arialunicid0-chinese-traditional' - * 'arialunicid0-korean' - * 'arialunicid0-japanese' - * - * @param string $fontName - */ - public function setFont($fontName) { - $this->_font = $fontName; - return $this; - } + protected $_font = 'freesans'; /** - * Get Paper Size + * Orientation (Over-ride) * - * @return int + * @var string */ - public function getPaperSize() { - return $this->_paperSize; + protected $_orientation = NULL; + + /** + * Paper size (Over-ride) + * + * @var int + */ + protected $_paperSize = NULL; + + + /** + * Temporary storage for Save Array Return type + * + * @var string + */ + private $_saveArrayReturnType; + + /** + * Paper Sizes xRef List + * + * @var array + */ + protected static $_paperSizes = array( + PHPExcel_Worksheet_PageSetup::PAPERSIZE_LETTER + => 'LETTER', // (8.5 in. by 11 in.) + PHPExcel_Worksheet_PageSetup::PAPERSIZE_LETTER_SMALL + => 'LETTER', // (8.5 in. by 11 in.) + PHPExcel_Worksheet_PageSetup::PAPERSIZE_TABLOID + => array(792.00, 1224.00), // (11 in. by 17 in.) + PHPExcel_Worksheet_PageSetup::PAPERSIZE_LEDGER + => array(1224.00, 792.00), // (17 in. by 11 in.) + PHPExcel_Worksheet_PageSetup::PAPERSIZE_LEGAL + => 'LEGAL', // (8.5 in. by 14 in.) + PHPExcel_Worksheet_PageSetup::PAPERSIZE_STATEMENT + => array(396.00, 612.00), // (5.5 in. by 8.5 in.) + PHPExcel_Worksheet_PageSetup::PAPERSIZE_EXECUTIVE + => 'EXECUTIVE', // (7.25 in. by 10.5 in.) + PHPExcel_Worksheet_PageSetup::PAPERSIZE_A3 + => 'A3', // (297 mm by 420 mm) + PHPExcel_Worksheet_PageSetup::PAPERSIZE_A4 + => 'A4', // (210 mm by 297 mm) + PHPExcel_Worksheet_PageSetup::PAPERSIZE_A4_SMALL + => 'A4', // (210 mm by 297 mm) + PHPExcel_Worksheet_PageSetup::PAPERSIZE_A5 + => 'A5', // (148 mm by 210 mm) + PHPExcel_Worksheet_PageSetup::PAPERSIZE_B4 + => 'B4', // (250 mm by 353 mm) + PHPExcel_Worksheet_PageSetup::PAPERSIZE_B5 + => 'B5', // (176 mm by 250 mm) + PHPExcel_Worksheet_PageSetup::PAPERSIZE_FOLIO + => 'FOLIO', // (8.5 in. by 13 in.) + PHPExcel_Worksheet_PageSetup::PAPERSIZE_QUARTO + => array(609.45, 779.53), // (215 mm by 275 mm) + PHPExcel_Worksheet_PageSetup::PAPERSIZE_STANDARD_1 + => array(720.00, 1008.00), // (10 in. by 14 in.) + PHPExcel_Worksheet_PageSetup::PAPERSIZE_STANDARD_2 + => array(792.00, 1224.00), // (11 in. by 17 in.) + PHPExcel_Worksheet_PageSetup::PAPERSIZE_NOTE + => 'LETTER', // (8.5 in. by 11 in.) + PHPExcel_Worksheet_PageSetup::PAPERSIZE_NO9_ENVELOPE + => array(279.00, 639.00), // (3.875 in. by 8.875 in.) + PHPExcel_Worksheet_PageSetup::PAPERSIZE_NO10_ENVELOPE + => array(297.00, 684.00), // (4.125 in. by 9.5 in.) + PHPExcel_Worksheet_PageSetup::PAPERSIZE_NO11_ENVELOPE + => array(324.00, 747.00), // (4.5 in. by 10.375 in.) + PHPExcel_Worksheet_PageSetup::PAPERSIZE_NO12_ENVELOPE + => array(342.00, 792.00), // (4.75 in. by 11 in.) + PHPExcel_Worksheet_PageSetup::PAPERSIZE_NO14_ENVELOPE + => array(360.00, 828.00), // (5 in. by 11.5 in.) + PHPExcel_Worksheet_PageSetup::PAPERSIZE_C + => array(1224.00, 1584.00), // (17 in. by 22 in.) + PHPExcel_Worksheet_PageSetup::PAPERSIZE_D + => array(1584.00, 2448.00), // (22 in. by 34 in.) + PHPExcel_Worksheet_PageSetup::PAPERSIZE_E + => array(2448.00, 3168.00), // (34 in. by 44 in.) + PHPExcel_Worksheet_PageSetup::PAPERSIZE_DL_ENVELOPE + => array(311.81, 623.62), // (110 mm by 220 mm) + PHPExcel_Worksheet_PageSetup::PAPERSIZE_C5_ENVELOPE + => 'C5', // (162 mm by 229 mm) + PHPExcel_Worksheet_PageSetup::PAPERSIZE_C3_ENVELOPE + => 'C3', // (324 mm by 458 mm) + PHPExcel_Worksheet_PageSetup::PAPERSIZE_C4_ENVELOPE + => 'C4', // (229 mm by 324 mm) + PHPExcel_Worksheet_PageSetup::PAPERSIZE_C6_ENVELOPE + => 'C6', // (114 mm by 162 mm) + PHPExcel_Worksheet_PageSetup::PAPERSIZE_C65_ENVELOPE + => array(323.15, 649.13), // (114 mm by 229 mm) + PHPExcel_Worksheet_PageSetup::PAPERSIZE_B4_ENVELOPE + => 'B4', // (250 mm by 353 mm) + PHPExcel_Worksheet_PageSetup::PAPERSIZE_B5_ENVELOPE + => 'B5', // (176 mm by 250 mm) + PHPExcel_Worksheet_PageSetup::PAPERSIZE_B6_ENVELOPE + => array(498.90, 354.33), // (176 mm by 125 mm) + PHPExcel_Worksheet_PageSetup::PAPERSIZE_ITALY_ENVELOPE + => array(311.81, 651.97), // (110 mm by 230 mm) + PHPExcel_Worksheet_PageSetup::PAPERSIZE_MONARCH_ENVELOPE + => array(279.00, 540.00), // (3.875 in. by 7.5 in.) + PHPExcel_Worksheet_PageSetup::PAPERSIZE_6_3_4_ENVELOPE + => array(261.00, 468.00), // (3.625 in. by 6.5 in.) + PHPExcel_Worksheet_PageSetup::PAPERSIZE_US_STANDARD_FANFOLD + => array(1071.00, 792.00), // (14.875 in. by 11 in.) + PHPExcel_Worksheet_PageSetup::PAPERSIZE_GERMAN_STANDARD_FANFOLD + => array(612.00, 864.00), // (8.5 in. by 12 in.) + PHPExcel_Worksheet_PageSetup::PAPERSIZE_GERMAN_LEGAL_FANFOLD + => 'FOLIO', // (8.5 in. by 13 in.) + PHPExcel_Worksheet_PageSetup::PAPERSIZE_ISO_B4 + => 'B4', // (250 mm by 353 mm) + PHPExcel_Worksheet_PageSetup::PAPERSIZE_JAPANESE_DOUBLE_POSTCARD + => array(566.93, 419.53), // (200 mm by 148 mm) + PHPExcel_Worksheet_PageSetup::PAPERSIZE_STANDARD_PAPER_1 + => array(648.00, 792.00), // (9 in. by 11 in.) + PHPExcel_Worksheet_PageSetup::PAPERSIZE_STANDARD_PAPER_2 + => array(720.00, 792.00), // (10 in. by 11 in.) + PHPExcel_Worksheet_PageSetup::PAPERSIZE_STANDARD_PAPER_3 + => array(1080.00, 792.00), // (15 in. by 11 in.) + PHPExcel_Worksheet_PageSetup::PAPERSIZE_INVITE_ENVELOPE + => array(623.62, 623.62), // (220 mm by 220 mm) + PHPExcel_Worksheet_PageSetup::PAPERSIZE_LETTER_EXTRA_PAPER + => array(667.80, 864.00), // (9.275 in. by 12 in.) + PHPExcel_Worksheet_PageSetup::PAPERSIZE_LEGAL_EXTRA_PAPER + => array(667.80, 1080.00), // (9.275 in. by 15 in.) + PHPExcel_Worksheet_PageSetup::PAPERSIZE_TABLOID_EXTRA_PAPER + => array(841.68, 1296.00), // (11.69 in. by 18 in.) + PHPExcel_Worksheet_PageSetup::PAPERSIZE_A4_EXTRA_PAPER + => array(668.98, 912.76), // (236 mm by 322 mm) + PHPExcel_Worksheet_PageSetup::PAPERSIZE_LETTER_TRANSVERSE_PAPER + => array(595.80, 792.00), // (8.275 in. by 11 in.) + PHPExcel_Worksheet_PageSetup::PAPERSIZE_A4_TRANSVERSE_PAPER + => 'A4', // (210 mm by 297 mm) + PHPExcel_Worksheet_PageSetup::PAPERSIZE_LETTER_EXTRA_TRANSVERSE_PAPER + => array(667.80, 864.00), // (9.275 in. by 12 in.) + PHPExcel_Worksheet_PageSetup::PAPERSIZE_SUPERA_SUPERA_A4_PAPER + => array(643.46, 1009.13), // (227 mm by 356 mm) + PHPExcel_Worksheet_PageSetup::PAPERSIZE_SUPERB_SUPERB_A3_PAPER + => array(864.57, 1380.47), // (305 mm by 487 mm) + PHPExcel_Worksheet_PageSetup::PAPERSIZE_LETTER_PLUS_PAPER + => array(612.00, 913.68), // (8.5 in. by 12.69 in.) + PHPExcel_Worksheet_PageSetup::PAPERSIZE_A4_PLUS_PAPER + => array(595.28, 935.43), // (210 mm by 330 mm) + PHPExcel_Worksheet_PageSetup::PAPERSIZE_A5_TRANSVERSE_PAPER + => 'A5', // (148 mm by 210 mm) + PHPExcel_Worksheet_PageSetup::PAPERSIZE_JIS_B5_TRANSVERSE_PAPER + => array(515.91, 728.50), // (182 mm by 257 mm) + PHPExcel_Worksheet_PageSetup::PAPERSIZE_A3_EXTRA_PAPER + => array(912.76, 1261.42), // (322 mm by 445 mm) + PHPExcel_Worksheet_PageSetup::PAPERSIZE_A5_EXTRA_PAPER + => array(493.23, 666.14), // (174 mm by 235 mm) + PHPExcel_Worksheet_PageSetup::PAPERSIZE_ISO_B5_EXTRA_PAPER + => array(569.76, 782.36), // (201 mm by 276 mm) + PHPExcel_Worksheet_PageSetup::PAPERSIZE_A2_PAPER + => 'A2', // (420 mm by 594 mm) + PHPExcel_Worksheet_PageSetup::PAPERSIZE_A3_TRANSVERSE_PAPER + => 'A3', // (297 mm by 420 mm) + PHPExcel_Worksheet_PageSetup::PAPERSIZE_A3_EXTRA_TRANSVERSE_PAPER + => array(912.76, 1261.42) // (322 mm by 445 mm) + ); + + /** + * Create a new PHPExcel_Writer_PDF + * + * @param PHPExcel $phpExcel PHPExcel object + */ + public function __construct(PHPExcel $phpExcel) + { + parent::__construct($phpExcel); + $this->setUseInlineCss(TRUE); + $this->_tempDir = PHPExcel_Shared_File::sys_get_temp_dir(); } /** - * Set Paper Size + * Get Font * - * @param int $pValue - * @return PHPExcel_Writer_PDF + * @return string */ - public function setPaperSize($pValue = PHPExcel_Worksheet_PageSetup::PAPERSIZE_LETTER) { - $this->_paperSize = $pValue; - return $this; + public function getFont() + { + return $this->_font; } /** - * Get Orientation + * Set font. Examples: + * 'arialunicid0-chinese-simplified' + * 'arialunicid0-chinese-traditional' + * 'arialunicid0-korean' + * 'arialunicid0-japanese' * - * @return string + * @param string $fontName */ - public function getOrientation() { - return $this->_orientation; + public function setFont($fontName) + { + $this->_font = $fontName; + return $this; } /** - * Set Orientation + * Get Paper Size * - * @param string $pValue - * @return PHPExcel_Writer_PDF + * @return int */ - public function setOrientation($pValue = PHPExcel_Worksheet_PageSetup::ORIENTATION_DEFAULT) { - $this->_orientation = $pValue; - return $this; + public function getPaperSize() + { + return $this->_paperSize; } - /** - * Get temporary storage directory - * - * @return string - */ - public function getTempDir() { - return $this->_tempDir; - } + /** + * Set Paper Size + * + * @param string $pValue Paper size + * @return PHPExcel_Writer_PDF + */ + public function setPaperSize($pValue = PHPExcel_Worksheet_PageSetup::PAPERSIZE_LETTER) + { + $this->_paperSize = $pValue; + return $this; + } + + /** + * Get Orientation + * + * @return string + */ + public function getOrientation() + { + return $this->_orientation; + } + + /** + * Set Orientation + * + * @param string $pValue Page orientation + * @return PHPExcel_Writer_PDF + */ + public function setOrientation($pValue = PHPExcel_Worksheet_PageSetup::ORIENTATION_DEFAULT) + { + $this->_orientation = $pValue; + return $this; + } + + /** + * Get temporary storage directory + * + * @return string + */ + public function getTempDir() + { + return $this->_tempDir; + } + + /** + * Set temporary storage directory + * + * @param string $pValue Temporary storage directory + * @throws PHPExcel_Writer_Exception when directory does not exist + * @return PHPExcel_Writer_PDF + */ + public function setTempDir($pValue = '') + { + if (is_dir($pValue)) { + $this->_tempDir = $pValue; + } else { + throw new PHPExcel_Writer_Exception("Directory does not exist: $pValue"); + } + return $this; + } + + /** + * Save PHPExcel to PDF file, pre-save + * + * @param string $pFilename Name of the file to save as + * @throws PHPExcel_Writer_Exception + */ + protected function prepareForSave($pFilename = NULL) + { + // garbage collect + $this->_phpExcel->garbageCollect(); + + $this->_saveArrayReturnType = PHPExcel_Calculation::getArrayReturnType(); + PHPExcel_Calculation::setArrayReturnType(PHPExcel_Calculation::RETURN_ARRAY_AS_VALUE); + + // Open file + $fileHandle = fopen($pFilename, 'w'); + if ($fileHandle === FALSE) { + throw new PHPExcel_Writer_Exception("Could not open file $pFilename for writing."); + } + + // Set PDF + $this->_isPdf = TRUE; + // Build CSS + $this->buildCSS(TRUE); + + return $fileHandle; + } + + /** + * Save PHPExcel to PDF file, post-save + * + * @param resource $fileHandle + * @throws PHPExcel_Writer_Exception + */ + protected function restoreStateAfterSave($fileHandle) + { + // Close file + fclose($fileHandle); + + PHPExcel_Calculation::setArrayReturnType($this->_saveArrayReturnType); + } - /** - * Set temporary storage directory - * - * @param string $pValue Temporary storage directory - * @throws Exception Exception when directory does not exist - * @return PHPExcel_Writer_PDF - */ - public function setTempDir($pValue = '') { - if (is_dir($pValue)) { - $this->_tempDir = $pValue; - } else { - throw new Exception("Directory does not exist: $pValue"); - } - return $this; - } } diff --git a/htdocs/includes/phpexcel/PHPExcel/Writer/PDF/DomPDF.php b/htdocs/includes/phpexcel/PHPExcel/Writer/PDF/DomPDF.php index a8ab4efd945..111dd36078c 100644 --- a/htdocs/includes/phpexcel/PHPExcel/Writer/PDF/DomPDF.php +++ b/htdocs/includes/phpexcel/PHPExcel/Writer/PDF/DomPDF.php @@ -1,128 +1,120 @@ _phpExcel->garbageCollect(); + /** + * Save PHPExcel to file + * + * @param string $pFilename Name of the file to save as + * @throws PHPExcel_Writer_Exception + */ + public function save($pFilename = NULL) + { + $fileHandle = parent::prepareForSave($pFilename); - $saveArrayReturnType = PHPExcel_Calculation::getArrayReturnType(); - PHPExcel_Calculation::setArrayReturnType(PHPExcel_Calculation::RETURN_ARRAY_AS_VALUE); + // Default PDF paper size + $paperSize = 'LETTER'; // Letter (8.5 in. by 11 in.) - // Open file - $fileHandle = fopen($pFilename, 'w'); - if ($fileHandle === false) { - throw new Exception("Could not open file $pFilename for writing."); - } + // Check for paper size and page orientation + if (is_null($this->getSheetIndex())) { + $orientation = ($this->_phpExcel->getSheet(0)->getPageSetup()->getOrientation() + == PHPExcel_Worksheet_PageSetup::ORIENTATION_LANDSCAPE) + ? 'L' + : 'P'; + $printPaperSize = $this->_phpExcel->getSheet(0)->getPageSetup()->getPaperSize(); + $printMargins = $this->_phpExcel->getSheet(0)->getPageMargins(); + } else { + $orientation = ($this->_phpExcel->getSheet($this->getSheetIndex())->getPageSetup()->getOrientation() + == PHPExcel_Worksheet_PageSetup::ORIENTATION_LANDSCAPE) + ? 'L' + : 'P'; + $printPaperSize = $this->_phpExcel->getSheet($this->getSheetIndex())->getPageSetup()->getPaperSize(); + $printMargins = $this->_phpExcel->getSheet($this->getSheetIndex())->getPageMargins(); + } - // Set PDF - $this->_isPdf = true; - // Build CSS - $this->buildCSS(true); + // Override Page Orientation + if (!is_null($this->getOrientation())) { + $orientation = ($this->getOrientation() == PHPExcel_Worksheet_PageSetup::ORIENTATION_DEFAULT) + ? PHPExcel_Worksheet_PageSetup::ORIENTATION_PORTRAIT + : $this->getOrientation(); + } + // Override Paper Size + if (!is_null($this->getPaperSize())) { + $printPaperSize = $this->getPaperSize(); + } - // Default PDF paper size - $paperSize = 'LETTER'; // Letter (8.5 in. by 11 in.) + if (isset(self::$_paperSizes[$printPaperSize])) { + $paperSize = self::$_paperSizes[$printPaperSize]; + } - // Check for paper size and page orientation - if (is_null($this->getSheetIndex())) { - $orientation = ($this->_phpExcel->getSheet(0)->getPageSetup()->getOrientation() == PHPExcel_Worksheet_PageSetup::ORIENTATION_LANDSCAPE) ? 'L' : 'P'; - $printPaperSize = $this->_phpExcel->getSheet(0)->getPageSetup()->getPaperSize(); - $printMargins = $this->_phpExcel->getSheet(0)->getPageMargins(); - } else { - $orientation = ($this->_phpExcel->getSheet($this->getSheetIndex())->getPageSetup()->getOrientation() == PHPExcel_Worksheet_PageSetup::ORIENTATION_LANDSCAPE) ? 'L' : 'P'; - $printPaperSize = $this->_phpExcel->getSheet($this->getSheetIndex())->getPageSetup()->getPaperSize(); - $printMargins = $this->_phpExcel->getSheet($this->getSheetIndex())->getPageMargins(); - } + $orientation = ($orientation == 'L') ? 'landscape' : 'portrait'; - // Override Page Orientation - if (!is_null($this->getOrientation())) { - $orientation = ($this->getOrientation() == PHPExcel_Worksheet_PageSetup::ORIENTATION_DEFAULT) ? - PHPExcel_Worksheet_PageSetup::ORIENTATION_PORTRAIT : $this->getOrientation(); - } - // Override Paper Size - if (!is_null($this->getPaperSize())) { - $printPaperSize = $this->getPaperSize(); - } + // Create PDF + $pdf = new DOMPDF(); + $pdf->set_paper(strtolower($paperSize), $orientation); - if (isset(self::$_paperSizes[$printPaperSize])) { - $paperSize = self::$_paperSizes[$printPaperSize]; - } + $pdf->load_html( + $this->generateHTMLHeader(FALSE) . + $this->generateSheetData() . + $this->generateHTMLFooter() + ); + $pdf->render(); - $orientation = ($orientation == 'L') ? 'landscape' : 'portrait'; + // Write to file + fwrite($fileHandle, $pdf->output()); - // Create PDF - $pdf = new DOMPDF(); - $pdf->set_paper(strtolower($paperSize), $orientation); - - $pdf->load_html( - $this->generateHTMLHeader(false) . - $this->generateSheetData() . - $this->generateHTMLFooter() - ); - $pdf->render(); - - // Write to file - fwrite($fileHandle, $pdf->output()); - - // Close file - fclose($fileHandle); - - PHPExcel_Calculation::setArrayReturnType($saveArrayReturnType); - } + parent::restoreStateAfterSave($fileHandle); + } } diff --git a/htdocs/includes/phpexcel/PHPExcel/Writer/PDF/mPDF.php b/htdocs/includes/phpexcel/PHPExcel/Writer/PDF/mPDF.php index 5f9f2a350fc..8e274f4ce79 100644 --- a/htdocs/includes/phpexcel/PHPExcel/Writer/PDF/mPDF.php +++ b/htdocs/includes/phpexcel/PHPExcel/Writer/PDF/mPDF.php @@ -1,135 +1,130 @@ _phpExcel->garbageCollect(); + /** + * Save PHPExcel to file + * + * @param string $pFilename Name of the file to save as + * @throws PHPExcel_Writer_Exception + */ + public function save($pFilename = NULL) + { + $fileHandle = parent::prepareForSave($pFilename); - $saveArrayReturnType = PHPExcel_Calculation::getArrayReturnType(); - PHPExcel_Calculation::setArrayReturnType(PHPExcel_Calculation::RETURN_ARRAY_AS_VALUE); + // Default PDF paper size + $paperSize = 'LETTER'; // Letter (8.5 in. by 11 in.) - // Open file - $fileHandle = fopen($pFilename, 'w'); - if ($fileHandle === false) { - throw new Exception("Could not open file $pFilename for writing."); - } + // Check for paper size and page orientation + if (is_null($this->getSheetIndex())) { + $orientation = ($this->_phpExcel->getSheet(0)->getPageSetup()->getOrientation() + == PHPExcel_Worksheet_PageSetup::ORIENTATION_LANDSCAPE) + ? 'L' + : 'P'; + $printPaperSize = $this->_phpExcel->getSheet(0)->getPageSetup()->getPaperSize(); + $printMargins = $this->_phpExcel->getSheet(0)->getPageMargins(); + } else { + $orientation = ($this->_phpExcel->getSheet($this->getSheetIndex())->getPageSetup()->getOrientation() + == PHPExcel_Worksheet_PageSetup::ORIENTATION_LANDSCAPE) + ? 'L' + : 'P'; + $printPaperSize = $this->_phpExcel->getSheet($this->getSheetIndex())->getPageSetup()->getPaperSize(); + $printMargins = $this->_phpExcel->getSheet($this->getSheetIndex())->getPageMargins(); + } + $this->setOrientation($orientation); - // Set PDF - $this->_isPdf = true; - // Build CSS - $this->buildCSS(true); + // Override Page Orientation + if (!is_null($this->getOrientation())) { + $orientation = ($this->getOrientation() == PHPExcel_Worksheet_PageSetup::ORIENTATION_DEFAULT) + ? PHPExcel_Worksheet_PageSetup::ORIENTATION_PORTRAIT + : $this->getOrientation(); + } + $orientation = strtoupper($orientation); - // Default PDF paper size - $paperSize = 'LETTER'; // Letter (8.5 in. by 11 in.) + // Override Paper Size + if (!is_null($this->getPaperSize())) { + $printPaperSize = $this->getPaperSize(); + } - // Check for paper size and page orientation - if (is_null($this->getSheetIndex())) { - $orientation = ($this->_phpExcel->getSheet(0)->getPageSetup()->getOrientation() == PHPExcel_Worksheet_PageSetup::ORIENTATION_LANDSCAPE) ? 'L' : 'P'; - $printPaperSize = $this->_phpExcel->getSheet(0)->getPageSetup()->getPaperSize(); - $printMargins = $this->_phpExcel->getSheet(0)->getPageMargins(); - } else { - $orientation = ($this->_phpExcel->getSheet($this->getSheetIndex())->getPageSetup()->getOrientation() == PHPExcel_Worksheet_PageSetup::ORIENTATION_LANDSCAPE) ? 'L' : 'P'; - $printPaperSize = $this->_phpExcel->getSheet($this->getSheetIndex())->getPageSetup()->getPaperSize(); - $printMargins = $this->_phpExcel->getSheet($this->getSheetIndex())->getPageMargins(); - } - $this->setOrientation($orientation); + if (isset(self::$_paperSizes[$printPaperSize])) { + $paperSize = self::$_paperSizes[$printPaperSize]; + } - // Override Page Orientation - if (!is_null($this->getOrientation())) { - $orientation = ($this->getOrientation() == PHPExcel_Worksheet_PageSetup::ORIENTATION_DEFAULT) ? - PHPExcel_Worksheet_PageSetup::ORIENTATION_PORTRAIT : $this->getOrientation(); - } - $orientation = strtoupper($orientation); - - // Override Paper Size - if (!is_null($this->getPaperSize())) { - $printPaperSize = $this->getPaperSize(); - } - - if (isset(self::$_paperSizes[$printPaperSize])) { - $paperSize = self::$_paperSizes[$printPaperSize]; - } - - // Create PDF - $pdf = new mpdf(); - $pdf->_setPageSize(strtoupper($paperSize), $orientation); + // Create PDF + $pdf = new mpdf(); + $ortmp = $orientation; + $pdf->_setPageSize(strtoupper($paperSize), $ortmp); $pdf->DefOrientation = $orientation; - // Document info - $pdf->SetTitle($this->_phpExcel->getProperties()->getTitle()); - $pdf->SetAuthor($this->_phpExcel->getProperties()->getCreator()); - $pdf->SetSubject($this->_phpExcel->getProperties()->getSubject()); - $pdf->SetKeywords($this->_phpExcel->getProperties()->getKeywords()); - $pdf->SetCreator($this->_phpExcel->getProperties()->getCreator()); + $pdf->AddPage($orientation); - $pdf->WriteHTML( - $this->generateHTMLHeader(false) . - $this->generateSheetData() . - $this->generateHTMLFooter() - ); + // Document info + $pdf->SetTitle($this->_phpExcel->getProperties()->getTitle()); + $pdf->SetAuthor($this->_phpExcel->getProperties()->getCreator()); + $pdf->SetSubject($this->_phpExcel->getProperties()->getSubject()); + $pdf->SetKeywords($this->_phpExcel->getProperties()->getKeywords()); + $pdf->SetCreator($this->_phpExcel->getProperties()->getCreator()); - // Write to file - fwrite($fileHandle, $pdf->Output('','S')); + $pdf->WriteHTML( + $this->generateHTMLHeader(FALSE) . + $this->generateSheetData() . + $this->generateHTMLFooter() + ); - // Close file - fclose($fileHandle); + // Write to file + fwrite($fileHandle, $pdf->Output('', 'S')); - PHPExcel_Calculation::setArrayReturnType($saveArrayReturnType); - } + parent::restoreStateAfterSave($fileHandle); + } } diff --git a/htdocs/includes/phpexcel/PHPExcel/Writer/PDF/tcPDF.php b/htdocs/includes/phpexcel/PHPExcel/Writer/PDF/tcPDF.php index d77ab91a9fc..c3809ec750c 100644 --- a/htdocs/includes/phpexcel/PHPExcel/Writer/PDF/tcPDF.php +++ b/htdocs/includes/phpexcel/PHPExcel/Writer/PDF/tcPDF.php @@ -1,147 +1,136 @@ _phpExcel->garbageCollect(); + /** + * Save PHPExcel to file + * + * @param string $pFilename Name of the file to save as + * @throws PHPExcel_Writer_Exception + */ + public function save($pFilename = NULL) + { + $fileHandle = parent::prepareForSave($pFilename); - $saveArrayReturnType = PHPExcel_Calculation::getArrayReturnType(); - PHPExcel_Calculation::setArrayReturnType(PHPExcel_Calculation::RETURN_ARRAY_AS_VALUE); + // Default PDF paper size + $paperSize = 'LETTER'; // Letter (8.5 in. by 11 in.) - // Open file - $fileHandle = fopen($pFilename, 'w'); - if ($fileHandle === false) { - throw new Exception("Could not open file $pFilename for writing."); - } + // Check for paper size and page orientation + if (is_null($this->getSheetIndex())) { + $orientation = ($this->_phpExcel->getSheet(0)->getPageSetup()->getOrientation() + == PHPExcel_Worksheet_PageSetup::ORIENTATION_LANDSCAPE) + ? 'L' + : 'P'; + $printPaperSize = $this->_phpExcel->getSheet(0)->getPageSetup()->getPaperSize(); + $printMargins = $this->_phpExcel->getSheet(0)->getPageMargins(); + } else { + $orientation = ($this->_phpExcel->getSheet($this->getSheetIndex())->getPageSetup()->getOrientation() + == PHPExcel_Worksheet_PageSetup::ORIENTATION_LANDSCAPE) + ? 'L' + : 'P'; + $printPaperSize = $this->_phpExcel->getSheet($this->getSheetIndex())->getPageSetup()->getPaperSize(); + $printMargins = $this->_phpExcel->getSheet($this->getSheetIndex())->getPageMargins(); + } - // Set PDF - $this->_isPdf = true; - // Build CSS - $this->buildCSS(true); + // Override Page Orientation + if (!is_null($this->getOrientation())) { + $orientation = ($this->getOrientation() == PHPExcel_Worksheet_PageSetup::ORIENTATION_LANDSCAPE) + ? 'L' + : 'P'; + } + // Override Paper Size + if (!is_null($this->getPaperSize())) { + $printPaperSize = $this->getPaperSize(); + } - // Default PDF paper size - $paperSize = 'LETTER'; // Letter (8.5 in. by 11 in.) - - // Check for paper size and page orientation - if (is_null($this->getSheetIndex())) { - $orientation = ($this->_phpExcel->getSheet(0)->getPageSetup()->getOrientation() == PHPExcel_Worksheet_PageSetup::ORIENTATION_LANDSCAPE) ? 'L' : 'P'; - $printPaperSize = $this->_phpExcel->getSheet(0)->getPageSetup()->getPaperSize(); - $printMargins = $this->_phpExcel->getSheet(0)->getPageMargins(); - } else { - $orientation = ($this->_phpExcel->getSheet($this->getSheetIndex())->getPageSetup()->getOrientation() == PHPExcel_Worksheet_PageSetup::ORIENTATION_LANDSCAPE) ? 'L' : 'P'; - $printPaperSize = $this->_phpExcel->getSheet($this->getSheetIndex())->getPageSetup()->getPaperSize(); - $printMargins = $this->_phpExcel->getSheet($this->getSheetIndex())->getPageMargins(); - } - - // Override Page Orientation - if (!is_null($this->getOrientation())) { - $orientation = ($this->getOrientation() == PHPExcel_Worksheet_PageSetup::ORIENTATION_LANDSCAPE) ? - 'L' : 'P'; - } - // Override Paper Size - if (!is_null($this->getPaperSize())) { - $printPaperSize = $this->getPaperSize(); - } + if (isset(self::$_paperSizes[$printPaperSize])) { + $paperSize = self::$_paperSizes[$printPaperSize]; + } - if (isset(self::$_paperSizes[$printPaperSize])) { - $paperSize = self::$_paperSizes[$printPaperSize]; - } + // Create PDF + $pdf = new TCPDF($orientation, 'pt', $paperSize); + $pdf->setFontSubsetting(FALSE); + // Set margins, converting inches to points (using 72 dpi) + $pdf->SetMargins($printMargins->getLeft() * 72, $printMargins->getTop() * 72, $printMargins->getRight() * 72); + $pdf->SetAutoPageBreak(TRUE, $printMargins->getBottom() * 72); + $pdf->setPrintHeader(FALSE); + $pdf->setPrintFooter(FALSE); - // Create PDF - $pdf = new TCPDF($orientation, 'pt', $paperSize); - $pdf->setFontSubsetting(false); - // Set margins, converting inches to points (using 72 dpi) - $pdf->SetMargins($printMargins->getLeft() * 72,$printMargins->getTop() * 72,$printMargins->getRight() * 72); - $pdf->SetAutoPageBreak(true,$printMargins->getBottom() * 72); -// $pdf->setHeaderMargin($printMargins->getHeader() * 72); -// $pdf->setFooterMargin($printMargins->getFooter() * 72); + $pdf->AddPage(); - $pdf->setPrintHeader(false); - $pdf->setPrintFooter(false); + // Set the appropriate font + $pdf->SetFont($this->getFont()); + $pdf->writeHTML( + $this->generateHTMLHeader(FALSE) . + $this->generateSheetData() . + $this->generateHTMLFooter() + ); - $pdf->AddPage(); + // Document info + $pdf->SetTitle($this->_phpExcel->getProperties()->getTitle()); + $pdf->SetAuthor($this->_phpExcel->getProperties()->getCreator()); + $pdf->SetSubject($this->_phpExcel->getProperties()->getSubject()); + $pdf->SetKeywords($this->_phpExcel->getProperties()->getKeywords()); + $pdf->SetCreator($this->_phpExcel->getProperties()->getCreator()); - // Set the appropriate font - $pdf->SetFont($this->getFont()); - $pdf->writeHTML( - $this->generateHTMLHeader(false) . - $this->generateSheetData() . - $this->generateHTMLFooter() - ); + // Write to file + fwrite($fileHandle, $pdf->output($pFilename, 'S')); - // Document info - $pdf->SetTitle($this->_phpExcel->getProperties()->getTitle()); - $pdf->SetAuthor($this->_phpExcel->getProperties()->getCreator()); - $pdf->SetSubject($this->_phpExcel->getProperties()->getSubject()); - $pdf->SetKeywords($this->_phpExcel->getProperties()->getKeywords()); - $pdf->SetCreator($this->_phpExcel->getProperties()->getCreator()); - - // Write to file - fwrite($fileHandle, $pdf->output($pFilename, 'S')); - - // Close file - fclose($fileHandle); - - PHPExcel_Calculation::setArrayReturnType($saveArrayReturnType); - } + parent::restoreStateAfterSave($fileHandle); + } } diff --git a/htdocs/includes/phpexcel/PHPExcel/locale/bg/config b/htdocs/includes/phpexcel/PHPExcel/locale/bg/config new file mode 100644 index 00000000000..d7ecb2b2ab1 --- /dev/null +++ b/htdocs/includes/phpexcel/PHPExcel/locale/bg/config @@ -0,0 +1,49 @@ +## +## PHPExcel +## + +## Copyright (c) 2006 - 2013 PHPExcel +## +## This library is free software; you can redistribute it and/or +## modify it under the terms of the GNU Lesser General Public +## License as published by the Free Software Foundation; either +## version 2.1 of the License, or (at your option) any later version. +## +## This library is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +## Lesser General Public License for more details. +## +## You should have received a copy of the GNU Lesser General Public +## License along with this library; if not, write to the Free Software +## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +## +## @category PHPExcel +## @package PHPExcel_Settings +## @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) +## @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +## @version 1.8.0, 2014-03-02 +## +## + + +ArgumentSeparator = ; + + +## +## (For future use) +## +currencySymbol = лв + + +## +## Excel Error Codes (For future use) + +## +NULL = #ПРАЗНО! +DIV0 = #ДЕЛ/0! +VALUE = #СТОЙНОСТ! +REF = #РЕФ! +NAME = #ИМЕ? +NUM = #ЧИСЛО! +NA = #Н/Д diff --git a/htdocs/includes/phpexcel/PHPExcel/locale/cs/config b/htdocs/includes/phpexcel/PHPExcel/locale/cs/config index 38a44128e27..af4589b0955 100644 --- a/htdocs/includes/phpexcel/PHPExcel/locale/cs/config +++ b/htdocs/includes/phpexcel/PHPExcel/locale/cs/config @@ -1,7 +1,7 @@ -## +## ## PHPExcel ## -## Copyright (c) 2006 - 2011 PHPExcel +## Copyright (c) 2006 - 2013 PHPExcel ## ## This library is free software; you can redistribute it and/or ## modify it under the terms of the GNU Lesser General Public @@ -19,9 +19,9 @@ ## ## @category PHPExcel ## @package PHPExcel_Settings -## @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel) +## @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) ## @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL -## @version 1.7.8, 2012-10-12 +## @version 1.8.0, 2014-03-02 ## ## diff --git a/htdocs/includes/phpexcel/PHPExcel/locale/cs/functions b/htdocs/includes/phpexcel/PHPExcel/locale/cs/functions index 992dc37535e..f324759d247 100644 --- a/htdocs/includes/phpexcel/PHPExcel/locale/cs/functions +++ b/htdocs/includes/phpexcel/PHPExcel/locale/cs/functions @@ -1,7 +1,7 @@ -## +## ## PHPExcel ## -## Copyright (c) 2006 - 2011 PHPExcel +## Copyright (c) 2006 - 2013 PHPExcel ## ## This library is free software; you can redistribute it and/or ## modify it under the terms of the GNU Lesser General Public @@ -19,9 +19,9 @@ ## ## @category PHPExcel ## @package PHPExcel_Calculation -## @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel) +## @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) ## @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL -## @version 1.7.8, 2012-10-12 +## @version 1.8.0, 2014-03-02 ## ## Data in this file derived from http://www.piuha.fi/excel-function-name-translation/ ## diff --git a/htdocs/includes/phpexcel/PHPExcel/locale/da/config b/htdocs/includes/phpexcel/PHPExcel/locale/da/config index 49292f1cf67..1ddecb936f4 100644 --- a/htdocs/includes/phpexcel/PHPExcel/locale/da/config +++ b/htdocs/includes/phpexcel/PHPExcel/locale/da/config @@ -1,7 +1,7 @@ -## +## ## PHPExcel ## -## Copyright (c) 2006 - 2011 PHPExcel +## Copyright (c) 2006 - 2013 PHPExcel ## ## This library is free software; you can redistribute it and/or ## modify it under the terms of the GNU Lesser General Public @@ -19,9 +19,9 @@ ## ## @category PHPExcel ## @package PHPExcel_Settings -## @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel) +## @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) ## @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL -## @version 1.7.8, 2012-10-12 +## @version 1.8.0, 2014-03-02 ## ## diff --git a/htdocs/includes/phpexcel/PHPExcel/locale/da/functions b/htdocs/includes/phpexcel/PHPExcel/locale/da/functions index affc19a1ac2..102d57843e7 100644 --- a/htdocs/includes/phpexcel/PHPExcel/locale/da/functions +++ b/htdocs/includes/phpexcel/PHPExcel/locale/da/functions @@ -1,7 +1,7 @@ -## +## ## PHPExcel ## -## Copyright (c) 2006 - 2011 PHPExcel +## Copyright (c) 2006 - 2013 PHPExcel ## ## This library is free software; you can redistribute it and/or ## modify it under the terms of the GNU Lesser General Public @@ -19,9 +19,9 @@ ## ## @category PHPExcel ## @package PHPExcel_Calculation -## @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel) +## @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) ## @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL -## @version 1.7.8, 2012-10-12 +## @version 1.8.0, 2014-03-02 ## ## Data in this file derived from http://www.piuha.fi/excel-function-name-translation/ ## diff --git a/htdocs/includes/phpexcel/PHPExcel/locale/de/config b/htdocs/includes/phpexcel/PHPExcel/locale/de/config index 95193498fe6..c9972751661 100644 --- a/htdocs/includes/phpexcel/PHPExcel/locale/de/config +++ b/htdocs/includes/phpexcel/PHPExcel/locale/de/config @@ -1,7 +1,7 @@ -## +## ## PHPExcel ## -## Copyright (c) 2006 - 2011 PHPExcel +## Copyright (c) 2006 - 2013 PHPExcel ## ## This library is free software; you can redistribute it and/or ## modify it under the terms of the GNU Lesser General Public @@ -19,9 +19,9 @@ ## ## @category PHPExcel ## @package PHPExcel_Settings -## @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel) +## @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) ## @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL -## @version 1.7.8, 2012-10-12 +## @version 1.8.0, 2014-03-02 ## ## diff --git a/htdocs/includes/phpexcel/PHPExcel/locale/de/functions b/htdocs/includes/phpexcel/PHPExcel/locale/de/functions index 1c19c5b22ce..8ce08de4d5d 100644 --- a/htdocs/includes/phpexcel/PHPExcel/locale/de/functions +++ b/htdocs/includes/phpexcel/PHPExcel/locale/de/functions @@ -1,7 +1,7 @@ -## +## ## PHPExcel ## -## Copyright (c) 2006 - 2011 PHPExcel +## Copyright (c) 2006 - 2013 PHPExcel ## ## This library is free software; you can redistribute it and/or ## modify it under the terms of the GNU Lesser General Public @@ -19,9 +19,9 @@ ## ## @category PHPExcel ## @package PHPExcel_Calculation -## @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel) +## @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) ## @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL -## @version 1.7.8, 2012-10-12 +## @version 1.8.0, 2014-03-02 ## ## Data in this file derived from http://www.piuha.fi/excel-function-name-translation/ ## diff --git a/htdocs/includes/phpexcel/PHPExcel/locale/en/uk/config b/htdocs/includes/phpexcel/PHPExcel/locale/en/uk/config index 1bcfcb2b79c..dfcc63b0e8f 100644 --- a/htdocs/includes/phpexcel/PHPExcel/locale/en/uk/config +++ b/htdocs/includes/phpexcel/PHPExcel/locale/en/uk/config @@ -1,7 +1,7 @@ -## +## ## PHPExcel ## -## Copyright (c) 2006 - 2011 PHPExcel +## Copyright (c) 2006 - 2013 PHPExcel ## ## This library is free software; you can redistribute it and/or ## modify it under the terms of the GNU Lesser General Public @@ -19,9 +19,9 @@ ## ## @category PHPExcel ## @package PHPExcel_Settings -## @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel) +## @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) ## @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL -## @version 1.7.8, 2012-10-12 +## @version 1.8.0, 2014-03-02 ## ## diff --git a/htdocs/includes/phpexcel/PHPExcel/locale/es/config b/htdocs/includes/phpexcel/PHPExcel/locale/es/config index 039f5b8c877..0b11eb7af07 100644 --- a/htdocs/includes/phpexcel/PHPExcel/locale/es/config +++ b/htdocs/includes/phpexcel/PHPExcel/locale/es/config @@ -1,7 +1,7 @@ -## +## ## PHPExcel ## -## Copyright (c) 2006 - 2011 PHPExcel +## Copyright (c) 2006 - 2013 PHPExcel ## ## This library is free software; you can redistribute it and/or ## modify it under the terms of the GNU Lesser General Public @@ -19,9 +19,9 @@ ## ## @category PHPExcel ## @package PHPExcel_Settings -## @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel) +## @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) ## @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL -## @version 1.7.8, 2012-10-12 +## @version 1.8.0, 2014-03-02 ## ## diff --git a/htdocs/includes/phpexcel/PHPExcel/locale/es/functions b/htdocs/includes/phpexcel/PHPExcel/locale/es/functions index 9d47f0e491a..f6e6fd2b6b3 100644 --- a/htdocs/includes/phpexcel/PHPExcel/locale/es/functions +++ b/htdocs/includes/phpexcel/PHPExcel/locale/es/functions @@ -1,7 +1,7 @@ -## +## ## PHPExcel ## -## Copyright (c) 2006 - 2011 PHPExcel +## Copyright (c) 2006 - 2013 PHPExcel ## ## This library is free software; you can redistribute it and/or ## modify it under the terms of the GNU Lesser General Public @@ -19,9 +19,9 @@ ## ## @category PHPExcel ## @package PHPExcel_Calculation -## @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel) +## @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) ## @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL -## @version 1.7.8, 2012-10-12 +## @version 1.8.0, 2014-03-02 ## ## Data in this file derived from http://www.piuha.fi/excel-function-name-translation/ ## diff --git a/htdocs/includes/phpexcel/PHPExcel/locale/fi/config b/htdocs/includes/phpexcel/PHPExcel/locale/fi/config index ba274e1d5c2..380f39793d7 100644 --- a/htdocs/includes/phpexcel/PHPExcel/locale/fi/config +++ b/htdocs/includes/phpexcel/PHPExcel/locale/fi/config @@ -1,7 +1,7 @@ -## +## ## PHPExcel ## -## Copyright (c) 2006 - 2011 PHPExcel +## Copyright (c) 2006 - 2013 PHPExcel ## ## This library is free software; you can redistribute it and/or ## modify it under the terms of the GNU Lesser General Public @@ -19,9 +19,9 @@ ## ## @category PHPExcel ## @package PHPExcel_Settings -## @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel) +## @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) ## @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL -## @version 1.7.8, 2012-10-12 +## @version 1.8.0, 2014-03-02 ## ## diff --git a/htdocs/includes/phpexcel/PHPExcel/locale/fi/functions b/htdocs/includes/phpexcel/PHPExcel/locale/fi/functions index 25e08eacd35..bf60bec0012 100644 --- a/htdocs/includes/phpexcel/PHPExcel/locale/fi/functions +++ b/htdocs/includes/phpexcel/PHPExcel/locale/fi/functions @@ -1,7 +1,7 @@ -## +## ## PHPExcel ## -## Copyright (c) 2006 - 2011 PHPExcel +## Copyright (c) 2006 - 2013 PHPExcel ## ## This library is free software; you can redistribute it and/or ## modify it under the terms of the GNU Lesser General Public @@ -19,9 +19,9 @@ ## ## @category PHPExcel ## @package PHPExcel_Calculation -## @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel) +## @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) ## @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL -## @version 1.7.8, 2012-10-12 +## @version 1.8.0, 2014-03-02 ## ## Data in this file derived from http://www.piuha.fi/excel-function-name-translation/ ## diff --git a/htdocs/includes/phpexcel/PHPExcel/locale/fr/config b/htdocs/includes/phpexcel/PHPExcel/locale/fr/config index 8ae183a698a..368b3c3cc3d 100644 --- a/htdocs/includes/phpexcel/PHPExcel/locale/fr/config +++ b/htdocs/includes/phpexcel/PHPExcel/locale/fr/config @@ -1,7 +1,7 @@ -## +## ## PHPExcel ## -## Copyright (c) 2006 - 2011 PHPExcel +## Copyright (c) 2006 - 2013 PHPExcel ## ## This library is free software; you can redistribute it and/or ## modify it under the terms of the GNU Lesser General Public @@ -19,9 +19,9 @@ ## ## @category PHPExcel ## @package PHPExcel_Settings -## @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel) +## @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) ## @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL -## @version 1.7.8, 2012-10-12 +## @version 1.8.0, 2014-03-02 ## ## diff --git a/htdocs/includes/phpexcel/PHPExcel/locale/fr/functions b/htdocs/includes/phpexcel/PHPExcel/locale/fr/functions index ebb8339b6ac..e85dba5b89a 100644 --- a/htdocs/includes/phpexcel/PHPExcel/locale/fr/functions +++ b/htdocs/includes/phpexcel/PHPExcel/locale/fr/functions @@ -1,7 +1,7 @@ -## +## ## PHPExcel ## -## Copyright (c) 2006 - 2011 PHPExcel +## Copyright (c) 2006 - 2013 PHPExcel ## ## This library is free software; you can redistribute it and/or ## modify it under the terms of the GNU Lesser General Public @@ -19,9 +19,9 @@ ## ## @category PHPExcel ## @package PHPExcel_Calculation -## @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel) +## @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) ## @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL -## @version 1.7.8, 2012-10-12 +## @version 1.8.0, 2014-03-02 ## ## Data in this file derived from http://www.piuha.fi/excel-function-name-translation/ ## diff --git a/htdocs/includes/phpexcel/PHPExcel/locale/hu/config b/htdocs/includes/phpexcel/PHPExcel/locale/hu/config index 725b5698f2a..e04151cb8a7 100644 --- a/htdocs/includes/phpexcel/PHPExcel/locale/hu/config +++ b/htdocs/includes/phpexcel/PHPExcel/locale/hu/config @@ -1,7 +1,7 @@ -## +## ## PHPExcel ## -## Copyright (c) 2006 - 2011 PHPExcel +## Copyright (c) 2006 - 2013 PHPExcel ## ## This library is free software; you can redistribute it and/or ## modify it under the terms of the GNU Lesser General Public @@ -19,9 +19,9 @@ ## ## @category PHPExcel ## @package PHPExcel_Settings -## @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel) +## @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) ## @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL -## @version 1.7.8, 2012-10-12 +## @version 1.8.0, 2014-03-02 ## ## diff --git a/htdocs/includes/phpexcel/PHPExcel/locale/hu/functions b/htdocs/includes/phpexcel/PHPExcel/locale/hu/functions index a3855c066e5..77cae928e60 100644 --- a/htdocs/includes/phpexcel/PHPExcel/locale/hu/functions +++ b/htdocs/includes/phpexcel/PHPExcel/locale/hu/functions @@ -1,7 +1,7 @@ -## +## ## PHPExcel ## -## Copyright (c) 2006 - 2011 PHPExcel +## Copyright (c) 2006 - 2013 PHPExcel ## ## This library is free software; you can redistribute it and/or ## modify it under the terms of the GNU Lesser General Public @@ -19,9 +19,9 @@ ## ## @category PHPExcel ## @package PHPExcel_Calculation -## @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel) +## @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) ## @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL -## @version 1.7.8, 2012-10-12 +## @version 1.8.0, 2014-03-02 ## ## Data in this file derived from http://www.piuha.fi/excel-function-name-translation/ ## diff --git a/htdocs/includes/phpexcel/PHPExcel/locale/it/config b/htdocs/includes/phpexcel/PHPExcel/locale/it/config index 5baad5378d6..94499fe2767 100644 --- a/htdocs/includes/phpexcel/PHPExcel/locale/it/config +++ b/htdocs/includes/phpexcel/PHPExcel/locale/it/config @@ -1,7 +1,7 @@ -## +## ## PHPExcel ## -## Copyright (c) 2006 - 2011 PHPExcel +## Copyright (c) 2006 - 2013 PHPExcel ## ## This library is free software; you can redistribute it and/or ## modify it under the terms of the GNU Lesser General Public @@ -19,9 +19,9 @@ ## ## @category PHPExcel ## @package PHPExcel_Settings -## @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel) +## @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) ## @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL -## @version 1.7.8, 2012-10-12 +## @version 1.8.0, 2014-03-02 ## ## diff --git a/htdocs/includes/phpexcel/PHPExcel/locale/it/functions b/htdocs/includes/phpexcel/PHPExcel/locale/it/functions index 3d092048130..033b9696420 100644 --- a/htdocs/includes/phpexcel/PHPExcel/locale/it/functions +++ b/htdocs/includes/phpexcel/PHPExcel/locale/it/functions @@ -1,7 +1,7 @@ -## +## ## PHPExcel ## -## Copyright (c) 2006 - 2011 PHPExcel +## Copyright (c) 2006 - 2013 PHPExcel ## ## This library is free software; you can redistribute it and/or ## modify it under the terms of the GNU Lesser General Public @@ -19,9 +19,9 @@ ## ## @category PHPExcel ## @package PHPExcel_Calculation -## @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel) +## @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) ## @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL -## @version 1.7.8, 2012-10-12 +## @version 1.8.0, 2014-03-02 ## ## Data in this file derived from http://www.piuha.fi/excel-function-name-translation/ ## diff --git a/htdocs/includes/phpexcel/PHPExcel/locale/nl/config b/htdocs/includes/phpexcel/PHPExcel/locale/nl/config index d56b38fdbf7..00c1b0ff592 100644 --- a/htdocs/includes/phpexcel/PHPExcel/locale/nl/config +++ b/htdocs/includes/phpexcel/PHPExcel/locale/nl/config @@ -1,7 +1,7 @@ -## +## ## PHPExcel ## -## Copyright (c) 2006 - 2011 PHPExcel +## Copyright (c) 2006 - 2013 PHPExcel ## ## This library is free software; you can redistribute it and/or ## modify it under the terms of the GNU Lesser General Public @@ -19,9 +19,9 @@ ## ## @category PHPExcel ## @package PHPExcel_Settings -## @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel) +## @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) ## @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL -## @version 1.7.8, 2012-10-12 +## @version 1.8.0, 2014-03-02 ## ## diff --git a/htdocs/includes/phpexcel/PHPExcel/locale/nl/functions b/htdocs/includes/phpexcel/PHPExcel/locale/nl/functions index 6e941216d13..63800086167 100644 --- a/htdocs/includes/phpexcel/PHPExcel/locale/nl/functions +++ b/htdocs/includes/phpexcel/PHPExcel/locale/nl/functions @@ -1,7 +1,7 @@ -## +## ## PHPExcel ## -## Copyright (c) 2006 - 2011 PHPExcel +## Copyright (c) 2006 - 2013 PHPExcel ## ## This library is free software; you can redistribute it and/or ## modify it under the terms of the GNU Lesser General Public @@ -19,9 +19,9 @@ ## ## @category PHPExcel ## @package PHPExcel_Calculation -## @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel) +## @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) ## @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL -## @version 1.7.8, 2012-10-12 +## @version 1.8.0, 2014-03-02 ## ## Data in this file derived from http://www.piuha.fi/excel-function-name-translation/ ## diff --git a/htdocs/includes/phpexcel/PHPExcel/locale/no/config b/htdocs/includes/phpexcel/PHPExcel/locale/no/config index 482e4bc4464..5bf96a1b18a 100644 --- a/htdocs/includes/phpexcel/PHPExcel/locale/no/config +++ b/htdocs/includes/phpexcel/PHPExcel/locale/no/config @@ -1,7 +1,7 @@ -## +## ## PHPExcel ## -## Copyright (c) 2006 - 2011 PHPExcel +## Copyright (c) 2006 - 2013 PHPExcel ## ## This library is free software; you can redistribute it and/or ## modify it under the terms of the GNU Lesser General Public @@ -19,9 +19,9 @@ ## ## @category PHPExcel ## @package PHPExcel_Settings -## @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel) +## @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) ## @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL -## @version 1.7.8, 2012-10-12 +## @version 1.8.0, 2014-03-02 ## ## diff --git a/htdocs/includes/phpexcel/PHPExcel/locale/no/functions b/htdocs/includes/phpexcel/PHPExcel/locale/no/functions index eb5ae02dd27..917c7f7d79a 100644 --- a/htdocs/includes/phpexcel/PHPExcel/locale/no/functions +++ b/htdocs/includes/phpexcel/PHPExcel/locale/no/functions @@ -1,7 +1,7 @@ -## +## ## PHPExcel ## -## Copyright (c) 2006 - 2011 PHPExcel +## Copyright (c) 2006 - 2013 PHPExcel ## ## This library is free software; you can redistribute it and/or ## modify it under the terms of the GNU Lesser General Public @@ -19,9 +19,9 @@ ## ## @category PHPExcel ## @package PHPExcel_Calculation -## @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel) +## @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) ## @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL -## @version 1.7.8, 2012-10-12 +## @version 1.8.0, 2014-03-02 ## ## Data in this file derived from http://www.piuha.fi/excel-function-name-translation/ ## diff --git a/htdocs/includes/phpexcel/PHPExcel/locale/pl/config b/htdocs/includes/phpexcel/PHPExcel/locale/pl/config index 6823761e012..5061311c85d 100644 --- a/htdocs/includes/phpexcel/PHPExcel/locale/pl/config +++ b/htdocs/includes/phpexcel/PHPExcel/locale/pl/config @@ -1,7 +1,7 @@ -## +## ## PHPExcel ## -## Copyright (c) 2006 - 2011 PHPExcel +## Copyright (c) 2006 - 2013 PHPExcel ## ## This library is free software; you can redistribute it and/or ## modify it under the terms of the GNU Lesser General Public @@ -19,9 +19,9 @@ ## ## @category PHPExcel ## @package PHPExcel_Settings -## @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel) +## @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) ## @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL -## @version 1.7.8, 2012-10-12 +## @version 1.8.0, 2014-03-02 ## ## diff --git a/htdocs/includes/phpexcel/PHPExcel/locale/pl/functions b/htdocs/includes/phpexcel/PHPExcel/locale/pl/functions index 14858433784..14499c05926 100644 --- a/htdocs/includes/phpexcel/PHPExcel/locale/pl/functions +++ b/htdocs/includes/phpexcel/PHPExcel/locale/pl/functions @@ -1,7 +1,7 @@ -## +## ## PHPExcel ## -## Copyright (c) 2006 - 2011 PHPExcel +## Copyright (c) 2006 - 2013 PHPExcel ## ## This library is free software; you can redistribute it and/or ## modify it under the terms of the GNU Lesser General Public @@ -19,9 +19,9 @@ ## ## @category PHPExcel ## @package PHPExcel_Calculation -## @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel) +## @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) ## @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL -## @version 1.7.8, 2012-10-12 +## @version 1.8.0, 2014-03-02 ## ## Data in this file derived from http://www.piuha.fi/excel-function-name-translation/ ## diff --git a/htdocs/includes/phpexcel/PHPExcel/locale/pt/br/config b/htdocs/includes/phpexcel/PHPExcel/locale/pt/br/config index b8e696454aa..b4bf7041d22 100644 --- a/htdocs/includes/phpexcel/PHPExcel/locale/pt/br/config +++ b/htdocs/includes/phpexcel/PHPExcel/locale/pt/br/config @@ -1,7 +1,7 @@ -## +## ## PHPExcel ## -## Copyright (c) 2006 - 2011 PHPExcel +## Copyright (c) 2006 - 2013 PHPExcel ## ## This library is free software; you can redistribute it and/or ## modify it under the terms of the GNU Lesser General Public @@ -19,9 +19,9 @@ ## ## @category PHPExcel ## @package PHPExcel_Settings -## @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel) +## @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) ## @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL -## @version 1.7.8, 2012-10-12 +## @version 1.8.0, 2014-03-02 ## ## diff --git a/htdocs/includes/phpexcel/PHPExcel/locale/pt/br/functions b/htdocs/includes/phpexcel/PHPExcel/locale/pt/br/functions index 11d45f1fd77..a062a7fad51 100644 --- a/htdocs/includes/phpexcel/PHPExcel/locale/pt/br/functions +++ b/htdocs/includes/phpexcel/PHPExcel/locale/pt/br/functions @@ -1,4 +1,4 @@ -## +## ## Add-in and Automation functions Funções Suplemento e Automação ## GETPIVOTDATA = INFODADOSTABELADINÂMICA ## Retorna os dados armazenados em um relatório de tabela dinâmica diff --git a/htdocs/includes/phpexcel/PHPExcel/locale/pt/config b/htdocs/includes/phpexcel/PHPExcel/locale/pt/config index 595ee96835b..60b422bd4c7 100644 --- a/htdocs/includes/phpexcel/PHPExcel/locale/pt/config +++ b/htdocs/includes/phpexcel/PHPExcel/locale/pt/config @@ -1,7 +1,7 @@ -## +## ## PHPExcel ## -## Copyright (c) 2006 - 2011 PHPExcel +## Copyright (c) 2006 - 2013 PHPExcel ## ## This library is free software; you can redistribute it and/or ## modify it under the terms of the GNU Lesser General Public @@ -19,9 +19,9 @@ ## ## @category PHPExcel ## @package PHPExcel_Settings -## @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel) +## @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) ## @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL -## @version 1.7.8, 2012-10-12 +## @version 1.8.0, 2014-03-02 ## ## diff --git a/htdocs/includes/phpexcel/PHPExcel/locale/pt/functions b/htdocs/includes/phpexcel/PHPExcel/locale/pt/functions index 05e8bcaea7d..ba4eb471bad 100644 --- a/htdocs/includes/phpexcel/PHPExcel/locale/pt/functions +++ b/htdocs/includes/phpexcel/PHPExcel/locale/pt/functions @@ -1,4 +1,4 @@ -## +## ## Add-in and Automation functions Funções de Suplemento e Automatização ## GETPIVOTDATA = OBTERDADOSDIN ## Devolve dados armazenados num relatório de Tabela Dinâmica diff --git a/htdocs/includes/phpexcel/PHPExcel/locale/ru/config b/htdocs/includes/phpexcel/PHPExcel/locale/ru/config index aa7e685787b..6f6ace23116 100644 --- a/htdocs/includes/phpexcel/PHPExcel/locale/ru/config +++ b/htdocs/includes/phpexcel/PHPExcel/locale/ru/config @@ -1,7 +1,7 @@ -## +## ## PHPExcel ## -## Copyright (c) 2006 - 2011 PHPExcel +## Copyright (c) 2006 - 2013 PHPExcel ## ## This library is free software; you can redistribute it and/or ## modify it under the terms of the GNU Lesser General Public @@ -19,9 +19,9 @@ ## ## @category PHPExcel ## @package PHPExcel_Settings -## @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel) +## @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) ## @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL -## @version 1.7.8, 2012-10-12 +## @version 1.8.0, 2014-03-02 ## ## diff --git a/htdocs/includes/phpexcel/PHPExcel/locale/ru/functions b/htdocs/includes/phpexcel/PHPExcel/locale/ru/functions index f37afc2491c..bd636861950 100644 --- a/htdocs/includes/phpexcel/PHPExcel/locale/ru/functions +++ b/htdocs/includes/phpexcel/PHPExcel/locale/ru/functions @@ -1,7 +1,7 @@ -## +## ## PHPExcel ## -## Copyright (c) 2006 - 2011 PHPExcel +## Copyright (c) 2006 - 2013 PHPExcel ## ## This library is free software; you can redistribute it and/or ## modify it under the terms of the GNU Lesser General Public @@ -19,9 +19,9 @@ ## ## @category PHPExcel ## @package PHPExcel_Calculation -## @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel) +## @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) ## @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL -## @version 1.7.8, 2012-10-12 +## @version 1.8.0, 2014-03-02 ## ## Data in this file derived from information provided by web-junior (http://www.web-junior.net/) ## diff --git a/htdocs/includes/phpexcel/PHPExcel/locale/sv/config b/htdocs/includes/phpexcel/PHPExcel/locale/sv/config index 6a597781650..5d1a9a9fbde 100644 --- a/htdocs/includes/phpexcel/PHPExcel/locale/sv/config +++ b/htdocs/includes/phpexcel/PHPExcel/locale/sv/config @@ -1,7 +1,7 @@ -## +## ## PHPExcel ## -## Copyright (c) 2006 - 2011 PHPExcel +## Copyright (c) 2006 - 2013 PHPExcel ## ## This library is free software; you can redistribute it and/or ## modify it under the terms of the GNU Lesser General Public @@ -19,9 +19,9 @@ ## ## @category PHPExcel ## @package PHPExcel_Settings -## @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel) +## @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) ## @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL -## @version 1.7.8, 2012-10-12 +## @version 1.8.0, 2014-03-02 ## ## diff --git a/htdocs/includes/phpexcel/PHPExcel/locale/sv/functions b/htdocs/includes/phpexcel/PHPExcel/locale/sv/functions index 27f61e7f834..73b2deb5eb2 100644 --- a/htdocs/includes/phpexcel/PHPExcel/locale/sv/functions +++ b/htdocs/includes/phpexcel/PHPExcel/locale/sv/functions @@ -1,4 +1,4 @@ -## +## ## Add-in and Automation functions Tilläggs- och automatiseringsfunktioner ## GETPIVOTDATA = HÄMTA.PIVOTDATA ## Returnerar data som lagrats i en pivottabellrapport diff --git a/htdocs/includes/phpexcel/PHPExcel/locale/tr/config b/htdocs/includes/phpexcel/PHPExcel/locale/tr/config index bd75af628ee..de69cf5872c 100644 --- a/htdocs/includes/phpexcel/PHPExcel/locale/tr/config +++ b/htdocs/includes/phpexcel/PHPExcel/locale/tr/config @@ -1,7 +1,7 @@ -## +## ## PHPExcel ## -## Copyright (c) 2006 - 2011 PHPExcel +## Copyright (c) 2006 - 2013 PHPExcel ## ## This library is free software; you can redistribute it and/or ## modify it under the terms of the GNU Lesser General Public @@ -19,9 +19,9 @@ ## ## @category PHPExcel ## @package PHPExcel_Settings -## @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel) +## @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) ## @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL -## @version 1.7.8, 2012-10-12 +## @version 1.8.0, 2014-03-02 ## ## diff --git a/htdocs/includes/phpexcel/PHPExcel/locale/tr/functions b/htdocs/includes/phpexcel/PHPExcel/locale/tr/functions index f8cd30fbd2e..c327bca4265 100644 --- a/htdocs/includes/phpexcel/PHPExcel/locale/tr/functions +++ b/htdocs/includes/phpexcel/PHPExcel/locale/tr/functions @@ -1,7 +1,7 @@ -## +## ## PHPExcel ## -## Copyright (c) 2006 - 2011 PHPExcel +## Copyright (c) 2006 - 2013 PHPExcel ## ## This library is free software; you can redistribute it and/or ## modify it under the terms of the GNU Lesser General Public @@ -19,9 +19,9 @@ ## ## @category PHPExcel ## @package PHPExcel_Calculation -## @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel) +## @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) ## @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL -## @version 1.7.8, 2012-10-12 +## @version 1.8.0, 2014-03-02 ## ## Data in this file derived from http://www.piuha.fi/excel-function-name-translation/ ## diff --git a/htdocs/includes/phpexcel/changelog.txt b/htdocs/includes/phpexcel/changelog.txt index 3040d3438ca..a87065ab886 100644 --- a/htdocs/includes/phpexcel/changelog.txt +++ b/htdocs/includes/phpexcel/changelog.txt @@ -1,7 +1,7 @@ ************************************************************************************** * PHPExcel * -* Copyright (c) 2006 - 2012 PHPExcel +* Copyright (c) 2006 - 2014 PHPExcel * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -17,61 +17,98 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * -* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) +* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL -* @version 1.7.8, 2012-10-12 +* @version 1.8.0, 2014-03-02 ************************************************************************************** --------------------------------------------------------------------------------- -BREAKING CHANGE! As part of the planned changes for handling array formulae in -workbooks, there are some changes that will affect the PHPExcel_Cell object -methods. - -The following methods are now deprecated, and will be removed in version 1.7.9: - getCalculatedValue() The getValue() method will return calculated - values for cells containing formulae instead. - setCalculatedValue() The cell value will always contain the result of a - any formula calculation. - setFormulaAttributes() Will now be determined by the arguments to the - setFormula() method. - getFormulaAttributes() This will be replaced by the getArrayFormulaRange() - method. - -The following methods will be added in version 1.7.9 - getFormula() Use to retrieve a cell formula, will return the cell - value if the cell doesn't contain a formula, or - is not part of an array formula range. - setFormula() Use to set a cell formula. It will still be possible - to set formulae using the setValue() and - setValueExplicit() methods. - calculate() Use to execute a formula calculation to update the - cell value. - isFormula() Use to determine if a cell contains a formula, or is - part of an array formula range or not. - isArrayFormula() Use to determine if a cell contains an array formula, - or is part of an array formula range or not. - getArrayFormulaRange() Use to retrieve an array formula range. - -The following methods will be changed in version 1.7.9 - setValue() The logic behind this will be modified to store - formula values in the new cell property structure, - but it will still perform the same function. - setValueExplicit() The logic behind this will be modified to store - formula values in the new cell property structure, - but it will still perform the same function. - getValue() Will no longer return a formula if the cell contains - a formula, but will return the calculated value - instead. For cells that don't contain a formula, - it will still return the stored value. - getDataType() Will return the datatype of the calculated value for - cells that contain formulae. - setDataType() Error handling will be added to prevent setting a - cell datatype to an inappropriate value. --------------------------------------------------------------------------------- +2014-03-02 (v1.8.0): +- Bugfix: (MBaker) Work item CP19830 - Undefined variable: fileHandle in CSV Reader +- Bugfix: (MBaker) Work item CP19968 - Out of memory in style/supervisor.php +- Bugfix: (MBaker) - Style error with merged cells in PDF Writer +- Bugfix: (MBaker) - Problem with cloning worksheets +- Bugfix: (tavoarcila) Work Item GH-259 - Bug fix reading Open Office files +- Bugfix: (MBaker) Work item CP20397 - Serious bug in absolute cell reference used in shared formula + Would also have affected insert/delete column/row +- Bugfix: (RomanSyroeshko) Work Item GH-267 - CHOOSE() returns "#VALUE!" if the 1st entry is chosen +- Bugfix: (Gemorroj) Work Item GH-268 - When duplicating styles, styles shifted by one column to the right + Fix also applied to duplicating conditional styles +- Bugfix: (IndrekHaav) Work Item GH-212 - Fix for formulae that reference a sheet whose name begins with a digit: + these were erroneously identified as numeric values, causing the parser to throw an undefined variable error. +- Bugfix: (IndrekHaav) Work Item CP16208 - Fixed undefined variable error due to $styleArray being used before it's initialised +- Bugfix: (PowerKiKi) Work Item GH-273 - ISTEXT() return wrong result if referencing an empty but formatted cell +- Bugfix: (PowerKiKi) Work Item GH-270/GH-31 - Binary comparison of strings are case insensitive +- Bugfix: (MBaker) Work Item GH-275 - Insert New Row/Column Before is not correctly updating formula references +- Bugfix: (MBaker) Work Item GH-257 - Passing an array of cells to _generateRow() in the HTML/PDF Writer causes caching problems with last cell in the range +- Bugfix: (MBaker) Work Item GH-193 - Fix to empty worksheet garbage collection when using cell caching +- Bugfix: (Jazzo) Work Item GH-248 - Excel2007 does not correctly mark rows as hidden +- Bugfix: (Roy Shahbazian) Work Item GH-299 - Fixed typo in Chart/Layout set/getYMode() +- Bugfix: (EliuFlorez) Work item GH-279 - Fatal error: Call to a member function cellExists() line: 3327 in calculation.php if referenced worksheet doesn't exist +- Bugfix: (MBaker) Work Item GH-290 - AdvancedValueBinder "Division by zero"-error +- Bugfix: (MBaker) Work Item CP20604 - Adding Sheet to Workbook Bug +- Bugfix: (MBaker) Work item CP20703 - Calculation engine incorrectly evaluates empty cells as #VALUE +- Bugfix: (MBaker) Work item CP20760 - Formula references to cell on another sheet in ODS files +- Bugfix: (MBaker) Work item GH321,GH158,CP17824 - LibreOffice created XLSX files results in an empty file. +- Feature: (amerov) - Implementation of the Excel HLOOKUP() function +- Feature: (MBaker) - Added "Quote Prefix" to style settings (Excel2007 Reader and Writer only) +- Feature: (MBaker) - Added Horizontal FILL alignment for Excel5 and Excel2007 Readers/Writers, and Horizontal DISTRIBUTED alignment for Excel2007 Reader/Writer +- Feature: (trvrnrth) Work Item GH-261 - Add support for reading protected (RC4 encrypted) .xls files +- Feature: (LWol) Work Item GH-252 - Adding support for macros, Ribbon in Excel 2007 +- General: (cdhutch) Work item CP20055 - Remove array_shift in ReferenceHelper::insertNewBefore improves column or row delete speed +- General: (MBaker) - Improve stock chart handling and rendering, with help from Swashata Ghosh +- General: (MBaker) - Fix to calculation properties for Excel2007 so that the opening application will only recalculate on load if it's actually required +- General: (MBaker) - Modified Excel2007 Writer to default preCalculateFormulas to false + Note that autosize columns will still recalculate affected formulae internally +- General: (dresenhista) Work Item GH-242 - Functionality to getHighestRow() for a specified column, and getHighestColumn() for a specified row +- General: (adamriyadi) Work Item GH-247 - Modify PHPExcel_Reader_Excel2007 to use zipClass from PHPExcel_Settings::getZipClass() + This allows the use of PCLZip when reading for people that don't have access to ZipArchive +- General: (infojunkie) Work Item GH-276 - Convert properties to string in OOCalc reader +- Security: (maartenba) Work Item GH-322 - Disable libxml external entity loading by default. + This is to prevent XML External Entity Processing (XXE) injection attacks (see http://websec.io/2012/08/27/Preventing-XEE-in-PHP.html for an explanation of XXE injection). + Reference CVE-2014-2054 -Fixed in develop branch: +2013-06-02 (v1.7.9): +- Feature: (MBaker) Include charts option for HTML Writer +- Feature: (MBaker) Added composer file +- Feature: (MBaker) Added getStyle() method to Cell object +- Bugfix: (Asker) Work item 18777 - Error in PHPEXCEL/Calculation.php script on line 2976 (stack pop check) +- Bugfix: (MBaker) Work item 18794 - CSV files without a file extension being identified as HTML +- Bugfix: (AndreKR) Work item GH-66 - Wrong check for maximum number of rows in Excel5 Writer +- Bugfix: (MBaker) Work item GH-67 - Cache directory for DiscISAM cache storage cannot be set +- Bugfix: (MBaker) Work item 17976 - Fix to Excel2007 Reader for hyperlinks with an anchor fragment (following a #), otherwise they were treated as sheet references +- Bugfix: (MBaker) Work item 18963 - getSheetNames() fails on numeric (floating point style) names with trailing zeroes +- Bugfix: (MBaker) Work item GH-130 - Single cell print area +- General: (kea) Work item GH-69 - Improved AdvancedValueBinder for currency +- General: (MBaker) Work items 17936 and 17840 - Fix for environments where there is no access to /tmp but to upload_tmp_dir + Provided an option to set the sys_get_temp_dir() call to use the upload_tmp_dir; though by default the standard temp directory will still be used +- General: (amironov ) Work item GH-84 - Search style by identity in PHPExcel_Worksheet::duplicateStyle() +- General: (karak) Work item GH-85 - Fill SheetView IO in Excel5 +- General: (cfhay) Work item 18958 - Memory and Speed improvements in PHPExcel_Reader_Excel5 +- General: (MBaker) Work item GH-78 - Modify listWorksheetNames() and listWorksheetInfo to use XMLReader with streamed XML rather than SimpleXML +- General: (dbonsch) Restructuring of PHPExcel Exceptions +- General: (MBaker) Work items 16926 and 15145 - Refactor Calculation Engine from singleton to a Multiton + Ensures that calculation cache is maintained independently for different workbooks +- General: (MBaker) Modify cell's getCalculatedValue() method to return the content of RichText objects rather than the RichText object itself +- Bugfix: (techhead) Work item GH-70 - Fixed formula/formatting bug when removing rows +- Bugfix: (alexgann) Work item GH-63 - Fix to cellExists for non-existent namedRanges +- Bugfix: (MBaker) Work item 18844 - cache_in_memory_gzip "eats" last worksheet line, cache_in_memory doesn't +- Feature: (Progi1984) Work item GH-22 - Sheet View in Excel5 Writer +- Bugfix: (amironov) Work item GH-82 - PHPExcel_Worksheet::getCellCollection() may not return last cached cell +- Bugfix: (teso) Work item 18551 - Rich Text containing UTF-8 characters creating unreadable content with Excel5 Writer +- Bugfix: (MBaker) Work item GH-104 - echo statements in HTML.php +- Feature: (Progi1984) Work item GH-8/CP11704 : Conditional formatting in Excel 5 Writer +- Bugfix: (MBaker) Work item GH-113 - canRead() Error for GoogleDocs ODS files: in ODS files from Google Docs there is no mimetype file +- Bugfix: (MBaker) Work item GH-80 - "Sheet index is out of bounds." Exception +- Bugfix: (ccorliss) Work item GH-105 - Fixed number format fatal error +- Bugfix: (MBaker) - Add DROP TABLE in destructor for SQLite and SQLite3 cache controllers +- Bugfix: (alexgann) Work item GH-154 - Fix merged-cell borders on HTML/PDF output +- Bugfix: (Shanto) Work item GH-161 - Fix: Hyperlinks break when removing rows +- Bugfix: (neclimdul) Work item GH-166 - Fix Extra Table Row From Images and Charts + + +2012-10-12 (v1.7.8): - Special: (kkamkou) Phar builder script to add phar file as a distribution option - Feature: (MBaker) Refactor PDF Writer to allow use with a choice of PDF Rendering library rather than restricting to tcPDF @@ -140,7 +177,7 @@ Fixed in develop branch: - General: (MBaker) Reduce cell caching overhead using dirty flag to ensure that cells are only rewritten to the cache if they have actually been changed - General: (MBaker) Improved memory usage in CSV Writer - General: (MBaker) Improved speed and memory usage in Excel5 Writer -- General: (MBaker) Experimental - +- General: (MBaker) Experimental - Added getHighestDataColumn(), getHighestDataRow(), getHighestRowAndColumn() and calculateWorksheetDataDimension() methods for the worksheet that return the highest row and column that have cell records - General: (MBaker) Change iterators to implement Iterator rather than extend CachingIterator, as a fix for PHP 5.4. changes in SPL - Bugfix: (MBaker) Work item 15459 - Invalid cell coordinate in Autofilter for Excel2007 Writer diff --git a/htdocs/includes/phpexcel/install.txt b/htdocs/includes/phpexcel/install.txt index e52bcda8ef3..3fa420222f5 100644 --- a/htdocs/includes/phpexcel/install.txt +++ b/htdocs/includes/phpexcel/install.txt @@ -7,19 +7,19 @@ * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. -* +* * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. -* +* * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * -* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) +* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL -* @version 1.7.8, 2012-10-12 +* @version 1.8.0, 2014-03-02 ************************************************************************************** Requirements @@ -59,16 +59,16 @@ Getting started --------------- A good way to get started is to run some of the tests included in the download. -Copy the "Tests" folder next to your "Classes" folder from above so you end up with: +Copy the "Examples" folder next to your "Classes" folder from above so you end up with: -/var/www/Tests/01simple.php -/var/www/Tests/02types.php +/var/www/Examples/01simple.php +/var/www/Examples/02types.php ... Start running the test by pointing your browser to the test scripts: -http://example.com/Tests/01simple.php -http://example.com/Tests/02types.php +http://example.com/Examples/01simple.php +http://example.com/Examples/02types.php ... Note: It may be necessary to modify the include/require statements at the beginning of