ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
PageSetup.php
Go to the documentation of this file.
1<?php
108{
109 /* Paper size */
117 const PAPERSIZE_A3 = 8;
118 const PAPERSIZE_A4 = 9;
120 const PAPERSIZE_A5 = 11;
121 const PAPERSIZE_B4 = 12;
122 const PAPERSIZE_B5 = 13;
123 const PAPERSIZE_FOLIO = 14;
127 const PAPERSIZE_NOTE = 18;
133 const PAPERSIZE_C = 24;
134 const PAPERSIZE_D = 25;
135 const PAPERSIZE_E = 26;
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 */
185
186
193
200
209 private $_scale = 100;
210
217 private $_fitToPage = FALSE;
218
225 private $_fitToHeight = 1;
226
233 private $_fitToWidth = 1;
234
240 private $_columnsToRepeatAtLeft = array('', '');
241
247 private $_rowsToRepeatAtTop = array(0, 0);
248
254 private $_horizontalCentered = FALSE;
255
261 private $_verticalCentered = FALSE;
262
268 private $_printArea = NULL;
269
275 private $_firstPageNumber = NULL;
276
280 public function __construct()
281 {
282 }
283
289 public function getPaperSize() {
290 return $this->_paperSize;
291 }
292
300 $this->_paperSize = $pValue;
301 return $this;
302 }
303
309 public function getOrientation() {
310 return $this->_orientation;
311 }
312
320 $this->_orientation = $pValue;
321 return $this;
322 }
323
329 public function getScale() {
330 return $this->_scale;
331 }
332
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
363 public function getFitToPage() {
364 return $this->_fitToPage;
365 }
366
373 public function setFitToPage($pValue = TRUE) {
374 $this->_fitToPage = $pValue;
375 return $this;
376 }
377
383 public function getFitToHeight() {
384 return $this->_fitToHeight;
385 }
386
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
407 public function getFitToWidth() {
408 return $this->_fitToWidth;
409 }
410
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
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
446 public function getColumnsToRepeatAtLeft() {
448 }
449
456 public function setColumnsToRepeatAtLeft($pValue = null) {
457 if (is_array($pValue)) {
458 $this->_columnsToRepeatAtLeft = $pValue;
459 }
460 return $this;
461 }
462
470 public function setColumnsToRepeatAtLeftByStartAndEnd($pStart = 'A', $pEnd = 'A') {
471 $this->_columnsToRepeatAtLeft = array($pStart, $pEnd);
472 return $this;
473 }
474
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
495 public function getRowsToRepeatAtTop() {
497 }
498
505 public function setRowsToRepeatAtTop($pValue = null) {
506 if (is_array($pValue)) {
507 $this->_rowsToRepeatAtTop = $pValue;
508 }
509 return $this;
510 }
511
519 public function setRowsToRepeatAtTopByStartAndEnd($pStart = 1, $pEnd = 1) {
520 $this->_rowsToRepeatAtTop = array($pStart, $pEnd);
521 return $this;
522 }
523
529 public function getHorizontalCentered() {
531 }
532
539 public function setHorizontalCentered($value = false) {
540 $this->_horizontalCentered = $value;
541 return $this;
542 }
543
549 public function getVerticalCentered() {
551 }
552
559 public function setVerticalCentered($value = false) {
560 $this->_verticalCentered = $value;
561 return $this;
562 }
563
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
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
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
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
703 public function addPrintArea($value, $index = -1) {
704 return $this->setPrintArea($value, $index, self::SETPRINTRANGE_INSERT);
705 }
706
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
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
761 public function getFirstPageNumber() {
763 }
764
771 public function setFirstPageNumber($value = null) {
772 $this->_firstPageNumber = $value;
773 return $this;
774 }
775
781 public function resetFirstPageNumber() {
782 return $this->setFirstPageNumber(null);
783 }
784
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}
An exception for terminatinating execution or to throw for unit testing.
static stringFromColumnIndex($pColumnIndex=0)
String from columnindex.
Definition: Cell.php:825
getVerticalCentered()
Get center page vertically.
Definition: PageSetup.php:549
__construct()
Create a new PHPExcel_Worksheet_PageSetup.
Definition: PageSetup.php:280
setColumnsToRepeatAtLeftByStartAndEnd($pStart='A', $pEnd='A')
Set Columns to repeat at left by start and end.
Definition: PageSetup.php:470
setColumnsToRepeatAtLeft($pValue=null)
Set Columns to repeat at left.
Definition: PageSetup.php:456
setOrientation($pValue=PHPExcel_Worksheet_PageSetup::ORIENTATION_DEFAULT)
Set Orientation.
Definition: PageSetup.php:319
getFirstPageNumber()
Get first page number.
Definition: PageSetup.php:761
isRowsToRepeatAtTopSet()
Is Rows to repeat at top set?
Definition: PageSetup.php:480
setFitToWidth($pValue=1, $pUpdate=TRUE)
Set Fit To Width.
Definition: PageSetup.php:418
setPaperSize($pValue=PHPExcel_Worksheet_PageSetup::PAPERSIZE_LETTER)
Set Paper Size.
Definition: PageSetup.php:299
getHorizontalCentered()
Get center page horizontally.
Definition: PageSetup.php:529
addPrintArea($value, $index=-1)
Add a new print area (e.g.
Definition: PageSetup.php:703
getFitToPage()
Get Fit To Page.
Definition: PageSetup.php:363
addPrintAreaByColumnAndRow($column1, $row1, $column2, $row2, $index=-1)
Add a new print area to the list of print areas.
Definition: PageSetup.php:751
setFirstPageNumber($value=null)
Set first page number.
Definition: PageSetup.php:771
const PAPERSIZE_LETTER_EXTRA_TRANSVERSE_PAPER
Definition: PageSetup.php:163
clearPrintArea($index=0)
Clear a print area.
Definition: PageSetup.php:611
setHorizontalCentered($value=false)
Set center page horizontally.
Definition: PageSetup.php:539
setScale($pValue=100, $pUpdate=true)
Set Scale.
Definition: PageSetup.php:344
getColumnsToRepeatAtLeft()
Get Columns to repeat at left.
Definition: PageSetup.php:446
getPaperSize()
Get Paper Size.
Definition: PageSetup.php:289
isPrintAreaSet($index=0)
Is print area set?
Definition: PageSetup.php:594
setRowsToRepeatAtTop($pValue=null)
Set Rows to repeat at top.
Definition: PageSetup.php:505
resetFirstPageNumber()
Reset first page number.
Definition: PageSetup.php:781
__clone()
Implement PHP __clone to create a deep clone, not just a shallow copy.
Definition: PageSetup.php:788
setVerticalCentered($value=false)
Set center page vertically.
Definition: PageSetup.php:559
isColumnsToRepeatAtLeftSet()
Is Columns to repeat at left set?
Definition: PageSetup.php:431
getFitToHeight()
Get Fit To Height.
Definition: PageSetup.php:383
setPrintAreaByColumnAndRow($column1, $row1, $column2, $row2, $index=0, $method=self::SETPRINTRANGE_OVERWRITE)
Set print area.
Definition: PageSetup.php:730
setFitToPage($pValue=TRUE)
Set Fit To Page.
Definition: PageSetup.php:373
setPrintArea($value, $index=0, $method=self::SETPRINTRANGE_OVERWRITE)
Set print area.
Definition: PageSetup.php:645
setRowsToRepeatAtTopByStartAndEnd($pStart=1, $pEnd=1)
Set Rows to repeat at top by start and end.
Definition: PageSetup.php:519
setFitToHeight($pValue=1, $pUpdate=TRUE)
Set Fit To Height.
Definition: PageSetup.php:394
getFitToWidth()
Get Fit To Width.
Definition: PageSetup.php:407
getRowsToRepeatAtTop()
Get Rows to repeat at top.
Definition: PageSetup.php:495
getOrientation()
Get Orientation.
Definition: PageSetup.php:309