Differences Between: [Versions 310 and 311] [Versions 310 and 400] [Versions 310 and 401] [Versions 310 and 402] [Versions 310 and 403]
1 <?php 2 3 namespace PhpOffice\PhpSpreadsheet\Worksheet; 4 5 use PhpOffice\PhpSpreadsheet\Exception as PhpSpreadsheetException; 6 7 class SheetView 8 { 9 // Sheet View types 10 const SHEETVIEW_NORMAL = 'normal'; 11 const SHEETVIEW_PAGE_LAYOUT = 'pageLayout'; 12 const SHEETVIEW_PAGE_BREAK_PREVIEW = 'pageBreakPreview'; 13 14 private static $sheetViewTypes = [ 15 self::SHEETVIEW_NORMAL, 16 self::SHEETVIEW_PAGE_LAYOUT, 17 self::SHEETVIEW_PAGE_BREAK_PREVIEW, 18 ]; 19 20 /** 21 * ZoomScale. 22 * 23 * Valid values range from 10 to 400. 24 * 25 * @var int 26 */ 27 private $zoomScale = 100; 28 29 /** 30 * ZoomScaleNormal. 31 * 32 * Valid values range from 10 to 400. 33 * 34 * @var int 35 */ 36 private $zoomScaleNormal = 100; 37 38 /** 39 * ShowZeros. 40 * 41 * If true, "null" values from a calculation will be shown as "0". This is the default Excel behaviour and can be changed 42 * with the advanced worksheet option "Show a zero in cells that have zero value" 43 * 44 * @var bool 45 */ 46 private $showZeros = true; 47 48 /** 49 * View. 50 * 51 * Valid values range from 10 to 400. 52 * 53 * @var string 54 */ 55 private $sheetviewType = self::SHEETVIEW_NORMAL; 56 57 /** 58 * Create a new SheetView. 59 */ 60 public function __construct() 61 { 62 } 63 64 /** 65 * Get ZoomScale. 66 * 67 * @return int 68 */ 69 public function getZoomScale() 70 { 71 return $this->zoomScale; 72 } 73 74 /** 75 * Set ZoomScale. 76 * Valid values range from 10 to 400. 77 * 78 * @param int $pValue 79 * 80 * @throws PhpSpreadsheetException 81 * 82 * @return SheetView 83 */ 84 public function setZoomScale($pValue) 85 { 86 // Microsoft Office Excel 2007 only allows setting a scale between 10 and 400 via the user interface, 87 // but it is apparently still able to handle any scale >= 1 88 if (($pValue >= 1) || $pValue === null) { 89 $this->zoomScale = $pValue; 90 } else { 91 throw new PhpSpreadsheetException('Scale must be greater than or equal to 1.'); 92 } 93 94 return $this; 95 } 96 97 /** 98 * Get ZoomScaleNormal. 99 * 100 * @return int 101 */ 102 public function getZoomScaleNormal() 103 { 104 return $this->zoomScaleNormal; 105 } 106 107 /** 108 * Set ZoomScale. 109 * Valid values range from 10 to 400. 110 * 111 * @param int $pValue 112 * 113 * @throws PhpSpreadsheetException 114 * 115 * @return SheetView 116 */ 117 public function setZoomScaleNormal($pValue) 118 { 119 if (($pValue >= 1) || $pValue === null) { 120 $this->zoomScaleNormal = $pValue; 121 } else { 122 throw new PhpSpreadsheetException('Scale must be greater than or equal to 1.'); 123 } 124 125 return $this; 126 } 127 128 /** 129 * Set ShowZeroes setting. 130 * 131 * @param bool $pValue 132 */ 133 public function setShowZeros($pValue) 134 { 135 $this->showZeros = $pValue; 136 } 137 138 /** 139 * @return bool 140 */ 141 public function getShowZeros() 142 { 143 return $this->showZeros; 144 } 145 146 /** 147 * Get View. 148 * 149 * @return string 150 */ 151 public function getView() 152 { 153 return $this->sheetviewType; 154 } 155 156 /** 157 * Set View. 158 * 159 * Valid values are 160 * 'normal' self::SHEETVIEW_NORMAL 161 * 'pageLayout' self::SHEETVIEW_PAGE_LAYOUT 162 * 'pageBreakPreview' self::SHEETVIEW_PAGE_BREAK_PREVIEW 163 * 164 * @param string $pValue 165 * 166 * @throws PhpSpreadsheetException 167 * 168 * @return SheetView 169 */ 170 public function setView($pValue) 171 { 172 // MS Excel 2007 allows setting the view to 'normal', 'pageLayout' or 'pageBreakPreview' via the user interface 173 if ($pValue === null) { 174 $pValue = self::SHEETVIEW_NORMAL; 175 } 176 if (in_array($pValue, self::$sheetViewTypes)) { 177 $this->sheetviewType = $pValue; 178 } else { 179 throw new PhpSpreadsheetException('Invalid sheetview layout type.'); 180 } 181 182 return $this; 183 } 184 185 /** 186 * Implement PHP __clone to create a deep clone, not just a shallow copy. 187 */ 188 public function __clone() 189 { 190 $vars = get_object_vars($this); 191 foreach ($vars as $key => $value) { 192 if (is_object($value)) { 193 $this->$key = clone $value; 194 } else { 195 $this->$key = $value; 196 } 197 } 198 } 199 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body