PluginProbe
TablePress – Tables in WordPress made easy / 3.4
TablePress – Tables in WordPress made easy v3.4
3.4 3.3.4 3.3.3 3.3.2 3.3.1 trunk 1.12 1.14 1.9.2 2.0.4 2.1.7 2.1.8 2.2 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.3 2.3.1 2.3.2 2.4 2.4.1 2.4.2 2.4.3 All 45 releases
tablepress / libraries / vendor / PhpSpreadsheet / Worksheet / SheetView.php

SheetView.php in TablePress – Tables in WordPress made easy 3.4, at libraries/vendor/PhpSpreadsheet/Worksheet/SheetView.php

206 lines 4.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace TablePress\PhpOffice\PhpSpreadsheet\Worksheet;
4
5 use TablePress\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 const SHEET_VIEW_TYPES = [
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 private ?int $zoomScale = 100;
26
27 /**
28 * ZoomScaleNormal.
29 *
30 * Valid values range from 10 to 400.
31 */
32 private ?int $zoomScaleNormal = 100;
33
34 /**
35 * ZoomScalePageLayoutView.
36 *
37 * Valid values range from 10 to 400.
38 */
39 private int $zoomScalePageLayoutView = 100;
40
41 /**
42 * ZoomScaleSheetLayoutView.
43 *
44 * Valid values range from 10 to 400.
45 */
46 private int $zoomScaleSheetLayoutView = 100;
47
48 /**
49 * ShowZeros.
50 *
51 * If true, "null" values from a calculation will be shown as "0". This is the default Excel behaviour and can be changed
52 * with the advanced worksheet option "Show a zero in cells that have zero value"
53 */
54 private bool $showZeros = true;
55
56 /**
57 * View.
58 *
59 * Valid values range from 10 to 400.
60 */
61 private string $sheetviewType = self::SHEETVIEW_NORMAL;
62
63 /**
64 * Create a new SheetView.
65 */
66 public function __construct()
67 {
68 }
69
70 /**
71 * Get ZoomScale.
72 */
73 public function getZoomScale(): ?int
74 {
75 return $this->zoomScale;
76 }
77
78 /**
79 * Set ZoomScale.
80 * Valid values range from 10 to 400.
81 *
82 * @return $this
83 */
84 public function setZoomScale(?int $zoomScale)
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 ($zoomScale === null || $zoomScale >= 1) {
89 $this->zoomScale = $zoomScale;
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 public function getZoomScaleNormal(): ?int
101 {
102 return $this->zoomScaleNormal;
103 }
104
105 /**
106 * Set ZoomScale.
107 * Valid values range from 10 to 400.
108 *
109 * @return $this
110 */
111 public function setZoomScaleNormal(?int $zoomScaleNormal)
112 {
113 if ($zoomScaleNormal === null || $zoomScaleNormal >= 1) {
114 $this->zoomScaleNormal = $zoomScaleNormal;
115 } else {
116 throw new PhpSpreadsheetException('Scale must be greater than or equal to 1.');
117 }
118
119 return $this;
120 }
121
122 public function getZoomScalePageLayoutView(): int
123 {
124 return $this->zoomScalePageLayoutView;
125 }
126
127 /**
128 * @return static
129 */
130 public function setZoomScalePageLayoutView(int $zoomScalePageLayoutView)
131 {
132 if ($zoomScalePageLayoutView >= 1) {
133 $this->zoomScalePageLayoutView = $zoomScalePageLayoutView;
134 } else {
135 throw new PhpSpreadsheetException('Scale must be greater than or equal to 1.');
136 }
137
138 return $this;
139 }
140
141 public function getZoomScaleSheetLayoutView(): int
142 {
143 return $this->zoomScaleSheetLayoutView;
144 }
145
146 /**
147 * @return static
148 */
149 public function setZoomScaleSheetLayoutView(int $zoomScaleSheetLayoutView)
150 {
151 if ($zoomScaleSheetLayoutView >= 1) {
152 $this->zoomScaleSheetLayoutView = $zoomScaleSheetLayoutView;
153 } else {
154 throw new PhpSpreadsheetException('Scale must be greater than or equal to 1.');
155 }
156
157 return $this;
158 }
159
160 /**
161 * Set ShowZeroes setting.
162 */
163 public function setShowZeros(bool $showZeros): void
164 {
165 $this->showZeros = $showZeros;
166 }
167
168 public function getShowZeros(): bool
169 {
170 return $this->showZeros;
171 }
172
173 /**
174 * Get View.
175 */
176 public function getView(): string
177 {
178 return $this->sheetviewType;
179 }
180
181 /**
182 * Set View.
183 *
184 * Valid values are
185 * 'normal' self::SHEETVIEW_NORMAL
186 * 'pageLayout' self::SHEETVIEW_PAGE_LAYOUT
187 * 'pageBreakPreview' self::SHEETVIEW_PAGE_BREAK_PREVIEW
188 *
189 * @return $this
190 */
191 public function setView(?string $sheetViewType)
192 {
193 // MS Excel 2007 allows setting the view to 'normal', 'pageLayout' or 'pageBreakPreview' via the user interface
194 if ($sheetViewType === null) {
195 $sheetViewType = self::SHEETVIEW_NORMAL;
196 }
197 if (in_array($sheetViewType, self::SHEET_VIEW_TYPES)) {
198 $this->sheetviewType = $sheetViewType;
199 } else {
200 throw new PhpSpreadsheetException('Invalid sheetview layout type.');
201 }
202
203 return $this;
204 }
205 }
206