| @@ -1,16 +1,9 @@ | ||
| 1 | 1 | <?php |
| 2 | - | |
| 3 | -/** PHPExcel root directory */ | |
| 4 | -if (!defined('PHPEXCEL_ROOT')) { | |
| 5 | - define('PHPEXCEL_ROOT', dirname(__FILE__) . '/'); | |
| 6 | - require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php'); | |
| 7 | -} | |
| 8 | - | |
| 9 | 2 | /** |
| 10 | 3 | * PHPExcel |
| 11 | 4 | * |
| 12 | - * Copyright (c) 2006 - 2015 PHPExcel | |
| 5 | + * Copyright (c) 2006 - 2014 PHPExcel | |
| 13 | 6 | * |
| 14 | 7 | * This library is free software; you can redistribute it and/or |
| 15 | 8 | * modify it under the terms of the GNU Lesser General Public |
| 16 | 9 | * License as published by the Free Software Foundation; either |
| @@ -26,12 +19,28 @@ | ||
| 26 | 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
| 27 | 20 | * |
| 28 | 21 | * @category PHPExcel |
| 29 | 22 | * @package PHPExcel |
| 30 | - * @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel) | |
| 23 | + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) | |
| 31 | 24 | * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL |
| 32 | 25 | * @version ##VERSION##, ##DATE## |
| 33 | 26 | */ |
| 27 | + | |
| 28 | + | |
| 29 | +/** PHPExcel root directory */ | |
| 30 | +if (!defined('PHPEXCEL_ROOT')) { | |
| 31 | + define('PHPEXCEL_ROOT', dirname(__FILE__) . '/'); | |
| 32 | + require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php'); | |
| 33 | +} | |
| 34 | + | |
| 35 | + | |
| 36 | +/** | |
| 37 | + * PHPExcel | |
| 38 | + * | |
| 39 | + * @category PHPExcel | |
| 40 | + * @package PHPExcel | |
| 41 | + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) | |
| 42 | + */ | |
| 34 | 43 | class PHPExcel |
| 35 | 44 | { |
| 36 | 45 | /** |
| 37 | 46 | * Unique ID |
| @@ -37,9 +46,9 @@ | ||
| 37 | 46 | * Unique ID |
| 38 | 47 | * |
| 39 | 48 | * @var string |
| 40 | 49 | */ |
| 41 | - private $uniqueID; | |
| 50 | + private $_uniqueID; | |
| 42 | 51 | |
| 43 | 52 | /** |
| 44 | 53 | * Document properties |
| 45 | 54 | * |
| @@ -44,9 +53,9 @@ | ||
| 44 | 53 | * Document properties |
| 45 | 54 | * |
| 46 | 55 | * @var PHPExcel_DocumentProperties |
| 47 | 56 | */ |
| 48 | - private $properties; | |
| 57 | + private $_properties; | |
| 49 | 58 | |
| 50 | 59 | /** |
| 51 | 60 | * Document security |
| 52 | 61 | * |
| @@ -51,9 +60,9 @@ | ||
| 51 | 60 | * Document security |
| 52 | 61 | * |
| 53 | 62 | * @var PHPExcel_DocumentSecurity |
| 54 | 63 | */ |
| 55 | - private $security; | |
| 64 | + private $_security; | |
| 56 | 65 | |
| 57 | 66 | /** |
| 58 | 67 | * Collection of Worksheet objects |
| 59 | 68 | * |
| @@ -58,23 +67,23 @@ | ||
| 58 | 67 | * Collection of Worksheet objects |
| 59 | 68 | * |
| 60 | 69 | * @var PHPExcel_Worksheet[] |
| 61 | 70 | */ |
| 62 | - private $workSheetCollection = array(); | |
| 71 | + private $_workSheetCollection = array(); | |
| 63 | 72 | |
| 64 | 73 | /** |
| 65 | - * Calculation Engine | |
| 66 | - * | |
| 67 | - * @var PHPExcel_Calculation | |
| 68 | - */ | |
| 69 | - private $calculationEngine; | |
| 74 | + * Calculation Engine | |
| 75 | + * | |
| 76 | + * @var PHPExcel_Calculation | |
| 77 | + */ | |
| 78 | + private $_calculationEngine = NULL; | |
| 70 | 79 | |
| 71 | 80 | /** |
| 72 | 81 | * Active sheet index |
| 73 | 82 | * |
| 74 | - * @var integer | |
| 83 | + * @var int | |
| 75 | 84 | */ |
| 76 | - private $activeSheetIndex = 0; | |
| 85 | + private $_activeSheetIndex = 0; | |
| 77 | 86 | |
| 78 | 87 | /** |
| 79 | 88 | * Named ranges |
| 80 | 89 | * |
| @@ -79,9 +88,9 @@ | ||
| 79 | 88 | * Named ranges |
| 80 | 89 | * |
| 81 | 90 | * @var PHPExcel_NamedRange[] |
| 82 | 91 | */ |
| 83 | - private $namedRanges = array(); | |
| 92 | + private $_namedRanges = array(); | |
| 84 | 93 | |
| 85 | 94 | /** |
| 86 | 95 | * CellXf supervisor |
| 87 | 96 | * |
| @@ -86,9 +95,9 @@ | ||
| 86 | 95 | * CellXf supervisor |
| 87 | 96 | * |
| 88 | 97 | * @var PHPExcel_Style |
| 89 | 98 | */ |
| 90 | - private $cellXfSupervisor; | |
| 99 | + private $_cellXfSupervisor; | |
| 91 | 100 | |
| 92 | 101 | /** |
| 93 | 102 | * CellXf collection |
| 94 | 103 | * |
| @@ -93,9 +102,9 @@ | ||
| 93 | 102 | * CellXf collection |
| 94 | 103 | * |
| 95 | 104 | * @var PHPExcel_Style[] |
| 96 | 105 | */ |
| 97 | - private $cellXfCollection = array(); | |
| 106 | + private $_cellXfCollection = array(); | |
| 98 | 107 | |
| 99 | 108 | /** |
| 100 | 109 | * CellStyleXf collection |
| 101 | 110 | * |
| @@ -100,237 +109,221 @@ | ||
| 100 | 109 | * CellStyleXf collection |
| 101 | 110 | * |
| 102 | 111 | * @var PHPExcel_Style[] |
| 103 | 112 | */ |
| 104 | - private $cellStyleXfCollection = array(); | |
| 113 | + private $_cellStyleXfCollection = array(); | |
| 105 | 114 | |
| 106 | - /** | |
| 107 | - * hasMacros : this workbook have macros ? | |
| 108 | - * | |
| 109 | - * @var bool | |
| 110 | - */ | |
| 111 | - private $hasMacros = false; | |
| 115 | + /** | |
| 116 | + * _hasMacros : this workbook have macros ? | |
| 117 | + * | |
| 118 | + * @var bool | |
| 119 | + */ | |
| 120 | + private $_hasMacros = FALSE; | |
| 112 | 121 | |
| 113 | - /** | |
| 114 | - * macrosCode : all macros code (the vbaProject.bin file, this include form, code, etc.), null if no macro | |
| 115 | - * | |
| 116 | - * @var binary | |
| 117 | - */ | |
| 118 | - private $macrosCode; | |
| 119 | - /** | |
| 120 | - * macrosCertificate : if macros are signed, contains vbaProjectSignature.bin file, null if not signed | |
| 121 | - * | |
| 122 | - * @var binary | |
| 123 | - */ | |
| 124 | - private $macrosCertificate; | |
| 122 | + /** | |
| 123 | + * _macrosCode : all macros code (the vbaProject.bin file, this include form, code, etc.), NULL if no macro | |
| 124 | + * | |
| 125 | + * @var binary | |
| 126 | + */ | |
| 127 | + private $_macrosCode=NULL; | |
| 128 | + /** | |
| 129 | + * _macrosCertificate : if macros are signed, contains vbaProjectSignature.bin file, NULL if not signed | |
| 130 | + * | |
| 131 | + * @var binary | |
| 132 | + */ | |
| 133 | + private $_macrosCertificate=NULL; | |
| 125 | 134 | |
| 126 | - /** | |
| 127 | - * ribbonXMLData : null if workbook is'nt Excel 2007 or not contain a customized UI | |
| 128 | - * | |
| 129 | - * @var null|string | |
| 130 | - */ | |
| 131 | - private $ribbonXMLData; | |
| 135 | + /** | |
| 136 | + * _ribbonXMLData : NULL if workbook is'nt Excel 2007 or not contain a customized UI | |
| 137 | + * | |
| 138 | + * @var NULL|string | |
| 139 | + */ | |
| 140 | + private $_ribbonXMLData=NULL; | |
| 132 | 141 | |
| 133 | - /** | |
| 134 | - * ribbonBinObjects : null if workbook is'nt Excel 2007 or not contain embedded objects (picture(s)) for Ribbon Elements | |
| 135 | - * ignored if $ribbonXMLData is null | |
| 136 | - * | |
| 137 | - * @var null|array | |
| 138 | - */ | |
| 139 | - private $ribbonBinObjects; | |
| 142 | + /** | |
| 143 | + * _ribbonBinObjects : NULL if workbook is'nt Excel 2007 or not contain embedded objects (picture(s)) for Ribbon Elements | |
| 144 | + * ignored if $_ribbonXMLData is null | |
| 145 | + * | |
| 146 | + * @var NULL|array | |
| 147 | + */ | |
| 148 | + private $_ribbonBinObjects=NULL; | |
| 140 | 149 | |
| 141 | - /** | |
| 142 | - * The workbook has macros ? | |
| 143 | - * | |
| 144 | - * @return boolean true if workbook has macros, false if not | |
| 145 | - */ | |
| 146 | - public function hasMacros() | |
| 147 | - { | |
| 148 | - return $this->hasMacros; | |
| 149 | - } | |
| 150 | + /** | |
| 151 | + * The workbook has macros ? | |
| 152 | + * | |
| 153 | + * @return true if workbook has macros, false if not | |
| 154 | + */ | |
| 155 | + public function hasMacros(){ | |
| 156 | + return $this->_hasMacros; | |
| 157 | + } | |
| 150 | 158 | |
| 151 | - /** | |
| 152 | - * Define if a workbook has macros | |
| 153 | - * | |
| 154 | - * @param boolean $hasMacros true|false | |
| 155 | - */ | |
| 156 | - public function setHasMacros($hasMacros = false) | |
| 157 | - { | |
| 158 | - $this->hasMacros = (bool) $hasMacros; | |
| 159 | - } | |
| 159 | + /** | |
| 160 | + * Define if a workbook has macros | |
| 161 | + * | |
| 162 | + * @param true|false | |
| 163 | + */ | |
| 164 | + public function setHasMacros($hasMacros=false){ | |
| 165 | + $this->_hasMacros=(bool)$hasMacros; | |
| 166 | + } | |
| 160 | 167 | |
| 161 | - /** | |
| 162 | - * Set the macros code | |
| 163 | - * | |
| 164 | - * @param string $MacrosCode string|null | |
| 165 | - */ | |
| 166 | - public function setMacrosCode($MacrosCode = null) | |
| 167 | - { | |
| 168 | - $this->macrosCode=$MacrosCode; | |
| 169 | - $this->setHasMacros(!is_null($MacrosCode)); | |
| 170 | - } | |
| 168 | + /** | |
| 169 | + * Set the macros code | |
| 170 | + * | |
| 171 | + * @param binary string|null | |
| 172 | + */ | |
| 173 | + public function setMacrosCode($MacrosCode){ | |
| 174 | + $this->_macrosCode=$MacrosCode; | |
| 175 | + $this->setHasMacros(!is_null($MacrosCode)); | |
| 176 | + } | |
| 171 | 177 | |
| 172 | - /** | |
| 173 | - * Return the macros code | |
| 174 | - * | |
| 175 | - * @return string|null | |
| 176 | - */ | |
| 177 | - public function getMacrosCode() | |
| 178 | - { | |
| 179 | - return $this->macrosCode; | |
| 180 | - } | |
| 178 | + /** | |
| 179 | + * Return the macros code | |
| 180 | + * | |
| 181 | + * @return binary|null | |
| 182 | + */ | |
| 183 | + public function getMacrosCode(){ | |
| 184 | + return $this->_macrosCode; | |
| 185 | + } | |
| 181 | 186 | |
| 182 | - /** | |
| 183 | - * Set the macros certificate | |
| 184 | - * | |
| 185 | - * @param string|null $Certificate | |
| 186 | - */ | |
| 187 | - public function setMacrosCertificate($Certificate = null) | |
| 188 | - { | |
| 189 | - $this->macrosCertificate=$Certificate; | |
| 190 | - } | |
| 187 | + /** | |
| 188 | + * Set the macros certificate | |
| 189 | + * | |
| 190 | + * @param binary|null | |
| 191 | + */ | |
| 192 | + public function setMacrosCertificate($Certificate=NULL){ | |
| 193 | + $this->_macrosCertificate=$Certificate; | |
| 194 | + } | |
| 191 | 195 | |
| 192 | - /** | |
| 193 | - * Is the project signed ? | |
| 194 | - * | |
| 195 | - * @return boolean true|false | |
| 196 | - */ | |
| 197 | - public function hasMacrosCertificate() | |
| 198 | - { | |
| 199 | - return !is_null($this->macrosCertificate); | |
| 200 | - } | |
| 196 | + /** | |
| 197 | + * Is the project signed ? | |
| 198 | + * | |
| 199 | + * @return true|false | |
| 200 | + */ | |
| 201 | + public function hasMacrosCertificate(){ | |
| 202 | + return !is_null($this->_macrosCertificate); | |
| 203 | + } | |
| 201 | 204 | |
| 202 | - /** | |
| 203 | - * Return the macros certificate | |
| 204 | - * | |
| 205 | - * @return string|null | |
| 206 | - */ | |
| 207 | - public function getMacrosCertificate() | |
| 208 | - { | |
| 209 | - return $this->macrosCertificate; | |
| 210 | - } | |
| 205 | + /** | |
| 206 | + * Return the macros certificate | |
| 207 | + * | |
| 208 | + * @return binary|null | |
| 209 | + */ | |
| 210 | + public function getMacrosCertificate(){ | |
| 211 | + return $this->_macrosCertificate; | |
| 212 | + } | |
| 211 | 213 | |
| 212 | - /** | |
| 213 | - * Remove all macros, certificate from spreadsheet | |
| 214 | - * | |
| 215 | - */ | |
| 216 | - public function discardMacros() | |
| 217 | - { | |
| 218 | - $this->hasMacros=false; | |
| 219 | - $this->macrosCode=null; | |
| 220 | - $this->macrosCertificate=null; | |
| 221 | - } | |
| 214 | + /** | |
| 215 | + * Remove all macros, certificate from spreadsheet | |
| 216 | + * | |
| 217 | + * @param none | |
| 218 | + * @return void | |
| 219 | + */ | |
| 220 | + public function discardMacros(){ | |
| 221 | + $this->_hasMacros=false; | |
| 222 | + $this->_macrosCode=NULL; | |
| 223 | + $this->_macrosCertificate=NULL; | |
| 224 | + } | |
| 222 | 225 | |
| 223 | - /** | |
| 224 | - * set ribbon XML data | |
| 225 | - * | |
| 226 | - */ | |
| 227 | - public function setRibbonXMLData($Target = null, $XMLData = null) | |
| 228 | - { | |
| 229 | - if (!is_null($Target) && !is_null($XMLData)) { | |
| 230 | - $this->ribbonXMLData = array('target' => $Target, 'data' => $XMLData); | |
| 231 | - } else { | |
| 232 | - $this->ribbonXMLData = null; | |
| 233 | - } | |
| 234 | - } | |
| 226 | + /** | |
| 227 | + * set ribbon XML data | |
| 228 | + * | |
| 229 | + */ | |
| 230 | + public function setRibbonXMLData($Target=NULL, $XMLData=NULL){ | |
| 231 | + if(!is_null($Target) && !is_null($XMLData)){ | |
| 232 | + $this->_ribbonXMLData=array('target'=>$Target, 'data'=>$XMLData); | |
| 233 | + }else{ | |
| 234 | + $this->_ribbonXMLData=NULL; | |
| 235 | + } | |
| 236 | + } | |
| 235 | 237 | |
| 236 | - /** | |
| 237 | - * retrieve ribbon XML Data | |
| 238 | - * | |
| 239 | - * return string|null|array | |
| 240 | - */ | |
| 241 | - public function getRibbonXMLData($What = 'all') //we need some constants here... | |
| 242 | - { | |
| 243 | - $ReturnData = null; | |
| 244 | - $What = strtolower($What); | |
| 245 | - switch ($What){ | |
| 246 | - case 'all': | |
| 247 | - $ReturnData = $this->ribbonXMLData; | |
| 248 | - break; | |
| 249 | - case 'target': | |
| 250 | - case 'data': | |
| 251 | - if (is_array($this->ribbonXMLData) && array_key_exists($What, $this->ribbonXMLData)) { | |
| 252 | - $ReturnData = $this->ribbonXMLData[$What]; | |
| 253 | - } | |
| 254 | - break; | |
| 255 | - } | |
| 238 | + /** | |
| 239 | + * retrieve ribbon XML Data | |
| 240 | + * | |
| 241 | + * return string|null|array | |
| 242 | + */ | |
| 243 | + public function getRibbonXMLData($What='all'){//we need some constants here... | |
| 244 | + $ReturnData=NULL; | |
| 245 | + $What=strtolower($What); | |
| 246 | + switch($What){ | |
| 247 | + case 'all': | |
| 248 | + $ReturnData=$this->_ribbonXMLData; | |
| 249 | + break; | |
| 250 | + case 'target': | |
| 251 | + case 'data': | |
| 252 | + if(is_array($this->_ribbonXMLData) && array_key_exists($What,$this->_ribbonXMLData)){ | |
| 253 | + $ReturnData=$this->_ribbonXMLData[$What]; | |
| 254 | + }//else $ReturnData stay at null | |
| 255 | + break; | |
| 256 | + }//default: $ReturnData at null | |
| 257 | + return $ReturnData; | |
| 258 | + } | |
| 256 | 259 | |
| 257 | - return $ReturnData; | |
| 258 | - } | |
| 260 | + /** | |
| 261 | + * store binaries ribbon objects (pictures) | |
| 262 | + * | |
| 263 | + */ | |
| 264 | + public function setRibbonBinObjects($BinObjectsNames=NULL, $BinObjectsData=NULL){ | |
| 265 | + if(!is_null($BinObjectsNames) && !is_null($BinObjectsData)){ | |
| 266 | + $this->_ribbonBinObjects=array('names'=>$BinObjectsNames, 'data'=>$BinObjectsData); | |
| 267 | + }else{ | |
| 268 | + $this->_ribbonBinObjects=NULL; | |
| 269 | + } | |
| 270 | + } | |
| 271 | + /** | |
| 272 | + * return the extension of a filename. Internal use for a array_map callback (php<5.3 don't like lambda function) | |
| 273 | + * | |
| 274 | + */ | |
| 275 | + private function _getExtensionOnly($ThePath){ | |
| 276 | + return pathinfo($ThePath, PATHINFO_EXTENSION); | |
| 277 | + } | |
| 259 | 278 | |
| 260 | - /** | |
| 261 | - * store binaries ribbon objects (pictures) | |
| 262 | - * | |
| 263 | - */ | |
| 264 | - public function setRibbonBinObjects($BinObjectsNames = null, $BinObjectsData = null) | |
| 265 | - { | |
| 266 | - if (!is_null($BinObjectsNames) && !is_null($BinObjectsData)) { | |
| 267 | - $this->ribbonBinObjects = array('names' => $BinObjectsNames, 'data' => $BinObjectsData); | |
| 268 | - } else { | |
| 269 | - $this->ribbonBinObjects = null; | |
| 270 | - } | |
| 271 | - } | |
| 272 | - /** | |
| 273 | - * return the extension of a filename. Internal use for a array_map callback (php<5.3 don't like lambda function) | |
| 274 | - * | |
| 275 | - */ | |
| 276 | - private function getExtensionOnly($ThePath) | |
| 277 | - { | |
| 278 | - return pathinfo($ThePath, PATHINFO_EXTENSION); | |
| 279 | - } | |
| 279 | + /** | |
| 280 | + * retrieve Binaries Ribbon Objects | |
| 281 | + * | |
| 282 | + */ | |
| 283 | + public function getRibbonBinObjects($What='all'){ | |
| 284 | + $ReturnData=NULL; | |
| 285 | + $What=strtolower($What); | |
| 286 | + switch($What){ | |
| 287 | + case 'all': | |
| 288 | + return $this->_ribbonBinObjects; | |
| 289 | + break; | |
| 290 | + case 'names': | |
| 291 | + case 'data': | |
| 292 | + if(is_array($this->_ribbonBinObjects) && array_key_exists($What, $this->_ribbonBinObjects)){ | |
| 293 | + $ReturnData=$this->_ribbonBinObjects[$What]; | |
| 294 | + } | |
| 295 | + break; | |
| 296 | + case 'types': | |
| 297 | + if(is_array($this->_ribbonBinObjects) && array_key_exists('data', $this->_ribbonBinObjects) && is_array($this->_ribbonBinObjects['data'])){ | |
| 298 | + $tmpTypes=array_keys($this->_ribbonBinObjects['data']); | |
| 299 | + $ReturnData=array_unique(array_map(array($this,'_getExtensionOnly'), $tmpTypes)); | |
| 300 | + }else | |
| 301 | + $ReturnData=array();//the caller want an array... not null if empty | |
| 302 | + break; | |
| 303 | + } | |
| 304 | + return $ReturnData; | |
| 305 | + } | |
| 280 | 306 | |
| 281 | - /** | |
| 282 | - * retrieve Binaries Ribbon Objects | |
| 283 | - * | |
| 284 | - */ | |
| 285 | - public function getRibbonBinObjects($What = 'all') | |
| 286 | - { | |
| 287 | - $ReturnData = null; | |
| 288 | - $What = strtolower($What); | |
| 289 | - switch($What) { | |
| 290 | - case 'all': | |
| 291 | - return $this->ribbonBinObjects; | |
| 292 | - break; | |
| 293 | - case 'names': | |
| 294 | - case 'data': | |
| 295 | - if (is_array($this->ribbonBinObjects) && array_key_exists($What, $this->ribbonBinObjects)) { | |
| 296 | - $ReturnData=$this->ribbonBinObjects[$What]; | |
| 297 | - } | |
| 298 | - break; | |
| 299 | - case 'types': | |
| 300 | - if (is_array($this->ribbonBinObjects) && | |
| 301 | - array_key_exists('data', $this->ribbonBinObjects) && is_array($this->ribbonBinObjects['data'])) { | |
| 302 | - $tmpTypes=array_keys($this->ribbonBinObjects['data']); | |
| 303 | - $ReturnData = array_unique(array_map(array($this, 'getExtensionOnly'), $tmpTypes)); | |
| 304 | - } else { | |
| 305 | - $ReturnData=array(); // the caller want an array... not null if empty | |
| 306 | - } | |
| 307 | - break; | |
| 308 | - } | |
| 309 | - return $ReturnData; | |
| 310 | - } | |
| 307 | + /** | |
| 308 | + * This workbook have a custom UI ? | |
| 309 | + * | |
| 310 | + * @return true|false | |
| 311 | + */ | |
| 312 | + public function hasRibbon(){ | |
| 313 | + return !is_null($this->_ribbonXMLData); | |
| 314 | + } | |
| 311 | 315 | |
| 312 | - /** | |
| 313 | - * This workbook have a custom UI ? | |
| 314 | - * | |
| 315 | - * @return boolean true|false | |
| 316 | - */ | |
| 317 | - public function hasRibbon() | |
| 318 | - { | |
| 319 | - return !is_null($this->ribbonXMLData); | |
| 320 | - } | |
| 316 | + /** | |
| 317 | + * This workbook have additionnal object for the ribbon ? | |
| 318 | + * | |
| 319 | + * @return true|false | |
| 320 | + */ | |
| 321 | + public function hasRibbonBinObjects(){ | |
| 322 | + return !is_null($this->_ribbonBinObjects); | |
| 323 | + } | |
| 321 | 324 | |
| 322 | - /** | |
| 323 | - * This workbook have additionnal object for the ribbon ? | |
| 324 | - * | |
| 325 | - * @return boolean true|false | |
| 326 | - */ | |
| 327 | - public function hasRibbonBinObjects() | |
| 328 | - { | |
| 329 | - return !is_null($this->ribbonBinObjects); | |
| 330 | - } | |
| 331 | - | |
| 332 | - /** | |
| 325 | + /** | |
| 333 | 326 | * Check if a sheet with a specified code name already exists |
| 334 | 327 | * |
| 335 | 328 | * @param string $pSheetCodeName Name of the worksheet to check |
| 336 | 329 | * @return boolean |
| @@ -336,54 +329,54 @@ | ||
| 336 | 329 | * @return boolean |
| 337 | 330 | */ |
| 338 | 331 | public function sheetCodeNameExists($pSheetCodeName) |
| 339 | 332 | { |
| 340 | - return ($this->getSheetByCodeName($pSheetCodeName) !== null); | |
| 333 | + return ($this->getSheetByCodeName($pSheetCodeName) !== NULL); | |
| 341 | 334 | } |
| 342 | 335 | |
| 343 | - /** | |
| 344 | - * Get sheet by code name. Warning : sheet don't have always a code name ! | |
| 345 | - * | |
| 346 | - * @param string $pName Sheet name | |
| 347 | - * @return PHPExcel_Worksheet | |
| 348 | - */ | |
| 349 | - public function getSheetByCodeName($pName = '') | |
| 350 | - { | |
| 351 | - $worksheetCount = count($this->workSheetCollection); | |
| 352 | - for ($i = 0; $i < $worksheetCount; ++$i) { | |
| 353 | - if ($this->workSheetCollection[$i]->getCodeName() == $pName) { | |
| 354 | - return $this->workSheetCollection[$i]; | |
| 355 | - } | |
| 356 | - } | |
| 336 | + /** | |
| 337 | + * Get sheet by code name. Warning : sheet don't have always a code name ! | |
| 338 | + * | |
| 339 | + * @param string $pName Sheet name | |
| 340 | + * @return PHPExcel_Worksheet | |
| 341 | + */ | |
| 342 | + public function getSheetByCodeName($pName = '') | |
| 343 | + { | |
| 344 | + $worksheetCount = count($this->_workSheetCollection); | |
| 345 | + for ($i = 0; $i < $worksheetCount; ++$i) { | |
| 346 | + if ($this->_workSheetCollection[$i]->getCodeName() == $pName) { | |
| 347 | + return $this->_workSheetCollection[$i]; | |
| 348 | + } | |
| 349 | + } | |
| 357 | 350 | |
| 358 | - return null; | |
| 359 | - } | |
| 351 | + return null; | |
| 352 | + } | |
| 360 | 353 | |
| 361 | - /** | |
| 362 | - * Create a new PHPExcel with one Worksheet | |
| 363 | - */ | |
| 364 | - public function __construct() | |
| 365 | - { | |
| 366 | - $this->uniqueID = uniqid(); | |
| 367 | - $this->calculationEngine = new PHPExcel_Calculation($this); | |
| 354 | + /** | |
| 355 | + * Create a new PHPExcel with one Worksheet | |
| 356 | + */ | |
| 357 | + public function __construct() | |
| 358 | + { | |
| 359 | + $this->_uniqueID = uniqid(); | |
| 360 | + $this->_calculationEngine = PHPExcel_Calculation::getInstance($this); | |
| 368 | 361 | |
| 369 | - // Initialise worksheet collection and add one worksheet | |
| 370 | - $this->workSheetCollection = array(); | |
| 371 | - $this->workSheetCollection[] = new PHPExcel_Worksheet($this); | |
| 372 | - $this->activeSheetIndex = 0; | |
| 362 | + // Initialise worksheet collection and add one worksheet | |
| 363 | + $this->_workSheetCollection = array(); | |
| 364 | + $this->_workSheetCollection[] = new PHPExcel_Worksheet($this); | |
| 365 | + $this->_activeSheetIndex = 0; | |
| 373 | 366 | |
| 374 | 367 | // Create document properties |
| 375 | - $this->properties = new PHPExcel_DocumentProperties(); | |
| 368 | + $this->_properties = new PHPExcel_DocumentProperties(); | |
| 376 | 369 | |
| 377 | 370 | // Create document security |
| 378 | - $this->security = new PHPExcel_DocumentSecurity(); | |
| 371 | + $this->_security = new PHPExcel_DocumentSecurity(); | |
| 379 | 372 | |
| 380 | 373 | // Set named ranges |
| 381 | - $this->namedRanges = array(); | |
| 374 | + $this->_namedRanges = array(); | |
| 382 | 375 | |
| 383 | 376 | // Create the cellXf supervisor |
| 384 | - $this->cellXfSupervisor = new PHPExcel_Style(true); | |
| 385 | - $this->cellXfSupervisor->bindParent($this); | |
| 377 | + $this->_cellXfSupervisor = new PHPExcel_Style(true); | |
| 378 | + $this->_cellXfSupervisor->bindParent($this); | |
| 386 | 379 | |
| 387 | 380 | // Create the default style |
| 388 | 381 | $this->addCellXf(new PHPExcel_Style); |
| 389 | 382 | $this->addCellStyleXf(new PHPExcel_Style); |
| @@ -392,13 +385,12 @@ | ||
| 392 | 385 | /** |
| 393 | 386 | * Code to execute when this worksheet is unset() |
| 394 | 387 | * |
| 395 | 388 | */ |
| 396 | - public function __destruct() | |
| 397 | - { | |
| 398 | - $this->calculationEngine = null; | |
| 389 | + public function __destruct() { | |
| 390 | + PHPExcel_Calculation::unsetInstance($this); | |
| 399 | 391 | $this->disconnectWorksheets(); |
| 400 | - } | |
| 392 | + } // function __destruct() | |
| 401 | 393 | |
| 402 | 394 | /** |
| 403 | 395 | * Disconnect all worksheets from this PHPExcel workbook object, |
| 404 | 396 | * typically so that the PHPExcel object can be unset |
| @@ -405,26 +397,26 @@ | ||
| 405 | 397 | * |
| 406 | 398 | */ |
| 407 | 399 | public function disconnectWorksheets() |
| 408 | 400 | { |
| 409 | - $worksheet = null; | |
| 410 | - foreach ($this->workSheetCollection as $k => &$worksheet) { | |
| 401 | + $worksheet = NULL; | |
| 402 | + foreach($this->_workSheetCollection as $k => &$worksheet) { | |
| 411 | 403 | $worksheet->disconnectCells(); |
| 412 | - $this->workSheetCollection[$k] = null; | |
| 404 | + $this->_workSheetCollection[$k] = null; | |
| 413 | 405 | } |
| 414 | 406 | unset($worksheet); |
| 415 | - $this->workSheetCollection = array(); | |
| 407 | + $this->_workSheetCollection = array(); | |
| 416 | 408 | } |
| 417 | 409 | |
| 418 | - /** | |
| 419 | - * Return the calculation engine for this worksheet | |
| 420 | - * | |
| 421 | - * @return PHPExcel_Calculation | |
| 422 | - */ | |
| 423 | - public function getCalculationEngine() | |
| 424 | - { | |
| 425 | - return $this->calculationEngine; | |
| 426 | - } // function getCellCacheController() | |
| 410 | + /** | |
| 411 | + * Return the calculation engine for this worksheet | |
| 412 | + * | |
| 413 | + * @return PHPExcel_Calculation | |
| 414 | + */ | |
| 415 | + public function getCalculationEngine() | |
| 416 | + { | |
| 417 | + return $this->_calculationEngine; | |
| 418 | + } // function getCellCacheController() | |
| 427 | 419 | |
| 428 | 420 | /** |
| 429 | 421 | * Get properties |
| 430 | 422 | * |
| @@ -431,9 +423,9 @@ | ||
| 431 | 423 | * @return PHPExcel_DocumentProperties |
| 432 | 424 | */ |
| 433 | 425 | public function getProperties() |
| 434 | 426 | { |
| 435 | - return $this->properties; | |
| 427 | + return $this->_properties; | |
| 436 | 428 | } |
| 437 | 429 | |
| 438 | 430 | /** |
| 439 | 431 | * Set properties |
| @@ -441,9 +433,9 @@ | ||
| 441 | 433 | * @param PHPExcel_DocumentProperties $pValue |
| 442 | 434 | */ |
| 443 | 435 | public function setProperties(PHPExcel_DocumentProperties $pValue) |
| 444 | 436 | { |
| 445 | - $this->properties = $pValue; | |
| 437 | + $this->_properties = $pValue; | |
| 446 | 438 | } |
| 447 | 439 | |
| 448 | 440 | /** |
| 449 | 441 | * Get security |
| @@ -451,9 +443,9 @@ | ||
| 451 | 443 | * @return PHPExcel_DocumentSecurity |
| 452 | 444 | */ |
| 453 | 445 | public function getSecurity() |
| 454 | 446 | { |
| 455 | - return $this->security; | |
| 447 | + return $this->_security; | |
| 456 | 448 | } |
| 457 | 449 | |
| 458 | 450 | /** |
| 459 | 451 | * Set security |
| @@ -461,9 +453,9 @@ | ||
| 461 | 453 | * @param PHPExcel_DocumentSecurity $pValue |
| 462 | 454 | */ |
| 463 | 455 | public function setSecurity(PHPExcel_DocumentSecurity $pValue) |
| 464 | 456 | { |
| 465 | - $this->security = $pValue; | |
| 457 | + $this->_security = $pValue; | |
| 466 | 458 | } |
| 467 | 459 | |
| 468 | 460 | /** |
| 469 | 461 | * Get active sheet |
| @@ -473,9 +465,9 @@ | ||
| 473 | 465 | * @throws PHPExcel_Exception |
| 474 | 466 | */ |
| 475 | 467 | public function getActiveSheet() |
| 476 | 468 | { |
| 477 | - return $this->getSheet($this->activeSheetIndex); | |
| 469 | + return $this->getSheet($this->_activeSheetIndex); | |
| 478 | 470 | } |
| 479 | 471 | |
| 480 | 472 | /** |
| 481 | 473 | * Create sheet and add it to this workbook |
| @@ -483,9 +475,9 @@ | ||
| 483 | 475 | * @param int|null $iSheetIndex Index where sheet should go (0,1,..., or null for last) |
| 484 | 476 | * @return PHPExcel_Worksheet |
| 485 | 477 | * @throws PHPExcel_Exception |
| 486 | 478 | */ |
| 487 | - public function createSheet($iSheetIndex = null) | |
| 479 | + public function createSheet($iSheetIndex = NULL) | |
| 488 | 480 | { |
| 489 | 481 | $newSheet = new PHPExcel_Worksheet($this); |
| 490 | 482 | $this->addSheet($newSheet, $iSheetIndex); |
| 491 | 483 | return $newSheet; |
| @@ -498,9 +490,9 @@ | ||
| 498 | 490 | * @return boolean |
| 499 | 491 | */ |
| 500 | 492 | public function sheetNameExists($pSheetName) |
| 501 | 493 | { |
| 502 | - return ($this->getSheetByName($pSheetName) !== null); | |
| 494 | + return ($this->getSheetByName($pSheetName) !== NULL); | |
| 503 | 495 | } |
| 504 | 496 | |
| 505 | 497 | /** |
| 506 | 498 | * Add sheet |
| @@ -509,33 +501,33 @@ | ||
| 509 | 501 | * @param int|null $iSheetIndex Index where sheet should go (0,1,..., or null for last) |
| 510 | 502 | * @return PHPExcel_Worksheet |
| 511 | 503 | * @throws PHPExcel_Exception |
| 512 | 504 | */ |
| 513 | - public function addSheet(PHPExcel_Worksheet $pSheet, $iSheetIndex = null) | |
| 505 | + public function addSheet(PHPExcel_Worksheet $pSheet, $iSheetIndex = NULL) | |
| 514 | 506 | { |
| 515 | 507 | if ($this->sheetNameExists($pSheet->getTitle())) { |
| 516 | 508 | throw new PHPExcel_Exception( |
| 517 | - "Workbook already contains a worksheet named '{$pSheet->getTitle()}'. Rename this worksheet first." | |
| 509 | + "Workbook already contains a worksheet named '{$pSheet->getTitle()}'. Rename this worksheet first." | |
| 518 | 510 | ); |
| 519 | 511 | } |
| 520 | 512 | |
| 521 | - if ($iSheetIndex === null) { | |
| 522 | - if ($this->activeSheetIndex < 0) { | |
| 523 | - $this->activeSheetIndex = 0; | |
| 513 | + if($iSheetIndex === NULL) { | |
| 514 | + if ($this->_activeSheetIndex < 0) { | |
| 515 | + $this->_activeSheetIndex = 0; | |
| 524 | 516 | } |
| 525 | - $this->workSheetCollection[] = $pSheet; | |
| 517 | + $this->_workSheetCollection[] = $pSheet; | |
| 526 | 518 | } else { |
| 527 | 519 | // Insert the sheet at the requested index |
| 528 | 520 | array_splice( |
| 529 | - $this->workSheetCollection, | |
| 521 | + $this->_workSheetCollection, | |
| 530 | 522 | $iSheetIndex, |
| 531 | 523 | 0, |
| 532 | 524 | array($pSheet) |
| 533 | - ); | |
| 525 | + ); | |
| 534 | 526 | |
| 535 | 527 | // Adjust active sheet index if necessary |
| 536 | - if ($this->activeSheetIndex >= $iSheetIndex) { | |
| 537 | - ++$this->activeSheetIndex; | |
| 528 | + if ($this->_activeSheetIndex >= $iSheetIndex) { | |
| 529 | + ++$this->_activeSheetIndex; | |
| 538 | 530 | } |
| 539 | 531 | } |
| 540 | 532 | |
| 541 | 533 | if ($pSheet->getParent() === null) { |
| @@ -553,20 +545,21 @@ | ||
| 553 | 545 | */ |
| 554 | 546 | public function removeSheetByIndex($pIndex = 0) |
| 555 | 547 | { |
| 556 | 548 | |
| 557 | - $numSheets = count($this->workSheetCollection); | |
| 549 | + $numSheets = count($this->_workSheetCollection); | |
| 550 | + | |
| 558 | 551 | if ($pIndex > $numSheets - 1) { |
| 559 | 552 | throw new PHPExcel_Exception( |
| 560 | - "You tried to remove a sheet by the out of bounds index: {$pIndex}. The actual number of sheets is {$numSheets}." | |
| 553 | + "You tried to remove a sheet by the out of bounds index: {$pIndex}. The actual number of sheets is {$numSheets}." | |
| 561 | 554 | ); |
| 562 | 555 | } else { |
| 563 | - array_splice($this->workSheetCollection, $pIndex, 1); | |
| 556 | + array_splice($this->_workSheetCollection, $pIndex, 1); | |
| 564 | 557 | } |
| 565 | 558 | // Adjust active sheet index if necessary |
| 566 | - if (($this->activeSheetIndex >= $pIndex) && | |
| 567 | - ($pIndex > count($this->workSheetCollection) - 1)) { | |
| 568 | - --$this->activeSheetIndex; | |
| 559 | + if (($this->_activeSheetIndex >= $pIndex) && | |
| 560 | + ($pIndex > count($this->_workSheetCollection) - 1)) { | |
| 561 | + --$this->_activeSheetIndex; | |
| 569 | 562 | } |
| 570 | 563 | |
| 571 | 564 | } |
| 572 | 565 | |
| @@ -578,9 +571,9 @@ | ||
| 578 | 571 | * @throws PHPExcel_Exception |
| 579 | 572 | */ |
| 580 | 573 | public function getSheet($pIndex = 0) |
| 581 | 574 | { |
| 582 | - if (!isset($this->workSheetCollection[$pIndex])) { | |
| 575 | + if (!isset($this->_workSheetCollection[$pIndex])) { | |
| 583 | 576 | $numSheets = $this->getSheetCount(); |
| 584 | 577 | throw new PHPExcel_Exception( |
| 585 | 578 | "Your requested sheet index: {$pIndex} is out of bounds. The actual number of sheets is {$numSheets}." |
| 586 | 579 | ); |
| @@ -585,9 +578,9 @@ | ||
| 585 | 578 | "Your requested sheet index: {$pIndex} is out of bounds. The actual number of sheets is {$numSheets}." |
| 586 | 579 | ); |
| 587 | 580 | } |
| 588 | 581 | |
| 589 | - return $this->workSheetCollection[$pIndex]; | |
| 582 | + return $this->_workSheetCollection[$pIndex]; | |
| 590 | 583 | } |
| 591 | 584 | |
| 592 | 585 | /** |
| 593 | 586 | * Get all sheets |
| @@ -595,9 +588,9 @@ | ||
| 595 | 588 | * @return PHPExcel_Worksheet[] |
| 596 | 589 | */ |
| 597 | 590 | public function getAllSheets() |
| 598 | 591 | { |
| 599 | - return $this->workSheetCollection; | |
| 592 | + return $this->_workSheetCollection; | |
| 600 | 593 | } |
| 601 | 594 | |
| 602 | 595 | /** |
| 603 | 596 | * Get sheet by name |
| @@ -606,16 +599,16 @@ | ||
| 606 | 599 | * @return PHPExcel_Worksheet |
| 607 | 600 | */ |
| 608 | 601 | public function getSheetByName($pName = '') |
| 609 | 602 | { |
| 610 | - $worksheetCount = count($this->workSheetCollection); | |
| 603 | + $worksheetCount = count($this->_workSheetCollection); | |
| 611 | 604 | for ($i = 0; $i < $worksheetCount; ++$i) { |
| 612 | - if ($this->workSheetCollection[$i]->getTitle() === $pName) { | |
| 613 | - return $this->workSheetCollection[$i]; | |
| 605 | + if ($this->_workSheetCollection[$i]->getTitle() === $pName) { | |
| 606 | + return $this->_workSheetCollection[$i]; | |
| 614 | 607 | } |
| 615 | 608 | } |
| 616 | 609 | |
| 617 | - return null; | |
| 610 | + return NULL; | |
| 618 | 611 | } |
| 619 | 612 | |
| 620 | 613 | /** |
| 621 | 614 | * Get index for sheet |
| @@ -620,14 +613,14 @@ | ||
| 620 | 613 | /** |
| 621 | 614 | * Get index for sheet |
| 622 | 615 | * |
| 623 | 616 | * @param PHPExcel_Worksheet $pSheet |
| 624 | - * @return int Sheet index | |
| 617 | + * @return Sheet index | |
| 625 | 618 | * @throws PHPExcel_Exception |
| 626 | 619 | */ |
| 627 | 620 | public function getIndex(PHPExcel_Worksheet $pSheet) |
| 628 | 621 | { |
| 629 | - foreach ($this->workSheetCollection as $key => $value) { | |
| 622 | + foreach ($this->_workSheetCollection as $key => $value) { | |
| 630 | 623 | if ($value->getHashCode() == $pSheet->getHashCode()) { |
| 631 | 624 | return $key; |
| 632 | 625 | } |
| 633 | 626 | } |
| @@ -639,9 +632,9 @@ | ||
| 639 | 632 | * Set index for sheet by sheet name. |
| 640 | 633 | * |
| 641 | 634 | * @param string $sheetName Sheet name to modify index for |
| 642 | 635 | * @param int $newIndex New index for the sheet |
| 643 | - * @return int New sheet index | |
| 636 | + * @return New sheet index | |
| 644 | 637 | * @throws PHPExcel_Exception |
| 645 | 638 | */ |
| 646 | 639 | public function setIndexByName($sheetName, $newIndex) |
| 647 | 640 | { |
| @@ -646,14 +639,14 @@ | ||
| 646 | 639 | public function setIndexByName($sheetName, $newIndex) |
| 647 | 640 | { |
| 648 | 641 | $oldIndex = $this->getIndex($this->getSheetByName($sheetName)); |
| 649 | 642 | $pSheet = array_splice( |
| 650 | - $this->workSheetCollection, | |
| 643 | + $this->_workSheetCollection, | |
| 651 | 644 | $oldIndex, |
| 652 | 645 | 1 |
| 653 | 646 | ); |
| 654 | 647 | array_splice( |
| 655 | - $this->workSheetCollection, | |
| 648 | + $this->_workSheetCollection, | |
| 656 | 649 | $newIndex, |
| 657 | 650 | 0, |
| 658 | 651 | $pSheet |
| 659 | 652 | ); |
| @@ -666,9 +659,9 @@ | ||
| 666 | 659 | * @return int |
| 667 | 660 | */ |
| 668 | 661 | public function getSheetCount() |
| 669 | 662 | { |
| 670 | - return count($this->workSheetCollection); | |
| 663 | + return count($this->_workSheetCollection); | |
| 671 | 664 | } |
| 672 | 665 | |
| 673 | 666 | /** |
| 674 | 667 | * Get active sheet index |
| @@ -676,9 +669,9 @@ | ||
| 676 | 669 | * @return int Active sheet index |
| 677 | 670 | */ |
| 678 | 671 | public function getActiveSheetIndex() |
| 679 | 672 | { |
| 680 | - return $this->activeSheetIndex; | |
| 673 | + return $this->_activeSheetIndex; | |
| 681 | 674 | } |
| 682 | 675 | |
| 683 | 676 | /** |
| 684 | 677 | * Set active sheet index |
| @@ -688,16 +681,16 @@ | ||
| 688 | 681 | * @return PHPExcel_Worksheet |
| 689 | 682 | */ |
| 690 | 683 | public function setActiveSheetIndex($pIndex = 0) |
| 691 | 684 | { |
| 692 | - $numSheets = count($this->workSheetCollection); | |
| 685 | + $numSheets = count($this->_workSheetCollection); | |
| 693 | 686 | |
| 694 | 687 | if ($pIndex > $numSheets - 1) { |
| 695 | 688 | throw new PHPExcel_Exception( |
| 696 | - "You tried to set a sheet active by the out of bounds index: {$pIndex}. The actual number of sheets is {$numSheets}." | |
| 689 | + "You tried to set a sheet active by the out of bounds index: {$pIndex}. The actual number of sheets is {$numSheets}." | |
| 697 | 690 | ); |
| 698 | 691 | } else { |
| 699 | - $this->activeSheetIndex = $pIndex; | |
| 692 | + $this->_activeSheetIndex = $pIndex; | |
| 700 | 693 | } |
| 701 | 694 | return $this->getActiveSheet(); |
| 702 | 695 | } |
| 703 | 696 | |
| @@ -741,16 +734,15 @@ | ||
| 741 | 734 | * @param int|null $iSheetIndex Index where sheet should go (0,1,..., or null for last) |
| 742 | 735 | * @throws PHPExcel_Exception |
| 743 | 736 | * @return PHPExcel_Worksheet |
| 744 | 737 | */ |
| 745 | - public function addExternalSheet(PHPExcel_Worksheet $pSheet, $iSheetIndex = null) | |
| 746 | - { | |
| 738 | + public function addExternalSheet(PHPExcel_Worksheet $pSheet, $iSheetIndex = null) { | |
| 747 | 739 | if ($this->sheetNameExists($pSheet->getTitle())) { |
| 748 | 740 | throw new PHPExcel_Exception("Workbook already contains a worksheet named '{$pSheet->getTitle()}'. Rename the external sheet first."); |
| 749 | 741 | } |
| 750 | 742 | |
| 751 | 743 | // count how many cellXfs there are in this workbook currently, we will need this below |
| 752 | - $countCellXfs = count($this->cellXfCollection); | |
| 744 | + $countCellXfs = count($this->_cellXfCollection); | |
| 753 | 745 | |
| 754 | 746 | // copy all the shared cellXfs from the external workbook and append them to the current |
| 755 | 747 | foreach ($pSheet->getParent()->getCellXfCollection() as $cellXf) { |
| 756 | 748 | $this->addCellXf(clone $cellXf); |
| @@ -761,9 +753,9 @@ | ||
| 761 | 753 | |
| 762 | 754 | // update the cellXfs |
| 763 | 755 | foreach ($pSheet->getCellCollection(false) as $cellID) { |
| 764 | 756 | $cell = $pSheet->getCell($cellID); |
| 765 | - $cell->setXfIndex($cell->getXfIndex() + $countCellXfs); | |
| 757 | + $cell->setXfIndex( $cell->getXfIndex() + $countCellXfs ); | |
| 766 | 758 | } |
| 767 | 759 | |
| 768 | 760 | return $this->addSheet($pSheet, $iSheetIndex); |
| 769 | 761 | } |
| @@ -772,11 +764,10 @@ | ||
| 772 | 764 | * Get named ranges |
| 773 | 765 | * |
| 774 | 766 | * @return PHPExcel_NamedRange[] |
| 775 | 767 | */ |
| 776 | - public function getNamedRanges() | |
| 777 | - { | |
| 778 | - return $this->namedRanges; | |
| 768 | + public function getNamedRanges() { | |
| 769 | + return $this->_namedRanges; | |
| 779 | 770 | } |
| 780 | 771 | |
| 781 | 772 | /** |
| 782 | 773 | * Add named range |
| @@ -781,18 +772,17 @@ | ||
| 781 | 772 | /** |
| 782 | 773 | * Add named range |
| 783 | 774 | * |
| 784 | 775 | * @param PHPExcel_NamedRange $namedRange |
| 785 | - * @return boolean | |
| 776 | + * @return PHPExcel | |
| 786 | 777 | */ |
| 787 | - public function addNamedRange(PHPExcel_NamedRange $namedRange) | |
| 788 | - { | |
| 778 | + public function addNamedRange(PHPExcel_NamedRange $namedRange) { | |
| 789 | 779 | if ($namedRange->getScope() == null) { |
| 790 | 780 | // global scope |
| 791 | - $this->namedRanges[$namedRange->getName()] = $namedRange; | |
| 781 | + $this->_namedRanges[$namedRange->getName()] = $namedRange; | |
| 792 | 782 | } else { |
| 793 | 783 | // local scope |
| 794 | - $this->namedRanges[$namedRange->getScope()->getTitle().'!'.$namedRange->getName()] = $namedRange; | |
| 784 | + $this->_namedRanges[$namedRange->getScope()->getTitle().'!'.$namedRange->getName()] = $namedRange; | |
| 795 | 785 | } |
| 796 | 786 | return true; |
| 797 | 787 | } |
| 798 | 788 | |
| @@ -802,21 +792,20 @@ | ||
| 802 | 792 | * @param string $namedRange |
| 803 | 793 | * @param PHPExcel_Worksheet|null $pSheet Scope. Use null for global scope |
| 804 | 794 | * @return PHPExcel_NamedRange|null |
| 805 | 795 | */ |
| 806 | - public function getNamedRange($namedRange, PHPExcel_Worksheet $pSheet = null) | |
| 807 | - { | |
| 796 | + public function getNamedRange($namedRange, PHPExcel_Worksheet $pSheet = null) { | |
| 808 | 797 | $returnValue = null; |
| 809 | 798 | |
| 810 | - if ($namedRange != '' && ($namedRange !== null)) { | |
| 799 | + if ($namedRange != '' && ($namedRange !== NULL)) { | |
| 811 | 800 | // first look for global defined name |
| 812 | - if (isset($this->namedRanges[$namedRange])) { | |
| 813 | - $returnValue = $this->namedRanges[$namedRange]; | |
| 801 | + if (isset($this->_namedRanges[$namedRange])) { | |
| 802 | + $returnValue = $this->_namedRanges[$namedRange]; | |
| 814 | 803 | } |
| 815 | 804 | |
| 816 | 805 | // then look for local defined name (has priority over global defined name if both names exist) |
| 817 | - if (($pSheet !== null) && isset($this->namedRanges[$pSheet->getTitle() . '!' . $namedRange])) { | |
| 818 | - $returnValue = $this->namedRanges[$pSheet->getTitle() . '!' . $namedRange]; | |
| 806 | + if (($pSheet !== NULL) && isset($this->_namedRanges[$pSheet->getTitle() . '!' . $namedRange])) { | |
| 807 | + $returnValue = $this->_namedRanges[$pSheet->getTitle() . '!' . $namedRange]; | |
| 819 | 808 | } |
| 820 | 809 | } |
| 821 | 810 | |
| 822 | 811 | return $returnValue; |
| @@ -828,17 +817,16 @@ | ||
| 828 | 817 | * @param string $namedRange |
| 829 | 818 | * @param PHPExcel_Worksheet|null $pSheet Scope: use null for global scope. |
| 830 | 819 | * @return PHPExcel |
| 831 | 820 | */ |
| 832 | - public function removeNamedRange($namedRange, PHPExcel_Worksheet $pSheet = null) | |
| 833 | - { | |
| 834 | - if ($pSheet === null) { | |
| 835 | - if (isset($this->namedRanges[$namedRange])) { | |
| 836 | - unset($this->namedRanges[$namedRange]); | |
| 821 | + public function removeNamedRange($namedRange, PHPExcel_Worksheet $pSheet = null) { | |
| 822 | + if ($pSheet === NULL) { | |
| 823 | + if (isset($this->_namedRanges[$namedRange])) { | |
| 824 | + unset($this->_namedRanges[$namedRange]); | |
| 837 | 825 | } |
| 838 | 826 | } else { |
| 839 | - if (isset($this->namedRanges[$pSheet->getTitle() . '!' . $namedRange])) { | |
| 840 | - unset($this->namedRanges[$pSheet->getTitle() . '!' . $namedRange]); | |
| 827 | + if (isset($this->_namedRanges[$pSheet->getTitle() . '!' . $namedRange])) { | |
| 828 | + unset($this->_namedRanges[$pSheet->getTitle() . '!' . $namedRange]); | |
| 841 | 829 | } |
| 842 | 830 | } |
| 843 | 831 | return $this; |
| 844 | 832 | } |
| @@ -847,10 +835,9 @@ | ||
| 847 | 835 | * Get worksheet iterator |
| 848 | 836 | * |
| 849 | 837 | * @return PHPExcel_WorksheetIterator |
| 850 | 838 | */ |
| 851 | - public function getWorksheetIterator() | |
| 852 | - { | |
| 839 | + public function getWorksheetIterator() { | |
| 853 | 840 | return new PHPExcel_WorksheetIterator($this); |
| 854 | 841 | } |
| 855 | 842 | |
| 856 | 843 | /** |
| @@ -857,16 +844,15 @@ | ||
| 857 | 844 | * Copy workbook (!= clone!) |
| 858 | 845 | * |
| 859 | 846 | * @return PHPExcel |
| 860 | 847 | */ |
| 861 | - public function copy() | |
| 862 | - { | |
| 848 | + public function copy() { | |
| 863 | 849 | $copied = clone $this; |
| 864 | 850 | |
| 865 | - $worksheetCount = count($this->workSheetCollection); | |
| 851 | + $worksheetCount = count($this->_workSheetCollection); | |
| 866 | 852 | for ($i = 0; $i < $worksheetCount; ++$i) { |
| 867 | - $this->workSheetCollection[$i] = $this->workSheetCollection[$i]->copy(); | |
| 868 | - $this->workSheetCollection[$i]->rebindParent($this); | |
| 853 | + $this->_workSheetCollection[$i] = $this->_workSheetCollection[$i]->copy(); | |
| 854 | + $this->_workSheetCollection[$i]->rebindParent($this); | |
| 869 | 855 | } |
| 870 | 856 | |
| 871 | 857 | return $copied; |
| 872 | 858 | } |
| @@ -873,11 +859,10 @@ | ||
| 873 | 859 | |
| 874 | 860 | /** |
| 875 | 861 | * Implement PHP __clone to create a deep clone, not just a shallow copy. |
| 876 | 862 | */ |
| 877 | - public function __clone() | |
| 878 | - { | |
| 879 | - foreach ($this as $key => $val) { | |
| 863 | + public function __clone() { | |
| 864 | + foreach($this as $key => $val) { | |
| 880 | 865 | if (is_object($val) || (is_array($val))) { |
| 881 | 866 | $this->{$key} = unserialize(serialize($val)); |
| 882 | 867 | } |
| 883 | 868 | } |
| @@ -889,9 +874,9 @@ | ||
| 889 | 874 | * @return PHPExcel_Style[] |
| 890 | 875 | */ |
| 891 | 876 | public function getCellXfCollection() |
| 892 | 877 | { |
| 893 | - return $this->cellXfCollection; | |
| 878 | + return $this->_cellXfCollection; | |
| 894 | 879 | } |
| 895 | 880 | |
| 896 | 881 | /** |
| 897 | 882 | * Get cellXf by index |
| @@ -900,9 +885,9 @@ | ||
| 900 | 885 | * @return PHPExcel_Style |
| 901 | 886 | */ |
| 902 | 887 | public function getCellXfByIndex($pIndex = 0) |
| 903 | 888 | { |
| 904 | - return $this->cellXfCollection[$pIndex]; | |
| 889 | + return $this->_cellXfCollection[$pIndex]; | |
| 905 | 890 | } |
| 906 | 891 | |
| 907 | 892 | /** |
| 908 | 893 | * Get cellXf by hash code |
| @@ -907,13 +892,13 @@ | ||
| 907 | 892 | /** |
| 908 | 893 | * Get cellXf by hash code |
| 909 | 894 | * |
| 910 | 895 | * @param string $pValue |
| 911 | - * @return PHPExcel_Style|boolean False if no match found | |
| 896 | + * @return PHPExcel_Style|false | |
| 912 | 897 | */ |
| 913 | 898 | public function getCellXfByHashCode($pValue = '') |
| 914 | 899 | { |
| 915 | - foreach ($this->cellXfCollection as $cellXf) { | |
| 900 | + foreach ($this->_cellXfCollection as $cellXf) { | |
| 916 | 901 | if ($cellXf->getHashCode() == $pValue) { |
| 917 | 902 | return $cellXf; |
| 918 | 903 | } |
| 919 | 904 | } |
| @@ -927,9 +912,9 @@ | ||
| 927 | 912 | * @return boolean |
| 928 | 913 | */ |
| 929 | 914 | public function cellXfExists($pCellStyle = null) |
| 930 | 915 | { |
| 931 | - return in_array($pCellStyle, $this->cellXfCollection, true); | |
| 916 | + return in_array($pCellStyle, $this->_cellXfCollection, true); | |
| 932 | 917 | } |
| 933 | 918 | |
| 934 | 919 | /** |
| 935 | 920 | * Get default style |
| @@ -938,10 +923,10 @@ | ||
| 938 | 923 | * @throws PHPExcel_Exception |
| 939 | 924 | */ |
| 940 | 925 | public function getDefaultStyle() |
| 941 | 926 | { |
| 942 | - if (isset($this->cellXfCollection[0])) { | |
| 943 | - return $this->cellXfCollection[0]; | |
| 927 | + if (isset($this->_cellXfCollection[0])) { | |
| 928 | + return $this->_cellXfCollection[0]; | |
| 944 | 929 | } |
| 945 | 930 | throw new PHPExcel_Exception('No default style found for this workbook'); |
| 946 | 931 | } |
| 947 | 932 | |
| @@ -951,35 +936,35 @@ | ||
| 951 | 936 | * @param PHPExcel_Style $style |
| 952 | 937 | */ |
| 953 | 938 | public function addCellXf(PHPExcel_Style $style) |
| 954 | 939 | { |
| 955 | - $this->cellXfCollection[] = $style; | |
| 956 | - $style->setIndex(count($this->cellXfCollection) - 1); | |
| 940 | + $this->_cellXfCollection[] = $style; | |
| 941 | + $style->setIndex(count($this->_cellXfCollection) - 1); | |
| 957 | 942 | } |
| 958 | 943 | |
| 959 | 944 | /** |
| 960 | 945 | * Remove cellXf by index. It is ensured that all cells get their xf index updated. |
| 961 | 946 | * |
| 962 | - * @param integer $pIndex Index to cellXf | |
| 947 | + * @param int $pIndex Index to cellXf | |
| 963 | 948 | * @throws PHPExcel_Exception |
| 964 | 949 | */ |
| 965 | 950 | public function removeCellXfByIndex($pIndex = 0) |
| 966 | 951 | { |
| 967 | - if ($pIndex > count($this->cellXfCollection) - 1) { | |
| 952 | + if ($pIndex > count($this->_cellXfCollection) - 1) { | |
| 968 | 953 | throw new PHPExcel_Exception("CellXf index is out of bounds."); |
| 969 | 954 | } else { |
| 970 | 955 | // first remove the cellXf |
| 971 | - array_splice($this->cellXfCollection, $pIndex, 1); | |
| 956 | + array_splice($this->_cellXfCollection, $pIndex, 1); | |
| 972 | 957 | |
| 973 | 958 | // then update cellXf indexes for cells |
| 974 | - foreach ($this->workSheetCollection as $worksheet) { | |
| 959 | + foreach ($this->_workSheetCollection as $worksheet) { | |
| 975 | 960 | foreach ($worksheet->getCellCollection(false) as $cellID) { |
| 976 | 961 | $cell = $worksheet->getCell($cellID); |
| 977 | 962 | $xfIndex = $cell->getXfIndex(); |
| 978 | - if ($xfIndex > $pIndex) { | |
| 963 | + if ($xfIndex > $pIndex ) { | |
| 979 | 964 | // decrease xf index by 1 |
| 980 | 965 | $cell->setXfIndex($xfIndex - 1); |
| 981 | - } elseif ($xfIndex == $pIndex) { | |
| 966 | + } else if ($xfIndex == $pIndex) { | |
| 982 | 967 | // set to default xf index 0 |
| 983 | 968 | $cell->setXfIndex(0); |
| 984 | 969 | } |
| 985 | 970 | } |
| @@ -993,9 +978,9 @@ | ||
| 993 | 978 | * @return PHPExcel_Style |
| 994 | 979 | */ |
| 995 | 980 | public function getCellXfSupervisor() |
| 996 | 981 | { |
| 997 | - return $this->cellXfSupervisor; | |
| 982 | + return $this->_cellXfSupervisor; | |
| 998 | 983 | } |
| 999 | 984 | |
| 1000 | 985 | /** |
| 1001 | 986 | * Get the workbook collection of cellStyleXfs |
| @@ -1003,20 +988,20 @@ | ||
| 1003 | 988 | * @return PHPExcel_Style[] |
| 1004 | 989 | */ |
| 1005 | 990 | public function getCellStyleXfCollection() |
| 1006 | 991 | { |
| 1007 | - return $this->cellStyleXfCollection; | |
| 992 | + return $this->_cellStyleXfCollection; | |
| 1008 | 993 | } |
| 1009 | 994 | |
| 1010 | 995 | /** |
| 1011 | 996 | * Get cellStyleXf by index |
| 1012 | 997 | * |
| 1013 | - * @param integer $pIndex Index to cellXf | |
| 998 | + * @param int $pIndex | |
| 1014 | 999 | * @return PHPExcel_Style |
| 1015 | 1000 | */ |
| 1016 | 1001 | public function getCellStyleXfByIndex($pIndex = 0) |
| 1017 | 1002 | { |
| 1018 | - return $this->cellStyleXfCollection[$pIndex]; | |
| 1003 | + return $this->_cellStyleXfCollection[$pIndex]; | |
| 1019 | 1004 | } |
| 1020 | 1005 | |
| 1021 | 1006 | /** |
| 1022 | 1007 | * Get cellStyleXf by hash code |
| @@ -1021,13 +1006,13 @@ | ||
| 1021 | 1006 | /** |
| 1022 | 1007 | * Get cellStyleXf by hash code |
| 1023 | 1008 | * |
| 1024 | 1009 | * @param string $pValue |
| 1025 | - * @return PHPExcel_Style|boolean False if no match found | |
| 1010 | + * @return PHPExcel_Style|false | |
| 1026 | 1011 | */ |
| 1027 | 1012 | public function getCellStyleXfByHashCode($pValue = '') |
| 1028 | 1013 | { |
| 1029 | - foreach ($this->cellStyleXfCollection as $cellStyleXf) { | |
| 1014 | + foreach ($this->_cellStyleXfCollection as $cellStyleXf) { | |
| 1030 | 1015 | if ($cellStyleXf->getHashCode() == $pValue) { |
| 1031 | 1016 | return $cellStyleXf; |
| 1032 | 1017 | } |
| 1033 | 1018 | } |
| @@ -1040,24 +1025,24 @@ | ||
| 1040 | 1025 | * @param PHPExcel_Style $pStyle |
| 1041 | 1026 | */ |
| 1042 | 1027 | public function addCellStyleXf(PHPExcel_Style $pStyle) |
| 1043 | 1028 | { |
| 1044 | - $this->cellStyleXfCollection[] = $pStyle; | |
| 1045 | - $pStyle->setIndex(count($this->cellStyleXfCollection) - 1); | |
| 1029 | + $this->_cellStyleXfCollection[] = $pStyle; | |
| 1030 | + $pStyle->setIndex(count($this->_cellStyleXfCollection) - 1); | |
| 1046 | 1031 | } |
| 1047 | 1032 | |
| 1048 | 1033 | /** |
| 1049 | 1034 | * Remove cellStyleXf by index |
| 1050 | 1035 | * |
| 1051 | - * @param integer $pIndex Index to cellXf | |
| 1036 | + * @param int $pIndex | |
| 1052 | 1037 | * @throws PHPExcel_Exception |
| 1053 | 1038 | */ |
| 1054 | 1039 | public function removeCellStyleXfByIndex($pIndex = 0) |
| 1055 | 1040 | { |
| 1056 | - if ($pIndex > count($this->cellStyleXfCollection) - 1) { | |
| 1041 | + if ($pIndex > count($this->_cellStyleXfCollection) - 1) { | |
| 1057 | 1042 | throw new PHPExcel_Exception("CellStyleXf index is out of bounds."); |
| 1058 | 1043 | } else { |
| 1059 | - array_splice($this->cellStyleXfCollection, $pIndex, 1); | |
| 1044 | + array_splice($this->_cellStyleXfCollection, $pIndex, 1); | |
| 1060 | 1045 | } |
| 1061 | 1046 | } |
| 1062 | 1047 | |
| 1063 | 1048 | /** |
| @@ -1067,13 +1052,14 @@ | ||
| 1067 | 1052 | public function garbageCollect() |
| 1068 | 1053 | { |
| 1069 | 1054 | // how many references are there to each cellXf ? |
| 1070 | 1055 | $countReferencesCellXf = array(); |
| 1071 | - foreach ($this->cellXfCollection as $index => $cellXf) { | |
| 1056 | + foreach ($this->_cellXfCollection as $index => $cellXf) { | |
| 1072 | 1057 | $countReferencesCellXf[$index] = 0; |
| 1073 | 1058 | } |
| 1074 | 1059 | |
| 1075 | 1060 | foreach ($this->getWorksheetIterator() as $sheet) { |
| 1061 | + | |
| 1076 | 1062 | // from cells |
| 1077 | 1063 | foreach ($sheet->getCellCollection(false) as $cellID) { |
| 1078 | 1064 | $cell = $sheet->getCell($cellID); |
| 1079 | 1065 | ++$countReferencesCellXf[$cell->getXfIndex()]; |
| @@ -1094,50 +1080,50 @@ | ||
| 1094 | 1080 | |
| 1095 | 1081 | // remove cellXfs without references and create mapping so we can update xfIndex |
| 1096 | 1082 | // for all cells and columns |
| 1097 | 1083 | $countNeededCellXfs = 0; |
| 1098 | - $map = array(); | |
| 1099 | - foreach ($this->cellXfCollection as $index => $cellXf) { | |
| 1084 | + foreach ($this->_cellXfCollection as $index => $cellXf) { | |
| 1100 | 1085 | if ($countReferencesCellXf[$index] > 0 || $index == 0) { // we must never remove the first cellXf |
| 1101 | 1086 | ++$countNeededCellXfs; |
| 1102 | 1087 | } else { |
| 1103 | - unset($this->cellXfCollection[$index]); | |
| 1088 | + unset($this->_cellXfCollection[$index]); | |
| 1104 | 1089 | } |
| 1105 | 1090 | $map[$index] = $countNeededCellXfs - 1; |
| 1106 | 1091 | } |
| 1107 | - $this->cellXfCollection = array_values($this->cellXfCollection); | |
| 1092 | + $this->_cellXfCollection = array_values($this->_cellXfCollection); | |
| 1108 | 1093 | |
| 1109 | 1094 | // update the index for all cellXfs |
| 1110 | - foreach ($this->cellXfCollection as $i => $cellXf) { | |
| 1095 | + foreach ($this->_cellXfCollection as $i => $cellXf) { | |
| 1111 | 1096 | $cellXf->setIndex($i); |
| 1112 | 1097 | } |
| 1113 | 1098 | |
| 1114 | 1099 | // make sure there is always at least one cellXf (there should be) |
| 1115 | - if (empty($this->cellXfCollection)) { | |
| 1116 | - $this->cellXfCollection[] = new PHPExcel_Style(); | |
| 1100 | + if (empty($this->_cellXfCollection)) { | |
| 1101 | + $this->_cellXfCollection[] = new PHPExcel_Style(); | |
| 1117 | 1102 | } |
| 1118 | 1103 | |
| 1119 | 1104 | // update the xfIndex for all cells, row dimensions, column dimensions |
| 1120 | 1105 | foreach ($this->getWorksheetIterator() as $sheet) { |
| 1106 | + | |
| 1121 | 1107 | // for all cells |
| 1122 | 1108 | foreach ($sheet->getCellCollection(false) as $cellID) { |
| 1123 | 1109 | $cell = $sheet->getCell($cellID); |
| 1124 | - $cell->setXfIndex($map[$cell->getXfIndex()]); | |
| 1110 | + $cell->setXfIndex( $map[$cell->getXfIndex()] ); | |
| 1125 | 1111 | } |
| 1126 | 1112 | |
| 1127 | 1113 | // for all row dimensions |
| 1128 | 1114 | foreach ($sheet->getRowDimensions() as $rowDimension) { |
| 1129 | 1115 | if ($rowDimension->getXfIndex() !== null) { |
| 1130 | - $rowDimension->setXfIndex($map[$rowDimension->getXfIndex()]); | |
| 1116 | + $rowDimension->setXfIndex( $map[$rowDimension->getXfIndex()] ); | |
| 1131 | 1117 | } |
| 1132 | 1118 | } |
| 1133 | 1119 | |
| 1134 | 1120 | // for all column dimensions |
| 1135 | 1121 | foreach ($sheet->getColumnDimensions() as $columnDimension) { |
| 1136 | - $columnDimension->setXfIndex($map[$columnDimension->getXfIndex()]); | |
| 1122 | + $columnDimension->setXfIndex( $map[$columnDimension->getXfIndex()] ); | |
| 1137 | 1123 | } |
| 1138 | 1124 | |
| 1139 | - // also do garbage collection for all the sheets | |
| 1125 | + // also do garbage collection for all the sheets | |
| 1140 | 1126 | $sheet->garbageCollect(); |
| 1141 | 1127 | } |
| 1142 | 1128 | } |
| 1143 | 1129 | |
| @@ -1145,9 +1131,9 @@ | ||
| 1145 | 1131 | * Return the unique ID value assigned to this spreadsheet workbook |
| 1146 | 1132 | * |
| 1147 | 1133 | * @return string |
| 1148 | 1134 | */ |
| 1149 | - public function getID() | |
| 1150 | - { | |
| 1151 | - return $this->uniqueID; | |
| 1135 | + public function getID() { | |
| 1136 | + return $this->_uniqueID; | |
| 1152 | 1137 | } |
| 1138 | + | |
| 1153 | 1139 | } |