← All changes
|
vendor/phpoffice/phpexcel/Classes/PHPExcel/Worksheet.php
+483
-506
3.1.0
→
3.0.10
View file →
| @@ -1,10 +1,9 @@ | ||
| 1 | 1 | <?php |
| 2 | - | |
| 3 | 2 | /** |
| 4 | - * PHPExcel_Worksheet | |
| 3 | + * PHPExcel | |
| 5 | 4 | * |
| 6 | - * Copyright (c) 2006 - 2015 PHPExcel | |
| 5 | + * Copyright (c) 2006 - 2014 PHPExcel | |
| 7 | 6 | * |
| 8 | 7 | * This library is free software; you can redistribute it and/or |
| 9 | 8 | * modify it under the terms of the GNU Lesser General Public |
| 10 | 9 | * License as published by the Free Software Foundation; either |
| @@ -20,12 +19,21 @@ | ||
| 20 | 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
| 21 | 20 | * |
| 22 | 21 | * @category PHPExcel |
| 23 | 22 | * @package PHPExcel_Worksheet |
| 24 | - * @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel) | |
| 23 | + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) | |
| 25 | 24 | * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL |
| 26 | 25 | * @version ##VERSION##, ##DATE## |
| 27 | 26 | */ |
| 27 | + | |
| 28 | + | |
| 29 | +/** | |
| 30 | + * PHPExcel_Worksheet | |
| 31 | + * | |
| 32 | + * @category PHPExcel | |
| 33 | + * @package PHPExcel_Worksheet | |
| 34 | + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) | |
| 35 | + */ | |
| 28 | 36 | class PHPExcel_Worksheet implements PHPExcel_IComparable |
| 29 | 37 | { |
| 30 | 38 | /* Break types */ |
| 31 | 39 | const BREAK_NONE = 0; |
| @@ -41,9 +49,9 @@ | ||
| 41 | 49 | * Invalid characters in sheet title |
| 42 | 50 | * |
| 43 | 51 | * @var array |
| 44 | 52 | */ |
| 45 | - private static $invalidCharacters = array('*', ':', '/', '\\', '?', '[', ']'); | |
| 53 | + private static $_invalidCharacters = array('*', ':', '/', '\\', '?', '[', ']'); | |
| 46 | 54 | |
| 47 | 55 | /** |
| 48 | 56 | * Parent spreadsheet |
| 49 | 57 | * |
| @@ -48,9 +56,9 @@ | ||
| 48 | 56 | * Parent spreadsheet |
| 49 | 57 | * |
| 50 | 58 | * @var PHPExcel |
| 51 | 59 | */ |
| 52 | - private $parent; | |
| 60 | + private $_parent; | |
| 53 | 61 | |
| 54 | 62 | /** |
| 55 | 63 | * Cacheable collection of cells |
| 56 | 64 | * |
| @@ -55,9 +63,9 @@ | ||
| 55 | 63 | * Cacheable collection of cells |
| 56 | 64 | * |
| 57 | 65 | * @var PHPExcel_CachedObjectStorage_xxx |
| 58 | 66 | */ |
| 59 | - private $cellCollection; | |
| 67 | + private $_cellCollection = null; | |
| 60 | 68 | |
| 61 | 69 | /** |
| 62 | 70 | * Collection of row dimensions |
| 63 | 71 | * |
| @@ -62,9 +70,9 @@ | ||
| 62 | 70 | * Collection of row dimensions |
| 63 | 71 | * |
| 64 | 72 | * @var PHPExcel_Worksheet_RowDimension[] |
| 65 | 73 | */ |
| 66 | - private $rowDimensions = array(); | |
| 74 | + private $_rowDimensions = array(); | |
| 67 | 75 | |
| 68 | 76 | /** |
| 69 | 77 | * Default row dimension |
| 70 | 78 | * |
| @@ -69,9 +77,9 @@ | ||
| 69 | 77 | * Default row dimension |
| 70 | 78 | * |
| 71 | 79 | * @var PHPExcel_Worksheet_RowDimension |
| 72 | 80 | */ |
| 73 | - private $defaultRowDimension; | |
| 81 | + private $_defaultRowDimension = null; | |
| 74 | 82 | |
| 75 | 83 | /** |
| 76 | 84 | * Collection of column dimensions |
| 77 | 85 | * |
| @@ -76,9 +84,9 @@ | ||
| 76 | 84 | * Collection of column dimensions |
| 77 | 85 | * |
| 78 | 86 | * @var PHPExcel_Worksheet_ColumnDimension[] |
| 79 | 87 | */ |
| 80 | - private $columnDimensions = array(); | |
| 88 | + private $_columnDimensions = array(); | |
| 81 | 89 | |
| 82 | 90 | /** |
| 83 | 91 | * Default column dimension |
| 84 | 92 | * |
| @@ -83,9 +91,9 @@ | ||
| 83 | 91 | * Default column dimension |
| 84 | 92 | * |
| 85 | 93 | * @var PHPExcel_Worksheet_ColumnDimension |
| 86 | 94 | */ |
| 87 | - private $defaultColumnDimension = null; | |
| 95 | + private $_defaultColumnDimension = null; | |
| 88 | 96 | |
| 89 | 97 | /** |
| 90 | 98 | * Collection of drawings |
| 91 | 99 | * |
| @@ -90,9 +98,9 @@ | ||
| 90 | 98 | * Collection of drawings |
| 91 | 99 | * |
| 92 | 100 | * @var PHPExcel_Worksheet_BaseDrawing[] |
| 93 | 101 | */ |
| 94 | - private $drawingCollection = null; | |
| 102 | + private $_drawingCollection = null; | |
| 95 | 103 | |
| 96 | 104 | /** |
| 97 | 105 | * Collection of Chart objects |
| 98 | 106 | * |
| @@ -97,9 +105,9 @@ | ||
| 97 | 105 | * Collection of Chart objects |
| 98 | 106 | * |
| 99 | 107 | * @var PHPExcel_Chart[] |
| 100 | 108 | */ |
| 101 | - private $chartCollection = array(); | |
| 109 | + private $_chartCollection = array(); | |
| 102 | 110 | |
| 103 | 111 | /** |
| 104 | 112 | * Worksheet title |
| 105 | 113 | * |
| @@ -104,9 +112,9 @@ | ||
| 104 | 112 | * Worksheet title |
| 105 | 113 | * |
| 106 | 114 | * @var string |
| 107 | 115 | */ |
| 108 | - private $title; | |
| 116 | + private $_title; | |
| 109 | 117 | |
| 110 | 118 | /** |
| 111 | 119 | * Sheet state |
| 112 | 120 | * |
| @@ -111,9 +119,9 @@ | ||
| 111 | 119 | * Sheet state |
| 112 | 120 | * |
| 113 | 121 | * @var string |
| 114 | 122 | */ |
| 115 | - private $sheetState; | |
| 123 | + private $_sheetState; | |
| 116 | 124 | |
| 117 | 125 | /** |
| 118 | 126 | * Page setup |
| 119 | 127 | * |
| @@ -118,9 +126,9 @@ | ||
| 118 | 126 | * Page setup |
| 119 | 127 | * |
| 120 | 128 | * @var PHPExcel_Worksheet_PageSetup |
| 121 | 129 | */ |
| 122 | - private $pageSetup; | |
| 130 | + private $_pageSetup; | |
| 123 | 131 | |
| 124 | 132 | /** |
| 125 | 133 | * Page margins |
| 126 | 134 | * |
| @@ -125,9 +133,9 @@ | ||
| 125 | 133 | * Page margins |
| 126 | 134 | * |
| 127 | 135 | * @var PHPExcel_Worksheet_PageMargins |
| 128 | 136 | */ |
| 129 | - private $pageMargins; | |
| 137 | + private $_pageMargins; | |
| 130 | 138 | |
| 131 | 139 | /** |
| 132 | 140 | * Page header/footer |
| 133 | 141 | * |
| @@ -132,9 +140,9 @@ | ||
| 132 | 140 | * Page header/footer |
| 133 | 141 | * |
| 134 | 142 | * @var PHPExcel_Worksheet_HeaderFooter |
| 135 | 143 | */ |
| 136 | - private $headerFooter; | |
| 144 | + private $_headerFooter; | |
| 137 | 145 | |
| 138 | 146 | /** |
| 139 | 147 | * Sheet view |
| 140 | 148 | * |
| @@ -139,9 +147,9 @@ | ||
| 139 | 147 | * Sheet view |
| 140 | 148 | * |
| 141 | 149 | * @var PHPExcel_Worksheet_SheetView |
| 142 | 150 | */ |
| 143 | - private $sheetView; | |
| 151 | + private $_sheetView; | |
| 144 | 152 | |
| 145 | 153 | /** |
| 146 | 154 | * Protection |
| 147 | 155 | * |
| @@ -146,9 +154,9 @@ | ||
| 146 | 154 | * Protection |
| 147 | 155 | * |
| 148 | 156 | * @var PHPExcel_Worksheet_Protection |
| 149 | 157 | */ |
| 150 | - private $protection; | |
| 158 | + private $_protection; | |
| 151 | 159 | |
| 152 | 160 | /** |
| 153 | 161 | * Collection of styles |
| 154 | 162 | * |
| @@ -153,9 +161,9 @@ | ||
| 153 | 161 | * Collection of styles |
| 154 | 162 | * |
| 155 | 163 | * @var PHPExcel_Style[] |
| 156 | 164 | */ |
| 157 | - private $styles = array(); | |
| 165 | + private $_styles = array(); | |
| 158 | 166 | |
| 159 | 167 | /** |
| 160 | 168 | * Conditional styles. Indexed by cell coordinate, e.g. 'A1' |
| 161 | 169 | * |
| @@ -160,9 +168,9 @@ | ||
| 160 | 168 | * Conditional styles. Indexed by cell coordinate, e.g. 'A1' |
| 161 | 169 | * |
| 162 | 170 | * @var array |
| 163 | 171 | */ |
| 164 | - private $conditionalStylesCollection = array(); | |
| 172 | + private $_conditionalStylesCollection = array(); | |
| 165 | 173 | |
| 166 | 174 | /** |
| 167 | 175 | * Is the current cell collection sorted already? |
| 168 | 176 | * |
| @@ -167,9 +175,9 @@ | ||
| 167 | 175 | * Is the current cell collection sorted already? |
| 168 | 176 | * |
| 169 | 177 | * @var boolean |
| 170 | 178 | */ |
| 171 | - private $cellCollectionIsSorted = false; | |
| 179 | + private $_cellCollectionIsSorted = false; | |
| 172 | 180 | |
| 173 | 181 | /** |
| 174 | 182 | * Collection of breaks |
| 175 | 183 | * |
| @@ -174,9 +182,9 @@ | ||
| 174 | 182 | * Collection of breaks |
| 175 | 183 | * |
| 176 | 184 | * @var array |
| 177 | 185 | */ |
| 178 | - private $breaks = array(); | |
| 186 | + private $_breaks = array(); | |
| 179 | 187 | |
| 180 | 188 | /** |
| 181 | 189 | * Collection of merged cell ranges |
| 182 | 190 | * |
| @@ -181,9 +189,9 @@ | ||
| 181 | 189 | * Collection of merged cell ranges |
| 182 | 190 | * |
| 183 | 191 | * @var array |
| 184 | 192 | */ |
| 185 | - private $mergeCells = array(); | |
| 193 | + private $_mergeCells = array(); | |
| 186 | 194 | |
| 187 | 195 | /** |
| 188 | 196 | * Collection of protected cell ranges |
| 189 | 197 | * |
| @@ -188,9 +196,9 @@ | ||
| 188 | 196 | * Collection of protected cell ranges |
| 189 | 197 | * |
| 190 | 198 | * @var array |
| 191 | 199 | */ |
| 192 | - private $protectedCells = array(); | |
| 200 | + private $_protectedCells = array(); | |
| 193 | 201 | |
| 194 | 202 | /** |
| 195 | 203 | * Autofilter Range and selection |
| 196 | 204 | * |
| @@ -195,9 +203,9 @@ | ||
| 195 | 203 | * Autofilter Range and selection |
| 196 | 204 | * |
| 197 | 205 | * @var PHPExcel_Worksheet_AutoFilter |
| 198 | 206 | */ |
| 199 | - private $autoFilter; | |
| 207 | + private $_autoFilter = NULL; | |
| 200 | 208 | |
| 201 | 209 | /** |
| 202 | 210 | * Freeze pane |
| 203 | 211 | * |
| @@ -202,9 +210,9 @@ | ||
| 202 | 210 | * Freeze pane |
| 203 | 211 | * |
| 204 | 212 | * @var string |
| 205 | 213 | */ |
| 206 | - private $freezePane = ''; | |
| 214 | + private $_freezePane = ''; | |
| 207 | 215 | |
| 208 | 216 | /** |
| 209 | 217 | * Show gridlines? |
| 210 | 218 | * |
| @@ -209,9 +217,9 @@ | ||
| 209 | 217 | * Show gridlines? |
| 210 | 218 | * |
| 211 | 219 | * @var boolean |
| 212 | 220 | */ |
| 213 | - private $showGridlines = true; | |
| 221 | + private $_showGridlines = true; | |
| 214 | 222 | |
| 215 | 223 | /** |
| 216 | 224 | * Print gridlines? |
| 217 | 225 | * |
| @@ -216,9 +224,9 @@ | ||
| 216 | 224 | * Print gridlines? |
| 217 | 225 | * |
| 218 | 226 | * @var boolean |
| 219 | 227 | */ |
| 220 | - private $printGridlines = false; | |
| 228 | + private $_printGridlines = false; | |
| 221 | 229 | |
| 222 | 230 | /** |
| 223 | 231 | * Show row and column headers? |
| 224 | 232 | * |
| @@ -223,9 +231,9 @@ | ||
| 223 | 231 | * Show row and column headers? |
| 224 | 232 | * |
| 225 | 233 | * @var boolean |
| 226 | 234 | */ |
| 227 | - private $showRowColHeaders = true; | |
| 235 | + private $_showRowColHeaders = true; | |
| 228 | 236 | |
| 229 | 237 | /** |
| 230 | 238 | * Show summary below? (Row/Column outline) |
| 231 | 239 | * |
| @@ -230,9 +238,9 @@ | ||
| 230 | 238 | * Show summary below? (Row/Column outline) |
| 231 | 239 | * |
| 232 | 240 | * @var boolean |
| 233 | 241 | */ |
| 234 | - private $showSummaryBelow = true; | |
| 242 | + private $_showSummaryBelow = true; | |
| 235 | 243 | |
| 236 | 244 | /** |
| 237 | 245 | * Show summary right? (Row/Column outline) |
| 238 | 246 | * |
| @@ -237,9 +245,9 @@ | ||
| 237 | 245 | * Show summary right? (Row/Column outline) |
| 238 | 246 | * |
| 239 | 247 | * @var boolean |
| 240 | 248 | */ |
| 241 | - private $showSummaryRight = true; | |
| 249 | + private $_showSummaryRight = true; | |
| 242 | 250 | |
| 243 | 251 | /** |
| 244 | 252 | * Collection of comments |
| 245 | 253 | * |
| @@ -244,9 +252,9 @@ | ||
| 244 | 252 | * Collection of comments |
| 245 | 253 | * |
| 246 | 254 | * @var PHPExcel_Comment[] |
| 247 | 255 | */ |
| 248 | - private $comments = array(); | |
| 256 | + private $_comments = array(); | |
| 249 | 257 | |
| 250 | 258 | /** |
| 251 | 259 | * Active cell. (Only one!) |
| 252 | 260 | * |
| @@ -251,9 +259,9 @@ | ||
| 251 | 259 | * Active cell. (Only one!) |
| 252 | 260 | * |
| 253 | 261 | * @var string |
| 254 | 262 | */ |
| 255 | - private $activeCell = 'A1'; | |
| 263 | + private $_activeCell = 'A1'; | |
| 256 | 264 | |
| 257 | 265 | /** |
| 258 | 266 | * Selected cells |
| 259 | 267 | * |
| @@ -258,9 +266,9 @@ | ||
| 258 | 266 | * Selected cells |
| 259 | 267 | * |
| 260 | 268 | * @var string |
| 261 | 269 | */ |
| 262 | - private $selectedCells = 'A1'; | |
| 270 | + private $_selectedCells = 'A1'; | |
| 263 | 271 | |
| 264 | 272 | /** |
| 265 | 273 | * Cached highest column |
| 266 | 274 | * |
| @@ -265,9 +273,9 @@ | ||
| 265 | 273 | * Cached highest column |
| 266 | 274 | * |
| 267 | 275 | * @var string |
| 268 | 276 | */ |
| 269 | - private $cachedHighestColumn = 'A'; | |
| 277 | + private $_cachedHighestColumn = 'A'; | |
| 270 | 278 | |
| 271 | 279 | /** |
| 272 | 280 | * Cached highest row |
| 273 | 281 | * |
| @@ -272,9 +280,9 @@ | ||
| 272 | 280 | * Cached highest row |
| 273 | 281 | * |
| 274 | 282 | * @var int |
| 275 | 283 | */ |
| 276 | - private $cachedHighestRow = 1; | |
| 284 | + private $_cachedHighestRow = 1; | |
| 277 | 285 | |
| 278 | 286 | /** |
| 279 | 287 | * Right-to-left? |
| 280 | 288 | * |
| @@ -279,9 +287,9 @@ | ||
| 279 | 287 | * Right-to-left? |
| 280 | 288 | * |
| 281 | 289 | * @var boolean |
| 282 | 290 | */ |
| 283 | - private $rightToLeft = false; | |
| 291 | + private $_rightToLeft = false; | |
| 284 | 292 | |
| 285 | 293 | /** |
| 286 | 294 | * Hyperlinks. Indexed by cell coordinate, e.g. 'A1' |
| 287 | 295 | * |
| @@ -286,9 +294,9 @@ | ||
| 286 | 294 | * Hyperlinks. Indexed by cell coordinate, e.g. 'A1' |
| 287 | 295 | * |
| 288 | 296 | * @var array |
| 289 | 297 | */ |
| 290 | - private $hyperlinkCollection = array(); | |
| 298 | + private $_hyperlinkCollection = array(); | |
| 291 | 299 | |
| 292 | 300 | /** |
| 293 | 301 | * Data validation objects. Indexed by cell coordinate, e.g. 'A1' |
| 294 | 302 | * |
| @@ -293,9 +301,9 @@ | ||
| 293 | 301 | * Data validation objects. Indexed by cell coordinate, e.g. 'A1' |
| 294 | 302 | * |
| 295 | 303 | * @var array |
| 296 | 304 | */ |
| 297 | - private $dataValidationCollection = array(); | |
| 305 | + private $_dataValidationCollection = array(); | |
| 298 | 306 | |
| 299 | 307 | /** |
| 300 | 308 | * Tab color |
| 301 | 309 | * |
| @@ -300,9 +308,9 @@ | ||
| 300 | 308 | * Tab color |
| 301 | 309 | * |
| 302 | 310 | * @var PHPExcel_Style_Color |
| 303 | 311 | */ |
| 304 | - private $tabColor; | |
| 312 | + private $_tabColor; | |
| 305 | 313 | |
| 306 | 314 | /** |
| 307 | 315 | * Dirty flag |
| 308 | 316 | * |
| @@ -307,9 +315,9 @@ | ||
| 307 | 315 | * Dirty flag |
| 308 | 316 | * |
| 309 | 317 | * @var boolean |
| 310 | 318 | */ |
| 311 | - private $dirty = true; | |
| 319 | + private $_dirty = true; | |
| 312 | 320 | |
| 313 | 321 | /** |
| 314 | 322 | * Hash |
| 315 | 323 | * |
| @@ -314,9 +322,9 @@ | ||
| 314 | 322 | * Hash |
| 315 | 323 | * |
| 316 | 324 | * @var string |
| 317 | 325 | */ |
| 318 | - private $hash; | |
| 326 | + private $_hash = null; | |
| 319 | 327 | |
| 320 | 328 | /** |
| 321 | 329 | * CodeName |
| 322 | 330 | * |
| @@ -321,11 +329,11 @@ | ||
| 321 | 329 | * CodeName |
| 322 | 330 | * |
| 323 | 331 | * @var string |
| 324 | 332 | */ |
| 325 | - private $codeName = null; | |
| 333 | + private $_codeName = null; | |
| 326 | 334 | |
| 327 | - /** | |
| 335 | + /** | |
| 328 | 336 | * Create a new worksheet |
| 329 | 337 | * |
| 330 | 338 | * @param PHPExcel $pParent |
| 331 | 339 | * @param string $pTitle |
| @@ -332,34 +340,44 @@ | ||
| 332 | 340 | */ |
| 333 | 341 | public function __construct(PHPExcel $pParent = null, $pTitle = 'Worksheet') |
| 334 | 342 | { |
| 335 | 343 | // Set parent and title |
| 336 | - $this->parent = $pParent; | |
| 337 | - $this->setTitle($pTitle, false); | |
| 344 | + $this->_parent = $pParent; | |
| 345 | + $this->setTitle($pTitle, FALSE); | |
| 338 | 346 | // setTitle can change $pTitle |
| 339 | - $this->setCodeName($this->getTitle()); | |
| 347 | + $this->setCodeName($this->getTitle()); | |
| 340 | 348 | $this->setSheetState(PHPExcel_Worksheet::SHEETSTATE_VISIBLE); |
| 341 | 349 | |
| 342 | - $this->cellCollection = PHPExcel_CachedObjectStorageFactory::getInstance($this); | |
| 350 | + $this->_cellCollection = PHPExcel_CachedObjectStorageFactory::getInstance($this); | |
| 351 | + | |
| 343 | 352 | // Set page setup |
| 344 | - $this->pageSetup = new PHPExcel_Worksheet_PageSetup(); | |
| 353 | + $this->_pageSetup = new PHPExcel_Worksheet_PageSetup(); | |
| 354 | + | |
| 345 | 355 | // Set page margins |
| 346 | - $this->pageMargins = new PHPExcel_Worksheet_PageMargins(); | |
| 356 | + $this->_pageMargins = new PHPExcel_Worksheet_PageMargins(); | |
| 357 | + | |
| 347 | 358 | // Set page header/footer |
| 348 | - $this->headerFooter = new PHPExcel_Worksheet_HeaderFooter(); | |
| 359 | + $this->_headerFooter = new PHPExcel_Worksheet_HeaderFooter(); | |
| 360 | + | |
| 349 | 361 | // Set sheet view |
| 350 | - $this->sheetView = new PHPExcel_Worksheet_SheetView(); | |
| 362 | + $this->_sheetView = new PHPExcel_Worksheet_SheetView(); | |
| 363 | + | |
| 351 | 364 | // Drawing collection |
| 352 | - $this->drawingCollection = new ArrayObject(); | |
| 365 | + $this->_drawingCollection = new ArrayObject(); | |
| 366 | + | |
| 353 | 367 | // Chart collection |
| 354 | - $this->chartCollection = new ArrayObject(); | |
| 368 | + $this->_chartCollection = new ArrayObject(); | |
| 369 | + | |
| 355 | 370 | // Protection |
| 356 | - $this->protection = new PHPExcel_Worksheet_Protection(); | |
| 371 | + $this->_protection = new PHPExcel_Worksheet_Protection(); | |
| 372 | + | |
| 357 | 373 | // Default row dimension |
| 358 | - $this->defaultRowDimension = new PHPExcel_Worksheet_RowDimension(null); | |
| 374 | + $this->_defaultRowDimension = new PHPExcel_Worksheet_RowDimension(NULL); | |
| 375 | + | |
| 359 | 376 | // Default column dimension |
| 360 | - $this->defaultColumnDimension = new PHPExcel_Worksheet_ColumnDimension(null); | |
| 361 | - $this->autoFilter = new PHPExcel_Worksheet_AutoFilter(null, $this); | |
| 377 | + $this->_defaultColumnDimension = new PHPExcel_Worksheet_ColumnDimension(NULL); | |
| 378 | + | |
| 379 | + $this->_autoFilter = new PHPExcel_Worksheet_AutoFilter(NULL, $this); | |
| 362 | 380 | } |
| 363 | 381 | |
| 364 | 382 | |
| 365 | 383 | /** |
| @@ -366,16 +384,15 @@ | ||
| 366 | 384 | * Disconnect all cells from this PHPExcel_Worksheet object, |
| 367 | 385 | * typically so that the worksheet object can be unset |
| 368 | 386 | * |
| 369 | 387 | */ |
| 370 | - public function disconnectCells() | |
| 371 | - { | |
| 372 | - if ($this->cellCollection !== null) { | |
| 373 | - $this->cellCollection->unsetWorksheetCells(); | |
| 374 | - $this->cellCollection = null; | |
| 375 | - } | |
| 388 | + public function disconnectCells() { | |
| 389 | + if ( $this->_cellCollection !== NULL){ | |
| 390 | + $this->_cellCollection->unsetWorksheetCells(); | |
| 391 | + $this->_cellCollection = NULL; | |
| 392 | + } | |
| 376 | 393 | // detach ourself from the workbook, so that it can then delete this worksheet successfully |
| 377 | - $this->parent = null; | |
| 394 | + $this->_parent = null; | |
| 378 | 395 | } |
| 379 | 396 | |
| 380 | 397 | /** |
| 381 | 398 | * Code to execute when this worksheet is unset() |
| @@ -380,14 +397,14 @@ | ||
| 380 | 397 | /** |
| 381 | 398 | * Code to execute when this worksheet is unset() |
| 382 | 399 | * |
| 383 | 400 | */ |
| 384 | - public function __destruct() | |
| 385 | - { | |
| 386 | - PHPExcel_Calculation::getInstance($this->parent)->clearCalculationCacheForWorksheet($this->title); | |
| 401 | + function __destruct() { | |
| 402 | + PHPExcel_Calculation::getInstance($this->_parent) | |
| 403 | + ->clearCalculationCacheForWorksheet($this->_title); | |
| 387 | 404 | |
| 388 | - $this->disconnectCells(); | |
| 389 | - } | |
| 405 | + $this->disconnectCells(); | |
| 406 | + } | |
| 390 | 407 | |
| 391 | 408 | /** |
| 392 | 409 | * Return the cache controller for the cell collection |
| 393 | 410 | * |
| @@ -392,12 +409,11 @@ | ||
| 392 | 409 | * Return the cache controller for the cell collection |
| 393 | 410 | * |
| 394 | 411 | * @return PHPExcel_CachedObjectStorage_xxx |
| 395 | 412 | */ |
| 396 | - public function getCellCacheController() | |
| 397 | - { | |
| 398 | - return $this->cellCollection; | |
| 399 | - } | |
| 413 | + public function getCellCacheController() { | |
| 414 | + return $this->_cellCollection; | |
| 415 | + } // function getCellCacheController() | |
| 400 | 416 | |
| 401 | 417 | |
| 402 | 418 | /** |
| 403 | 419 | * Get array of invalid characters for sheet title |
| @@ -405,9 +421,9 @@ | ||
| 405 | 421 | * @return array |
| 406 | 422 | */ |
| 407 | 423 | public static function getInvalidCharacters() |
| 408 | 424 | { |
| 409 | - return self::$invalidCharacters; | |
| 425 | + return self::$_invalidCharacters; | |
| 410 | 426 | } |
| 411 | 427 | |
| 412 | 428 | /** |
| 413 | 429 | * Check sheet code name for valid Excel syntax |
| @@ -415,9 +431,9 @@ | ||
| 415 | 431 | * @param string $pValue The string to check |
| 416 | 432 | * @return string The valid string |
| 417 | 433 | * @throws Exception |
| 418 | 434 | */ |
| 419 | - private static function checkSheetCodeName($pValue) | |
| 435 | + private static function _checkSheetCodeName($pValue) | |
| 420 | 436 | { |
| 421 | 437 | $CharCount = PHPExcel_Shared_String::CountCharacters($pValue); |
| 422 | 438 | if ($CharCount == 0) { |
| 423 | 439 | throw new PHPExcel_Exception('Sheet code name cannot be empty.'); |
| @@ -422,19 +438,19 @@ | ||
| 422 | 438 | if ($CharCount == 0) { |
| 423 | 439 | throw new PHPExcel_Exception('Sheet code name cannot be empty.'); |
| 424 | 440 | } |
| 425 | 441 | // Some of the printable ASCII characters are invalid: * : / \ ? [ ] and first and last characters cannot be a "'" |
| 426 | - if ((str_replace(self::$invalidCharacters, '', $pValue) !== $pValue) || | |
| 427 | - (PHPExcel_Shared_String::Substring($pValue, -1, 1)=='\'') || | |
| 428 | - (PHPExcel_Shared_String::Substring($pValue, 0, 1)=='\'')) { | |
| 442 | + if ((str_replace(self::$_invalidCharacters, '', $pValue) !== $pValue) || | |
| 443 | + (PHPExcel_Shared_String::Substring($pValue,-1,1)=='\'') || | |
| 444 | + (PHPExcel_Shared_String::Substring($pValue,0,1)=='\'')) { | |
| 429 | 445 | throw new PHPExcel_Exception('Invalid character found in sheet code name'); |
| 430 | 446 | } |
| 431 | - | |
| 447 | + | |
| 432 | 448 | // Maximum 31 characters allowed for sheet title |
| 433 | 449 | if ($CharCount > 31) { |
| 434 | 450 | throw new PHPExcel_Exception('Maximum 31 characters allowed in sheet code name.'); |
| 435 | 451 | } |
| 436 | - | |
| 452 | + | |
| 437 | 453 | return $pValue; |
| 438 | 454 | } |
| 439 | 455 | |
| 440 | 456 | /** |
| @@ -443,12 +459,12 @@ | ||
| 443 | 459 | * @param string $pValue The string to check |
| 444 | 460 | * @return string The valid string |
| 445 | 461 | * @throws PHPExcel_Exception |
| 446 | 462 | */ |
| 447 | - private static function checkSheetTitle($pValue) | |
| 463 | + private static function _checkSheetTitle($pValue) | |
| 448 | 464 | { |
| 449 | 465 | // Some of the printable ASCII characters are invalid: * : / \ ? [ ] |
| 450 | - if (str_replace(self::$invalidCharacters, '', $pValue) !== $pValue) { | |
| 466 | + if (str_replace(self::$_invalidCharacters, '', $pValue) !== $pValue) { | |
| 451 | 467 | throw new PHPExcel_Exception('Invalid character found in sheet title'); |
| 452 | 468 | } |
| 453 | 469 | |
| 454 | 470 | // Maximum 31 characters allowed for sheet title |
| @@ -470,10 +486,10 @@ | ||
| 470 | 486 | if ($pSorted) { |
| 471 | 487 | // Re-order cell collection |
| 472 | 488 | return $this->sortCellCollection(); |
| 473 | 489 | } |
| 474 | - if ($this->cellCollection !== null) { | |
| 475 | - return $this->cellCollection->getCellList(); | |
| 490 | + if ($this->_cellCollection !== NULL) { | |
| 491 | + return $this->_cellCollection->getCellList(); | |
| 476 | 492 | } |
| 477 | 493 | return array(); |
| 478 | 494 | } |
| 479 | 495 | |
| @@ -483,10 +499,10 @@ | ||
| 483 | 499 | * @return PHPExcel_Worksheet |
| 484 | 500 | */ |
| 485 | 501 | public function sortCellCollection() |
| 486 | 502 | { |
| 487 | - if ($this->cellCollection !== null) { | |
| 488 | - return $this->cellCollection->getSortedCellList(); | |
| 503 | + if ($this->_cellCollection !== NULL) { | |
| 504 | + return $this->_cellCollection->getSortedCellList(); | |
| 489 | 505 | } |
| 490 | 506 | return array(); |
| 491 | 507 | } |
| 492 | 508 | |
| @@ -496,9 +512,9 @@ | ||
| 496 | 512 | * @return PHPExcel_Worksheet_RowDimension[] |
| 497 | 513 | */ |
| 498 | 514 | public function getRowDimensions() |
| 499 | 515 | { |
| 500 | - return $this->rowDimensions; | |
| 516 | + return $this->_rowDimensions; | |
| 501 | 517 | } |
| 502 | 518 | |
| 503 | 519 | /** |
| 504 | 520 | * Get default row dimension |
| @@ -506,9 +522,9 @@ | ||
| 506 | 522 | * @return PHPExcel_Worksheet_RowDimension |
| 507 | 523 | */ |
| 508 | 524 | public function getDefaultRowDimension() |
| 509 | 525 | { |
| 510 | - return $this->defaultRowDimension; | |
| 526 | + return $this->_defaultRowDimension; | |
| 511 | 527 | } |
| 512 | 528 | |
| 513 | 529 | /** |
| 514 | 530 | * Get collection of column dimensions |
| @@ -516,9 +532,9 @@ | ||
| 516 | 532 | * @return PHPExcel_Worksheet_ColumnDimension[] |
| 517 | 533 | */ |
| 518 | 534 | public function getColumnDimensions() |
| 519 | 535 | { |
| 520 | - return $this->columnDimensions; | |
| 536 | + return $this->_columnDimensions; | |
| 521 | 537 | } |
| 522 | 538 | |
| 523 | 539 | /** |
| 524 | 540 | * Get default column dimension |
| @@ -526,9 +542,9 @@ | ||
| 526 | 542 | * @return PHPExcel_Worksheet_ColumnDimension |
| 527 | 543 | */ |
| 528 | 544 | public function getDefaultColumnDimension() |
| 529 | 545 | { |
| 530 | - return $this->defaultColumnDimension; | |
| 546 | + return $this->_defaultColumnDimension; | |
| 531 | 547 | } |
| 532 | 548 | |
| 533 | 549 | /** |
| 534 | 550 | * Get collection of drawings |
| @@ -536,9 +552,9 @@ | ||
| 536 | 552 | * @return PHPExcel_Worksheet_BaseDrawing[] |
| 537 | 553 | */ |
| 538 | 554 | public function getDrawingCollection() |
| 539 | 555 | { |
| 540 | - return $this->drawingCollection; | |
| 556 | + return $this->_drawingCollection; | |
| 541 | 557 | } |
| 542 | 558 | |
| 543 | 559 | /** |
| 544 | 560 | * Get collection of charts |
| @@ -546,9 +562,9 @@ | ||
| 546 | 562 | * @return PHPExcel_Chart[] |
| 547 | 563 | */ |
| 548 | 564 | public function getChartCollection() |
| 549 | 565 | { |
| 550 | - return $this->chartCollection; | |
| 566 | + return $this->_chartCollection; | |
| 551 | 567 | } |
| 552 | 568 | |
| 553 | 569 | /** |
| 554 | 570 | * Add chart |
| @@ -560,12 +576,12 @@ | ||
| 560 | 576 | public function addChart(PHPExcel_Chart $pChart = null, $iChartIndex = null) |
| 561 | 577 | { |
| 562 | 578 | $pChart->setWorksheet($this); |
| 563 | 579 | if (is_null($iChartIndex)) { |
| 564 | - $this->chartCollection[] = $pChart; | |
| 580 | + $this->_chartCollection[] = $pChart; | |
| 565 | 581 | } else { |
| 566 | 582 | // Insert the chart at the requested index |
| 567 | - array_splice($this->chartCollection, $iChartIndex, 0, array($pChart)); | |
| 583 | + array_splice($this->_chartCollection, $iChartIndex, 0, array($pChart)); | |
| 568 | 584 | } |
| 569 | 585 | |
| 570 | 586 | return $pChart; |
| 571 | 587 | } |
| @@ -576,9 +592,9 @@ | ||
| 576 | 592 | * @return int The number of charts |
| 577 | 593 | */ |
| 578 | 594 | public function getChartCount() |
| 579 | 595 | { |
| 580 | - return count($this->chartCollection); | |
| 596 | + return count($this->_chartCollection); | |
| 581 | 597 | } |
| 582 | 598 | |
| 583 | 599 | /** |
| 584 | 600 | * Get a chart by its index position |
| @@ -588,9 +604,9 @@ | ||
| 588 | 604 | * @throws PHPExcel_Exception |
| 589 | 605 | */ |
| 590 | 606 | public function getChartByIndex($index = null) |
| 591 | 607 | { |
| 592 | - $chartCount = count($this->chartCollection); | |
| 608 | + $chartCount = count($this->_chartCollection); | |
| 593 | 609 | if ($chartCount == 0) { |
| 594 | 610 | return false; |
| 595 | 611 | } |
| 596 | 612 | if (is_null($index)) { |
| @@ -595,13 +611,13 @@ | ||
| 595 | 611 | } |
| 596 | 612 | if (is_null($index)) { |
| 597 | 613 | $index = --$chartCount; |
| 598 | 614 | } |
| 599 | - if (!isset($this->chartCollection[$index])) { | |
| 615 | + if (!isset($this->_chartCollection[$index])) { | |
| 600 | 616 | return false; |
| 601 | 617 | } |
| 602 | 618 | |
| 603 | - return $this->chartCollection[$index]; | |
| 619 | + return $this->_chartCollection[$index]; | |
| 604 | 620 | } |
| 605 | 621 | |
| 606 | 622 | /** |
| 607 | 623 | * Return an array of the names of charts on this worksheet |
| @@ -611,9 +627,9 @@ | ||
| 611 | 627 | */ |
| 612 | 628 | public function getChartNames() |
| 613 | 629 | { |
| 614 | 630 | $chartNames = array(); |
| 615 | - foreach ($this->chartCollection as $chart) { | |
| 631 | + foreach($this->_chartCollection as $chart) { | |
| 616 | 632 | $chartNames[] = $chart->getName(); |
| 617 | 633 | } |
| 618 | 634 | return $chartNames; |
| 619 | 635 | } |
| @@ -626,15 +642,15 @@ | ||
| 626 | 642 | * @throws PHPExcel_Exception |
| 627 | 643 | */ |
| 628 | 644 | public function getChartByName($chartName = '') |
| 629 | 645 | { |
| 630 | - $chartCount = count($this->chartCollection); | |
| 646 | + $chartCount = count($this->_chartCollection); | |
| 631 | 647 | if ($chartCount == 0) { |
| 632 | 648 | return false; |
| 633 | 649 | } |
| 634 | - foreach ($this->chartCollection as $index => $chart) { | |
| 650 | + foreach($this->_chartCollection as $index => $chart) { | |
| 635 | 651 | if ($chart->getName() == $chartName) { |
| 636 | - return $this->chartCollection[$index]; | |
| 652 | + return $this->_chartCollection[$index]; | |
| 637 | 653 | } |
| 638 | 654 | } |
| 639 | 655 | return false; |
| 640 | 656 | } |
| @@ -652,9 +668,9 @@ | ||
| 652 | 668 | foreach ($currentColumnDimensions as $objColumnDimension) { |
| 653 | 669 | $newColumnDimensions[$objColumnDimension->getColumnIndex()] = $objColumnDimension; |
| 654 | 670 | } |
| 655 | 671 | |
| 656 | - $this->columnDimensions = $newColumnDimensions; | |
| 672 | + $this->_columnDimensions = $newColumnDimensions; | |
| 657 | 673 | |
| 658 | 674 | return $this; |
| 659 | 675 | } |
| 660 | 676 | |
| @@ -671,9 +687,9 @@ | ||
| 671 | 687 | foreach ($currentRowDimensions as $objRowDimension) { |
| 672 | 688 | $newRowDimensions[$objRowDimension->getRowIndex()] = $objRowDimension; |
| 673 | 689 | } |
| 674 | 690 | |
| 675 | - $this->rowDimensions = $newRowDimensions; | |
| 691 | + $this->_rowDimensions = $newRowDimensions; | |
| 676 | 692 | |
| 677 | 693 | return $this; |
| 678 | 694 | } |
| 679 | 695 | |
| @@ -716,8 +732,9 @@ | ||
| 716 | 732 | } |
| 717 | 733 | |
| 718 | 734 | // There is only something to do if there are some auto-size columns |
| 719 | 735 | if (!empty($autoSizes)) { |
| 736 | + | |
| 720 | 737 | // build list of cells references that participate in a merge |
| 721 | 738 | $isMergeCell = array(); |
| 722 | 739 | foreach ($this->getMergeCells() as $cells) { |
| 723 | 740 | foreach (PHPExcel_Cell::extractAllCellReferencesInRange($cells) as $cellReference) { |
| @@ -726,25 +743,25 @@ | ||
| 726 | 743 | } |
| 727 | 744 | |
| 728 | 745 | // loop through all cells in the worksheet |
| 729 | 746 | foreach ($this->getCellCollection(false) as $cellID) { |
| 730 | - $cell = $this->getCell($cellID, false); | |
| 731 | - if ($cell !== null && isset($autoSizes[$this->cellCollection->getCurrentColumn()])) { | |
| 747 | + $cell = $this->getCell($cellID); | |
| 748 | + if (isset($autoSizes[$this->_cellCollection->getCurrentColumn()])) { | |
| 732 | 749 | // Determine width if cell does not participate in a merge |
| 733 | - if (!isset($isMergeCell[$this->cellCollection->getCurrentAddress()])) { | |
| 750 | + if (!isset($isMergeCell[$this->_cellCollection->getCurrentAddress()])) { | |
| 734 | 751 | // Calculated value |
| 735 | 752 | // To formatted string |
| 736 | - $cellValue = PHPExcel_Style_NumberFormat::toFormattedString( | |
| 737 | - $cell->getCalculatedValue(), | |
| 738 | - $this->getParent()->getCellXfByIndex($cell->getXfIndex())->getNumberFormat()->getFormatCode() | |
| 739 | - ); | |
| 753 | + $cellValue = PHPExcel_Style_NumberFormat::toFormattedString( | |
| 754 | + $cell->getCalculatedValue(), | |
| 755 | + $this->getParent()->getCellXfByIndex($cell->getXfIndex())->getNumberFormat()->getFormatCode() | |
| 756 | + ); | |
| 740 | 757 | |
| 741 | - $autoSizes[$this->cellCollection->getCurrentColumn()] = max( | |
| 742 | - (float) $autoSizes[$this->cellCollection->getCurrentColumn()], | |
| 758 | + $autoSizes[$this->_cellCollection->getCurrentColumn()] = max( | |
| 759 | + (float) $autoSizes[$this->_cellCollection->getCurrentColumn()], | |
| 743 | 760 | (float)PHPExcel_Shared_Font::calculateColumnWidth( |
| 744 | - $this->getParent()->getCellXfByIndex($cell->getXfIndex())->getFont(), | |
| 761 | + $this->getParent()->getCellXfByIndex($cell->getXfIndex())->getFont(), | |
| 745 | 762 | $cellValue, |
| 746 | - $this->getParent()->getCellXfByIndex($cell->getXfIndex())->getAlignment()->getTextRotation(), | |
| 763 | + $this->getParent()->getCellXfByIndex($cell->getXfIndex())->getAlignment()->getTextRotation(), | |
| 747 | 764 | $this->getDefaultStyle()->getFont() |
| 748 | 765 | ) |
| 749 | 766 | ); |
| 750 | 767 | } |
| @@ -752,11 +769,9 @@ | ||
| 752 | 769 | } |
| 753 | 770 | |
| 754 | 771 | // adjust column widths |
| 755 | 772 | foreach ($autoSizes as $columnIndex => $width) { |
| 756 | - if ($width == -1) { | |
| 757 | - $width = $this->getDefaultColumnDimension()->getWidth(); | |
| 758 | - } | |
| 773 | + if ($width == -1) $width = $this->getDefaultColumnDimension()->getWidth(); | |
| 759 | 774 | $this->getColumnDimension($columnIndex)->setWidth($width); |
| 760 | 775 | } |
| 761 | 776 | } |
| 762 | 777 | |
| @@ -767,11 +782,10 @@ | ||
| 767 | 782 | * Get parent |
| 768 | 783 | * |
| 769 | 784 | * @return PHPExcel |
| 770 | 785 | */ |
| 771 | - public function getParent() | |
| 772 | - { | |
| 773 | - return $this->parent; | |
| 786 | + public function getParent() { | |
| 787 | + return $this->_parent; | |
| 774 | 788 | } |
| 775 | 789 | |
| 776 | 790 | /** |
| 777 | 791 | * Re-bind parent |
| @@ -778,21 +792,20 @@ | ||
| 778 | 792 | * |
| 779 | 793 | * @param PHPExcel $parent |
| 780 | 794 | * @return PHPExcel_Worksheet |
| 781 | 795 | */ |
| 782 | - public function rebindParent(PHPExcel $parent) | |
| 783 | - { | |
| 784 | - if ($this->parent !== null) { | |
| 785 | - $namedRanges = $this->parent->getNamedRanges(); | |
| 796 | + public function rebindParent(PHPExcel $parent) { | |
| 797 | + if ($this->_parent !== null) { | |
| 798 | + $namedRanges = $this->_parent->getNamedRanges(); | |
| 786 | 799 | foreach ($namedRanges as $namedRange) { |
| 787 | 800 | $parent->addNamedRange($namedRange); |
| 788 | 801 | } |
| 789 | 802 | |
| 790 | - $this->parent->removeSheetByIndex( | |
| 791 | - $this->parent->getIndex($this) | |
| 803 | + $this->_parent->removeSheetByIndex( | |
| 804 | + $this->_parent->getIndex($this) | |
| 792 | 805 | ); |
| 793 | 806 | } |
| 794 | - $this->parent = $parent; | |
| 807 | + $this->_parent = $parent; | |
| 795 | 808 | |
| 796 | 809 | return $this; |
| 797 | 810 | } |
| 798 | 811 | |
| @@ -802,9 +815,9 @@ | ||
| 802 | 815 | * @return string |
| 803 | 816 | */ |
| 804 | 817 | public function getTitle() |
| 805 | 818 | { |
| 806 | - return $this->title; | |
| 819 | + return $this->_title; | |
| 807 | 820 | } |
| 808 | 821 | |
| 809 | 822 | /** |
| 810 | 823 | * Set title |
| @@ -810,9 +823,9 @@ | ||
| 810 | 823 | * Set title |
| 811 | 824 | * |
| 812 | 825 | * @param string $pValue String containing the dimension of this worksheet |
| 813 | 826 | * @param string $updateFormulaCellReferences boolean Flag indicating whether cell references in formulae should |
| 814 | - * be updated to reflect the new sheet name. | |
| 827 | + * be updated to reflect the new sheet name. | |
| 815 | 828 | * This should be left as the default true, unless you are |
| 816 | 829 | * certain that no formula cells on any worksheet contain |
| 817 | 830 | * references to this worksheet |
| 818 | 831 | * @return PHPExcel_Worksheet |
| @@ -824,52 +837,51 @@ | ||
| 824 | 837 | return $this; |
| 825 | 838 | } |
| 826 | 839 | |
| 827 | 840 | // Syntax check |
| 828 | - self::checkSheetTitle($pValue); | |
| 841 | + self::_checkSheetTitle($pValue); | |
| 829 | 842 | |
| 830 | 843 | // Old title |
| 831 | 844 | $oldTitle = $this->getTitle(); |
| 832 | 845 | |
| 833 | - if ($this->parent) { | |
| 846 | + if ($this->_parent) { | |
| 834 | 847 | // Is there already such sheet name? |
| 835 | - if ($this->parent->sheetNameExists($pValue)) { | |
| 848 | + if ($this->_parent->sheetNameExists($pValue)) { | |
| 836 | 849 | // Use name, but append with lowest possible integer |
| 837 | 850 | |
| 838 | 851 | if (PHPExcel_Shared_String::CountCharacters($pValue) > 29) { |
| 839 | - $pValue = PHPExcel_Shared_String::Substring($pValue, 0, 29); | |
| 852 | + $pValue = PHPExcel_Shared_String::Substring($pValue,0,29); | |
| 840 | 853 | } |
| 841 | 854 | $i = 1; |
| 842 | - while ($this->parent->sheetNameExists($pValue . ' ' . $i)) { | |
| 855 | + while ($this->_parent->sheetNameExists($pValue . ' ' . $i)) { | |
| 843 | 856 | ++$i; |
| 844 | 857 | if ($i == 10) { |
| 845 | 858 | if (PHPExcel_Shared_String::CountCharacters($pValue) > 28) { |
| 846 | - $pValue = PHPExcel_Shared_String::Substring($pValue, 0, 28); | |
| 859 | + $pValue = PHPExcel_Shared_String::Substring($pValue,0,28); | |
| 847 | 860 | } |
| 848 | 861 | } elseif ($i == 100) { |
| 849 | 862 | if (PHPExcel_Shared_String::CountCharacters($pValue) > 27) { |
| 850 | - $pValue = PHPExcel_Shared_String::Substring($pValue, 0, 27); | |
| 863 | + $pValue = PHPExcel_Shared_String::Substring($pValue,0,27); | |
| 851 | 864 | } |
| 852 | 865 | } |
| 853 | 866 | } |
| 854 | 867 | |
| 855 | 868 | $altTitle = $pValue . ' ' . $i; |
| 856 | - return $this->setTitle($altTitle, $updateFormulaCellReferences); | |
| 869 | + return $this->setTitle($altTitle,$updateFormulaCellReferences); | |
| 857 | 870 | } |
| 858 | 871 | } |
| 859 | 872 | |
| 860 | 873 | // Set title |
| 861 | - $this->title = $pValue; | |
| 862 | - $this->dirty = true; | |
| 874 | + $this->_title = $pValue; | |
| 875 | + $this->_dirty = true; | |
| 863 | 876 | |
| 864 | - if ($this->parent && $this->parent->getCalculationEngine()) { | |
| 877 | + if ($this->_parent) { | |
| 865 | 878 | // New title |
| 866 | 879 | $newTitle = $this->getTitle(); |
| 867 | - $this->parent->getCalculationEngine() | |
| 868 | - ->renameCalculationCacheForWorksheet($oldTitle, $newTitle); | |
| 869 | - if ($updateFormulaCellReferences) { | |
| 870 | - PHPExcel_ReferenceHelper::getInstance()->updateNamedFormulas($this->parent, $oldTitle, $newTitle); | |
| 871 | - } | |
| 880 | + PHPExcel_Calculation::getInstance($this->_parent) | |
| 881 | + ->renameCalculationCacheForWorksheet($oldTitle, $newTitle); | |
| 882 | + if ($updateFormulaCellReferences) | |
| 883 | + PHPExcel_ReferenceHelper::getInstance()->updateNamedFormulas($this->_parent, $oldTitle, $newTitle); | |
| 872 | 884 | } |
| 873 | 885 | |
| 874 | 886 | return $this; |
| 875 | 887 | } |
| @@ -878,11 +890,10 @@ | ||
| 878 | 890 | * Get sheet state |
| 879 | 891 | * |
| 880 | 892 | * @return string Sheet state (visible, hidden, veryHidden) |
| 881 | 893 | */ |
| 882 | - public function getSheetState() | |
| 883 | - { | |
| 884 | - return $this->sheetState; | |
| 894 | + public function getSheetState() { | |
| 895 | + return $this->_sheetState; | |
| 885 | 896 | } |
| 886 | 897 | |
| 887 | 898 | /** |
| 888 | 899 | * Set sheet state |
| @@ -889,11 +900,10 @@ | ||
| 889 | 900 | * |
| 890 | 901 | * @param string $value Sheet state (visible, hidden, veryHidden) |
| 891 | 902 | * @return PHPExcel_Worksheet |
| 892 | 903 | */ |
| 893 | - public function setSheetState($value = PHPExcel_Worksheet::SHEETSTATE_VISIBLE) | |
| 894 | - { | |
| 895 | - $this->sheetState = $value; | |
| 904 | + public function setSheetState($value = PHPExcel_Worksheet::SHEETSTATE_VISIBLE) { | |
| 905 | + $this->_sheetState = $value; | |
| 896 | 906 | return $this; |
| 897 | 907 | } |
| 898 | 908 | |
| 899 | 909 | /** |
| @@ -902,9 +912,9 @@ | ||
| 902 | 912 | * @return PHPExcel_Worksheet_PageSetup |
| 903 | 913 | */ |
| 904 | 914 | public function getPageSetup() |
| 905 | 915 | { |
| 906 | - return $this->pageSetup; | |
| 916 | + return $this->_pageSetup; | |
| 907 | 917 | } |
| 908 | 918 | |
| 909 | 919 | /** |
| 910 | 920 | * Set page setup |
| @@ -913,9 +923,9 @@ | ||
| 913 | 923 | * @return PHPExcel_Worksheet |
| 914 | 924 | */ |
| 915 | 925 | public function setPageSetup(PHPExcel_Worksheet_PageSetup $pValue) |
| 916 | 926 | { |
| 917 | - $this->pageSetup = $pValue; | |
| 927 | + $this->_pageSetup = $pValue; | |
| 918 | 928 | return $this; |
| 919 | 929 | } |
| 920 | 930 | |
| 921 | 931 | /** |
| @@ -924,9 +934,9 @@ | ||
| 924 | 934 | * @return PHPExcel_Worksheet_PageMargins |
| 925 | 935 | */ |
| 926 | 936 | public function getPageMargins() |
| 927 | 937 | { |
| 928 | - return $this->pageMargins; | |
| 938 | + return $this->_pageMargins; | |
| 929 | 939 | } |
| 930 | 940 | |
| 931 | 941 | /** |
| 932 | 942 | * Set page margins |
| @@ -935,9 +945,9 @@ | ||
| 935 | 945 | * @return PHPExcel_Worksheet |
| 936 | 946 | */ |
| 937 | 947 | public function setPageMargins(PHPExcel_Worksheet_PageMargins $pValue) |
| 938 | 948 | { |
| 939 | - $this->pageMargins = $pValue; | |
| 949 | + $this->_pageMargins = $pValue; | |
| 940 | 950 | return $this; |
| 941 | 951 | } |
| 942 | 952 | |
| 943 | 953 | /** |
| @@ -946,9 +956,9 @@ | ||
| 946 | 956 | * @return PHPExcel_Worksheet_HeaderFooter |
| 947 | 957 | */ |
| 948 | 958 | public function getHeaderFooter() |
| 949 | 959 | { |
| 950 | - return $this->headerFooter; | |
| 960 | + return $this->_headerFooter; | |
| 951 | 961 | } |
| 952 | 962 | |
| 953 | 963 | /** |
| 954 | 964 | * Set page header/footer |
| @@ -957,9 +967,9 @@ | ||
| 957 | 967 | * @return PHPExcel_Worksheet |
| 958 | 968 | */ |
| 959 | 969 | public function setHeaderFooter(PHPExcel_Worksheet_HeaderFooter $pValue) |
| 960 | 970 | { |
| 961 | - $this->headerFooter = $pValue; | |
| 971 | + $this->_headerFooter = $pValue; | |
| 962 | 972 | return $this; |
| 963 | 973 | } |
| 964 | 974 | |
| 965 | 975 | /** |
| @@ -968,9 +978,9 @@ | ||
| 968 | 978 | * @return PHPExcel_Worksheet_SheetView |
| 969 | 979 | */ |
| 970 | 980 | public function getSheetView() |
| 971 | 981 | { |
| 972 | - return $this->sheetView; | |
| 982 | + return $this->_sheetView; | |
| 973 | 983 | } |
| 974 | 984 | |
| 975 | 985 | /** |
| 976 | 986 | * Set sheet view |
| @@ -979,9 +989,9 @@ | ||
| 979 | 989 | * @return PHPExcel_Worksheet |
| 980 | 990 | */ |
| 981 | 991 | public function setSheetView(PHPExcel_Worksheet_SheetView $pValue) |
| 982 | 992 | { |
| 983 | - $this->sheetView = $pValue; | |
| 993 | + $this->_sheetView = $pValue; | |
| 984 | 994 | return $this; |
| 985 | 995 | } |
| 986 | 996 | |
| 987 | 997 | /** |
| @@ -990,9 +1000,9 @@ | ||
| 990 | 1000 | * @return PHPExcel_Worksheet_Protection |
| 991 | 1001 | */ |
| 992 | 1002 | public function getProtection() |
| 993 | 1003 | { |
| 994 | - return $this->protection; | |
| 1004 | + return $this->_protection; | |
| 995 | 1005 | } |
| 996 | 1006 | |
| 997 | 1007 | /** |
| 998 | 1008 | * Set Protection |
| @@ -1001,10 +1011,10 @@ | ||
| 1001 | 1011 | * @return PHPExcel_Worksheet |
| 1002 | 1012 | */ |
| 1003 | 1013 | public function setProtection(PHPExcel_Worksheet_Protection $pValue) |
| 1004 | 1014 | { |
| 1005 | - $this->protection = $pValue; | |
| 1006 | - $this->dirty = true; | |
| 1015 | + $this->_protection = $pValue; | |
| 1016 | + $this->_dirty = true; | |
| 1007 | 1017 | |
| 1008 | 1018 | return $this; |
| 1009 | 1019 | } |
| 1010 | 1020 | |
| @@ -1017,9 +1027,9 @@ | ||
| 1017 | 1027 | */ |
| 1018 | 1028 | public function getHighestColumn($row = null) |
| 1019 | 1029 | { |
| 1020 | 1030 | if ($row == null) { |
| 1021 | - return $this->cachedHighestColumn; | |
| 1031 | + return $this->_cachedHighestColumn; | |
| 1022 | 1032 | } |
| 1023 | 1033 | return $this->getHighestDataColumn($row); |
| 1024 | 1034 | } |
| 1025 | 1035 | |
| @@ -1031,9 +1041,9 @@ | ||
| 1031 | 1041 | * @return string Highest column name that contains data |
| 1032 | 1042 | */ |
| 1033 | 1043 | public function getHighestDataColumn($row = null) |
| 1034 | 1044 | { |
| 1035 | - return $this->cellCollection->getHighestColumn($row); | |
| 1045 | + return $this->_cellCollection->getHighestColumn($row); | |
| 1036 | 1046 | } |
| 1037 | 1047 | |
| 1038 | 1048 | /** |
| 1039 | 1049 | * Get highest worksheet row |
| @@ -1044,9 +1054,9 @@ | ||
| 1044 | 1054 | */ |
| 1045 | 1055 | public function getHighestRow($column = null) |
| 1046 | 1056 | { |
| 1047 | 1057 | if ($column == null) { |
| 1048 | - return $this->cachedHighestRow; | |
| 1058 | + return $this->_cachedHighestRow; | |
| 1049 | 1059 | } |
| 1050 | 1060 | return $this->getHighestDataRow($column); |
| 1051 | 1061 | } |
| 1052 | 1062 | |
| @@ -1058,9 +1068,9 @@ | ||
| 1058 | 1068 | * @return string Highest row number that contains data |
| 1059 | 1069 | */ |
| 1060 | 1070 | public function getHighestDataRow($column = null) |
| 1061 | 1071 | { |
| 1062 | - return $this->cellCollection->getHighestRow($column); | |
| 1072 | + return $this->_cellCollection->getHighestRow($column); | |
| 1063 | 1073 | } |
| 1064 | 1074 | |
| 1065 | 1075 | /** |
| 1066 | 1076 | * Get highest worksheet column and highest row that have cell records |
| @@ -1068,9 +1078,9 @@ | ||
| 1068 | 1078 | * @return array Highest column name and highest row number |
| 1069 | 1079 | */ |
| 1070 | 1080 | public function getHighestRowAndColumn() |
| 1071 | 1081 | { |
| 1072 | - return $this->cellCollection->getHighestRowAndColumn(); | |
| 1082 | + return $this->_cellCollection->getHighestRowAndColumn(); | |
| 1073 | 1083 | } |
| 1074 | 1084 | |
| 1075 | 1085 | /** |
| 1076 | 1086 | * Set a cell value |
| @@ -1136,24 +1146,23 @@ | ||
| 1136 | 1146 | /** |
| 1137 | 1147 | * Get cell at a specific coordinate |
| 1138 | 1148 | * |
| 1139 | 1149 | * @param string $pCoordinate Coordinate of the cell |
| 1140 | - * @param boolean $createIfNotExists Flag indicating whether a new cell should be created if it doesn't | |
| 1141 | - * already exist, or a null should be returned instead | |
| 1142 | 1150 | * @throws PHPExcel_Exception |
| 1143 | - * @return null|PHPExcel_Cell Cell that was found/created or null | |
| 1151 | + * @return PHPExcel_Cell Cell that was found | |
| 1144 | 1152 | */ |
| 1145 | - public function getCell($pCoordinate = 'A1', $createIfNotExists = true) | |
| 1153 | + public function getCell($pCoordinate = 'A1') | |
| 1146 | 1154 | { |
| 1155 | + $pCoordinate = strtoupper($pCoordinate); | |
| 1147 | 1156 | // Check cell collection |
| 1148 | - if ($this->cellCollection->isDataSet(strtoupper($pCoordinate))) { | |
| 1149 | - return $this->cellCollection->getCacheData($pCoordinate); | |
| 1157 | + if ($this->_cellCollection->isDataSet($pCoordinate)) { | |
| 1158 | + return $this->_cellCollection->getCacheData($pCoordinate); | |
| 1150 | 1159 | } |
| 1151 | 1160 | |
| 1152 | 1161 | // Worksheet reference? |
| 1153 | 1162 | if (strpos($pCoordinate, '!') !== false) { |
| 1154 | 1163 | $worksheetReference = PHPExcel_Worksheet::extractSheetTitle($pCoordinate, true); |
| 1155 | - return $this->parent->getSheetByName($worksheetReference[0])->getCell(strtoupper($worksheetReference[1]), $createIfNotExists); | |
| 1164 | + return $this->_parent->getSheetByName($worksheetReference[0])->getCell($worksheetReference[1]); | |
| 1156 | 1165 | } |
| 1157 | 1166 | |
| 1158 | 1167 | // Named range? |
| 1159 | 1168 | if ((!preg_match('/^'.PHPExcel_Calculation::CALCULATION_REGEXP_CELLREF.'$/i', $pCoordinate, $matches)) && |
| @@ -1158,11 +1167,11 @@ | ||
| 1158 | 1167 | // Named range? |
| 1159 | 1168 | if ((!preg_match('/^'.PHPExcel_Calculation::CALCULATION_REGEXP_CELLREF.'$/i', $pCoordinate, $matches)) && |
| 1160 | 1169 | (preg_match('/^'.PHPExcel_Calculation::CALCULATION_REGEXP_NAMEDRANGE.'$/i', $pCoordinate, $matches))) { |
| 1161 | 1170 | $namedRange = PHPExcel_NamedRange::resolveRange($pCoordinate, $this); |
| 1162 | - if ($namedRange !== null) { | |
| 1171 | + if ($namedRange !== NULL) { | |
| 1163 | 1172 | $pCoordinate = $namedRange->getRange(); |
| 1164 | - return $namedRange->getWorksheet()->getCell($pCoordinate, $createIfNotExists); | |
| 1173 | + return $namedRange->getWorksheet()->getCell($pCoordinate); | |
| 1165 | 1174 | } |
| 1166 | 1175 | } |
| 1167 | 1176 | |
| 1168 | 1177 | // Uppercase coordinate |
| @@ -1173,32 +1182,29 @@ | ||
| 1173 | 1182 | } elseif (strpos($pCoordinate, '$') !== false) { |
| 1174 | 1183 | throw new PHPExcel_Exception('Cell coordinate must not be absolute.'); |
| 1175 | 1184 | } |
| 1176 | 1185 | |
| 1177 | - // Create new cell object, if required | |
| 1178 | - return $createIfNotExists ? $this->createNewCell($pCoordinate) : null; | |
| 1186 | + // Create new cell object | |
| 1187 | + return $this->_createNewCell($pCoordinate); | |
| 1179 | 1188 | } |
| 1180 | 1189 | |
| 1181 | 1190 | /** |
| 1182 | 1191 | * Get cell at a specific coordinate by using numeric cell coordinates |
| 1183 | 1192 | * |
| 1184 | - * @param string $pColumn Numeric column coordinate of the cell (starting from 0) | |
| 1193 | + * @param string $pColumn Numeric column coordinate of the cell | |
| 1185 | 1194 | * @param string $pRow Numeric row coordinate of the cell |
| 1186 | - * @param boolean $createIfNotExists Flag indicating whether a new cell should be created if it doesn't | |
| 1187 | - * already exist, or a null should be returned instead | |
| 1188 | - * @return null|PHPExcel_Cell Cell that was found/created or null | |
| 1195 | + * @return PHPExcel_Cell Cell that was found | |
| 1189 | 1196 | */ |
| 1190 | - public function getCellByColumnAndRow($pColumn = 0, $pRow = 1, $createIfNotExists = true) | |
| 1197 | + public function getCellByColumnAndRow($pColumn = 0, $pRow = 1) | |
| 1191 | 1198 | { |
| 1192 | 1199 | $columnLetter = PHPExcel_Cell::stringFromColumnIndex($pColumn); |
| 1193 | 1200 | $coordinate = $columnLetter . $pRow; |
| 1194 | 1201 | |
| 1195 | - if ($this->cellCollection->isDataSet($coordinate)) { | |
| 1196 | - return $this->cellCollection->getCacheData($coordinate); | |
| 1202 | + if ($this->_cellCollection->isDataSet($coordinate)) { | |
| 1203 | + return $this->_cellCollection->getCacheData($coordinate); | |
| 1197 | 1204 | } |
| 1198 | 1205 | |
| 1199 | - // Create new cell object, if required | |
| 1200 | - return $createIfNotExists ? $this->createNewCell($coordinate) : null; | |
| 1206 | + return $this->_createNewCell($coordinate); | |
| 1201 | 1207 | } |
| 1202 | 1208 | |
| 1203 | 1209 | /** |
| 1204 | 1210 | * Create a new cell at the specified coordinate |
| @@ -1205,39 +1211,42 @@ | ||
| 1205 | 1211 | * |
| 1206 | 1212 | * @param string $pCoordinate Coordinate of the cell |
| 1207 | 1213 | * @return PHPExcel_Cell Cell that was created |
| 1208 | 1214 | */ |
| 1209 | - private function createNewCell($pCoordinate) | |
| 1210 | - { | |
| 1211 | - $cell = $this->cellCollection->addCacheData( | |
| 1212 | - $pCoordinate, | |
| 1213 | - new PHPExcel_Cell(null, PHPExcel_Cell_DataType::TYPE_NULL, $this) | |
| 1214 | - ); | |
| 1215 | - $this->cellCollectionIsSorted = false; | |
| 1215 | + private function _createNewCell($pCoordinate) | |
| 1216 | + { | |
| 1217 | + $cell = $this->_cellCollection->addCacheData( | |
| 1218 | + $pCoordinate, | |
| 1219 | + new PHPExcel_Cell( | |
| 1220 | + NULL, | |
| 1221 | + PHPExcel_Cell_DataType::TYPE_NULL, | |
| 1222 | + $this | |
| 1223 | + ) | |
| 1224 | + ); | |
| 1225 | + $this->_cellCollectionIsSorted = false; | |
| 1216 | 1226 | |
| 1217 | 1227 | // Coordinates |
| 1218 | 1228 | $aCoordinates = PHPExcel_Cell::coordinateFromString($pCoordinate); |
| 1219 | - if (PHPExcel_Cell::columnIndexFromString($this->cachedHighestColumn) < PHPExcel_Cell::columnIndexFromString($aCoordinates[0])) { | |
| 1220 | - $this->cachedHighestColumn = $aCoordinates[0]; | |
| 1221 | - } | |
| 1222 | - $this->cachedHighestRow = max($this->cachedHighestRow, $aCoordinates[1]); | |
| 1229 | + if (PHPExcel_Cell::columnIndexFromString($this->_cachedHighestColumn) < PHPExcel_Cell::columnIndexFromString($aCoordinates[0])) | |
| 1230 | + $this->_cachedHighestColumn = $aCoordinates[0]; | |
| 1231 | + $this->_cachedHighestRow = max($this->_cachedHighestRow, $aCoordinates[1]); | |
| 1223 | 1232 | |
| 1224 | 1233 | // Cell needs appropriate xfIndex from dimensions records |
| 1225 | - // but don't create dimension records if they don't already exist | |
| 1226 | - $rowDimension = $this->getRowDimension($aCoordinates[1], false); | |
| 1227 | - $columnDimension = $this->getColumnDimension($aCoordinates[0], false); | |
| 1234 | + // but don't create dimension records if they don't already exist | |
| 1235 | + $rowDimension = $this->getRowDimension($aCoordinates[1], FALSE); | |
| 1236 | + $columnDimension = $this->getColumnDimension($aCoordinates[0], FALSE); | |
| 1228 | 1237 | |
| 1229 | - if ($rowDimension !== null && $rowDimension->getXfIndex() > 0) { | |
| 1238 | + if ($rowDimension !== NULL && $rowDimension->getXfIndex() > 0) { | |
| 1230 | 1239 | // then there is a row dimension with explicit style, assign it to the cell |
| 1231 | 1240 | $cell->setXfIndex($rowDimension->getXfIndex()); |
| 1232 | - } elseif ($columnDimension !== null && $columnDimension->getXfIndex() > 0) { | |
| 1241 | + } elseif ($columnDimension !== NULL && $columnDimension->getXfIndex() > 0) { | |
| 1233 | 1242 | // then there is a column dimension, assign it to the cell |
| 1234 | 1243 | $cell->setXfIndex($columnDimension->getXfIndex()); |
| 1235 | 1244 | } |
| 1236 | 1245 | |
| 1237 | 1246 | return $cell; |
| 1238 | - } | |
| 1239 | - | |
| 1247 | + } | |
| 1248 | + | |
| 1240 | 1249 | /** |
| 1241 | 1250 | * Does the cell at a specific coordinate exist? |
| 1242 | 1251 | * |
| 1243 | 1252 | * @param string $pCoordinate Coordinate of the cell |
| @@ -1248,9 +1257,9 @@ | ||
| 1248 | 1257 | { |
| 1249 | 1258 | // Worksheet reference? |
| 1250 | 1259 | if (strpos($pCoordinate, '!') !== false) { |
| 1251 | 1260 | $worksheetReference = PHPExcel_Worksheet::extractSheetTitle($pCoordinate, true); |
| 1252 | - return $this->parent->getSheetByName($worksheetReference[0])->cellExists(strtoupper($worksheetReference[1])); | |
| 1261 | + return $this->_parent->getSheetByName($worksheetReference[0])->cellExists(strtoupper($worksheetReference[1])); | |
| 1253 | 1262 | } |
| 1254 | 1263 | |
| 1255 | 1264 | // Named range? |
| 1256 | 1265 | if ((!preg_match('/^'.PHPExcel_Calculation::CALCULATION_REGEXP_CELLREF.'$/i', $pCoordinate, $matches)) && |
| @@ -1255,9 +1264,9 @@ | ||
| 1255 | 1264 | // Named range? |
| 1256 | 1265 | if ((!preg_match('/^'.PHPExcel_Calculation::CALCULATION_REGEXP_CELLREF.'$/i', $pCoordinate, $matches)) && |
| 1257 | 1266 | (preg_match('/^'.PHPExcel_Calculation::CALCULATION_REGEXP_NAMEDRANGE.'$/i', $pCoordinate, $matches))) { |
| 1258 | 1267 | $namedRange = PHPExcel_NamedRange::resolveRange($pCoordinate, $this); |
| 1259 | - if ($namedRange !== null) { | |
| 1268 | + if ($namedRange !== NULL) { | |
| 1260 | 1269 | $pCoordinate = $namedRange->getRange(); |
| 1261 | 1270 | if ($this->getHashCode() != $namedRange->getWorksheet()->getHashCode()) { |
| 1262 | 1271 | if (!$namedRange->getLocalOnly()) { |
| 1263 | 1272 | return $namedRange->getWorksheet()->cellExists($pCoordinate); |
| @@ -1264,19 +1273,18 @@ | ||
| 1264 | 1273 | } else { |
| 1265 | 1274 | throw new PHPExcel_Exception('Named range ' . $namedRange->getName() . ' is not accessible from within sheet ' . $this->getTitle()); |
| 1266 | 1275 | } |
| 1267 | 1276 | } |
| 1268 | - } else { | |
| 1269 | - return false; | |
| 1270 | 1277 | } |
| 1278 | + else { return false; } | |
| 1271 | 1279 | } |
| 1272 | 1280 | |
| 1273 | 1281 | // Uppercase coordinate |
| 1274 | 1282 | $pCoordinate = strtoupper($pCoordinate); |
| 1275 | 1283 | |
| 1276 | - if (strpos($pCoordinate, ':') !== false || strpos($pCoordinate, ',') !== false) { | |
| 1284 | + if (strpos($pCoordinate,':') !== false || strpos($pCoordinate,',') !== false) { | |
| 1277 | 1285 | throw new PHPExcel_Exception('Cell coordinate can not be a range of cells.'); |
| 1278 | - } elseif (strpos($pCoordinate, '$') !== false) { | |
| 1286 | + } elseif (strpos($pCoordinate,'$') !== false) { | |
| 1279 | 1287 | throw new PHPExcel_Exception('Cell coordinate must not be absolute.'); |
| 1280 | 1288 | } else { |
| 1281 | 1289 | // Coordinates |
| 1282 | 1290 | $aCoordinates = PHPExcel_Cell::coordinateFromString($pCoordinate); |
| @@ -1281,9 +1289,9 @@ | ||
| 1281 | 1289 | // Coordinates |
| 1282 | 1290 | $aCoordinates = PHPExcel_Cell::coordinateFromString($pCoordinate); |
| 1283 | 1291 | |
| 1284 | 1292 | // Cell exists? |
| 1285 | - return $this->cellCollection->isDataSet($pCoordinate); | |
| 1293 | + return $this->_cellCollection->isDataSet($pCoordinate); | |
| 1286 | 1294 | } |
| 1287 | 1295 | } |
| 1288 | 1296 | |
| 1289 | 1297 | /** |
| @@ -1303,23 +1311,22 @@ | ||
| 1303 | 1311 | * |
| 1304 | 1312 | * @param int $pRow Numeric index of the row |
| 1305 | 1313 | * @return PHPExcel_Worksheet_RowDimension |
| 1306 | 1314 | */ |
| 1307 | - public function getRowDimension($pRow = 1, $create = true) | |
| 1315 | + public function getRowDimension($pRow = 1, $create = TRUE) | |
| 1308 | 1316 | { |
| 1309 | 1317 | // Found |
| 1310 | 1318 | $found = null; |
| 1311 | 1319 | |
| 1312 | 1320 | // Get row dimension |
| 1313 | - if (!isset($this->rowDimensions[$pRow])) { | |
| 1314 | - if (!$create) { | |
| 1315 | - return null; | |
| 1316 | - } | |
| 1317 | - $this->rowDimensions[$pRow] = new PHPExcel_Worksheet_RowDimension($pRow); | |
| 1321 | + if (!isset($this->_rowDimensions[$pRow])) { | |
| 1322 | + if (!$create) | |
| 1323 | + return NULL; | |
| 1324 | + $this->_rowDimensions[$pRow] = new PHPExcel_Worksheet_RowDimension($pRow); | |
| 1318 | 1325 | |
| 1319 | - $this->cachedHighestRow = max($this->cachedHighestRow, $pRow); | |
| 1326 | + $this->_cachedHighestRow = max($this->_cachedHighestRow,$pRow); | |
| 1320 | 1327 | } |
| 1321 | - return $this->rowDimensions[$pRow]; | |
| 1328 | + return $this->_rowDimensions[$pRow]; | |
| 1322 | 1329 | } |
| 1323 | 1330 | |
| 1324 | 1331 | /** |
| 1325 | 1332 | * Get column dimension at a specific column |
| @@ -1326,25 +1333,23 @@ | ||
| 1326 | 1333 | * |
| 1327 | 1334 | * @param string $pColumn String index of the column |
| 1328 | 1335 | * @return PHPExcel_Worksheet_ColumnDimension |
| 1329 | 1336 | */ |
| 1330 | - public function getColumnDimension($pColumn = 'A', $create = true) | |
| 1337 | + public function getColumnDimension($pColumn = 'A', $create = TRUE) | |
| 1331 | 1338 | { |
| 1332 | 1339 | // Uppercase coordinate |
| 1333 | 1340 | $pColumn = strtoupper($pColumn); |
| 1334 | 1341 | |
| 1335 | 1342 | // Fetch dimensions |
| 1336 | - if (!isset($this->columnDimensions[$pColumn])) { | |
| 1337 | - if (!$create) { | |
| 1338 | - return null; | |
| 1339 | - } | |
| 1340 | - $this->columnDimensions[$pColumn] = new PHPExcel_Worksheet_ColumnDimension($pColumn); | |
| 1343 | + if (!isset($this->_columnDimensions[$pColumn])) { | |
| 1344 | + if (!$create) | |
| 1345 | + return NULL; | |
| 1346 | + $this->_columnDimensions[$pColumn] = new PHPExcel_Worksheet_ColumnDimension($pColumn); | |
| 1341 | 1347 | |
| 1342 | - if (PHPExcel_Cell::columnIndexFromString($this->cachedHighestColumn) < PHPExcel_Cell::columnIndexFromString($pColumn)) { | |
| 1343 | - $this->cachedHighestColumn = $pColumn; | |
| 1344 | - } | |
| 1348 | + if (PHPExcel_Cell::columnIndexFromString($this->_cachedHighestColumn) < PHPExcel_Cell::columnIndexFromString($pColumn)) | |
| 1349 | + $this->_cachedHighestColumn = $pColumn; | |
| 1345 | 1350 | } |
| 1346 | - return $this->columnDimensions[$pColumn]; | |
| 1351 | + return $this->_columnDimensions[$pColumn]; | |
| 1347 | 1352 | } |
| 1348 | 1353 | |
| 1349 | 1354 | /** |
| 1350 | 1355 | * Get column dimension at a specific column by using numeric cell coordinates |
| @@ -1363,9 +1368,9 @@ | ||
| 1363 | 1368 | * @return PHPExcel_Style[] |
| 1364 | 1369 | */ |
| 1365 | 1370 | public function getStyles() |
| 1366 | 1371 | { |
| 1367 | - return $this->styles; | |
| 1372 | + return $this->_styles; | |
| 1368 | 1373 | } |
| 1369 | 1374 | |
| 1370 | 1375 | /** |
| 1371 | 1376 | * Get default style of workbook. |
| @@ -1375,9 +1380,9 @@ | ||
| 1375 | 1380 | * @throws PHPExcel_Exception |
| 1376 | 1381 | */ |
| 1377 | 1382 | public function getDefaultStyle() |
| 1378 | 1383 | { |
| 1379 | - return $this->parent->getDefaultStyle(); | |
| 1384 | + return $this->_parent->getDefaultStyle(); | |
| 1380 | 1385 | } |
| 1381 | 1386 | |
| 1382 | 1387 | /** |
| 1383 | 1388 | * Set default style - should only be used by PHPExcel_IReader implementations! |
| @@ -1388,9 +1393,9 @@ | ||
| 1388 | 1393 | * @return PHPExcel_Worksheet |
| 1389 | 1394 | */ |
| 1390 | 1395 | public function setDefaultStyle(PHPExcel_Style $pValue) |
| 1391 | 1396 | { |
| 1392 | - $this->parent->getDefaultStyle()->applyFromArray(array( | |
| 1397 | + $this->_parent->getDefaultStyle()->applyFromArray(array( | |
| 1393 | 1398 | 'font' => array( |
| 1394 | 1399 | 'name' => $pValue->getFont()->getName(), |
| 1395 | 1400 | 'size' => $pValue->getFont()->getSize(), |
| 1396 | 1401 | ), |
| @@ -1407,14 +1412,14 @@ | ||
| 1407 | 1412 | */ |
| 1408 | 1413 | public function getStyle($pCellCoordinate = 'A1') |
| 1409 | 1414 | { |
| 1410 | 1415 | // set this sheet as active |
| 1411 | - $this->parent->setActiveSheetIndex($this->parent->getIndex($this)); | |
| 1416 | + $this->_parent->setActiveSheetIndex($this->_parent->getIndex($this)); | |
| 1412 | 1417 | |
| 1413 | 1418 | // set cell coordinate as active |
| 1414 | 1419 | $this->setSelectedCells(strtoupper($pCellCoordinate)); |
| 1415 | 1420 | |
| 1416 | - return $this->parent->getCellXfSupervisor(); | |
| 1421 | + return $this->_parent->getCellXfSupervisor(); | |
| 1417 | 1422 | } |
| 1418 | 1423 | |
| 1419 | 1424 | /** |
| 1420 | 1425 | * Get conditional styles for a cell |
| @@ -1424,12 +1429,12 @@ | ||
| 1424 | 1429 | */ |
| 1425 | 1430 | public function getConditionalStyles($pCoordinate = 'A1') |
| 1426 | 1431 | { |
| 1427 | 1432 | $pCoordinate = strtoupper($pCoordinate); |
| 1428 | - if (!isset($this->conditionalStylesCollection[$pCoordinate])) { | |
| 1429 | - $this->conditionalStylesCollection[$pCoordinate] = array(); | |
| 1433 | + if (!isset($this->_conditionalStylesCollection[$pCoordinate])) { | |
| 1434 | + $this->_conditionalStylesCollection[$pCoordinate] = array(); | |
| 1430 | 1435 | } |
| 1431 | - return $this->conditionalStylesCollection[$pCoordinate]; | |
| 1436 | + return $this->_conditionalStylesCollection[$pCoordinate]; | |
| 1432 | 1437 | } |
| 1433 | 1438 | |
| 1434 | 1439 | /** |
| 1435 | 1440 | * Do conditional styles exist for this cell? |
| @@ -1438,9 +1443,9 @@ | ||
| 1438 | 1443 | * @return boolean |
| 1439 | 1444 | */ |
| 1440 | 1445 | public function conditionalStylesExists($pCoordinate = 'A1') |
| 1441 | 1446 | { |
| 1442 | - if (isset($this->conditionalStylesCollection[strtoupper($pCoordinate)])) { | |
| 1447 | + if (isset($this->_conditionalStylesCollection[strtoupper($pCoordinate)])) { | |
| 1443 | 1448 | return true; |
| 1444 | 1449 | } |
| 1445 | 1450 | return false; |
| 1446 | 1451 | } |
| @@ -1452,9 +1457,9 @@ | ||
| 1452 | 1457 | * @return PHPExcel_Worksheet |
| 1453 | 1458 | */ |
| 1454 | 1459 | public function removeConditionalStyles($pCoordinate = 'A1') |
| 1455 | 1460 | { |
| 1456 | - unset($this->conditionalStylesCollection[strtoupper($pCoordinate)]); | |
| 1461 | + unset($this->_conditionalStylesCollection[strtoupper($pCoordinate)]); | |
| 1457 | 1462 | return $this; |
| 1458 | 1463 | } |
| 1459 | 1464 | |
| 1460 | 1465 | /** |
| @@ -1463,9 +1468,9 @@ | ||
| 1463 | 1468 | * @return array |
| 1464 | 1469 | */ |
| 1465 | 1470 | public function getConditionalStylesCollection() |
| 1466 | 1471 | { |
| 1467 | - return $this->conditionalStylesCollection; | |
| 1472 | + return $this->_conditionalStylesCollection; | |
| 1468 | 1473 | } |
| 1469 | 1474 | |
| 1470 | 1475 | /** |
| 1471 | 1476 | * Set conditional styles |
| @@ -1475,9 +1480,9 @@ | ||
| 1475 | 1480 | * @return PHPExcel_Worksheet |
| 1476 | 1481 | */ |
| 1477 | 1482 | public function setConditionalStyles($pCoordinate = 'A1', $pValue) |
| 1478 | 1483 | { |
| 1479 | - $this->conditionalStylesCollection[strtoupper($pCoordinate)] = $pValue; | |
| 1484 | + $this->_conditionalStylesCollection[strtoupper($pCoordinate)] = $pValue; | |
| 1480 | 1485 | return $this; |
| 1481 | 1486 | } |
| 1482 | 1487 | |
| 1483 | 1488 | /** |
| @@ -1491,11 +1496,12 @@ | ||
| 1491 | 1496 | */ |
| 1492 | 1497 | public function getStyleByColumnAndRow($pColumn = 0, $pRow = 1, $pColumn2 = null, $pRow2 = null) |
| 1493 | 1498 | { |
| 1494 | 1499 | if (!is_null($pColumn2) && !is_null($pRow2)) { |
| 1495 | - $cellRange = PHPExcel_Cell::stringFromColumnIndex($pColumn) . $pRow . ':' . PHPExcel_Cell::stringFromColumnIndex($pColumn2) . $pRow2; | |
| 1496 | - return $this->getStyle($cellRange); | |
| 1497 | - } | |
| 1500 | + $cellRange = PHPExcel_Cell::stringFromColumnIndex($pColumn) . $pRow . ':' . | |
| 1501 | + PHPExcel_Cell::stringFromColumnIndex($pColumn2) . $pRow2; | |
| 1502 | + return $this->getStyle($cellRange); | |
| 1503 | + } | |
| 1498 | 1504 | |
| 1499 | 1505 | return $this->getStyle(PHPExcel_Cell::stringFromColumnIndex($pColumn) . $pRow); |
| 1500 | 1506 | } |
| 1501 | 1507 | |
| @@ -1531,10 +1537,10 @@ | ||
| 1531 | 1537 | // make sure we have a real style and not supervisor |
| 1532 | 1538 | $style = $pCellStyle->getIsSupervisor() ? $pCellStyle->getSharedComponent() : $pCellStyle; |
| 1533 | 1539 | |
| 1534 | 1540 | // Add the style to the workbook if necessary |
| 1535 | - $workbook = $this->parent; | |
| 1536 | - if ($existingStyle = $this->parent->getCellXfByHashCode($pCellStyle->getHashCode())) { | |
| 1541 | + $workbook = $this->_parent; | |
| 1542 | + if ($existingStyle = $this->_parent->getCellXfByHashCode($pCellStyle->getHashCode())) { | |
| 1537 | 1543 | // there is already such cell Xf in our collection |
| 1538 | 1544 | $xfIndex = $existingStyle->getIndex(); |
| 1539 | 1545 | } else { |
| 1540 | 1546 | // we don't have such a cell Xf, need to add |
| @@ -1566,9 +1572,9 @@ | ||
| 1566 | 1572 | * Duplicate conditional style to a range of cells |
| 1567 | 1573 | * |
| 1568 | 1574 | * Please note that this will overwrite existing cell styles for cells in range! |
| 1569 | 1575 | * |
| 1570 | - * @param array of PHPExcel_Style_Conditional $pCellStyle Cell style to duplicate | |
| 1576 | + * @param array of PHPExcel_Style_Conditional $pCellStyle Cell style to duplicate | |
| 1571 | 1577 | * @param string $pRange Range of cells (i.e. "A1:B10"), or just one cell (i.e. "A1") |
| 1572 | 1578 | * @throws PHPExcel_Exception |
| 1573 | 1579 | * @return PHPExcel_Worksheet |
| 1574 | 1580 | */ |
| @@ -1573,9 +1579,9 @@ | ||
| 1573 | 1579 | * @return PHPExcel_Worksheet |
| 1574 | 1580 | */ |
| 1575 | 1581 | public function duplicateConditionalStyle(array $pCellStyle = null, $pRange = '') |
| 1576 | 1582 | { |
| 1577 | - foreach ($pCellStyle as $cellStyle) { | |
| 1583 | + foreach($pCellStyle as $cellStyle) { | |
| 1578 | 1584 | if (!($cellStyle instanceof PHPExcel_Style_Conditional)) { |
| 1579 | 1585 | throw new PHPExcel_Exception('Style is not a conditional style'); |
| 1580 | 1586 | } |
| 1581 | 1587 | } |
| @@ -1633,15 +1639,15 @@ | ||
| 1633 | 1639 | // Uppercase coordinate |
| 1634 | 1640 | $pCell = strtoupper($pCell); |
| 1635 | 1641 | |
| 1636 | 1642 | if ($pCell != '') { |
| 1637 | - if ($pBreak == PHPExcel_Worksheet::BREAK_NONE) { | |
| 1638 | - if (isset($this->breaks[$pCell])) { | |
| 1639 | - unset($this->breaks[$pCell]); | |
| 1640 | - } | |
| 1641 | - } else { | |
| 1642 | - $this->breaks[$pCell] = $pBreak; | |
| 1643 | - } | |
| 1643 | + if ($pBreak == PHPExcel_Worksheet::BREAK_NONE) { | |
| 1644 | + if (isset($this->_breaks[$pCell])) { | |
| 1645 | + unset($this->_breaks[$pCell]); | |
| 1646 | + } | |
| 1647 | + } else { | |
| 1648 | + $this->_breaks[$pCell] = $pBreak; | |
| 1649 | + } | |
| 1644 | 1650 | } else { |
| 1645 | 1651 | throw new PHPExcel_Exception('No cell coordinate specified.'); |
| 1646 | 1652 | } |
| 1647 | 1653 | |
| @@ -1667,9 +1673,9 @@ | ||
| 1667 | 1673 | * @return array[] |
| 1668 | 1674 | */ |
| 1669 | 1675 | public function getBreaks() |
| 1670 | 1676 | { |
| 1671 | - return $this->breaks; | |
| 1677 | + return $this->_breaks; | |
| 1672 | 1678 | } |
| 1673 | 1679 | |
| 1674 | 1680 | /** |
| 1675 | 1681 | * Set merge on a cell range |
| @@ -1682,10 +1688,10 @@ | ||
| 1682 | 1688 | { |
| 1683 | 1689 | // Uppercase coordinate |
| 1684 | 1690 | $pRange = strtoupper($pRange); |
| 1685 | 1691 | |
| 1686 | - if (strpos($pRange, ':') !== false) { | |
| 1687 | - $this->mergeCells[$pRange] = $pRange; | |
| 1692 | + if (strpos($pRange,':') !== false) { | |
| 1693 | + $this->_mergeCells[$pRange] = $pRange; | |
| 1688 | 1694 | |
| 1689 | 1695 | // make sure cells are created |
| 1690 | 1696 | |
| 1691 | 1697 | // get the cells in the range |
| @@ -1696,15 +1702,14 @@ | ||
| 1696 | 1702 | if (!$this->cellExists($upperLeft)) { |
| 1697 | 1703 | $this->getCell($upperLeft)->setValueExplicit(null, PHPExcel_Cell_DataType::TYPE_NULL); |
| 1698 | 1704 | } |
| 1699 | 1705 | |
| 1700 | - // Blank out the rest of the cells in the range (if they exist) | |
| 1706 | + // create or blank out the rest of the cells in the range | |
| 1701 | 1707 | $count = count($aReferences); |
| 1702 | 1708 | for ($i = 1; $i < $count; $i++) { |
| 1703 | - if ($this->cellExists($aReferences[$i])) { | |
| 1704 | - $this->getCell($aReferences[$i])->setValueExplicit(null, PHPExcel_Cell_DataType::TYPE_NULL); | |
| 1705 | - } | |
| 1709 | + $this->getCell($aReferences[$i])->setValueExplicit(null, PHPExcel_Cell_DataType::TYPE_NULL); | |
| 1706 | 1710 | } |
| 1711 | + | |
| 1707 | 1712 | } else { |
| 1708 | 1713 | throw new PHPExcel_Exception('Merge must be set on a range of cells.'); |
| 1709 | 1714 | } |
| 1710 | 1715 | |
| @@ -1738,11 +1743,11 @@ | ||
| 1738 | 1743 | { |
| 1739 | 1744 | // Uppercase coordinate |
| 1740 | 1745 | $pRange = strtoupper($pRange); |
| 1741 | 1746 | |
| 1742 | - if (strpos($pRange, ':') !== false) { | |
| 1743 | - if (isset($this->mergeCells[$pRange])) { | |
| 1744 | - unset($this->mergeCells[$pRange]); | |
| 1747 | + if (strpos($pRange,':') !== false) { | |
| 1748 | + if (isset($this->_mergeCells[$pRange])) { | |
| 1749 | + unset($this->_mergeCells[$pRange]); | |
| 1745 | 1750 | } else { |
| 1746 | 1751 | throw new PHPExcel_Exception('Cell range ' . $pRange . ' not known as merged.'); |
| 1747 | 1752 | } |
| 1748 | 1753 | } else { |
| @@ -1774,9 +1779,9 @@ | ||
| 1774 | 1779 | * @return array[] |
| 1775 | 1780 | */ |
| 1776 | 1781 | public function getMergeCells() |
| 1777 | 1782 | { |
| 1778 | - return $this->mergeCells; | |
| 1783 | + return $this->_mergeCells; | |
| 1779 | 1784 | } |
| 1780 | 1785 | |
| 1781 | 1786 | /** |
| 1782 | 1787 | * Set merge cells array for the entire sheet. Use instead mergeCells() to merge |
| @@ -1785,9 +1790,10 @@ | ||
| 1785 | 1790 | * @param array |
| 1786 | 1791 | */ |
| 1787 | 1792 | public function setMergeCells($pValue = array()) |
| 1788 | 1793 | { |
| 1789 | - $this->mergeCells = $pValue; | |
| 1794 | + $this->_mergeCells = $pValue; | |
| 1795 | + | |
| 1790 | 1796 | return $this; |
| 1791 | 1797 | } |
| 1792 | 1798 | |
| 1793 | 1799 | /** |
| @@ -1806,9 +1812,9 @@ | ||
| 1806 | 1812 | |
| 1807 | 1813 | if (!$pAlreadyHashed) { |
| 1808 | 1814 | $pPassword = PHPExcel_Shared_PasswordHasher::hashPassword($pPassword); |
| 1809 | 1815 | } |
| 1810 | - $this->protectedCells[$pRange] = $pPassword; | |
| 1816 | + $this->_protectedCells[$pRange] = $pPassword; | |
| 1811 | 1817 | |
| 1812 | 1818 | return $this; |
| 1813 | 1819 | } |
| 1814 | 1820 | |
| @@ -1841,10 +1847,10 @@ | ||
| 1841 | 1847 | { |
| 1842 | 1848 | // Uppercase coordinate |
| 1843 | 1849 | $pRange = strtoupper($pRange); |
| 1844 | 1850 | |
| 1845 | - if (isset($this->protectedCells[$pRange])) { | |
| 1846 | - unset($this->protectedCells[$pRange]); | |
| 1851 | + if (isset($this->_protectedCells[$pRange])) { | |
| 1852 | + unset($this->_protectedCells[$pRange]); | |
| 1847 | 1853 | } else { |
| 1848 | 1854 | throw new PHPExcel_Exception('Cell range ' . $pRange . ' not known as protected.'); |
| 1849 | 1855 | } |
| 1850 | 1856 | return $this; |
| @@ -1874,9 +1880,9 @@ | ||
| 1874 | 1880 | * @return array[] |
| 1875 | 1881 | */ |
| 1876 | 1882 | public function getProtectedCells() |
| 1877 | 1883 | { |
| 1878 | - return $this->protectedCells; | |
| 1884 | + return $this->_protectedCells; | |
| 1879 | 1885 | } |
| 1880 | 1886 | |
| 1881 | 1887 | /** |
| 1882 | 1888 | * Get Autofilter |
| @@ -1884,9 +1890,9 @@ | ||
| 1884 | 1890 | * @return PHPExcel_Worksheet_AutoFilter |
| 1885 | 1891 | */ |
| 1886 | 1892 | public function getAutoFilter() |
| 1887 | 1893 | { |
| 1888 | - return $this->autoFilter; | |
| 1894 | + return $this->_autoFilter; | |
| 1889 | 1895 | } |
| 1890 | 1896 | |
| 1891 | 1897 | /** |
| 1892 | 1898 | * Set AutoFilter |
| @@ -1898,12 +1904,13 @@ | ||
| 1898 | 1904 | */ |
| 1899 | 1905 | public function setAutoFilter($pValue) |
| 1900 | 1906 | { |
| 1901 | 1907 | $pRange = strtoupper($pValue); |
| 1908 | + | |
| 1902 | 1909 | if (is_string($pValue)) { |
| 1903 | - $this->autoFilter->setRange($pValue); | |
| 1904 | - } elseif (is_object($pValue) && ($pValue instanceof PHPExcel_Worksheet_AutoFilter)) { | |
| 1905 | - $this->autoFilter = $pValue; | |
| 1910 | + $this->_autoFilter->setRange($pValue); | |
| 1911 | + } elseif(is_object($pValue) && ($pValue instanceof PHPExcel_Worksheet_AutoFilter)) { | |
| 1912 | + $this->_autoFilter = $pValue; | |
| 1906 | 1913 | } |
| 1907 | 1914 | return $this; |
| 1908 | 1915 | } |
| 1909 | 1916 | |
| @@ -1932,9 +1939,9 @@ | ||
| 1932 | 1939 | * @return PHPExcel_Worksheet |
| 1933 | 1940 | */ |
| 1934 | 1941 | public function removeAutoFilter() |
| 1935 | 1942 | { |
| 1936 | - $this->autoFilter->setRange(null); | |
| 1943 | + $this->_autoFilter->setRange(NULL); | |
| 1937 | 1944 | return $this; |
| 1938 | 1945 | } |
| 1939 | 1946 | |
| 1940 | 1947 | /** |
| @@ -1943,9 +1950,9 @@ | ||
| 1943 | 1950 | * @return string |
| 1944 | 1951 | */ |
| 1945 | 1952 | public function getFreezePane() |
| 1946 | 1953 | { |
| 1947 | - return $this->freezePane; | |
| 1954 | + return $this->_freezePane; | |
| 1948 | 1955 | } |
| 1949 | 1956 | |
| 1950 | 1957 | /** |
| 1951 | 1958 | * Freeze Pane |
| @@ -1962,10 +1969,11 @@ | ||
| 1962 | 1969 | public function freezePane($pCell = '') |
| 1963 | 1970 | { |
| 1964 | 1971 | // Uppercase coordinate |
| 1965 | 1972 | $pCell = strtoupper($pCell); |
| 1966 | - if (strpos($pCell, ':') === false && strpos($pCell, ',') === false) { | |
| 1967 | - $this->freezePane = $pCell; | |
| 1973 | + | |
| 1974 | + if (strpos($pCell,':') === false && strpos($pCell,',') === false) { | |
| 1975 | + $this->_freezePane = $pCell; | |
| 1968 | 1976 | } else { |
| 1969 | 1977 | throw new PHPExcel_Exception('Freeze pane can not be set on a range of cells.'); |
| 1970 | 1978 | } |
| 1971 | 1979 | return $this; |
| @@ -2001,10 +2009,9 @@ | ||
| 2001 | 2009 | * @param int $pNumRows Number of rows to insert |
| 2002 | 2010 | * @throws PHPExcel_Exception |
| 2003 | 2011 | * @return PHPExcel_Worksheet |
| 2004 | 2012 | */ |
| 2005 | - public function insertNewRowBefore($pBefore = 1, $pNumRows = 1) | |
| 2006 | - { | |
| 2013 | + public function insertNewRowBefore($pBefore = 1, $pNumRows = 1) { | |
| 2007 | 2014 | if ($pBefore >= 1) { |
| 2008 | 2015 | $objReferenceHelper = PHPExcel_ReferenceHelper::getInstance(); |
| 2009 | 2016 | $objReferenceHelper->insertNewBefore('A' . $pBefore, 0, $pNumRows, $this); |
| 2010 | 2017 | } else { |
| @@ -2020,10 +2027,9 @@ | ||
| 2020 | 2027 | * @param int $pNumCols Number of columns to insert |
| 2021 | 2028 | * @throws PHPExcel_Exception |
| 2022 | 2029 | * @return PHPExcel_Worksheet |
| 2023 | 2030 | */ |
| 2024 | - public function insertNewColumnBefore($pBefore = 'A', $pNumCols = 1) | |
| 2025 | - { | |
| 2031 | + public function insertNewColumnBefore($pBefore = 'A', $pNumCols = 1) { | |
| 2026 | 2032 | if (!is_numeric($pBefore)) { |
| 2027 | 2033 | $objReferenceHelper = PHPExcel_ReferenceHelper::getInstance(); |
| 2028 | 2034 | $objReferenceHelper->insertNewBefore($pBefore . '1', $pNumCols, 0, $this); |
| 2029 | 2035 | } else { |
| @@ -2039,10 +2045,9 @@ | ||
| 2039 | 2045 | * @param int $pNumCols Number of columns to insert |
| 2040 | 2046 | * @throws PHPExcel_Exception |
| 2041 | 2047 | * @return PHPExcel_Worksheet |
| 2042 | 2048 | */ |
| 2043 | - public function insertNewColumnBeforeByIndex($pBefore = 0, $pNumCols = 1) | |
| 2044 | - { | |
| 2049 | + public function insertNewColumnBeforeByIndex($pBefore = 0, $pNumCols = 1) { | |
| 2045 | 2050 | if ($pBefore >= 0) { |
| 2046 | 2051 | return $this->insertNewColumnBefore(PHPExcel_Cell::stringFromColumnIndex($pBefore), $pNumCols); |
| 2047 | 2052 | } else { |
| 2048 | 2053 | throw new PHPExcel_Exception("Columns can only be inserted before at least column A (0)."); |
| @@ -2056,15 +2061,14 @@ | ||
| 2056 | 2061 | * @param int $pNumRows Number of rows to remove |
| 2057 | 2062 | * @throws PHPExcel_Exception |
| 2058 | 2063 | * @return PHPExcel_Worksheet |
| 2059 | 2064 | */ |
| 2060 | - public function removeRow($pRow = 1, $pNumRows = 1) | |
| 2061 | - { | |
| 2065 | + public function removeRow($pRow = 1, $pNumRows = 1) { | |
| 2062 | 2066 | if ($pRow >= 1) { |
| 2063 | 2067 | $highestRow = $this->getHighestDataRow(); |
| 2064 | 2068 | $objReferenceHelper = PHPExcel_ReferenceHelper::getInstance(); |
| 2065 | 2069 | $objReferenceHelper->insertNewBefore('A' . ($pRow + $pNumRows), 0, -$pNumRows, $this); |
| 2066 | - for ($r = 0; $r < $pNumRows; ++$r) { | |
| 2070 | + for($r = 0; $r < $pNumRows; ++$r) { | |
| 2067 | 2071 | $this->getCellCacheController()->removeRow($highestRow); |
| 2068 | 2072 | --$highestRow; |
| 2069 | 2073 | } |
| 2070 | 2074 | } else { |
| @@ -2080,16 +2084,15 @@ | ||
| 2080 | 2084 | * @param int $pNumCols Number of columns to remove |
| 2081 | 2085 | * @throws PHPExcel_Exception |
| 2082 | 2086 | * @return PHPExcel_Worksheet |
| 2083 | 2087 | */ |
| 2084 | - public function removeColumn($pColumn = 'A', $pNumCols = 1) | |
| 2085 | - { | |
| 2088 | + public function removeColumn($pColumn = 'A', $pNumCols = 1) { | |
| 2086 | 2089 | if (!is_numeric($pColumn)) { |
| 2087 | 2090 | $highestColumn = $this->getHighestDataColumn(); |
| 2088 | 2091 | $pColumn = PHPExcel_Cell::stringFromColumnIndex(PHPExcel_Cell::columnIndexFromString($pColumn) - 1 + $pNumCols); |
| 2089 | 2092 | $objReferenceHelper = PHPExcel_ReferenceHelper::getInstance(); |
| 2090 | 2093 | $objReferenceHelper->insertNewBefore($pColumn . '1', -$pNumCols, 0, $this); |
| 2091 | - for ($c = 0; $c < $pNumCols; ++$c) { | |
| 2094 | + for($c = 0; $c < $pNumCols; ++$c) { | |
| 2092 | 2095 | $this->getCellCacheController()->removeColumn($highestColumn); |
| 2093 | 2096 | $highestColumn = PHPExcel_Cell::stringFromColumnIndex(PHPExcel_Cell::columnIndexFromString($highestColumn) - 2); |
| 2094 | 2097 | } |
| 2095 | 2098 | } else { |
| @@ -2105,10 +2108,9 @@ | ||
| 2105 | 2108 | * @param int $pNumCols Number of columns to remove |
| 2106 | 2109 | * @throws PHPExcel_Exception |
| 2107 | 2110 | * @return PHPExcel_Worksheet |
| 2108 | 2111 | */ |
| 2109 | - public function removeColumnByIndex($pColumn = 0, $pNumCols = 1) | |
| 2110 | - { | |
| 2112 | + public function removeColumnByIndex($pColumn = 0, $pNumCols = 1) { | |
| 2111 | 2113 | if ($pColumn >= 0) { |
| 2112 | 2114 | return $this->removeColumn(PHPExcel_Cell::stringFromColumnIndex($pColumn), $pNumCols); |
| 2113 | 2115 | } else { |
| 2114 | 2116 | throw new PHPExcel_Exception("Columns to be deleted should at least start from column 0"); |
| @@ -2119,11 +2121,10 @@ | ||
| 2119 | 2121 | * Show gridlines? |
| 2120 | 2122 | * |
| 2121 | 2123 | * @return boolean |
| 2122 | 2124 | */ |
| 2123 | - public function getShowGridlines() | |
| 2124 | - { | |
| 2125 | - return $this->showGridlines; | |
| 2125 | + public function getShowGridlines() { | |
| 2126 | + return $this->_showGridlines; | |
| 2126 | 2127 | } |
| 2127 | 2128 | |
| 2128 | 2129 | /** |
| 2129 | 2130 | * Set show gridlines |
| @@ -2130,11 +2131,10 @@ | ||
| 2130 | 2131 | * |
| 2131 | 2132 | * @param boolean $pValue Show gridlines (true/false) |
| 2132 | 2133 | * @return PHPExcel_Worksheet |
| 2133 | 2134 | */ |
| 2134 | - public function setShowGridlines($pValue = false) | |
| 2135 | - { | |
| 2136 | - $this->showGridlines = $pValue; | |
| 2135 | + public function setShowGridlines($pValue = false) { | |
| 2136 | + $this->_showGridlines = $pValue; | |
| 2137 | 2137 | return $this; |
| 2138 | 2138 | } |
| 2139 | 2139 | |
| 2140 | 2140 | /** |
| @@ -2141,11 +2141,10 @@ | ||
| 2141 | 2141 | * Print gridlines? |
| 2142 | 2142 | * |
| 2143 | 2143 | * @return boolean |
| 2144 | 2144 | */ |
| 2145 | - public function getPrintGridlines() | |
| 2146 | - { | |
| 2147 | - return $this->printGridlines; | |
| 2145 | + public function getPrintGridlines() { | |
| 2146 | + return $this->_printGridlines; | |
| 2148 | 2147 | } |
| 2149 | 2148 | |
| 2150 | 2149 | /** |
| 2151 | 2150 | * Set print gridlines |
| @@ -2152,11 +2151,10 @@ | ||
| 2152 | 2151 | * |
| 2153 | 2152 | * @param boolean $pValue Print gridlines (true/false) |
| 2154 | 2153 | * @return PHPExcel_Worksheet |
| 2155 | 2154 | */ |
| 2156 | - public function setPrintGridlines($pValue = false) | |
| 2157 | - { | |
| 2158 | - $this->printGridlines = $pValue; | |
| 2155 | + public function setPrintGridlines($pValue = false) { | |
| 2156 | + $this->_printGridlines = $pValue; | |
| 2159 | 2157 | return $this; |
| 2160 | 2158 | } |
| 2161 | 2159 | |
| 2162 | 2160 | /** |
| @@ -2163,11 +2161,10 @@ | ||
| 2163 | 2161 | * Show row and column headers? |
| 2164 | 2162 | * |
| 2165 | 2163 | * @return boolean |
| 2166 | 2164 | */ |
| 2167 | - public function getShowRowColHeaders() | |
| 2168 | - { | |
| 2169 | - return $this->showRowColHeaders; | |
| 2165 | + public function getShowRowColHeaders() { | |
| 2166 | + return $this->_showRowColHeaders; | |
| 2170 | 2167 | } |
| 2171 | 2168 | |
| 2172 | 2169 | /** |
| 2173 | 2170 | * Set show row and column headers |
| @@ -2174,11 +2171,10 @@ | ||
| 2174 | 2171 | * |
| 2175 | 2172 | * @param boolean $pValue Show row and column headers (true/false) |
| 2176 | 2173 | * @return PHPExcel_Worksheet |
| 2177 | 2174 | */ |
| 2178 | - public function setShowRowColHeaders($pValue = false) | |
| 2179 | - { | |
| 2180 | - $this->showRowColHeaders = $pValue; | |
| 2175 | + public function setShowRowColHeaders($pValue = false) { | |
| 2176 | + $this->_showRowColHeaders = $pValue; | |
| 2181 | 2177 | return $this; |
| 2182 | 2178 | } |
| 2183 | 2179 | |
| 2184 | 2180 | /** |
| @@ -2185,11 +2181,10 @@ | ||
| 2185 | 2181 | * Show summary below? (Row/Column outlining) |
| 2186 | 2182 | * |
| 2187 | 2183 | * @return boolean |
| 2188 | 2184 | */ |
| 2189 | - public function getShowSummaryBelow() | |
| 2190 | - { | |
| 2191 | - return $this->showSummaryBelow; | |
| 2185 | + public function getShowSummaryBelow() { | |
| 2186 | + return $this->_showSummaryBelow; | |
| 2192 | 2187 | } |
| 2193 | 2188 | |
| 2194 | 2189 | /** |
| 2195 | 2190 | * Set show summary below |
| @@ -2196,11 +2191,10 @@ | ||
| 2196 | 2191 | * |
| 2197 | 2192 | * @param boolean $pValue Show summary below (true/false) |
| 2198 | 2193 | * @return PHPExcel_Worksheet |
| 2199 | 2194 | */ |
| 2200 | - public function setShowSummaryBelow($pValue = true) | |
| 2201 | - { | |
| 2202 | - $this->showSummaryBelow = $pValue; | |
| 2195 | + public function setShowSummaryBelow($pValue = true) { | |
| 2196 | + $this->_showSummaryBelow = $pValue; | |
| 2203 | 2197 | return $this; |
| 2204 | 2198 | } |
| 2205 | 2199 | |
| 2206 | 2200 | /** |
| @@ -2207,11 +2201,10 @@ | ||
| 2207 | 2201 | * Show summary right? (Row/Column outlining) |
| 2208 | 2202 | * |
| 2209 | 2203 | * @return boolean |
| 2210 | 2204 | */ |
| 2211 | - public function getShowSummaryRight() | |
| 2212 | - { | |
| 2213 | - return $this->showSummaryRight; | |
| 2205 | + public function getShowSummaryRight() { | |
| 2206 | + return $this->_showSummaryRight; | |
| 2214 | 2207 | } |
| 2215 | 2208 | |
| 2216 | 2209 | /** |
| 2217 | 2210 | * Set show summary right |
| @@ -2218,11 +2211,10 @@ | ||
| 2218 | 2211 | * |
| 2219 | 2212 | * @param boolean $pValue Show summary right (true/false) |
| 2220 | 2213 | * @return PHPExcel_Worksheet |
| 2221 | 2214 | */ |
| 2222 | - public function setShowSummaryRight($pValue = true) | |
| 2223 | - { | |
| 2224 | - $this->showSummaryRight = $pValue; | |
| 2215 | + public function setShowSummaryRight($pValue = true) { | |
| 2216 | + $this->_showSummaryRight = $pValue; | |
| 2225 | 2217 | return $this; |
| 2226 | 2218 | } |
| 2227 | 2219 | |
| 2228 | 2220 | /** |
| @@ -2231,20 +2223,20 @@ | ||
| 2231 | 2223 | * @return PHPExcel_Comment[] |
| 2232 | 2224 | */ |
| 2233 | 2225 | public function getComments() |
| 2234 | 2226 | { |
| 2235 | - return $this->comments; | |
| 2227 | + return $this->_comments; | |
| 2236 | 2228 | } |
| 2237 | 2229 | |
| 2238 | 2230 | /** |
| 2239 | 2231 | * Set comments array for the entire sheet. |
| 2240 | 2232 | * |
| 2241 | - * @param array of PHPExcel_Comment | |
| 2233 | + * @param array of PHPExcel_Comment | |
| 2242 | 2234 | * @return PHPExcel_Worksheet |
| 2243 | 2235 | */ |
| 2244 | 2236 | public function setComments($pValue = array()) |
| 2245 | 2237 | { |
| 2246 | - $this->comments = $pValue; | |
| 2238 | + $this->_comments = $pValue; | |
| 2247 | 2239 | |
| 2248 | 2240 | return $this; |
| 2249 | 2241 | } |
| 2250 | 2242 | |
| @@ -2259,22 +2251,22 @@ | ||
| 2259 | 2251 | { |
| 2260 | 2252 | // Uppercase coordinate |
| 2261 | 2253 | $pCellCoordinate = strtoupper($pCellCoordinate); |
| 2262 | 2254 | |
| 2263 | - if (strpos($pCellCoordinate, ':') !== false || strpos($pCellCoordinate, ',') !== false) { | |
| 2255 | + if (strpos($pCellCoordinate,':') !== false || strpos($pCellCoordinate,',') !== false) { | |
| 2264 | 2256 | throw new PHPExcel_Exception('Cell coordinate string can not be a range of cells.'); |
| 2265 | - } elseif (strpos($pCellCoordinate, '$') !== false) { | |
| 2257 | + } else if (strpos($pCellCoordinate,'$') !== false) { | |
| 2266 | 2258 | throw new PHPExcel_Exception('Cell coordinate string must not be absolute.'); |
| 2267 | - } elseif ($pCellCoordinate == '') { | |
| 2259 | + } else if ($pCellCoordinate == '') { | |
| 2268 | 2260 | throw new PHPExcel_Exception('Cell coordinate can not be zero-length string.'); |
| 2269 | 2261 | } else { |
| 2270 | 2262 | // Check if we already have a comment for this cell. |
| 2271 | 2263 | // If not, create a new comment. |
| 2272 | - if (isset($this->comments[$pCellCoordinate])) { | |
| 2273 | - return $this->comments[$pCellCoordinate]; | |
| 2264 | + if (isset($this->_comments[$pCellCoordinate])) { | |
| 2265 | + return $this->_comments[$pCellCoordinate]; | |
| 2274 | 2266 | } else { |
| 2275 | 2267 | $newComment = new PHPExcel_Comment(); |
| 2276 | - $this->comments[$pCellCoordinate] = $newComment; | |
| 2268 | + $this->_comments[$pCellCoordinate] = $newComment; | |
| 2277 | 2269 | return $newComment; |
| 2278 | 2270 | } |
| 2279 | 2271 | } |
| 2280 | 2272 | } |
| @@ -2308,9 +2300,9 @@ | ||
| 2308 | 2300 | * @return string Example: 'A1' |
| 2309 | 2301 | */ |
| 2310 | 2302 | public function getActiveCell() |
| 2311 | 2303 | { |
| 2312 | - return $this->activeCell; | |
| 2304 | + return $this->_activeCell; | |
| 2313 | 2305 | } |
| 2314 | 2306 | |
| 2315 | 2307 | /** |
| 2316 | 2308 | * Get selected cells |
| @@ -2318,9 +2310,9 @@ | ||
| 2318 | 2310 | * @return string |
| 2319 | 2311 | */ |
| 2320 | 2312 | public function getSelectedCells() |
| 2321 | 2313 | { |
| 2322 | - return $this->selectedCells; | |
| 2314 | + return $this->_selectedCells; | |
| 2323 | 2315 | } |
| 2324 | 2316 | |
| 2325 | 2317 | /** |
| 2326 | 2318 | * Selected cell |
| @@ -2356,15 +2348,15 @@ | ||
| 2356 | 2348 | |
| 2357 | 2349 | // Convert '1:3' to 'A1:XFD3' |
| 2358 | 2350 | $pCoordinate = preg_replace('/^([0-9]+):([0-9]+)$/', 'A${1}:XFD${2}', $pCoordinate); |
| 2359 | 2351 | |
| 2360 | - if (strpos($pCoordinate, ':') !== false || strpos($pCoordinate, ',') !== false) { | |
| 2352 | + if (strpos($pCoordinate,':') !== false || strpos($pCoordinate,',') !== false) { | |
| 2361 | 2353 | list($first, ) = PHPExcel_Cell::splitRange($pCoordinate); |
| 2362 | - $this->activeCell = $first[0]; | |
| 2354 | + $this->_activeCell = $first[0]; | |
| 2363 | 2355 | } else { |
| 2364 | - $this->activeCell = $pCoordinate; | |
| 2356 | + $this->_activeCell = $pCoordinate; | |
| 2365 | 2357 | } |
| 2366 | - $this->selectedCells = $pCoordinate; | |
| 2358 | + $this->_selectedCells = $pCoordinate; | |
| 2367 | 2359 | return $this; |
| 2368 | 2360 | } |
| 2369 | 2361 | |
| 2370 | 2362 | /** |
| @@ -2384,11 +2376,10 @@ | ||
| 2384 | 2376 | * Get right-to-left |
| 2385 | 2377 | * |
| 2386 | 2378 | * @return boolean |
| 2387 | 2379 | */ |
| 2388 | - public function getRightToLeft() | |
| 2389 | - { | |
| 2390 | - return $this->rightToLeft; | |
| 2380 | + public function getRightToLeft() { | |
| 2381 | + return $this->_rightToLeft; | |
| 2391 | 2382 | } |
| 2392 | 2383 | |
| 2393 | 2384 | /** |
| 2394 | 2385 | * Set right-to-left |
| @@ -2395,11 +2386,10 @@ | ||
| 2395 | 2386 | * |
| 2396 | 2387 | * @param boolean $value Right-to-left true/false |
| 2397 | 2388 | * @return PHPExcel_Worksheet |
| 2398 | 2389 | */ |
| 2399 | - public function setRightToLeft($value = false) | |
| 2400 | - { | |
| 2401 | - $this->rightToLeft = $value; | |
| 2390 | + public function setRightToLeft($value = false) { | |
| 2391 | + $this->_rightToLeft = $value; | |
| 2402 | 2392 | return $this; |
| 2403 | 2393 | } |
| 2404 | 2394 | |
| 2405 | 2395 | /** |
| @@ -2411,10 +2401,9 @@ | ||
| 2411 | 2401 | * @param boolean $strictNullComparison Apply strict comparison when testing for null values in the array |
| 2412 | 2402 | * @throws PHPExcel_Exception |
| 2413 | 2403 | * @return PHPExcel_Worksheet |
| 2414 | 2404 | */ |
| 2415 | - public function fromArray($source = null, $nullValue = null, $startCell = 'A1', $strictNullComparison = false) | |
| 2416 | - { | |
| 2405 | + public function fromArray($source = null, $nullValue = null, $startCell = 'A1', $strictNullComparison = false) { | |
| 2417 | 2406 | if (is_array($source)) { |
| 2418 | 2407 | // Convert a 1-D array to 2-D (for ease of looping) |
| 2419 | 2408 | if (!is_array(end($source))) { |
| 2420 | 2409 | $source = array($source); |
| @@ -2425,9 +2414,9 @@ | ||
| 2425 | 2414 | |
| 2426 | 2415 | // Loop through $source |
| 2427 | 2416 | foreach ($source as $rowData) { |
| 2428 | 2417 | $currentColumn = $startColumn; |
| 2429 | - foreach ($rowData as $cellValue) { | |
| 2418 | + foreach($rowData as $cellValue) { | |
| 2430 | 2419 | if ($strictNullComparison) { |
| 2431 | 2420 | if ($cellValue !== $nullValue) { |
| 2432 | 2421 | // Set cell value |
| 2433 | 2422 | $this->getCell($currentColumn . $startRow)->setValue($cellValue); |
| @@ -2458,10 +2447,9 @@ | ||
| 2458 | 2447 | * @param boolean $returnCellRef False - Return a simple array of rows and columns indexed by number counting from zero |
| 2459 | 2448 | * True - Return rows and columns indexed by their actual row and column IDs |
| 2460 | 2449 | * @return array |
| 2461 | 2450 | */ |
| 2462 | - public function rangeToArray($pRange = 'A1', $nullValue = null, $calculateFormulas = true, $formatData = true, $returnCellRef = false) | |
| 2463 | - { | |
| 2451 | + public function rangeToArray($pRange = 'A1', $nullValue = null, $calculateFormulas = true, $formatData = true, $returnCellRef = false) { | |
| 2464 | 2452 | // Returnvalue |
| 2465 | 2453 | $returnValue = array(); |
| 2466 | 2454 | // Identify the range that we need to extract from the worksheet |
| 2467 | 2455 | list($rangeStart, $rangeEnd) = PHPExcel_Cell::rangeBoundaries($pRange); |
| @@ -2479,12 +2467,12 @@ | ||
| 2479 | 2467 | // Loop through columns in the current row |
| 2480 | 2468 | for ($col = $minCol; $col != $maxCol; ++$col) { |
| 2481 | 2469 | $cRef = ($returnCellRef) ? $col : ++$c; |
| 2482 | 2470 | // Using getCell() will create a new cell if it doesn't already exist. We don't want that to happen |
| 2483 | - // so we test and retrieve directly against cellCollection | |
| 2484 | - if ($this->cellCollection->isDataSet($col.$row)) { | |
| 2471 | + // so we test and retrieve directly against _cellCollection | |
| 2472 | + if ($this->_cellCollection->isDataSet($col.$row)) { | |
| 2485 | 2473 | // Cell exists |
| 2486 | - $cell = $this->cellCollection->getCacheData($col.$row); | |
| 2474 | + $cell = $this->_cellCollection->getCacheData($col.$row); | |
| 2487 | 2475 | if ($cell->getValue() !== null) { |
| 2488 | 2476 | if ($cell->getValue() instanceof PHPExcel_RichText) { |
| 2489 | 2477 | $returnValue[$rRef][$cRef] = $cell->getValue()->getPlainText(); |
| 2490 | 2478 | } else { |
| @@ -2495,12 +2483,14 @@ | ||
| 2495 | 2483 | } |
| 2496 | 2484 | } |
| 2497 | 2485 | |
| 2498 | 2486 | if ($formatData) { |
| 2499 | - $style = $this->parent->getCellXfByIndex($cell->getXfIndex()); | |
| 2487 | + $style = $this->_parent->getCellXfByIndex($cell->getXfIndex()); | |
| 2500 | 2488 | $returnValue[$rRef][$cRef] = PHPExcel_Style_NumberFormat::toFormattedString( |
| 2501 | - $returnValue[$rRef][$cRef], | |
| 2502 | - ($style && $style->getNumberFormat()) ? $style->getNumberFormat()->getFormatCode() : PHPExcel_Style_NumberFormat::FORMAT_GENERAL | |
| 2489 | + $returnValue[$rRef][$cRef], | |
| 2490 | + ($style && $style->getNumberFormat()) ? | |
| 2491 | + $style->getNumberFormat()->getFormatCode() : | |
| 2492 | + PHPExcel_Style_NumberFormat::FORMAT_GENERAL | |
| 2503 | 2493 | ); |
| 2504 | 2494 | } |
| 2505 | 2495 | } else { |
| 2506 | 2496 | // Cell holds a NULL |
| @@ -2529,16 +2519,16 @@ | ||
| 2529 | 2519 | * True - Return rows and columns indexed by their actual row and column IDs |
| 2530 | 2520 | * @return array |
| 2531 | 2521 | * @throws PHPExcel_Exception |
| 2532 | 2522 | */ |
| 2533 | - public function namedRangeToArray($pNamedRange = '', $nullValue = null, $calculateFormulas = true, $formatData = true, $returnCellRef = false) | |
| 2534 | - { | |
| 2523 | + public function namedRangeToArray($pNamedRange = '', $nullValue = null, $calculateFormulas = true, $formatData = true, $returnCellRef = false) { | |
| 2535 | 2524 | $namedRange = PHPExcel_NamedRange::resolveRange($pNamedRange, $this); |
| 2536 | - if ($namedRange !== null) { | |
| 2525 | + if ($namedRange !== NULL) { | |
| 2537 | 2526 | $pWorkSheet = $namedRange->getWorksheet(); |
| 2538 | 2527 | $pCellRange = $namedRange->getRange(); |
| 2539 | 2528 | |
| 2540 | - return $pWorkSheet->rangeToArray($pCellRange, $nullValue, $calculateFormulas, $formatData, $returnCellRef); | |
| 2529 | + return $pWorkSheet->rangeToArray( $pCellRange, | |
| 2530 | + $nullValue, $calculateFormulas, $formatData, $returnCellRef); | |
| 2541 | 2531 | } |
| 2542 | 2532 | |
| 2543 | 2533 | throw new PHPExcel_Exception('Named Range '.$pNamedRange.' does not exist.'); |
| 2544 | 2534 | } |
| @@ -2553,10 +2543,9 @@ | ||
| 2553 | 2543 | * @param boolean $returnCellRef False - Return a simple array of rows and columns indexed by number counting from zero |
| 2554 | 2544 | * True - Return rows and columns indexed by their actual row and column IDs |
| 2555 | 2545 | * @return array |
| 2556 | 2546 | */ |
| 2557 | - public function toArray($nullValue = null, $calculateFormulas = true, $formatData = true, $returnCellRef = false) | |
| 2558 | - { | |
| 2547 | + public function toArray($nullValue = null, $calculateFormulas = true, $formatData = true, $returnCellRef = false) { | |
| 2559 | 2548 | // Garbage collect... |
| 2560 | 2549 | $this->garbageCollect(); |
| 2561 | 2550 | |
| 2562 | 2551 | // Identify the range that we need to extract from the worksheet |
| @@ -2562,9 +2551,10 @@ | ||
| 2562 | 2551 | // Identify the range that we need to extract from the worksheet |
| 2563 | 2552 | $maxCol = $this->getHighestColumn(); |
| 2564 | 2553 | $maxRow = $this->getHighestRow(); |
| 2565 | 2554 | // Return |
| 2566 | - return $this->rangeToArray('A1:'.$maxCol.$maxRow, $nullValue, $calculateFormulas, $formatData, $returnCellRef); | |
| 2555 | + return $this->rangeToArray( 'A1:'.$maxCol.$maxRow, | |
| 2556 | + $nullValue, $calculateFormulas, $formatData, $returnCellRef); | |
| 2567 | 2557 | } |
| 2568 | 2558 | |
| 2569 | 2559 | /** |
| 2570 | 2560 | * Get row iterator |
| @@ -2573,10 +2563,9 @@ | ||
| 2573 | 2563 | * @param integer $endRow The row number at which to stop iterating |
| 2574 | 2564 | * |
| 2575 | 2565 | * @return PHPExcel_Worksheet_RowIterator |
| 2576 | 2566 | */ |
| 2577 | - public function getRowIterator($startRow = 1, $endRow = null) | |
| 2578 | - { | |
| 2567 | + public function getRowIterator($startRow = 1, $endRow = null) { | |
| 2579 | 2568 | return new PHPExcel_Worksheet_RowIterator($this, $startRow, $endRow); |
| 2580 | 2569 | } |
| 2581 | 2570 | |
| 2582 | 2571 | /** |
| @@ -2586,10 +2575,9 @@ | ||
| 2586 | 2575 | * @param string $endColumn The column address at which to stop iterating |
| 2587 | 2576 | * |
| 2588 | 2577 | * @return PHPExcel_Worksheet_ColumnIterator |
| 2589 | 2578 | */ |
| 2590 | - public function getColumnIterator($startColumn = 'A', $endColumn = null) | |
| 2591 | - { | |
| 2579 | + public function getColumnIterator($startColumn = 'A', $endColumn = null) { | |
| 2592 | 2580 | return new PHPExcel_Worksheet_ColumnIterator($this, $startColumn, $endColumn); |
| 2593 | 2581 | } |
| 2594 | 2582 | |
| 2595 | 2583 | /** |
| @@ -2596,12 +2584,11 @@ | ||
| 2596 | 2584 | * Run PHPExcel garabage collector. |
| 2597 | 2585 | * |
| 2598 | 2586 | * @return PHPExcel_Worksheet |
| 2599 | 2587 | */ |
| 2600 | - public function garbageCollect() | |
| 2601 | - { | |
| 2588 | + public function garbageCollect() { | |
| 2602 | 2589 | // Flush cache |
| 2603 | - $this->cellCollection->getCacheData('A1'); | |
| 2590 | + $this->_cellCollection->getCacheData('A1'); | |
| 2604 | 2591 | // Build a reference table from images |
| 2605 | 2592 | // $imageCoordinates = array(); |
| 2606 | 2593 | // $iterator = $this->getDrawingCollection()->getIterator(); |
| 2607 | 2594 | // while ($iterator->valid()) { |
| @@ -2610,29 +2597,29 @@ | ||
| 2610 | 2597 | // $iterator->next(); |
| 2611 | 2598 | // } |
| 2612 | 2599 | // |
| 2613 | 2600 | // Lookup highest column and highest row if cells are cleaned |
| 2614 | - $colRow = $this->cellCollection->getHighestRowAndColumn(); | |
| 2601 | + $colRow = $this->_cellCollection->getHighestRowAndColumn(); | |
| 2615 | 2602 | $highestRow = $colRow['row']; |
| 2616 | 2603 | $highestColumn = PHPExcel_Cell::columnIndexFromString($colRow['column']); |
| 2617 | 2604 | |
| 2618 | 2605 | // Loop through column dimensions |
| 2619 | - foreach ($this->columnDimensions as $dimension) { | |
| 2620 | - $highestColumn = max($highestColumn, PHPExcel_Cell::columnIndexFromString($dimension->getColumnIndex())); | |
| 2606 | + foreach ($this->_columnDimensions as $dimension) { | |
| 2607 | + $highestColumn = max($highestColumn,PHPExcel_Cell::columnIndexFromString($dimension->getColumnIndex())); | |
| 2621 | 2608 | } |
| 2622 | 2609 | |
| 2623 | 2610 | // Loop through row dimensions |
| 2624 | - foreach ($this->rowDimensions as $dimension) { | |
| 2625 | - $highestRow = max($highestRow, $dimension->getRowIndex()); | |
| 2611 | + foreach ($this->_rowDimensions as $dimension) { | |
| 2612 | + $highestRow = max($highestRow,$dimension->getRowIndex()); | |
| 2626 | 2613 | } |
| 2627 | 2614 | |
| 2628 | 2615 | // Cache values |
| 2629 | 2616 | if ($highestColumn < 0) { |
| 2630 | - $this->cachedHighestColumn = 'A'; | |
| 2617 | + $this->_cachedHighestColumn = 'A'; | |
| 2631 | 2618 | } else { |
| 2632 | - $this->cachedHighestColumn = PHPExcel_Cell::stringFromColumnIndex(--$highestColumn); | |
| 2619 | + $this->_cachedHighestColumn = PHPExcel_Cell::stringFromColumnIndex(--$highestColumn); | |
| 2633 | 2620 | } |
| 2634 | - $this->cachedHighestRow = $highestRow; | |
| 2621 | + $this->_cachedHighestRow = $highestRow; | |
| 2635 | 2622 | |
| 2636 | 2623 | // Return |
| 2637 | 2624 | return $this; |
| 2638 | 2625 | } |
| @@ -2641,15 +2628,18 @@ | ||
| 2641 | 2628 | * Get hash code |
| 2642 | 2629 | * |
| 2643 | 2630 | * @return string Hash code |
| 2644 | 2631 | */ |
| 2645 | - public function getHashCode() | |
| 2646 | - { | |
| 2647 | - if ($this->dirty) { | |
| 2648 | - $this->hash = md5($this->title . $this->autoFilter . ($this->protection->isProtectionEnabled() ? 't' : 'f') . __CLASS__); | |
| 2649 | - $this->dirty = false; | |
| 2632 | + public function getHashCode() { | |
| 2633 | + if ($this->_dirty) { | |
| 2634 | + $this->_hash = md5( $this->_title . | |
| 2635 | + $this->_autoFilter . | |
| 2636 | + ($this->_protection->isProtectionEnabled() ? 't' : 'f') . | |
| 2637 | + __CLASS__ | |
| 2638 | + ); | |
| 2639 | + $this->_dirty = false; | |
| 2650 | 2640 | } |
| 2651 | - return $this->hash; | |
| 2641 | + return $this->_hash; | |
| 2652 | 2642 | } |
| 2653 | 2643 | |
| 2654 | 2644 | /** |
| 2655 | 2645 | * Extract worksheet title from range. |
| @@ -2660,10 +2650,9 @@ | ||
| 2660 | 2650 | * @param string $pRange Range to extract title from |
| 2661 | 2651 | * @param bool $returnRange Return range? (see example) |
| 2662 | 2652 | * @return mixed |
| 2663 | 2653 | */ |
| 2664 | - public static function extractSheetTitle($pRange, $returnRange = false) | |
| 2665 | - { | |
| 2654 | + public static function extractSheetTitle($pRange, $returnRange = false) { | |
| 2666 | 2655 | // Sheet title included? |
| 2667 | 2656 | if (($sep = strpos($pRange, '!')) === false) { |
| 2668 | 2657 | return ''; |
| 2669 | 2658 | } |
| @@ -2668,9 +2657,11 @@ | ||
| 2668 | 2657 | return ''; |
| 2669 | 2658 | } |
| 2670 | 2659 | |
| 2671 | 2660 | if ($returnRange) { |
| 2672 | - return array(trim(substr($pRange, 0, $sep), "'"), substr($pRange, $sep + 1)); | |
| 2661 | + return array( trim(substr($pRange, 0, $sep),"'"), | |
| 2662 | + substr($pRange, $sep + 1) | |
| 2663 | + ); | |
| 2673 | 2664 | } |
| 2674 | 2665 | |
| 2675 | 2666 | return substr($pRange, $sep + 1); |
| 2676 | 2667 | } |
| @@ -2682,15 +2673,15 @@ | ||
| 2682 | 2673 | */ |
| 2683 | 2674 | public function getHyperlink($pCellCoordinate = 'A1') |
| 2684 | 2675 | { |
| 2685 | 2676 | // return hyperlink if we already have one |
| 2686 | - if (isset($this->hyperlinkCollection[$pCellCoordinate])) { | |
| 2687 | - return $this->hyperlinkCollection[$pCellCoordinate]; | |
| 2677 | + if (isset($this->_hyperlinkCollection[$pCellCoordinate])) { | |
| 2678 | + return $this->_hyperlinkCollection[$pCellCoordinate]; | |
| 2688 | 2679 | } |
| 2689 | 2680 | |
| 2690 | 2681 | // else create hyperlink |
| 2691 | - $this->hyperlinkCollection[$pCellCoordinate] = new PHPExcel_Cell_Hyperlink(); | |
| 2692 | - return $this->hyperlinkCollection[$pCellCoordinate]; | |
| 2682 | + $this->_hyperlinkCollection[$pCellCoordinate] = new PHPExcel_Cell_Hyperlink(); | |
| 2683 | + return $this->_hyperlinkCollection[$pCellCoordinate]; | |
| 2693 | 2684 | } |
| 2694 | 2685 | |
| 2695 | 2686 | /** |
| 2696 | 2687 | * Set hyperlnk |
| @@ -2701,11 +2692,11 @@ | ||
| 2701 | 2692 | */ |
| 2702 | 2693 | public function setHyperlink($pCellCoordinate = 'A1', PHPExcel_Cell_Hyperlink $pHyperlink = null) |
| 2703 | 2694 | { |
| 2704 | 2695 | if ($pHyperlink === null) { |
| 2705 | - unset($this->hyperlinkCollection[$pCellCoordinate]); | |
| 2696 | + unset($this->_hyperlinkCollection[$pCellCoordinate]); | |
| 2706 | 2697 | } else { |
| 2707 | - $this->hyperlinkCollection[$pCellCoordinate] = $pHyperlink; | |
| 2698 | + $this->_hyperlinkCollection[$pCellCoordinate] = $pHyperlink; | |
| 2708 | 2699 | } |
| 2709 | 2700 | return $this; |
| 2710 | 2701 | } |
| 2711 | 2702 | |
| @@ -2716,9 +2707,9 @@ | ||
| 2716 | 2707 | * @return boolean |
| 2717 | 2708 | */ |
| 2718 | 2709 | public function hyperlinkExists($pCoordinate = 'A1') |
| 2719 | 2710 | { |
| 2720 | - return isset($this->hyperlinkCollection[$pCoordinate]); | |
| 2711 | + return isset($this->_hyperlinkCollection[$pCoordinate]); | |
| 2721 | 2712 | } |
| 2722 | 2713 | |
| 2723 | 2714 | /** |
| 2724 | 2715 | * Get collection of hyperlinks |
| @@ -2726,9 +2717,9 @@ | ||
| 2726 | 2717 | * @return PHPExcel_Cell_Hyperlink[] |
| 2727 | 2718 | */ |
| 2728 | 2719 | public function getHyperlinkCollection() |
| 2729 | 2720 | { |
| 2730 | - return $this->hyperlinkCollection; | |
| 2721 | + return $this->_hyperlinkCollection; | |
| 2731 | 2722 | } |
| 2732 | 2723 | |
| 2733 | 2724 | /** |
| 2734 | 2725 | * Get data validation |
| @@ -2737,15 +2728,15 @@ | ||
| 2737 | 2728 | */ |
| 2738 | 2729 | public function getDataValidation($pCellCoordinate = 'A1') |
| 2739 | 2730 | { |
| 2740 | 2731 | // return data validation if we already have one |
| 2741 | - if (isset($this->dataValidationCollection[$pCellCoordinate])) { | |
| 2742 | - return $this->dataValidationCollection[$pCellCoordinate]; | |
| 2732 | + if (isset($this->_dataValidationCollection[$pCellCoordinate])) { | |
| 2733 | + return $this->_dataValidationCollection[$pCellCoordinate]; | |
| 2743 | 2734 | } |
| 2744 | 2735 | |
| 2745 | 2736 | // else create data validation |
| 2746 | - $this->dataValidationCollection[$pCellCoordinate] = new PHPExcel_Cell_DataValidation(); | |
| 2747 | - return $this->dataValidationCollection[$pCellCoordinate]; | |
| 2737 | + $this->_dataValidationCollection[$pCellCoordinate] = new PHPExcel_Cell_DataValidation(); | |
| 2738 | + return $this->_dataValidationCollection[$pCellCoordinate]; | |
| 2748 | 2739 | } |
| 2749 | 2740 | |
| 2750 | 2741 | /** |
| 2751 | 2742 | * Set data validation |
| @@ -2756,11 +2747,11 @@ | ||
| 2756 | 2747 | */ |
| 2757 | 2748 | public function setDataValidation($pCellCoordinate = 'A1', PHPExcel_Cell_DataValidation $pDataValidation = null) |
| 2758 | 2749 | { |
| 2759 | 2750 | if ($pDataValidation === null) { |
| 2760 | - unset($this->dataValidationCollection[$pCellCoordinate]); | |
| 2751 | + unset($this->_dataValidationCollection[$pCellCoordinate]); | |
| 2761 | 2752 | } else { |
| 2762 | - $this->dataValidationCollection[$pCellCoordinate] = $pDataValidation; | |
| 2753 | + $this->_dataValidationCollection[$pCellCoordinate] = $pDataValidation; | |
| 2763 | 2754 | } |
| 2764 | 2755 | return $this; |
| 2765 | 2756 | } |
| 2766 | 2757 | |
| @@ -2771,9 +2762,9 @@ | ||
| 2771 | 2762 | * @return boolean |
| 2772 | 2763 | */ |
| 2773 | 2764 | public function dataValidationExists($pCoordinate = 'A1') |
| 2774 | 2765 | { |
| 2775 | - return isset($this->dataValidationCollection[$pCoordinate]); | |
| 2766 | + return isset($this->_dataValidationCollection[$pCoordinate]); | |
| 2776 | 2767 | } |
| 2777 | 2768 | |
| 2778 | 2769 | /** |
| 2779 | 2770 | * Get collection of data validations |
| @@ -2781,9 +2772,9 @@ | ||
| 2781 | 2772 | * @return PHPExcel_Cell_DataValidation[] |
| 2782 | 2773 | */ |
| 2783 | 2774 | public function getDataValidationCollection() |
| 2784 | 2775 | { |
| 2785 | - return $this->dataValidationCollection; | |
| 2776 | + return $this->_dataValidationCollection; | |
| 2786 | 2777 | } |
| 2787 | 2778 | |
| 2788 | 2779 | /** |
| 2789 | 2780 | * Accepts a range, returning it as a range that falls within the current highest row and column of the worksheet |
| @@ -2790,34 +2781,25 @@ | ||
| 2790 | 2781 | * |
| 2791 | 2782 | * @param string $range |
| 2792 | 2783 | * @return string Adjusted range value |
| 2793 | 2784 | */ |
| 2794 | - public function shrinkRangeToFit($range) | |
| 2795 | - { | |
| 2785 | + public function shrinkRangeToFit($range) { | |
| 2796 | 2786 | $maxCol = $this->getHighestColumn(); |
| 2797 | 2787 | $maxRow = $this->getHighestRow(); |
| 2798 | 2788 | $maxCol = PHPExcel_Cell::columnIndexFromString($maxCol); |
| 2799 | 2789 | |
| 2800 | - $rangeBlocks = explode(' ', $range); | |
| 2790 | + $rangeBlocks = explode(' ',$range); | |
| 2801 | 2791 | foreach ($rangeBlocks as &$rangeSet) { |
| 2802 | 2792 | $rangeBoundaries = PHPExcel_Cell::getRangeBoundaries($rangeSet); |
| 2803 | 2793 | |
| 2804 | - if (PHPExcel_Cell::columnIndexFromString($rangeBoundaries[0][0]) > $maxCol) { | |
| 2805 | - $rangeBoundaries[0][0] = PHPExcel_Cell::stringFromColumnIndex($maxCol); | |
| 2806 | - } | |
| 2807 | - if ($rangeBoundaries[0][1] > $maxRow) { | |
| 2808 | - $rangeBoundaries[0][1] = $maxRow; | |
| 2809 | - } | |
| 2810 | - if (PHPExcel_Cell::columnIndexFromString($rangeBoundaries[1][0]) > $maxCol) { | |
| 2811 | - $rangeBoundaries[1][0] = PHPExcel_Cell::stringFromColumnIndex($maxCol); | |
| 2812 | - } | |
| 2813 | - if ($rangeBoundaries[1][1] > $maxRow) { | |
| 2814 | - $rangeBoundaries[1][1] = $maxRow; | |
| 2815 | - } | |
| 2794 | + if (PHPExcel_Cell::columnIndexFromString($rangeBoundaries[0][0]) > $maxCol) { $rangeBoundaries[0][0] = PHPExcel_Cell::stringFromColumnIndex($maxCol); } | |
| 2795 | + if ($rangeBoundaries[0][1] > $maxRow) { $rangeBoundaries[0][1] = $maxRow; } | |
| 2796 | + if (PHPExcel_Cell::columnIndexFromString($rangeBoundaries[1][0]) > $maxCol) { $rangeBoundaries[1][0] = PHPExcel_Cell::stringFromColumnIndex($maxCol); } | |
| 2797 | + if ($rangeBoundaries[1][1] > $maxRow) { $rangeBoundaries[1][1] = $maxRow; } | |
| 2816 | 2798 | $rangeSet = $rangeBoundaries[0][0].$rangeBoundaries[0][1].':'.$rangeBoundaries[1][0].$rangeBoundaries[1][1]; |
| 2817 | 2799 | } |
| 2818 | 2800 | unset($rangeSet); |
| 2819 | - $stRange = implode(' ', $rangeBlocks); | |
| 2801 | + $stRange = implode(' ',$rangeBlocks); | |
| 2820 | 2802 | |
| 2821 | 2803 | return $stRange; |
| 2822 | 2804 | } |
| 2823 | 2805 | |
| @@ -2827,12 +2809,12 @@ | ||
| 2827 | 2809 | * @return PHPExcel_Style_Color |
| 2828 | 2810 | */ |
| 2829 | 2811 | public function getTabColor() |
| 2830 | 2812 | { |
| 2831 | - if ($this->tabColor === null) { | |
| 2832 | - $this->tabColor = new PHPExcel_Style_Color(); | |
| 2833 | - } | |
| 2834 | - return $this->tabColor; | |
| 2813 | + if ($this->_tabColor === NULL) | |
| 2814 | + $this->_tabColor = new PHPExcel_Style_Color(); | |
| 2815 | + | |
| 2816 | + return $this->_tabColor; | |
| 2835 | 2817 | } |
| 2836 | 2818 | |
| 2837 | 2819 | /** |
| 2838 | 2820 | * Reset tab color |
| @@ -2840,10 +2822,10 @@ | ||
| 2840 | 2822 | * @return PHPExcel_Worksheet |
| 2841 | 2823 | */ |
| 2842 | 2824 | public function resetTabColor() |
| 2843 | 2825 | { |
| 2844 | - $this->tabColor = null; | |
| 2845 | - unset($this->tabColor); | |
| 2826 | + $this->_tabColor = null; | |
| 2827 | + unset($this->_tabColor); | |
| 2846 | 2828 | |
| 2847 | 2829 | return $this; |
| 2848 | 2830 | } |
| 2849 | 2831 | |
| @@ -2853,9 +2835,9 @@ | ||
| 2853 | 2835 | * @return boolean |
| 2854 | 2836 | */ |
| 2855 | 2837 | public function isTabColorSet() |
| 2856 | 2838 | { |
| 2857 | - return ($this->tabColor !== null); | |
| 2839 | + return ($this->_tabColor !== NULL); | |
| 2858 | 2840 | } |
| 2859 | 2841 | |
| 2860 | 2842 | /** |
| 2861 | 2843 | * Copy worksheet (!= clone!) |
| @@ -2861,10 +2843,9 @@ | ||
| 2861 | 2843 | * Copy worksheet (!= clone!) |
| 2862 | 2844 | * |
| 2863 | 2845 | * @return PHPExcel_Worksheet |
| 2864 | 2846 | */ |
| 2865 | - public function copy() | |
| 2866 | - { | |
| 2847 | + public function copy() { | |
| 2867 | 2848 | $copied = clone $this; |
| 2868 | 2849 | |
| 2869 | 2850 | return $copied; |
| 2870 | 2851 | } |
| @@ -2871,27 +2852,26 @@ | ||
| 2871 | 2852 | |
| 2872 | 2853 | /** |
| 2873 | 2854 | * Implement PHP __clone to create a deep clone, not just a shallow copy. |
| 2874 | 2855 | */ |
| 2875 | - public function __clone() | |
| 2876 | - { | |
| 2856 | + public function __clone() { | |
| 2877 | 2857 | foreach ($this as $key => $val) { |
| 2878 | - if ($key == 'parent') { | |
| 2858 | + if ($key == '_parent') { | |
| 2879 | 2859 | continue; |
| 2880 | 2860 | } |
| 2881 | 2861 | |
| 2882 | 2862 | if (is_object($val) || (is_array($val))) { |
| 2883 | - if ($key == 'cellCollection') { | |
| 2884 | - $newCollection = clone $this->cellCollection; | |
| 2863 | + if ($key == '_cellCollection') { | |
| 2864 | + $newCollection = clone $this->_cellCollection; | |
| 2885 | 2865 | $newCollection->copyCellCollection($this); |
| 2886 | - $this->cellCollection = $newCollection; | |
| 2887 | - } elseif ($key == 'drawingCollection') { | |
| 2888 | - $newCollection = clone $this->drawingCollection; | |
| 2889 | - $this->drawingCollection = $newCollection; | |
| 2890 | - } elseif (($key == 'autoFilter') && ($this->autoFilter instanceof PHPExcel_Worksheet_AutoFilter)) { | |
| 2891 | - $newAutoFilter = clone $this->autoFilter; | |
| 2892 | - $this->autoFilter = $newAutoFilter; | |
| 2893 | - $this->autoFilter->setParent($this); | |
| 2866 | + $this->_cellCollection = $newCollection; | |
| 2867 | + } elseif ($key == '_drawingCollection') { | |
| 2868 | + $newCollection = clone $this->_drawingCollection; | |
| 2869 | + $this->_drawingCollection = $newCollection; | |
| 2870 | + } elseif (($key == '_autoFilter') && ($this->_autoFilter instanceof PHPExcel_Worksheet_AutoFilter)) { | |
| 2871 | + $newAutoFilter = clone $this->_autoFilter; | |
| 2872 | + $this->_autoFilter = $newAutoFilter; | |
| 2873 | + $this->_autoFilter->setParent($this); | |
| 2894 | 2874 | } else { |
| 2895 | 2875 | $this->{$key} = unserialize(serialize($val)); |
| 2896 | 2876 | } |
| 2897 | 2877 | } |
| @@ -2897,72 +2877,69 @@ | ||
| 2897 | 2877 | } |
| 2898 | 2878 | } |
| 2899 | 2879 | } |
| 2900 | 2880 | /** |
| 2901 | - * Define the code name of the sheet | |
| 2902 | - * | |
| 2903 | - * @param null|string Same rule as Title minus space not allowed (but, like Excel, change silently space to underscore) | |
| 2904 | - * @return objWorksheet | |
| 2905 | - * @throws PHPExcel_Exception | |
| 2906 | - */ | |
| 2907 | - public function setCodeName($pValue = null) | |
| 2908 | - { | |
| 2909 | - // Is this a 'rename' or not? | |
| 2910 | - if ($this->getCodeName() == $pValue) { | |
| 2911 | - return $this; | |
| 2912 | - } | |
| 2913 | - $pValue = str_replace(' ', '_', $pValue);//Excel does this automatically without flinching, we are doing the same | |
| 2914 | - // Syntax check | |
| 2881 | + * Define the code name of the sheet | |
| 2882 | + * | |
| 2883 | + * @param null|string Same rule as Title minus space not allowed (but, like Excel, change silently space to underscore) | |
| 2884 | + * @return objWorksheet | |
| 2885 | + * @throws PHPExcel_Exception | |
| 2886 | + */ | |
| 2887 | + public function setCodeName($pValue=null){ | |
| 2888 | + // Is this a 'rename' or not? | |
| 2889 | + if ($this->getCodeName() == $pValue) { | |
| 2890 | + return $this; | |
| 2891 | + } | |
| 2892 | + $pValue = str_replace(' ', '_', $pValue);//Excel does this automatically without flinching, we are doing the same | |
| 2893 | + // Syntax check | |
| 2915 | 2894 | // throw an exception if not valid |
| 2916 | - self::checkSheetCodeName($pValue); | |
| 2895 | + self::_checkSheetCodeName($pValue); | |
| 2917 | 2896 | |
| 2918 | - // We use the same code that setTitle to find a valid codeName else not using a space (Excel don't like) but a '_' | |
| 2919 | - | |
| 2897 | + // We use the same code that setTitle to find a valid codeName else not using a space (Excel don't like) but a '_' | |
| 2898 | + | |
| 2920 | 2899 | if ($this->getParent()) { |
| 2921 | - // Is there already such sheet name? | |
| 2922 | - if ($this->getParent()->sheetCodeNameExists($pValue)) { | |
| 2923 | - // Use name, but append with lowest possible integer | |
| 2900 | + // Is there already such sheet name? | |
| 2901 | + if ($this->getParent()->sheetCodeNameExists($pValue)) { | |
| 2902 | + // Use name, but append with lowest possible integer | |
| 2924 | 2903 | |
| 2925 | - if (PHPExcel_Shared_String::CountCharacters($pValue) > 29) { | |
| 2926 | - $pValue = PHPExcel_Shared_String::Substring($pValue, 0, 29); | |
| 2927 | - } | |
| 2928 | - $i = 1; | |
| 2929 | - while ($this->getParent()->sheetCodeNameExists($pValue . '_' . $i)) { | |
| 2930 | - ++$i; | |
| 2931 | - if ($i == 10) { | |
| 2932 | - if (PHPExcel_Shared_String::CountCharacters($pValue) > 28) { | |
| 2933 | - $pValue = PHPExcel_Shared_String::Substring($pValue, 0, 28); | |
| 2934 | - } | |
| 2935 | - } elseif ($i == 100) { | |
| 2936 | - if (PHPExcel_Shared_String::CountCharacters($pValue) > 27) { | |
| 2937 | - $pValue = PHPExcel_Shared_String::Substring($pValue, 0, 27); | |
| 2938 | - } | |
| 2939 | - } | |
| 2940 | - } | |
| 2904 | + if (PHPExcel_Shared_String::CountCharacters($pValue) > 29) { | |
| 2905 | + $pValue = PHPExcel_Shared_String::Substring($pValue,0,29); | |
| 2906 | + } | |
| 2907 | + $i = 1; | |
| 2908 | + while ($this->getParent()->sheetCodeNameExists($pValue . '_' . $i)) { | |
| 2909 | + ++$i; | |
| 2910 | + if ($i == 10) { | |
| 2911 | + if (PHPExcel_Shared_String::CountCharacters($pValue) > 28) { | |
| 2912 | + $pValue = PHPExcel_Shared_String::Substring($pValue,0,28); | |
| 2913 | + } | |
| 2914 | + } elseif ($i == 100) { | |
| 2915 | + if (PHPExcel_Shared_String::CountCharacters($pValue) > 27) { | |
| 2916 | + $pValue = PHPExcel_Shared_String::Substring($pValue,0,27); | |
| 2917 | + } | |
| 2918 | + } | |
| 2919 | + } | |
| 2941 | 2920 | |
| 2942 | - $pValue = $pValue . '_' . $i;// ok, we have a valid name | |
| 2943 | - //codeName is'nt used in formula : no need to call for an update | |
| 2944 | - //return $this->setTitle($altTitle, $updateFormulaCellReferences); | |
| 2945 | - } | |
| 2946 | - } | |
| 2921 | + $pValue = $pValue . '_' . $i;// ok, we have a valid name | |
| 2922 | + //codeName is'nt used in formula : no need to call for an update | |
| 2923 | + //return $this->setTitle($altTitle,$updateFormulaCellReferences); | |
| 2924 | + } | |
| 2925 | + } | |
| 2947 | 2926 | |
| 2948 | - $this->codeName=$pValue; | |
| 2949 | - return $this; | |
| 2950 | - } | |
| 2951 | - /** | |
| 2952 | - * Return the code name of the sheet | |
| 2953 | - * | |
| 2954 | - * @return null|string | |
| 2955 | - */ | |
| 2956 | - public function getCodeName() | |
| 2957 | - { | |
| 2958 | - return $this->codeName; | |
| 2959 | - } | |
| 2960 | - /** | |
| 2961 | - * Sheet has a code name ? | |
| 2962 | - * @return boolean | |
| 2963 | - */ | |
| 2964 | - public function hasCodeName() | |
| 2965 | - { | |
| 2966 | - return !(is_null($this->codeName)); | |
| 2967 | - } | |
| 2927 | + $this->_codeName=$pValue; | |
| 2928 | + return $this; | |
| 2929 | + } | |
| 2930 | + /** | |
| 2931 | + * Return the code name of the sheet | |
| 2932 | + * | |
| 2933 | + * @return null|string | |
| 2934 | + */ | |
| 2935 | + public function getCodeName(){ | |
| 2936 | + return $this->_codeName; | |
| 2937 | + } | |
| 2938 | + /** | |
| 2939 | + * Sheet has a code name ? | |
| 2940 | + * @return boolean | |
| 2941 | + */ | |
| 2942 | + public function hasCodeName(){ | |
| 2943 | + return !(is_null($this->_codeName)); | |
| 2944 | + } | |
| 2968 | 2945 | } |