[ Index ] |
PHP Cross Reference of moodle-2.8 |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * PHPExcel 4 * 5 * Copyright (c) 2006 - 2014 PHPExcel 6 * 7 * This library is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU Lesser General Public 9 * License as published by the Free Software Foundation; either 10 * version 2.1 of the License, or (at your option) any later version. 11 * 12 * This library is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 * Lesser General Public License for more details. 16 * 17 * You should have received a copy of the GNU Lesser General Public 18 * License along with this library; if not, write to the Free Software 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 20 * 21 * @category PHPExcel 22 * @package PHPExcel_Worksheet 23 * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) 24 * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL 25 * @version ##VERSION##, ##DATE## 26 */ 27 28 29 /** 30 * PHPExcel_Worksheet_PageSetup 31 * 32 * <code> 33 * Paper size taken from Office Open XML Part 4 - Markup Language Reference, page 1988: 34 * 35 * 1 = Letter paper (8.5 in. by 11 in.) 36 * 2 = Letter small paper (8.5 in. by 11 in.) 37 * 3 = Tabloid paper (11 in. by 17 in.) 38 * 4 = Ledger paper (17 in. by 11 in.) 39 * 5 = Legal paper (8.5 in. by 14 in.) 40 * 6 = Statement paper (5.5 in. by 8.5 in.) 41 * 7 = Executive paper (7.25 in. by 10.5 in.) 42 * 8 = A3 paper (297 mm by 420 mm) 43 * 9 = A4 paper (210 mm by 297 mm) 44 * 10 = A4 small paper (210 mm by 297 mm) 45 * 11 = A5 paper (148 mm by 210 mm) 46 * 12 = B4 paper (250 mm by 353 mm) 47 * 13 = B5 paper (176 mm by 250 mm) 48 * 14 = Folio paper (8.5 in. by 13 in.) 49 * 15 = Quarto paper (215 mm by 275 mm) 50 * 16 = Standard paper (10 in. by 14 in.) 51 * 17 = Standard paper (11 in. by 17 in.) 52 * 18 = Note paper (8.5 in. by 11 in.) 53 * 19 = #9 envelope (3.875 in. by 8.875 in.) 54 * 20 = #10 envelope (4.125 in. by 9.5 in.) 55 * 21 = #11 envelope (4.5 in. by 10.375 in.) 56 * 22 = #12 envelope (4.75 in. by 11 in.) 57 * 23 = #14 envelope (5 in. by 11.5 in.) 58 * 24 = C paper (17 in. by 22 in.) 59 * 25 = D paper (22 in. by 34 in.) 60 * 26 = E paper (34 in. by 44 in.) 61 * 27 = DL envelope (110 mm by 220 mm) 62 * 28 = C5 envelope (162 mm by 229 mm) 63 * 29 = C3 envelope (324 mm by 458 mm) 64 * 30 = C4 envelope (229 mm by 324 mm) 65 * 31 = C6 envelope (114 mm by 162 mm) 66 * 32 = C65 envelope (114 mm by 229 mm) 67 * 33 = B4 envelope (250 mm by 353 mm) 68 * 34 = B5 envelope (176 mm by 250 mm) 69 * 35 = B6 envelope (176 mm by 125 mm) 70 * 36 = Italy envelope (110 mm by 230 mm) 71 * 37 = Monarch envelope (3.875 in. by 7.5 in.). 72 * 38 = 6 3/4 envelope (3.625 in. by 6.5 in.) 73 * 39 = US standard fanfold (14.875 in. by 11 in.) 74 * 40 = German standard fanfold (8.5 in. by 12 in.) 75 * 41 = German legal fanfold (8.5 in. by 13 in.) 76 * 42 = ISO B4 (250 mm by 353 mm) 77 * 43 = Japanese double postcard (200 mm by 148 mm) 78 * 44 = Standard paper (9 in. by 11 in.) 79 * 45 = Standard paper (10 in. by 11 in.) 80 * 46 = Standard paper (15 in. by 11 in.) 81 * 47 = Invite envelope (220 mm by 220 mm) 82 * 50 = Letter extra paper (9.275 in. by 12 in.) 83 * 51 = Legal extra paper (9.275 in. by 15 in.) 84 * 52 = Tabloid extra paper (11.69 in. by 18 in.) 85 * 53 = A4 extra paper (236 mm by 322 mm) 86 * 54 = Letter transverse paper (8.275 in. by 11 in.) 87 * 55 = A4 transverse paper (210 mm by 297 mm) 88 * 56 = Letter extra transverse paper (9.275 in. by 12 in.) 89 * 57 = SuperA/SuperA/A4 paper (227 mm by 356 mm) 90 * 58 = SuperB/SuperB/A3 paper (305 mm by 487 mm) 91 * 59 = Letter plus paper (8.5 in. by 12.69 in.) 92 * 60 = A4 plus paper (210 mm by 330 mm) 93 * 61 = A5 transverse paper (148 mm by 210 mm) 94 * 62 = JIS B5 transverse paper (182 mm by 257 mm) 95 * 63 = A3 extra paper (322 mm by 445 mm) 96 * 64 = A5 extra paper (174 mm by 235 mm) 97 * 65 = ISO B5 extra paper (201 mm by 276 mm) 98 * 66 = A2 paper (420 mm by 594 mm) 99 * 67 = A3 transverse paper (297 mm by 420 mm) 100 * 68 = A3 extra transverse paper (322 mm by 445 mm) 101 * </code> 102 * 103 * @category PHPExcel 104 * @package PHPExcel_Worksheet 105 * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) 106 */ 107 class PHPExcel_Worksheet_PageSetup 108 { 109 /* Paper size */ 110 const PAPERSIZE_LETTER = 1; 111 const PAPERSIZE_LETTER_SMALL = 2; 112 const PAPERSIZE_TABLOID = 3; 113 const PAPERSIZE_LEDGER = 4; 114 const PAPERSIZE_LEGAL = 5; 115 const PAPERSIZE_STATEMENT = 6; 116 const PAPERSIZE_EXECUTIVE = 7; 117 const PAPERSIZE_A3 = 8; 118 const PAPERSIZE_A4 = 9; 119 const PAPERSIZE_A4_SMALL = 10; 120 const PAPERSIZE_A5 = 11; 121 const PAPERSIZE_B4 = 12; 122 const PAPERSIZE_B5 = 13; 123 const PAPERSIZE_FOLIO = 14; 124 const PAPERSIZE_QUARTO = 15; 125 const PAPERSIZE_STANDARD_1 = 16; 126 const PAPERSIZE_STANDARD_2 = 17; 127 const PAPERSIZE_NOTE = 18; 128 const PAPERSIZE_NO9_ENVELOPE = 19; 129 const PAPERSIZE_NO10_ENVELOPE = 20; 130 const PAPERSIZE_NO11_ENVELOPE = 21; 131 const PAPERSIZE_NO12_ENVELOPE = 22; 132 const PAPERSIZE_NO14_ENVELOPE = 23; 133 const PAPERSIZE_C = 24; 134 const PAPERSIZE_D = 25; 135 const PAPERSIZE_E = 26; 136 const PAPERSIZE_DL_ENVELOPE = 27; 137 const PAPERSIZE_C5_ENVELOPE = 28; 138 const PAPERSIZE_C3_ENVELOPE = 29; 139 const PAPERSIZE_C4_ENVELOPE = 30; 140 const PAPERSIZE_C6_ENVELOPE = 31; 141 const PAPERSIZE_C65_ENVELOPE = 32; 142 const PAPERSIZE_B4_ENVELOPE = 33; 143 const PAPERSIZE_B5_ENVELOPE = 34; 144 const PAPERSIZE_B6_ENVELOPE = 35; 145 const PAPERSIZE_ITALY_ENVELOPE = 36; 146 const PAPERSIZE_MONARCH_ENVELOPE = 37; 147 const PAPERSIZE_6_3_4_ENVELOPE = 38; 148 const PAPERSIZE_US_STANDARD_FANFOLD = 39; 149 const PAPERSIZE_GERMAN_STANDARD_FANFOLD = 40; 150 const PAPERSIZE_GERMAN_LEGAL_FANFOLD = 41; 151 const PAPERSIZE_ISO_B4 = 42; 152 const PAPERSIZE_JAPANESE_DOUBLE_POSTCARD = 43; 153 const PAPERSIZE_STANDARD_PAPER_1 = 44; 154 const PAPERSIZE_STANDARD_PAPER_2 = 45; 155 const PAPERSIZE_STANDARD_PAPER_3 = 46; 156 const PAPERSIZE_INVITE_ENVELOPE = 47; 157 const PAPERSIZE_LETTER_EXTRA_PAPER = 48; 158 const PAPERSIZE_LEGAL_EXTRA_PAPER = 49; 159 const PAPERSIZE_TABLOID_EXTRA_PAPER = 50; 160 const PAPERSIZE_A4_EXTRA_PAPER = 51; 161 const PAPERSIZE_LETTER_TRANSVERSE_PAPER = 52; 162 const PAPERSIZE_A4_TRANSVERSE_PAPER = 53; 163 const PAPERSIZE_LETTER_EXTRA_TRANSVERSE_PAPER = 54; 164 const PAPERSIZE_SUPERA_SUPERA_A4_PAPER = 55; 165 const PAPERSIZE_SUPERB_SUPERB_A3_PAPER = 56; 166 const PAPERSIZE_LETTER_PLUS_PAPER = 57; 167 const PAPERSIZE_A4_PLUS_PAPER = 58; 168 const PAPERSIZE_A5_TRANSVERSE_PAPER = 59; 169 const PAPERSIZE_JIS_B5_TRANSVERSE_PAPER = 60; 170 const PAPERSIZE_A3_EXTRA_PAPER = 61; 171 const PAPERSIZE_A5_EXTRA_PAPER = 62; 172 const PAPERSIZE_ISO_B5_EXTRA_PAPER = 63; 173 const PAPERSIZE_A2_PAPER = 64; 174 const PAPERSIZE_A3_TRANSVERSE_PAPER = 65; 175 const PAPERSIZE_A3_EXTRA_TRANSVERSE_PAPER = 66; 176 177 /* Page orientation */ 178 const ORIENTATION_DEFAULT = 'default'; 179 const ORIENTATION_LANDSCAPE = 'landscape'; 180 const ORIENTATION_PORTRAIT = 'portrait'; 181 182 /* Print Range Set Method */ 183 const SETPRINTRANGE_OVERWRITE = 'O'; 184 const SETPRINTRANGE_INSERT = 'I'; 185 186 187 /** 188 * Paper size 189 * 190 * @var int 191 */ 192 private $_paperSize = PHPExcel_Worksheet_PageSetup::PAPERSIZE_LETTER; 193 194 /** 195 * Orientation 196 * 197 * @var string 198 */ 199 private $_orientation = PHPExcel_Worksheet_PageSetup::ORIENTATION_DEFAULT; 200 201 /** 202 * Scale (Print Scale) 203 * 204 * Print scaling. Valid values range from 10 to 400 205 * This setting is overridden when fitToWidth and/or fitToHeight are in use 206 * 207 * @var int? 208 */ 209 private $_scale = 100; 210 211 /** 212 * Fit To Page 213 * Whether scale or fitToWith / fitToHeight applies 214 * 215 * @var boolean 216 */ 217 private $_fitToPage = FALSE; 218 219 /** 220 * Fit To Height 221 * Number of vertical pages to fit on 222 * 223 * @var int? 224 */ 225 private $_fitToHeight = 1; 226 227 /** 228 * Fit To Width 229 * Number of horizontal pages to fit on 230 * 231 * @var int? 232 */ 233 private $_fitToWidth = 1; 234 235 /** 236 * Columns to repeat at left 237 * 238 * @var array Containing start column and end column, empty array if option unset 239 */ 240 private $_columnsToRepeatAtLeft = array('', ''); 241 242 /** 243 * Rows to repeat at top 244 * 245 * @var array Containing start row number and end row number, empty array if option unset 246 */ 247 private $_rowsToRepeatAtTop = array(0, 0); 248 249 /** 250 * Center page horizontally 251 * 252 * @var boolean 253 */ 254 private $_horizontalCentered = FALSE; 255 256 /** 257 * Center page vertically 258 * 259 * @var boolean 260 */ 261 private $_verticalCentered = FALSE; 262 263 /** 264 * Print area 265 * 266 * @var string 267 */ 268 private $_printArea = NULL; 269 270 /** 271 * First page number 272 * 273 * @var int 274 */ 275 private $_firstPageNumber = NULL; 276 277 /** 278 * Create a new PHPExcel_Worksheet_PageSetup 279 */ 280 public function __construct() 281 { 282 } 283 284 /** 285 * Get Paper Size 286 * 287 * @return int 288 */ 289 public function getPaperSize() { 290 return $this->_paperSize; 291 } 292 293 /** 294 * Set Paper Size 295 * 296 * @param int $pValue 297 * @return PHPExcel_Worksheet_PageSetup 298 */ 299 public function setPaperSize($pValue = PHPExcel_Worksheet_PageSetup::PAPERSIZE_LETTER) { 300 $this->_paperSize = $pValue; 301 return $this; 302 } 303 304 /** 305 * Get Orientation 306 * 307 * @return string 308 */ 309 public function getOrientation() { 310 return $this->_orientation; 311 } 312 313 /** 314 * Set Orientation 315 * 316 * @param string $pValue 317 * @return PHPExcel_Worksheet_PageSetup 318 */ 319 public function setOrientation($pValue = PHPExcel_Worksheet_PageSetup::ORIENTATION_DEFAULT) { 320 $this->_orientation = $pValue; 321 return $this; 322 } 323 324 /** 325 * Get Scale 326 * 327 * @return int? 328 */ 329 public function getScale() { 330 return $this->_scale; 331 } 332 333 /** 334 * Set Scale 335 * 336 * Print scaling. Valid values range from 10 to 400 337 * This setting is overridden when fitToWidth and/or fitToHeight are in use 338 * 339 * @param int? $pValue 340 * @param boolean $pUpdate Update fitToPage so scaling applies rather than fitToHeight / fitToWidth 341 * @return PHPExcel_Worksheet_PageSetup 342 * @throws PHPExcel_Exception 343 */ 344 public function setScale($pValue = 100, $pUpdate = true) { 345 // Microsoft Office Excel 2007 only allows setting a scale between 10 and 400 via the user interface, 346 // but it is apparently still able to handle any scale >= 0, where 0 results in 100 347 if (($pValue >= 0) || is_null($pValue)) { 348 $this->_scale = $pValue; 349 if ($pUpdate) { 350 $this->_fitToPage = false; 351 } 352 } else { 353 throw new PHPExcel_Exception("Scale must not be negative"); 354 } 355 return $this; 356 } 357 358 /** 359 * Get Fit To Page 360 * 361 * @return boolean 362 */ 363 public function getFitToPage() { 364 return $this->_fitToPage; 365 } 366 367 /** 368 * Set Fit To Page 369 * 370 * @param boolean $pValue 371 * @return PHPExcel_Worksheet_PageSetup 372 */ 373 public function setFitToPage($pValue = TRUE) { 374 $this->_fitToPage = $pValue; 375 return $this; 376 } 377 378 /** 379 * Get Fit To Height 380 * 381 * @return int? 382 */ 383 public function getFitToHeight() { 384 return $this->_fitToHeight; 385 } 386 387 /** 388 * Set Fit To Height 389 * 390 * @param int? $pValue 391 * @param boolean $pUpdate Update fitToPage so it applies rather than scaling 392 * @return PHPExcel_Worksheet_PageSetup 393 */ 394 public function setFitToHeight($pValue = 1, $pUpdate = TRUE) { 395 $this->_fitToHeight = $pValue; 396 if ($pUpdate) { 397 $this->_fitToPage = TRUE; 398 } 399 return $this; 400 } 401 402 /** 403 * Get Fit To Width 404 * 405 * @return int? 406 */ 407 public function getFitToWidth() { 408 return $this->_fitToWidth; 409 } 410 411 /** 412 * Set Fit To Width 413 * 414 * @param int? $pValue 415 * @param boolean $pUpdate Update fitToPage so it applies rather than scaling 416 * @return PHPExcel_Worksheet_PageSetup 417 */ 418 public function setFitToWidth($pValue = 1, $pUpdate = TRUE) { 419 $this->_fitToWidth = $pValue; 420 if ($pUpdate) { 421 $this->_fitToPage = TRUE; 422 } 423 return $this; 424 } 425 426 /** 427 * Is Columns to repeat at left set? 428 * 429 * @return boolean 430 */ 431 public function isColumnsToRepeatAtLeftSet() { 432 if (is_array($this->_columnsToRepeatAtLeft)) { 433 if ($this->_columnsToRepeatAtLeft[0] != '' && $this->_columnsToRepeatAtLeft[1] != '') { 434 return true; 435 } 436 } 437 438 return false; 439 } 440 441 /** 442 * Get Columns to repeat at left 443 * 444 * @return array Containing start column and end column, empty array if option unset 445 */ 446 public function getColumnsToRepeatAtLeft() { 447 return $this->_columnsToRepeatAtLeft; 448 } 449 450 /** 451 * Set Columns to repeat at left 452 * 453 * @param array $pValue Containing start column and end column, empty array if option unset 454 * @return PHPExcel_Worksheet_PageSetup 455 */ 456 public function setColumnsToRepeatAtLeft($pValue = null) { 457 if (is_array($pValue)) { 458 $this->_columnsToRepeatAtLeft = $pValue; 459 } 460 return $this; 461 } 462 463 /** 464 * Set Columns to repeat at left by start and end 465 * 466 * @param string $pStart 467 * @param string $pEnd 468 * @return PHPExcel_Worksheet_PageSetup 469 */ 470 public function setColumnsToRepeatAtLeftByStartAndEnd($pStart = 'A', $pEnd = 'A') { 471 $this->_columnsToRepeatAtLeft = array($pStart, $pEnd); 472 return $this; 473 } 474 475 /** 476 * Is Rows to repeat at top set? 477 * 478 * @return boolean 479 */ 480 public function isRowsToRepeatAtTopSet() { 481 if (is_array($this->_rowsToRepeatAtTop)) { 482 if ($this->_rowsToRepeatAtTop[0] != 0 && $this->_rowsToRepeatAtTop[1] != 0) { 483 return true; 484 } 485 } 486 487 return false; 488 } 489 490 /** 491 * Get Rows to repeat at top 492 * 493 * @return array Containing start column and end column, empty array if option unset 494 */ 495 public function getRowsToRepeatAtTop() { 496 return $this->_rowsToRepeatAtTop; 497 } 498 499 /** 500 * Set Rows to repeat at top 501 * 502 * @param array $pValue Containing start column and end column, empty array if option unset 503 * @return PHPExcel_Worksheet_PageSetup 504 */ 505 public function setRowsToRepeatAtTop($pValue = null) { 506 if (is_array($pValue)) { 507 $this->_rowsToRepeatAtTop = $pValue; 508 } 509 return $this; 510 } 511 512 /** 513 * Set Rows to repeat at top by start and end 514 * 515 * @param int $pStart 516 * @param int $pEnd 517 * @return PHPExcel_Worksheet_PageSetup 518 */ 519 public function setRowsToRepeatAtTopByStartAndEnd($pStart = 1, $pEnd = 1) { 520 $this->_rowsToRepeatAtTop = array($pStart, $pEnd); 521 return $this; 522 } 523 524 /** 525 * Get center page horizontally 526 * 527 * @return bool 528 */ 529 public function getHorizontalCentered() { 530 return $this->_horizontalCentered; 531 } 532 533 /** 534 * Set center page horizontally 535 * 536 * @param bool $value 537 * @return PHPExcel_Worksheet_PageSetup 538 */ 539 public function setHorizontalCentered($value = false) { 540 $this->_horizontalCentered = $value; 541 return $this; 542 } 543 544 /** 545 * Get center page vertically 546 * 547 * @return bool 548 */ 549 public function getVerticalCentered() { 550 return $this->_verticalCentered; 551 } 552 553 /** 554 * Set center page vertically 555 * 556 * @param bool $value 557 * @return PHPExcel_Worksheet_PageSetup 558 */ 559 public function setVerticalCentered($value = false) { 560 $this->_verticalCentered = $value; 561 return $this; 562 } 563 564 /** 565 * Get print area 566 * 567 * @param int $index Identifier for a specific print area range if several ranges have been set 568 * Default behaviour, or a index value of 0, will return all ranges as a comma-separated string 569 * Otherwise, the specific range identified by the value of $index will be returned 570 * Print areas are numbered from 1 571 * @throws PHPExcel_Exception 572 * @return string 573 */ 574 public function getPrintArea($index = 0) { 575 if ($index == 0) { 576 return $this->_printArea; 577 } 578 $printAreas = explode(',',$this->_printArea); 579 if (isset($printAreas[$index-1])) { 580 return $printAreas[$index-1]; 581 } 582 throw new PHPExcel_Exception("Requested Print Area does not exist"); 583 } 584 585 /** 586 * Is print area set? 587 * 588 * @param int $index Identifier for a specific print area range if several ranges have been set 589 * Default behaviour, or an index value of 0, will identify whether any print range is set 590 * Otherwise, existence of the range identified by the value of $index will be returned 591 * Print areas are numbered from 1 592 * @return boolean 593 */ 594 public function isPrintAreaSet($index = 0) { 595 if ($index == 0) { 596 return !is_null($this->_printArea); 597 } 598 $printAreas = explode(',',$this->_printArea); 599 return isset($printAreas[$index-1]); 600 } 601 602 /** 603 * Clear a print area 604 * 605 * @param int $index Identifier for a specific print area range if several ranges have been set 606 * Default behaviour, or an index value of 0, will clear all print ranges that are set 607 * Otherwise, the range identified by the value of $index will be removed from the series 608 * Print areas are numbered from 1 609 * @return PHPExcel_Worksheet_PageSetup 610 */ 611 public function clearPrintArea($index = 0) { 612 if ($index == 0) { 613 $this->_printArea = NULL; 614 } else { 615 $printAreas = explode(',',$this->_printArea); 616 if (isset($printAreas[$index-1])) { 617 unset($printAreas[$index-1]); 618 $this->_printArea = implode(',',$printAreas); 619 } 620 } 621 622 return $this; 623 } 624 625 /** 626 * Set print area. e.g. 'A1:D10' or 'A1:D10,G5:M20' 627 * 628 * @param string $value 629 * @param int $index Identifier for a specific print area range allowing several ranges to be set 630 * When the method is "O"verwrite, then a positive integer index will overwrite that indexed 631 * entry in the print areas list; a negative index value will identify which entry to 632 * overwrite working bacward through the print area to the list, with the last entry as -1. 633 * Specifying an index value of 0, will overwrite <b>all</b> existing print ranges. 634 * When the method is "I"nsert, then a positive index will insert after that indexed entry in 635 * the print areas list, while a negative index will insert before the indexed entry. 636 * Specifying an index value of 0, will always append the new print range at the end of the 637 * list. 638 * Print areas are numbered from 1 639 * @param string $method Determines the method used when setting multiple print areas 640 * Default behaviour, or the "O" method, overwrites existing print area 641 * The "I" method, inserts the new print area before any specified index, or at the end of the list 642 * @return PHPExcel_Worksheet_PageSetup 643 * @throws PHPExcel_Exception 644 */ 645 public function setPrintArea($value, $index = 0, $method = self::SETPRINTRANGE_OVERWRITE) { 646 if (strpos($value,'!') !== false) { 647 throw new PHPExcel_Exception('Cell coordinate must not specify a worksheet.'); 648 } elseif (strpos($value,':') === false) { 649 throw new PHPExcel_Exception('Cell coordinate must be a range of cells.'); 650 } elseif (strpos($value,'$') !== false) { 651 throw new PHPExcel_Exception('Cell coordinate must not be absolute.'); 652 } 653 $value = strtoupper($value); 654 655 if ($method == self::SETPRINTRANGE_OVERWRITE) { 656 if ($index == 0) { 657 $this->_printArea = $value; 658 } else { 659 $printAreas = explode(',',$this->_printArea); 660 if($index < 0) { 661 $index = count($printAreas) - abs($index) + 1; 662 } 663 if (($index <= 0) || ($index > count($printAreas))) { 664 throw new PHPExcel_Exception('Invalid index for setting print range.'); 665 } 666 $printAreas[$index-1] = $value; 667 $this->_printArea = implode(',',$printAreas); 668 } 669 } elseif($method == self::SETPRINTRANGE_INSERT) { 670 if ($index == 0) { 671 $this->_printArea .= ($this->_printArea == '') ? $value : ','.$value; 672 } else { 673 $printAreas = explode(',',$this->_printArea); 674 if($index < 0) { 675 $index = abs($index) - 1; 676 } 677 if ($index > count($printAreas)) { 678 throw new PHPExcel_Exception('Invalid index for setting print range.'); 679 } 680 $printAreas = array_merge(array_slice($printAreas,0,$index),array($value),array_slice($printAreas,$index)); 681 $this->_printArea = implode(',',$printAreas); 682 } 683 } else { 684 throw new PHPExcel_Exception('Invalid method for setting print range.'); 685 } 686 687 return $this; 688 } 689 690 /** 691 * Add a new print area (e.g. 'A1:D10' or 'A1:D10,G5:M20') to the list of print areas 692 * 693 * @param string $value 694 * @param int $index Identifier for a specific print area range allowing several ranges to be set 695 * A positive index will insert after that indexed entry in the print areas list, while a 696 * negative index will insert before the indexed entry. 697 * Specifying an index value of 0, will always append the new print range at the end of the 698 * list. 699 * Print areas are numbered from 1 700 * @return PHPExcel_Worksheet_PageSetup 701 * @throws PHPExcel_Exception 702 */ 703 public function addPrintArea($value, $index = -1) { 704 return $this->setPrintArea($value, $index, self::SETPRINTRANGE_INSERT); 705 } 706 707 /** 708 * Set print area 709 * 710 * @param int $column1 Column 1 711 * @param int $row1 Row 1 712 * @param int $column2 Column 2 713 * @param int $row2 Row 2 714 * @param int $index Identifier for a specific print area range allowing several ranges to be set 715 * When the method is "O"verwrite, then a positive integer index will overwrite that indexed 716 * entry in the print areas list; a negative index value will identify which entry to 717 * overwrite working bacward through the print area to the list, with the last entry as -1. 718 * Specifying an index value of 0, will overwrite <b>all</b> existing print ranges. 719 * When the method is "I"nsert, then a positive index will insert after that indexed entry in 720 * the print areas list, while a negative index will insert before the indexed entry. 721 * Specifying an index value of 0, will always append the new print range at the end of the 722 * list. 723 * Print areas are numbered from 1 724 * @param string $method Determines the method used when setting multiple print areas 725 * Default behaviour, or the "O" method, overwrites existing print area 726 * The "I" method, inserts the new print area before any specified index, or at the end of the list 727 * @return PHPExcel_Worksheet_PageSetup 728 * @throws PHPExcel_Exception 729 */ 730 public function setPrintAreaByColumnAndRow($column1, $row1, $column2, $row2, $index = 0, $method = self::SETPRINTRANGE_OVERWRITE) 731 { 732 return $this->setPrintArea(PHPExcel_Cell::stringFromColumnIndex($column1) . $row1 . ':' . PHPExcel_Cell::stringFromColumnIndex($column2) . $row2, $index, $method); 733 } 734 735 /** 736 * Add a new print area to the list of print areas 737 * 738 * @param int $column1 Start Column for the print area 739 * @param int $row1 Start Row for the print area 740 * @param int $column2 End Column for the print area 741 * @param int $row2 End Row for the print area 742 * @param int $index Identifier for a specific print area range allowing several ranges to be set 743 * A positive index will insert after that indexed entry in the print areas list, while a 744 * negative index will insert before the indexed entry. 745 * Specifying an index value of 0, will always append the new print range at the end of the 746 * list. 747 * Print areas are numbered from 1 748 * @return PHPExcel_Worksheet_PageSetup 749 * @throws PHPExcel_Exception 750 */ 751 public function addPrintAreaByColumnAndRow($column1, $row1, $column2, $row2, $index = -1) 752 { 753 return $this->setPrintArea(PHPExcel_Cell::stringFromColumnIndex($column1) . $row1 . ':' . PHPExcel_Cell::stringFromColumnIndex($column2) . $row2, $index, self::SETPRINTRANGE_INSERT); 754 } 755 756 /** 757 * Get first page number 758 * 759 * @return int 760 */ 761 public function getFirstPageNumber() { 762 return $this->_firstPageNumber; 763 } 764 765 /** 766 * Set first page number 767 * 768 * @param int $value 769 * @return PHPExcel_Worksheet_HeaderFooter 770 */ 771 public function setFirstPageNumber($value = null) { 772 $this->_firstPageNumber = $value; 773 return $this; 774 } 775 776 /** 777 * Reset first page number 778 * 779 * @return PHPExcel_Worksheet_HeaderFooter 780 */ 781 public function resetFirstPageNumber() { 782 return $this->setFirstPageNumber(null); 783 } 784 785 /** 786 * Implement PHP __clone to create a deep clone, not just a shallow copy. 787 */ 788 public function __clone() { 789 $vars = get_object_vars($this); 790 foreach ($vars as $key => $value) { 791 if (is_object($value)) { 792 $this->$key = clone $value; 793 } else { 794 $this->$key = $value; 795 } 796 } 797 } 798 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Fri Nov 28 20:29:05 2014 | Cross-referenced by PHPXref 0.7.1 |