Differences Between: [Versions 310 and 311] [Versions 311 and 400] [Versions 311 and 401] [Versions 311 and 402] [Versions 311 and 403] [Versions 39 and 311]
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 * @return $this 81 */ 82 public function setZoomScale($pValue) 83 { 84 // Microsoft Office Excel 2007 only allows setting a scale between 10 and 400 via the user interface, 85 // but it is apparently still able to handle any scale >= 1 86 if (($pValue >= 1) || $pValue === null) { 87 $this->zoomScale = $pValue; 88 } else { 89 throw new PhpSpreadsheetException('Scale must be greater than or equal to 1.'); 90 } 91 92 return $this; 93 } 94 95 /** 96 * Get ZoomScaleNormal. 97 * 98 * @return int 99 */ 100 public function getZoomScaleNormal() 101 { 102 return $this->zoomScaleNormal; 103 } 104 105 /** 106 * Set ZoomScale. 107 * Valid values range from 10 to 400. 108 * 109 * @param int $pValue 110 * 111 * @return $this 112 */ 113 public function setZoomScaleNormal($pValue) 114 { 115 if (($pValue >= 1) || $pValue === null) { 116 $this->zoomScaleNormal = $pValue; 117 } else { 118 throw new PhpSpreadsheetException('Scale must be greater than or equal to 1.'); 119 } 120 121 return $this; 122 } 123 124 /** 125 * Set ShowZeroes setting. 126 * 127 * @param bool $pValue 128 */ 129 public function setShowZeros($pValue): void 130 { 131 $this->showZeros = $pValue; 132 } 133 134 /** 135 * @return bool 136 */ 137 public function getShowZeros() 138 { 139 return $this->showZeros; 140 } 141 142 /** 143 * Get View. 144 * 145 * @return string 146 */ 147 public function getView() 148 { 149 return $this->sheetviewType; 150 } 151 152 /** 153 * Set View. 154 * 155 * Valid values are 156 * 'normal' self::SHEETVIEW_NORMAL 157 * 'pageLayout' self::SHEETVIEW_PAGE_LAYOUT 158 * 'pageBreakPreview' self::SHEETVIEW_PAGE_BREAK_PREVIEW 159 * 160 * @param string $pValue 161 * 162 * @return $this 163 */ 164 public function setView($pValue) 165 { 166 // MS Excel 2007 allows setting the view to 'normal', 'pageLayout' or 'pageBreakPreview' via the user interface 167 if ($pValue === null) { 168 $pValue = self::SHEETVIEW_NORMAL; 169 } 170 if (in_array($pValue, self::$sheetViewTypes)) { 171 $this->sheetviewType = $pValue; 172 } else { 173 throw new PhpSpreadsheetException('Invalid sheetview layout type.'); 174 } 175 176 return $this; 177 } 178 179 /** 180 * Implement PHP __clone to create a deep clone, not just a shallow copy. 181 */ 182 public function __clone() 183 { 184 $vars = get_object_vars($this); 185 foreach ($vars as $key => $value) { 186 if (is_object($value)) { 187 $this->$key = clone $value; 188 } else { 189 $this->$key = $value; 190 } 191 } 192 } 193 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body