5 * Copyright (c) 2006 - 2014 PHPExcel
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.
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.
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
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##
30 * PHPExcel_Worksheet_SheetView
33 * @package PHPExcel_Worksheet
34 * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
36 class PHPExcel_Worksheet_SheetView
39 /* Sheet View types */
40 const SHEETVIEW_NORMAL
= 'normal';
41 const SHEETVIEW_PAGE_LAYOUT
= 'pageLayout';
42 const SHEETVIEW_PAGE_BREAK_PREVIEW
= 'pageBreakPreview';
44 private static $_sheetViewTypes = array(
45 self
::SHEETVIEW_NORMAL
,
46 self
::SHEETVIEW_PAGE_LAYOUT
,
47 self
::SHEETVIEW_PAGE_BREAK_PREVIEW
,
53 * Valid values range from 10 to 400.
57 private $_zoomScale = 100;
62 * Valid values range from 10 to 400.
66 private $_zoomScaleNormal = 100;
71 * Valid values range from 10 to 400.
75 private $_sheetviewType = self
::SHEETVIEW_NORMAL
;
78 * Create a new PHPExcel_Worksheet_SheetView
80 public function __construct()
89 public function getZoomScale() {
90 return $this->_zoomScale
;
96 * Valid values range from 10 to 400.
99 * @throws PHPExcel_Exception
100 * @return PHPExcel_Worksheet_SheetView
102 public function setZoomScale($pValue = 100) {
103 // Microsoft Office Excel 2007 only allows setting a scale between 10 and 400 via the user interface,
104 // but it is apparently still able to handle any scale >= 1
105 if (($pValue >= 1) ||
is_null($pValue)) {
106 $this->_zoomScale
= $pValue;
108 throw new PHPExcel_Exception("Scale must be greater than or equal to 1.");
114 * Get ZoomScaleNormal
118 public function getZoomScaleNormal() {
119 return $this->_zoomScaleNormal
;
125 * Valid values range from 10 to 400.
128 * @throws PHPExcel_Exception
129 * @return PHPExcel_Worksheet_SheetView
131 public function setZoomScaleNormal($pValue = 100) {
132 if (($pValue >= 1) ||
is_null($pValue)) {
133 $this->_zoomScaleNormal
= $pValue;
135 throw new PHPExcel_Exception("Scale must be greater than or equal to 1.");
145 public function getView() {
146 return $this->_sheetviewType
;
153 * 'normal' self::SHEETVIEW_NORMAL
154 * 'pageLayout' self::SHEETVIEW_PAGE_LAYOUT
155 * 'pageBreakPreview' self::SHEETVIEW_PAGE_BREAK_PREVIEW
157 * @param string $pValue
158 * @throws PHPExcel_Exception
159 * @return PHPExcel_Worksheet_SheetView
161 public function setView($pValue = NULL) {
162 // MS Excel 2007 allows setting the view to 'normal', 'pageLayout' or 'pageBreakPreview'
163 // via the user interface
164 if ($pValue === NULL)
165 $pValue = self
::SHEETVIEW_NORMAL
;
166 if (in_array($pValue, self
::$_sheetViewTypes)) {
167 $this->_sheetviewType
= $pValue;
169 throw new PHPExcel_Exception("Invalid sheetview layout type.");
176 * Implement PHP __clone to create a deep clone, not just a shallow copy.
178 public function __clone() {
179 $vars = get_object_vars($this);
180 foreach ($vars as $key => $value) {
181 if (is_object($value)) {
182 $this->$key = clone $value;
184 $this->$key = $value;