PluginProbe
Visualizer – Tables & Charts Manager with Built-in AI Generator / 3.2.1
Visualizer – Tables & Charts Manager with Built-in AI Generator v3.2.1
4.0.8 4.0.7 4.0.6 4.0.5 4.0.4 4.0.3 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1.0 3.1.1 3.1.2 3.1.3 3.10.0 3.10.1 3.10.10 3.10.11 3.10.12 3.10.13 3.10.14 3.10.15 3.10.2 3.10.3 All 149 releases
visualizer / vendor / phpoffice / phpspreadsheet / src / PhpSpreadsheet / Reader / BaseReader.php

BaseReader.php in Visualizer – Tables & Charts Manager with Built-in AI Generator 3.2.1, at vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/BaseReader.php

240 lines 6.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace PhpOffice\PhpSpreadsheet\Reader;
4
5 use PhpOffice\PhpSpreadsheet\Reader\Security\XmlScanner;
6 use PhpOffice\PhpSpreadsheet\Shared\File;
7
8 abstract class BaseReader implements IReader
9 {
10 /**
11 * Read data only?
12 * Identifies whether the Reader should only read data values for cells, and ignore any formatting information;
13 * or whether it should read both data and formatting.
14 *
15 * @var bool
16 */
17 protected $readDataOnly = false;
18
19 /**
20 * Read empty cells?
21 * Identifies whether the Reader should read data values for cells all cells, or should ignore cells containing
22 * null value or empty string.
23 *
24 * @var bool
25 */
26 protected $readEmptyCells = true;
27
28 /**
29 * Read charts that are defined in the workbook?
30 * Identifies whether the Reader should read the definitions for any charts that exist in the workbook;.
31 *
32 * @var bool
33 */
34 protected $includeCharts = false;
35
36 /**
37 * Restrict which sheets should be loaded?
38 * This property holds an array of worksheet names to be loaded. If null, then all worksheets will be loaded.
39 *
40 * @var array of string
41 */
42 protected $loadSheetsOnly;
43
44 /**
45 * IReadFilter instance.
46 *
47 * @var IReadFilter
48 */
49 protected $readFilter;
50
51 protected $fileHandle;
52
53 /**
54 * @var XmlScanner
55 */
56 protected $securityScanner;
57
58 /**
59 * Read data only?
60 * If this is true, then the Reader will only read data values for cells, it will not read any formatting information.
61 * If false (the default) it will read data and formatting.
62 *
63 * @return bool
64 */
65 public function getReadDataOnly()
66 {
67 return $this->readDataOnly;
68 }
69
70 /**
71 * Set read data only
72 * Set to true, to advise the Reader only to read data values for cells, and to ignore any formatting information.
73 * Set to false (the default) to advise the Reader to read both data and formatting for cells.
74 *
75 * @param bool $pValue
76 *
77 * @return IReader
78 */
79 public function setReadDataOnly($pValue)
80 {
81 $this->readDataOnly = (bool) $pValue;
82
83 return $this;
84 }
85
86 /**
87 * Read empty cells?
88 * If this is true (the default), then the Reader will read data values for all cells, irrespective of value.
89 * If false it will not read data for cells containing a null value or an empty string.
90 *
91 * @return bool
92 */
93 public function getReadEmptyCells()
94 {
95 return $this->readEmptyCells;
96 }
97
98 /**
99 * Set read empty cells
100 * Set to true (the default) to advise the Reader read data values for all cells, irrespective of value.
101 * Set to false to advise the Reader to ignore cells containing a null value or an empty string.
102 *
103 * @param bool $pValue
104 *
105 * @return IReader
106 */
107 public function setReadEmptyCells($pValue)
108 {
109 $this->readEmptyCells = (bool) $pValue;
110
111 return $this;
112 }
113
114 /**
115 * Read charts in workbook?
116 * If this is true, then the Reader will include any charts that exist in the workbook.
117 * Note that a ReadDataOnly value of false overrides, and charts won't be read regardless of the IncludeCharts value.
118 * If false (the default) it will ignore any charts defined in the workbook file.
119 *
120 * @return bool
121 */
122 public function getIncludeCharts()
123 {
124 return $this->includeCharts;
125 }
126
127 /**
128 * Set read charts in workbook
129 * Set to true, to advise the Reader to include any charts that exist in the workbook.
130 * Note that a ReadDataOnly value of false overrides, and charts won't be read regardless of the IncludeCharts value.
131 * Set to false (the default) to discard charts.
132 *
133 * @param bool $pValue
134 *
135 * @return IReader
136 */
137 public function setIncludeCharts($pValue)
138 {
139 $this->includeCharts = (bool) $pValue;
140
141 return $this;
142 }
143
144 /**
145 * Get which sheets to load
146 * Returns either an array of worksheet names (the list of worksheets that should be loaded), or a null
147 * indicating that all worksheets in the workbook should be loaded.
148 *
149 * @return mixed
150 */
151 public function getLoadSheetsOnly()
152 {
153 return $this->loadSheetsOnly;
154 }
155
156 /**
157 * Set which sheets to load.
158 *
159 * @param mixed $value
160 * This should be either an array of worksheet names to be loaded, or a string containing a single worksheet name.
161 * If NULL, then it tells the Reader to read all worksheets in the workbook
162 *
163 * @return IReader
164 */
165 public function setLoadSheetsOnly($value)
166 {
167 if ($value === null) {
168 return $this->setLoadAllSheets();
169 }
170
171 $this->loadSheetsOnly = is_array($value) ? $value : [$value];
172
173 return $this;
174 }
175
176 /**
177 * Set all sheets to load
178 * Tells the Reader to load all worksheets from the workbook.
179 *
180 * @return IReader
181 */
182 public function setLoadAllSheets()
183 {
184 $this->loadSheetsOnly = null;
185
186 return $this;
187 }
188
189 /**
190 * Read filter.
191 *
192 * @return IReadFilter
193 */
194 public function getReadFilter()
195 {
196 return $this->readFilter;
197 }
198
199 /**
200 * Set read filter.
201 *
202 * @param IReadFilter $pValue
203 *
204 * @return IReader
205 */
206 public function setReadFilter(IReadFilter $pValue)
207 {
208 $this->readFilter = $pValue;
209
210 return $this;
211 }
212
213 public function getSecuritySCanner()
214 {
215 if (property_exists($this, 'securityScanner')) {
216 return $this->securityScanner;
217 }
218
219 return null;
220 }
221
222 /**
223 * Open file for reading.
224 *
225 * @param string $pFilename
226 *
227 * @throws Exception
228 */
229 protected function openFile($pFilename)
230 {
231 File::assertFile($pFilename);
232
233 // Open file
234 $this->fileHandle = fopen($pFilename, 'r');
235 if ($this->fileHandle === false) {
236 throw new Exception('Could not open file ' . $pFilename . ' for reading.');
237 }
238 }
239 }
240