Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
Complex classes like Worksheet often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use Worksheet, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
27 | class Worksheet implements IComparable |
||
28 | { |
||
29 | // Break types |
||
30 | const BREAK_NONE = 0; |
||
31 | const BREAK_ROW = 1; |
||
32 | const BREAK_COLUMN = 2; |
||
33 | |||
34 | // Sheet state |
||
35 | const SHEETSTATE_VISIBLE = 'visible'; |
||
36 | const SHEETSTATE_HIDDEN = 'hidden'; |
||
37 | const SHEETSTATE_VERYHIDDEN = 'veryHidden'; |
||
38 | |||
39 | /** |
||
40 | * Invalid characters in sheet title. |
||
41 | * |
||
42 | * @var array |
||
43 | */ |
||
44 | private static $invalidCharacters = ['*', ':', '/', '\\', '?', '[', ']']; |
||
45 | |||
46 | /** |
||
47 | * Parent spreadsheet. |
||
48 | * |
||
49 | * @var Spreadsheet |
||
50 | */ |
||
51 | private $parent; |
||
52 | |||
53 | /** |
||
54 | * Collection of cells. |
||
55 | * |
||
56 | * @var Cells |
||
57 | */ |
||
58 | private $cellCollection; |
||
59 | |||
60 | /** |
||
61 | * Collection of row dimensions. |
||
62 | * |
||
63 | * @var RowDimension[] |
||
64 | */ |
||
65 | private $rowDimensions = []; |
||
66 | |||
67 | /** |
||
68 | * Default row dimension. |
||
69 | * |
||
70 | * @var RowDimension |
||
71 | */ |
||
72 | private $defaultRowDimension; |
||
73 | |||
74 | /** |
||
75 | * Collection of column dimensions. |
||
76 | * |
||
77 | * @var ColumnDimension[] |
||
78 | */ |
||
79 | private $columnDimensions = []; |
||
80 | |||
81 | /** |
||
82 | * Default column dimension. |
||
83 | * |
||
84 | * @var ColumnDimension |
||
85 | */ |
||
86 | private $defaultColumnDimension; |
||
87 | |||
88 | /** |
||
89 | * Collection of drawings. |
||
90 | * |
||
91 | * @var BaseDrawing[] |
||
92 | */ |
||
93 | private $drawingCollection; |
||
94 | |||
95 | /** |
||
96 | * Collection of Chart objects. |
||
97 | * |
||
98 | * @var Chart[] |
||
99 | */ |
||
100 | private $chartCollection = []; |
||
101 | |||
102 | /** |
||
103 | * Worksheet title. |
||
104 | * |
||
105 | * @var string |
||
106 | */ |
||
107 | private $title; |
||
108 | |||
109 | /** |
||
110 | * Sheet state. |
||
111 | * |
||
112 | * @var string |
||
113 | */ |
||
114 | private $sheetState; |
||
115 | |||
116 | /** |
||
117 | * Page setup. |
||
118 | * |
||
119 | * @var PageSetup |
||
120 | */ |
||
121 | private $pageSetup; |
||
122 | |||
123 | /** |
||
124 | * Page margins. |
||
125 | * |
||
126 | * @var PageMargins |
||
127 | */ |
||
128 | private $pageMargins; |
||
129 | |||
130 | /** |
||
131 | * Page header/footer. |
||
132 | * |
||
133 | * @var HeaderFooter |
||
134 | */ |
||
135 | private $headerFooter; |
||
136 | |||
137 | /** |
||
138 | * Sheet view. |
||
139 | * |
||
140 | * @var SheetView |
||
141 | */ |
||
142 | private $sheetView; |
||
143 | |||
144 | /** |
||
145 | * Protection. |
||
146 | * |
||
147 | * @var Protection |
||
148 | */ |
||
149 | private $protection; |
||
150 | |||
151 | /** |
||
152 | * Collection of styles. |
||
153 | * |
||
154 | * @var Style[] |
||
155 | */ |
||
156 | private $styles = []; |
||
157 | |||
158 | /** |
||
159 | * Conditional styles. Indexed by cell coordinate, e.g. 'A1'. |
||
160 | * |
||
161 | * @var array |
||
162 | */ |
||
163 | private $conditionalStylesCollection = []; |
||
164 | |||
165 | /** |
||
166 | * Is the current cell collection sorted already? |
||
167 | * |
||
168 | * @var bool |
||
169 | */ |
||
170 | private $cellCollectionIsSorted = false; |
||
171 | |||
172 | /** |
||
173 | * Collection of breaks. |
||
174 | * |
||
175 | * @var array |
||
176 | */ |
||
177 | private $breaks = []; |
||
178 | |||
179 | /** |
||
180 | * Collection of merged cell ranges. |
||
181 | * |
||
182 | * @var array |
||
183 | */ |
||
184 | private $mergeCells = []; |
||
185 | |||
186 | /** |
||
187 | * Collection of protected cell ranges. |
||
188 | * |
||
189 | * @var array |
||
190 | */ |
||
191 | private $protectedCells = []; |
||
192 | |||
193 | /** |
||
194 | * Autofilter Range and selection. |
||
195 | * |
||
196 | * @var AutoFilter |
||
197 | */ |
||
198 | private $autoFilter; |
||
199 | |||
200 | /** |
||
201 | * Freeze pane. |
||
202 | * |
||
203 | * @var string |
||
204 | */ |
||
205 | private $freezePane = ''; |
||
206 | |||
207 | /** |
||
208 | * Show gridlines? |
||
209 | * |
||
210 | * @var bool |
||
211 | */ |
||
212 | private $showGridlines = true; |
||
213 | |||
214 | /** |
||
215 | * Print gridlines? |
||
216 | * |
||
217 | * @var bool |
||
218 | */ |
||
219 | private $printGridlines = false; |
||
220 | |||
221 | /** |
||
222 | * Show row and column headers? |
||
223 | * |
||
224 | * @var bool |
||
225 | */ |
||
226 | private $showRowColHeaders = true; |
||
227 | |||
228 | /** |
||
229 | * Show summary below? (Row/Column outline). |
||
230 | * |
||
231 | * @var bool |
||
232 | */ |
||
233 | private $showSummaryBelow = true; |
||
234 | |||
235 | /** |
||
236 | * Show summary right? (Row/Column outline). |
||
237 | * |
||
238 | * @var bool |
||
239 | */ |
||
240 | private $showSummaryRight = true; |
||
241 | |||
242 | /** |
||
243 | * Collection of comments. |
||
244 | * |
||
245 | * @var Comment[] |
||
246 | */ |
||
247 | private $comments = []; |
||
248 | |||
249 | /** |
||
250 | * Active cell. (Only one!). |
||
251 | * |
||
252 | * @var string |
||
253 | */ |
||
254 | private $activeCell = 'A1'; |
||
255 | |||
256 | /** |
||
257 | * Selected cells. |
||
258 | * |
||
259 | * @var string |
||
260 | */ |
||
261 | private $selectedCells = 'A1'; |
||
262 | |||
263 | /** |
||
264 | * Cached highest column. |
||
265 | * |
||
266 | * @var string |
||
267 | */ |
||
268 | private $cachedHighestColumn = 'A'; |
||
269 | |||
270 | /** |
||
271 | * Cached highest row. |
||
272 | * |
||
273 | * @var int |
||
274 | */ |
||
275 | private $cachedHighestRow = 1; |
||
276 | |||
277 | /** |
||
278 | * Right-to-left? |
||
279 | * |
||
280 | * @var bool |
||
281 | */ |
||
282 | private $rightToLeft = false; |
||
283 | |||
284 | /** |
||
285 | * Hyperlinks. Indexed by cell coordinate, e.g. 'A1'. |
||
286 | * |
||
287 | * @var array |
||
288 | */ |
||
289 | private $hyperlinkCollection = []; |
||
290 | |||
291 | /** |
||
292 | * Data validation objects. Indexed by cell coordinate, e.g. 'A1'. |
||
293 | * |
||
294 | * @var array |
||
295 | */ |
||
296 | private $dataValidationCollection = []; |
||
297 | |||
298 | /** |
||
299 | * Tab color. |
||
300 | * |
||
301 | * @var Color |
||
302 | */ |
||
303 | private $tabColor; |
||
304 | |||
305 | /** |
||
306 | * Dirty flag. |
||
307 | * |
||
308 | * @var bool |
||
309 | */ |
||
310 | private $dirty = true; |
||
311 | |||
312 | /** |
||
313 | * Hash. |
||
314 | * |
||
315 | * @var string |
||
316 | */ |
||
317 | private $hash; |
||
318 | |||
319 | /** |
||
320 | * CodeName. |
||
321 | * |
||
322 | * @var string |
||
323 | */ |
||
324 | private $codeName; |
||
325 | |||
326 | /** |
||
327 | * Create a new worksheet. |
||
328 | * |
||
329 | * @param Spreadsheet $parent |
||
330 | * @param string $pTitle |
||
331 | */ |
||
332 | 153 | public function __construct(Spreadsheet $parent = null, $pTitle = 'Worksheet') |
|
362 | |||
363 | /** |
||
364 | * Disconnect all cells from this Worksheet object, |
||
365 | * typically so that the worksheet object can be unset. |
||
366 | */ |
||
367 | 2 | public function disconnectCells() |
|
376 | |||
377 | /** |
||
378 | * Code to execute when this worksheet is unset(). |
||
379 | */ |
||
380 | 2 | public function __destruct() |
|
386 | |||
387 | /** |
||
388 | * Return the cell collection. |
||
389 | * |
||
390 | * @return Cells |
||
391 | */ |
||
392 | 117 | public function getCellCollection() |
|
396 | |||
397 | /** |
||
398 | * Get array of invalid characters for sheet title. |
||
399 | * |
||
400 | * @return array |
||
401 | */ |
||
402 | public static function getInvalidCharacters() |
||
406 | |||
407 | /** |
||
408 | * Check sheet code name for valid Excel syntax. |
||
409 | * |
||
410 | * @param string $pValue The string to check |
||
411 | * |
||
412 | * @throws Exception |
||
413 | * |
||
414 | * @return string The valid string |
||
415 | */ |
||
416 | 153 | private static function checkSheetCodeName($pValue) |
|
436 | |||
437 | /** |
||
438 | * Check sheet title for valid Excel syntax. |
||
439 | * |
||
440 | * @param string $pValue The string to check |
||
441 | * |
||
442 | * @throws Exception |
||
443 | * |
||
444 | * @return string The valid string |
||
445 | */ |
||
446 | 153 | private static function checkSheetTitle($pValue) |
|
460 | |||
461 | /** |
||
462 | * Get a sorted list of all cell coordinates currently held in the collection by row and column. |
||
463 | * |
||
464 | * @param bool $sorted Also sort the cell collection? |
||
465 | * |
||
466 | * @return string[] |
||
467 | */ |
||
468 | 68 | public function getCoordinates($sorted = true) |
|
480 | |||
481 | /** |
||
482 | * Get collection of row dimensions. |
||
483 | * |
||
484 | * @return RowDimension[] |
||
485 | */ |
||
486 | 62 | public function getRowDimensions() |
|
490 | |||
491 | /** |
||
492 | * Get default row dimension. |
||
493 | * |
||
494 | * @return RowDimension |
||
495 | */ |
||
496 | 77 | public function getDefaultRowDimension() |
|
500 | |||
501 | /** |
||
502 | * Get collection of column dimensions. |
||
503 | * |
||
504 | * @return ColumnDimension[] |
||
505 | */ |
||
506 | 62 | public function getColumnDimensions() |
|
510 | |||
511 | /** |
||
512 | * Get default column dimension. |
||
513 | * |
||
514 | * @return ColumnDimension |
||
515 | */ |
||
516 | 59 | public function getDefaultColumnDimension() |
|
520 | |||
521 | /** |
||
522 | * Get collection of drawings. |
||
523 | * |
||
524 | * @return BaseDrawing[] |
||
525 | */ |
||
526 | 63 | public function getDrawingCollection() |
|
530 | |||
531 | /** |
||
532 | * Get collection of charts. |
||
533 | * |
||
534 | * @return Chart[] |
||
535 | */ |
||
536 | 14 | public function getChartCollection() |
|
540 | |||
541 | /** |
||
542 | * Add chart. |
||
543 | * |
||
544 | * @param Chart $pChart |
||
545 | * @param null|int $iChartIndex Index where chart should go (0,1,..., or null for last) |
||
546 | * |
||
547 | * @return Chart |
||
548 | */ |
||
549 | 15 | public function addChart(Chart $pChart, $iChartIndex = null) |
|
561 | |||
562 | /** |
||
563 | * Return the count of charts on this worksheet. |
||
564 | * |
||
565 | * @return int The number of charts |
||
566 | */ |
||
567 | 14 | public function getChartCount() |
|
571 | |||
572 | /** |
||
573 | * Get a chart by its index position. |
||
574 | * |
||
575 | * @param string $index Chart index position |
||
576 | * |
||
577 | * @throws Exception |
||
578 | * |
||
579 | * @return Chart|false |
||
580 | */ |
||
581 | 13 | public function getChartByIndex($index) |
|
596 | |||
597 | /** |
||
598 | * Return an array of the names of charts on this worksheet. |
||
599 | * |
||
600 | * @throws Exception |
||
601 | * |
||
602 | * @return string[] The names of charts |
||
603 | */ |
||
604 | 2 | public function getChartNames() |
|
613 | |||
614 | /** |
||
615 | * Get a chart by name. |
||
616 | * |
||
617 | * @param string $chartName Chart name |
||
618 | * |
||
619 | * @throws Exception |
||
620 | * |
||
621 | * @return Chart|false |
||
622 | */ |
||
623 | 2 | public function getChartByName($chartName) |
|
637 | |||
638 | /** |
||
639 | * Refresh column dimensions. |
||
640 | * |
||
641 | * @return Worksheet |
||
642 | */ |
||
643 | 15 | public function refreshColumnDimensions() |
|
656 | |||
657 | /** |
||
658 | * Refresh row dimensions. |
||
659 | * |
||
660 | * @return Worksheet |
||
661 | */ |
||
662 | 2 | public function refreshRowDimensions() |
|
675 | |||
676 | /** |
||
677 | * Calculate worksheet dimension. |
||
678 | * |
||
679 | * @return string String containing the dimension of this worksheet |
||
680 | */ |
||
681 | 61 | public function calculateWorksheetDimension() |
|
686 | |||
687 | /** |
||
688 | * Calculate worksheet data dimension. |
||
689 | * |
||
690 | * @return string String containing the dimension of this worksheet that actually contain data |
||
691 | */ |
||
692 | public function calculateWorksheetDataDimension() |
||
697 | |||
698 | /** |
||
699 | * Calculate widths for auto-size columns. |
||
700 | * |
||
701 | * @return Worksheet; |
||
702 | */ |
||
703 | 47 | public function calculateColumnWidths() |
|
775 | |||
776 | /** |
||
777 | * Get parent. |
||
778 | * |
||
779 | * @return Spreadsheet |
||
780 | */ |
||
781 | 153 | public function getParent() |
|
785 | |||
786 | /** |
||
787 | * Re-bind parent. |
||
788 | * |
||
789 | * @param Spreadsheet $parent |
||
790 | * |
||
791 | * @return Worksheet |
||
792 | */ |
||
793 | 1 | public function rebindParent(Spreadsheet $parent) |
|
809 | |||
810 | /** |
||
811 | * Get title. |
||
812 | * |
||
813 | * @return string |
||
814 | */ |
||
815 | 153 | public function getTitle() |
|
819 | |||
820 | /** |
||
821 | * Set title. |
||
822 | * |
||
823 | * @param string $pValue String containing the dimension of this worksheet |
||
824 | * @param bool $updateFormulaCellReferences Flag indicating whether cell references in formulae should |
||
825 | * be updated to reflect the new sheet name. |
||
826 | * This should be left as the default true, unless you are |
||
827 | * certain that no formula cells on any worksheet contain |
||
828 | * references to this worksheet |
||
829 | * @param bool $validate False to skip validation of new title. WARNING: This should only be set |
||
830 | * at parse time (by Readers), where titles can be assumed to be valid. |
||
831 | * |
||
832 | * @return Worksheet |
||
833 | */ |
||
834 | 153 | public function setTitle($pValue, $updateFormulaCellReferences = true, $validate = true) |
|
891 | |||
892 | /** |
||
893 | * Get sheet state. |
||
894 | * |
||
895 | * @return string Sheet state (visible, hidden, veryHidden) |
||
896 | */ |
||
897 | 58 | public function getSheetState() |
|
901 | |||
902 | /** |
||
903 | * Set sheet state. |
||
904 | * |
||
905 | * @param string $value Sheet state (visible, hidden, veryHidden) |
||
906 | * |
||
907 | * @return Worksheet |
||
908 | */ |
||
909 | 153 | public function setSheetState($value) |
|
915 | |||
916 | /** |
||
917 | * Get page setup. |
||
918 | * |
||
919 | * @return PageSetup |
||
920 | */ |
||
921 | 78 | public function getPageSetup() |
|
925 | |||
926 | /** |
||
927 | * Set page setup. |
||
928 | * |
||
929 | * @param PageSetup $pValue |
||
930 | * |
||
931 | * @return Worksheet |
||
932 | */ |
||
933 | public function setPageSetup(PageSetup $pValue) |
||
939 | |||
940 | /** |
||
941 | * Get page margins. |
||
942 | * |
||
943 | * @return PageMargins |
||
944 | */ |
||
945 | 78 | public function getPageMargins() |
|
949 | |||
950 | /** |
||
951 | * Set page margins. |
||
952 | * |
||
953 | * @param PageMargins $pValue |
||
954 | * |
||
955 | * @return Worksheet |
||
956 | */ |
||
957 | public function setPageMargins(PageMargins $pValue) |
||
963 | |||
964 | /** |
||
965 | * Get page header/footer. |
||
966 | * |
||
967 | * @return HeaderFooter |
||
968 | */ |
||
969 | 64 | public function getHeaderFooter() |
|
973 | |||
974 | /** |
||
975 | * Set page header/footer. |
||
976 | * |
||
977 | * @param HeaderFooter $pValue |
||
978 | * |
||
979 | * @return Worksheet |
||
980 | */ |
||
981 | public function setHeaderFooter(HeaderFooter $pValue) |
||
987 | |||
988 | /** |
||
989 | * Get sheet view. |
||
990 | * |
||
991 | * @return SheetView |
||
992 | */ |
||
993 | 72 | public function getSheetView() |
|
997 | |||
998 | /** |
||
999 | * Set sheet view. |
||
1000 | * |
||
1001 | * @param SheetView $pValue |
||
1002 | * |
||
1003 | * @return Worksheet |
||
1004 | */ |
||
1005 | public function setSheetView(SheetView $pValue) |
||
1011 | |||
1012 | /** |
||
1013 | * Get Protection. |
||
1014 | * |
||
1015 | * @return Protection |
||
1016 | */ |
||
1017 | 65 | public function getProtection() |
|
1021 | |||
1022 | /** |
||
1023 | * Set Protection. |
||
1024 | * |
||
1025 | * @param Protection $pValue |
||
1026 | * |
||
1027 | * @return Worksheet |
||
1028 | */ |
||
1029 | public function setProtection(Protection $pValue) |
||
1036 | |||
1037 | /** |
||
1038 | * Get highest worksheet column. |
||
1039 | * |
||
1040 | * @param string $row Return the data highest column for the specified row, |
||
1041 | * or the highest column of any row if no row number is passed |
||
1042 | * |
||
1043 | * @return string Highest column name |
||
1044 | */ |
||
1045 | 78 | public function getHighestColumn($row = null) |
|
1053 | |||
1054 | /** |
||
1055 | * Get highest worksheet column that contains data. |
||
1056 | * |
||
1057 | * @param string $row Return the highest data column for the specified row, |
||
1058 | * or the highest data column of any row if no row number is passed |
||
1059 | * |
||
1060 | * @return string Highest column name that contains data |
||
1061 | */ |
||
1062 | 14 | public function getHighestDataColumn($row = null) |
|
1066 | |||
1067 | /** |
||
1068 | * Get highest worksheet row. |
||
1069 | * |
||
1070 | * @param string $column Return the highest data row for the specified column, |
||
1071 | * or the highest row of any column if no column letter is passed |
||
1072 | * |
||
1073 | * @return int Highest row number |
||
1074 | */ |
||
1075 | 78 | public function getHighestRow($column = null) |
|
1083 | |||
1084 | /** |
||
1085 | * Get highest worksheet row that contains data. |
||
1086 | * |
||
1087 | * @param string $column Return the highest data row for the specified column, |
||
1088 | * or the highest data row of any column if no column letter is passed |
||
1089 | * |
||
1090 | * @return string Highest row number that contains data |
||
1091 | */ |
||
1092 | 16 | public function getHighestDataRow($column = null) |
|
1096 | |||
1097 | /** |
||
1098 | * Get highest worksheet column and highest row that have cell records. |
||
1099 | * |
||
1100 | * @return array Highest column name and highest row number |
||
1101 | */ |
||
1102 | public function getHighestRowAndColumn() |
||
1106 | |||
1107 | /** |
||
1108 | * Set a cell value. |
||
1109 | * |
||
1110 | * @param string $pCoordinate Coordinate of the cell, eg: 'A1' |
||
1111 | * @param mixed $pValue Value of the cell |
||
1112 | * |
||
1113 | * @return Worksheet |
||
1114 | */ |
||
1115 | 55 | public function setCellValue($pCoordinate, $pValue) |
|
1121 | |||
1122 | /** |
||
1123 | * Set a cell value by using numeric cell coordinates. |
||
1124 | * |
||
1125 | * @param int $pColumn Numeric column coordinate of the cell (A = 0) |
||
1126 | * @param int $pRow Numeric row coordinate of the cell |
||
1127 | * @param mixed $pValue Value of the cell |
||
1128 | * |
||
1129 | * @return Worksheet |
||
1130 | */ |
||
1131 | public function setCellValueByColumnAndRow($pColumn, $pRow, $pValue) |
||
1137 | |||
1138 | /** |
||
1139 | * Set a cell value. |
||
1140 | * |
||
1141 | * @param string $pCoordinate Coordinate of the cell, eg: 'A1' |
||
1142 | * @param mixed $pValue Value of the cell |
||
1143 | * @param string $pDataType Explicit data type, see DataType::TYPE_* |
||
1144 | * |
||
1145 | * @return Worksheet |
||
1146 | */ |
||
1147 | 1 | public function setCellValueExplicit($pCoordinate, $pValue, $pDataType) |
|
1154 | |||
1155 | /** |
||
1156 | * Set a cell value by using numeric cell coordinates. |
||
1157 | * |
||
1158 | * @param int $pColumn Numeric column coordinate of the cell (A = 0) |
||
1159 | * @param int $pRow Numeric row coordinate of the cell |
||
1160 | * @param mixed $pValue Value of the cell |
||
1161 | * @param string $pDataType Explicit data type, see DataType::TYPE_* |
||
1162 | * |
||
1163 | * @return Worksheet |
||
1164 | */ |
||
1165 | public function setCellValueExplicitByColumnAndRow($pColumn, $pRow, $pValue, $pDataType) |
||
1171 | |||
1172 | /** |
||
1173 | * Get cell at a specific coordinate. |
||
1174 | * |
||
1175 | * @param string $pCoordinate Coordinate of the cell, eg: 'A1' |
||
1176 | * @param bool $createIfNotExists Flag indicating whether a new cell should be created if it doesn't |
||
1177 | * already exist, or a null should be returned instead |
||
1178 | * |
||
1179 | * @throws Exception |
||
1180 | * |
||
1181 | * @return null|Cell Cell that was found/created or null |
||
1182 | */ |
||
1183 | 116 | public function getCell($pCoordinate, $createIfNotExists = true) |
|
1220 | |||
1221 | /** |
||
1222 | * Get cell at a specific coordinate by using numeric cell coordinates. |
||
1223 | * |
||
1224 | * @param string $pColumn Numeric column coordinate of the cell |
||
1225 | * @param string $pRow Numeric row coordinate of the cell |
||
1226 | * @param bool $createIfNotExists Flag indicating whether a new cell should be created if it doesn't |
||
1227 | * already exist, or a null should be returned instead |
||
1228 | * |
||
1229 | * @return null|Cell Cell that was found/created or null |
||
1230 | */ |
||
1231 | 47 | public function getCellByColumnAndRow($pColumn, $pRow, $createIfNotExists = true) |
|
1243 | |||
1244 | /** |
||
1245 | * Create a new cell at the specified coordinate. |
||
1246 | * |
||
1247 | * @param string $pCoordinate Coordinate of the cell |
||
1248 | * |
||
1249 | * @return Cell Cell that was created |
||
1250 | */ |
||
1251 | 117 | private function createNewCell($pCoordinate) |
|
1279 | |||
1280 | /** |
||
1281 | * Does the cell at a specific coordinate exist? |
||
1282 | * |
||
1283 | * @param string $pCoordinate Coordinate of the cell eg: 'A1' |
||
1284 | * |
||
1285 | * @throws Exception |
||
1286 | * |
||
1287 | * @return bool |
||
1288 | */ |
||
1289 | 72 | public function cellExists($pCoordinate) |
|
1328 | |||
1329 | /** |
||
1330 | * Cell at a specific coordinate by using numeric cell coordinates exists? |
||
1331 | * |
||
1332 | * @param string $pColumn Numeric column coordinate of the cell (A = 0) |
||
1333 | * @param string $pRow Numeric row coordinate of the cell |
||
1334 | * |
||
1335 | * @return bool |
||
1336 | */ |
||
1337 | 6 | public function cellExistsByColumnAndRow($pColumn, $pRow) |
|
1341 | |||
1342 | /** |
||
1343 | * Get row dimension at a specific row. |
||
1344 | * |
||
1345 | * @param int $pRow Numeric index of the row |
||
1346 | * @param bool $create |
||
1347 | * |
||
1348 | * @return RowDimension |
||
1349 | */ |
||
1350 | 117 | public function getRowDimension($pRow, $create = true) |
|
1367 | |||
1368 | /** |
||
1369 | * Get column dimension at a specific column. |
||
1370 | * |
||
1371 | * @param string $pColumn String index of the column eg: 'A' |
||
1372 | * @param bool $create |
||
1373 | * |
||
1374 | * @return ColumnDimension |
||
1375 | */ |
||
1376 | 117 | public function getColumnDimension($pColumn, $create = true) |
|
1395 | |||
1396 | /** |
||
1397 | * Get column dimension at a specific column by using numeric cell coordinates. |
||
1398 | * |
||
1399 | * @param int $pColumn Numeric column coordinate of the cell (A = 0) |
||
1400 | * |
||
1401 | * @return ColumnDimension |
||
1402 | */ |
||
1403 | 12 | public function getColumnDimensionByColumn($pColumn) |
|
1407 | |||
1408 | /** |
||
1409 | * Get styles. |
||
1410 | * |
||
1411 | * @return Style[] |
||
1412 | */ |
||
1413 | public function getStyles() |
||
1417 | |||
1418 | /** |
||
1419 | * Get style for cell. |
||
1420 | * |
||
1421 | * @param string $pCellCoordinate Cell coordinate (or range) to get style for, eg: 'A1' |
||
1422 | * |
||
1423 | * @throws Exception |
||
1424 | * |
||
1425 | * @return Style |
||
1426 | */ |
||
1427 | 46 | public function getStyle($pCellCoordinate) |
|
1437 | |||
1438 | /** |
||
1439 | * Get conditional styles for a cell. |
||
1440 | * |
||
1441 | * @param string $pCoordinate eg: 'A1' |
||
1442 | * |
||
1443 | * @return Conditional[] |
||
1444 | */ |
||
1445 | 2 | public function getConditionalStyles($pCoordinate) |
|
1454 | |||
1455 | /** |
||
1456 | * Do conditional styles exist for this cell? |
||
1457 | * |
||
1458 | * @param string $pCoordinate eg: 'A1' |
||
1459 | * |
||
1460 | * @return bool |
||
1461 | */ |
||
1462 | 13 | public function conditionalStylesExists($pCoordinate) |
|
1470 | |||
1471 | /** |
||
1472 | * Removes conditional styles for a cell. |
||
1473 | * |
||
1474 | * @param string $pCoordinate eg: 'A1' |
||
1475 | * |
||
1476 | * @return Worksheet |
||
1477 | */ |
||
1478 | 14 | public function removeConditionalStyles($pCoordinate) |
|
1484 | |||
1485 | /** |
||
1486 | * Get collection of conditional styles. |
||
1487 | * |
||
1488 | * @return array |
||
1489 | */ |
||
1490 | 58 | public function getConditionalStylesCollection() |
|
1494 | |||
1495 | /** |
||
1496 | * Set conditional styles. |
||
1497 | * |
||
1498 | * @param string $pCoordinate eg: 'A1' |
||
1499 | * @param $pValue Conditional[] |
||
1500 | * |
||
1501 | * @return Worksheet |
||
1502 | */ |
||
1503 | 2 | public function setConditionalStyles($pCoordinate, $pValue) |
|
1509 | |||
1510 | /** |
||
1511 | * Get style for cell by using numeric cell coordinates. |
||
1512 | * |
||
1513 | * @param int $pColumn Numeric column coordinate of the cell (A = 0) |
||
1514 | * @param int $pRow Numeric row coordinate of the cell |
||
1515 | * @param int pColumn2 Numeric column coordinate of the range cell (A = 0) |
||
1516 | * @param int pRow2 Numeric row coordinate of the range cell |
||
1517 | * @param null|mixed $pColumn2 |
||
1518 | * @param null|mixed $pRow2 |
||
1519 | * |
||
1520 | * @return Style |
||
1521 | */ |
||
1522 | public function getStyleByColumnAndRow($pColumn, $pRow, $pColumn2 = null, $pRow2 = null) |
||
1532 | |||
1533 | /** |
||
1534 | * Duplicate cell style to a range of cells. |
||
1535 | * |
||
1536 | * Please note that this will overwrite existing cell styles for cells in range! |
||
1537 | * |
||
1538 | * @param Style $pCellStyle Cell style to duplicate |
||
1539 | * @param string $pRange Range of cells (i.e. "A1:B10"), or just one cell (i.e. "A1") |
||
1540 | * |
||
1541 | * @throws Exception |
||
1542 | * |
||
1543 | * @return Worksheet |
||
1544 | */ |
||
1545 | 2 | public function duplicateStyle(Style $pCellStyle, $pRange) |
|
1577 | |||
1578 | /** |
||
1579 | * Duplicate conditional style to a range of cells. |
||
1580 | * |
||
1581 | * Please note that this will overwrite existing cell styles for cells in range! |
||
1582 | * |
||
1583 | * @param Conditional[] $pCellStyle Cell style to duplicate |
||
1584 | * @param string $pRange Range of cells (i.e. "A1:B10"), or just one cell (i.e. "A1") |
||
1585 | * |
||
1586 | * @throws Exception |
||
1587 | * |
||
1588 | * @return Worksheet |
||
1589 | */ |
||
1590 | 2 | public function duplicateConditionalStyle(array $pCellStyle, $pRange = '') |
|
1617 | |||
1618 | /** |
||
1619 | * Set break on a cell. |
||
1620 | * |
||
1621 | * @param string $pCoordinate Cell coordinate (e.g. A1) |
||
1622 | * @param int $pBreak Break type (type of Worksheet::BREAK_*) |
||
1623 | * |
||
1624 | * @throws Exception |
||
1625 | * |
||
1626 | * @return Worksheet |
||
1627 | */ |
||
1628 | 1 | public function setBreak($pCoordinate, $pBreak) |
|
1647 | |||
1648 | /** |
||
1649 | * Set break on a cell by using numeric cell coordinates. |
||
1650 | * |
||
1651 | * @param int $pColumn Numeric column coordinate of the cell (A = 0) |
||
1652 | * @param int $pRow Numeric row coordinate of the cell |
||
1653 | * @param int $pBreak Break type (type of Worksheet::BREAK_*) |
||
1654 | * |
||
1655 | * @return Worksheet |
||
1656 | */ |
||
1657 | public function setBreakByColumnAndRow($pColumn, $pRow, $pBreak) |
||
1661 | |||
1662 | /** |
||
1663 | * Get breaks. |
||
1664 | * |
||
1665 | * @return array[] |
||
1666 | */ |
||
1667 | 62 | public function getBreaks() |
|
1671 | |||
1672 | /** |
||
1673 | * Set merge on a cell range. |
||
1674 | * |
||
1675 | * @param string $pRange Cell range (e.g. A1:E1) |
||
1676 | * |
||
1677 | * @throws Exception |
||
1678 | * |
||
1679 | * @return Worksheet |
||
1680 | */ |
||
1681 | 28 | public function mergeCells($pRange) |
|
1713 | |||
1714 | /** |
||
1715 | * Set merge on a cell range by using numeric cell coordinates. |
||
1716 | * |
||
1717 | * @param int $pColumn1 Numeric column coordinate of the first cell (A = 0) |
||
1718 | * @param int $pRow1 Numeric row coordinate of the first cell |
||
1719 | * @param int $pColumn2 Numeric column coordinate of the last cell (A = 0) |
||
1720 | * @param int $pRow2 Numeric row coordinate of the last cell |
||
1721 | * |
||
1722 | * @throws Exception |
||
1723 | * |
||
1724 | * @return Worksheet |
||
1725 | */ |
||
1726 | public function mergeCellsByColumnAndRow($pColumn1, $pRow1, $pColumn2, $pRow2) |
||
1732 | |||
1733 | /** |
||
1734 | * Remove merge on a cell range. |
||
1735 | * |
||
1736 | * @param string $pRange Cell range (e.g. A1:E1) |
||
1737 | * |
||
1738 | * @throws Exception |
||
1739 | * |
||
1740 | * @return Worksheet |
||
1741 | */ |
||
1742 | 12 | public function unmergeCells($pRange) |
|
1759 | |||
1760 | /** |
||
1761 | * Remove merge on a cell range by using numeric cell coordinates. |
||
1762 | * |
||
1763 | * @param int $pColumn1 Numeric column coordinate of the first cell (A = 0) |
||
1764 | * @param int $pRow1 Numeric row coordinate of the first cell |
||
1765 | * @param int $pColumn2 Numeric column coordinate of the last cell (A = 0) |
||
1766 | * @param int $pRow2 Numeric row coordinate of the last cell |
||
1767 | * |
||
1768 | * @throws Exception |
||
1769 | * |
||
1770 | * @return Worksheet |
||
1771 | */ |
||
1772 | public function unmergeCellsByColumnAndRow($pColumn1, $pRow1, $pColumn2, $pRow2) |
||
1778 | |||
1779 | /** |
||
1780 | * Get merge cells array. |
||
1781 | * |
||
1782 | * @return array[] |
||
1783 | */ |
||
1784 | 62 | public function getMergeCells() |
|
1788 | |||
1789 | /** |
||
1790 | * Set merge cells array for the entire sheet. Use instead mergeCells() to merge |
||
1791 | * a single cell range. |
||
1792 | * |
||
1793 | * @param array |
||
1794 | * @param mixed $pValue |
||
1795 | */ |
||
1796 | 15 | public function setMergeCells(array $pValue) |
|
1802 | |||
1803 | /** |
||
1804 | * Set protection on a cell range. |
||
1805 | * |
||
1806 | * @param string $pRange Cell (e.g. A1) or cell range (e.g. A1:E1) |
||
1807 | * @param string $pPassword Password to unlock the protection |
||
1808 | * @param bool $pAlreadyHashed If the password has already been hashed, set this to true |
||
1809 | * |
||
1810 | * @throws Exception |
||
1811 | * |
||
1812 | * @return Worksheet |
||
1813 | */ |
||
1814 | 12 | public function protectCells($pRange, $pPassword, $pAlreadyHashed = false) |
|
1826 | |||
1827 | /** |
||
1828 | * Set protection on a cell range by using numeric cell coordinates. |
||
1829 | * |
||
1830 | * @param int $pColumn1 Numeric column coordinate of the first cell (A = 0) |
||
1831 | * @param int $pRow1 Numeric row coordinate of the first cell |
||
1832 | * @param int $pColumn2 Numeric column coordinate of the last cell (A = 0) |
||
1833 | * @param int $pRow2 Numeric row coordinate of the last cell |
||
1834 | * @param string $pPassword Password to unlock the protection |
||
1835 | * @param bool $pAlreadyHashed If the password has already been hashed, set this to true |
||
1836 | * |
||
1837 | * @throws Exception |
||
1838 | * |
||
1839 | * @return Worksheet |
||
1840 | */ |
||
1841 | public function protectCellsByColumnAndRow($pColumn1, $pRow1, $pColumn2, $pRow2, $pPassword, $pAlreadyHashed = false) |
||
1847 | |||
1848 | /** |
||
1849 | * Remove protection on a cell range. |
||
1850 | * |
||
1851 | * @param string $pRange Cell (e.g. A1) or cell range (e.g. A1:E1) |
||
1852 | * |
||
1853 | * @throws Exception |
||
1854 | * |
||
1855 | * @return Worksheet |
||
1856 | */ |
||
1857 | 12 | public function unprotectCells($pRange) |
|
1870 | |||
1871 | /** |
||
1872 | * Remove protection on a cell range by using numeric cell coordinates. |
||
1873 | * |
||
1874 | * @param int $pColumn1 Numeric column coordinate of the first cell (A = 0) |
||
1875 | * @param int $pRow1 Numeric row coordinate of the first cell |
||
1876 | * @param int $pColumn2 Numeric column coordinate of the last cell (A = 0) |
||
1877 | * @param int $pRow2 Numeric row coordinate of the last cell |
||
1878 | * |
||
1879 | * @throws Exception |
||
1880 | * |
||
1881 | * @return Worksheet |
||
1882 | */ |
||
1883 | public function unprotectCellsByColumnAndRow($pColumn1, $pRow1, $pColumn2, $pRow2) |
||
1889 | |||
1890 | /** |
||
1891 | * Get protected cells. |
||
1892 | * |
||
1893 | * @return array[] |
||
1894 | */ |
||
1895 | 62 | public function getProtectedCells() |
|
1899 | |||
1900 | /** |
||
1901 | * Get Autofilter. |
||
1902 | * |
||
1903 | * @return AutoFilter |
||
1904 | */ |
||
1905 | 63 | public function getAutoFilter() |
|
1909 | |||
1910 | /** |
||
1911 | * Set AutoFilter. |
||
1912 | * |
||
1913 | * @param AutoFilter|string $pValue |
||
1914 | * A simple string containing a Cell range like 'A1:E10' is permitted for backward compatibility |
||
1915 | * |
||
1916 | * @throws Exception |
||
1917 | * |
||
1918 | * @return Worksheet |
||
1919 | */ |
||
1920 | 4 | public function setAutoFilter($pValue) |
|
1930 | |||
1931 | /** |
||
1932 | * Set Autofilter Range by using numeric cell coordinates. |
||
1933 | * |
||
1934 | * @param int $pColumn1 Numeric column coordinate of the first cell (A = 0) |
||
1935 | * @param int $pRow1 Numeric row coordinate of the first cell |
||
1936 | * @param int $pColumn2 Numeric column coordinate of the second cell (A = 0) |
||
1937 | * @param int $pRow2 Numeric row coordinate of the second cell |
||
1938 | * |
||
1939 | * @throws Exception |
||
1940 | * |
||
1941 | * @return Worksheet |
||
1942 | */ |
||
1943 | public function setAutoFilterByColumnAndRow($pColumn1, $pRow1, $pColumn2, $pRow2) |
||
1951 | |||
1952 | /** |
||
1953 | * Remove autofilter. |
||
1954 | * |
||
1955 | * @return Worksheet |
||
1956 | */ |
||
1957 | public function removeAutoFilter() |
||
1963 | |||
1964 | /** |
||
1965 | * Get Freeze Pane. |
||
1966 | * |
||
1967 | * @return string |
||
1968 | */ |
||
1969 | 62 | public function getFreezePane() |
|
1973 | |||
1974 | /** |
||
1975 | * Freeze Pane. |
||
1976 | * |
||
1977 | * @param string $pCell Cell (i.e. A2) |
||
1978 | * Examples: |
||
1979 | * A2 will freeze the rows above cell A2 (i.e row 1) |
||
1980 | * B1 will freeze the columns to the left of cell B1 (i.e column A) |
||
1981 | * B2 will freeze the rows above and to the left of cell A2 |
||
1982 | * (i.e row 1 and column A) |
||
1983 | * |
||
1984 | * @throws Exception |
||
1985 | * |
||
1986 | * @return Worksheet |
||
1987 | */ |
||
1988 | 4 | public function freezePane($pCell) |
|
2000 | |||
2001 | /** |
||
2002 | * Freeze Pane by using numeric cell coordinates. |
||
2003 | * |
||
2004 | * @param int $pColumn Numeric column coordinate of the cell (A = 0) |
||
2005 | * @param int $pRow Numeric row coordinate of the cell |
||
2006 | * |
||
2007 | * @throws Exception |
||
2008 | * |
||
2009 | * @return Worksheet |
||
2010 | */ |
||
2011 | public function freezePaneByColumnAndRow($pColumn, $pRow) |
||
2015 | |||
2016 | /** |
||
2017 | * Unfreeze Pane. |
||
2018 | * |
||
2019 | * @return Worksheet |
||
2020 | */ |
||
2021 | public function unfreezePane() |
||
2025 | |||
2026 | /** |
||
2027 | * Insert a new row, updating all possible related data. |
||
2028 | * |
||
2029 | * @param int $pBefore Insert before this one |
||
2030 | * @param int $pNumRows Number of rows to insert |
||
2031 | * |
||
2032 | * @throws Exception |
||
2033 | * |
||
2034 | * @return Worksheet |
||
2035 | */ |
||
2036 | 13 | View Code Duplication | public function insertNewRowBefore($pBefore, $pNumRows = 1) |
2047 | |||
2048 | /** |
||
2049 | * Insert a new column, updating all possible related data. |
||
2050 | * |
||
2051 | * @param int $pBefore Insert before this one, eg: 'A' |
||
2052 | * @param int $pNumCols Number of columns to insert |
||
2053 | * |
||
2054 | * @throws Exception |
||
2055 | * |
||
2056 | * @return Worksheet |
||
2057 | */ |
||
2058 | 12 | View Code Duplication | public function insertNewColumnBefore($pBefore, $pNumCols = 1) |
2069 | |||
2070 | /** |
||
2071 | * Insert a new column, updating all possible related data. |
||
2072 | * |
||
2073 | * @param int $pBefore Insert before this one (numeric column coordinate of the cell, A = 0) |
||
2074 | * @param int $pNumCols Number of columns to insert |
||
2075 | * |
||
2076 | * @throws Exception |
||
2077 | * |
||
2078 | * @return Worksheet |
||
2079 | */ |
||
2080 | public function insertNewColumnBeforeByIndex($pBefore, $pNumCols = 1) |
||
2088 | |||
2089 | /** |
||
2090 | * Delete a row, updating all possible related data. |
||
2091 | * |
||
2092 | * @param int $pRow Remove starting with this one |
||
2093 | * @param int $pNumRows Number of rows to remove |
||
2094 | * |
||
2095 | * @throws Exception |
||
2096 | * |
||
2097 | * @return Worksheet |
||
2098 | */ |
||
2099 | 15 | public function removeRow($pRow, $pNumRows = 1) |
|
2115 | |||
2116 | /** |
||
2117 | * Remove a column, updating all possible related data. |
||
2118 | * |
||
2119 | * @param string $pColumn Remove starting with this one, eg: 'A' |
||
2120 | * @param int $pNumCols Number of columns to remove |
||
2121 | * |
||
2122 | * @throws Exception |
||
2123 | * |
||
2124 | * @return Worksheet |
||
2125 | */ |
||
2126 | 12 | public function removeColumn($pColumn, $pNumCols = 1) |
|
2143 | |||
2144 | /** |
||
2145 | * Remove a column, updating all possible related data. |
||
2146 | * |
||
2147 | * @param int $pColumn Remove starting with this one (numeric column coordinate of the cell A = 0) |
||
2148 | * @param int $pNumCols Number of columns to remove |
||
2149 | * |
||
2150 | * @throws Exception |
||
2151 | * |
||
2152 | * @return Worksheet |
||
2153 | */ |
||
2154 | public function removeColumnByIndex($pColumn, $pNumCols = 1) |
||
2162 | |||
2163 | /** |
||
2164 | * Show gridlines? |
||
2165 | * |
||
2166 | * @return bool |
||
2167 | */ |
||
2168 | 62 | public function getShowGridlines() |
|
2172 | |||
2173 | /** |
||
2174 | * Set show gridlines. |
||
2175 | * |
||
2176 | * @param bool $pValue Show gridlines (true/false) |
||
2177 | * |
||
2178 | * @return Worksheet |
||
2179 | */ |
||
2180 | 26 | public function setShowGridlines($pValue) |
|
2186 | |||
2187 | /** |
||
2188 | * Print gridlines? |
||
2189 | * |
||
2190 | * @return bool |
||
2191 | */ |
||
2192 | 58 | public function getPrintGridlines() |
|
2196 | |||
2197 | /** |
||
2198 | * Set print gridlines. |
||
2199 | * |
||
2200 | * @param bool $pValue Print gridlines (true/false) |
||
2201 | * |
||
2202 | * @return Worksheet |
||
2203 | */ |
||
2204 | 17 | public function setPrintGridlines($pValue) |
|
2210 | |||
2211 | /** |
||
2212 | * Show row and column headers? |
||
2213 | * |
||
2214 | * @return bool |
||
2215 | */ |
||
2216 | 58 | public function getShowRowColHeaders() |
|
2220 | |||
2221 | /** |
||
2222 | * Set show row and column headers. |
||
2223 | * |
||
2224 | * @param bool $pValue Show row and column headers (true/false) |
||
2225 | * |
||
2226 | * @return Worksheet |
||
2227 | */ |
||
2228 | 23 | public function setShowRowColHeaders($pValue) |
|
2234 | |||
2235 | /** |
||
2236 | * Show summary below? (Row/Column outlining). |
||
2237 | * |
||
2238 | * @return bool |
||
2239 | */ |
||
2240 | 58 | public function getShowSummaryBelow() |
|
2244 | |||
2245 | /** |
||
2246 | * Set show summary below. |
||
2247 | * |
||
2248 | * @param bool $pValue Show summary below (true/false) |
||
2249 | * |
||
2250 | * @return Worksheet |
||
2251 | */ |
||
2252 | 23 | public function setShowSummaryBelow($pValue) |
|
2258 | |||
2259 | /** |
||
2260 | * Show summary right? (Row/Column outlining). |
||
2261 | * |
||
2262 | * @return bool |
||
2263 | */ |
||
2264 | 58 | public function getShowSummaryRight() |
|
2268 | |||
2269 | /** |
||
2270 | * Set show summary right. |
||
2271 | * |
||
2272 | * @param bool $pValue Show summary right (true/false) |
||
2273 | * |
||
2274 | * @return Worksheet |
||
2275 | */ |
||
2276 | 23 | public function setShowSummaryRight($pValue) |
|
2282 | |||
2283 | /** |
||
2284 | * Get comments. |
||
2285 | * |
||
2286 | * @return Comment[] |
||
2287 | */ |
||
2288 | 63 | public function getComments() |
|
2292 | |||
2293 | /** |
||
2294 | * Set comments array for the entire sheet. |
||
2295 | * |
||
2296 | * @param array of Comment |
||
2297 | * @param mixed $pValue |
||
2298 | * |
||
2299 | * @return Worksheet |
||
2300 | */ |
||
2301 | 15 | public function setComments(array $pValue) |
|
2307 | |||
2308 | /** |
||
2309 | * Get comment for cell. |
||
2310 | * |
||
2311 | * @param string $pCellCoordinate Cell coordinate to get comment for, eg: 'A1' |
||
2312 | * |
||
2313 | * @throws Exception |
||
2314 | * |
||
2315 | * @return Comment |
||
2316 | */ |
||
2317 | 21 | public function getComment($pCellCoordinate) |
|
2341 | |||
2342 | /** |
||
2343 | * Get comment for cell by using numeric cell coordinates. |
||
2344 | * |
||
2345 | * @param int $pColumn Numeric column coordinate of the cell (A = 0) |
||
2346 | * @param int $pRow Numeric row coordinate of the cell |
||
2347 | * |
||
2348 | * @return Comment |
||
2349 | */ |
||
2350 | 2 | public function getCommentByColumnAndRow($pColumn, $pRow) |
|
2354 | |||
2355 | /** |
||
2356 | * Get active cell. |
||
2357 | * |
||
2358 | * @return string Example: 'A1' |
||
2359 | */ |
||
2360 | 63 | public function getActiveCell() |
|
2364 | |||
2365 | /** |
||
2366 | * Get selected cells. |
||
2367 | * |
||
2368 | * @return string |
||
2369 | */ |
||
2370 | 62 | public function getSelectedCells() |
|
2374 | |||
2375 | /** |
||
2376 | * Selected cell. |
||
2377 | * |
||
2378 | * @param string $pCoordinate Cell (i.e. A1) |
||
2379 | * |
||
2380 | * @return Worksheet |
||
2381 | */ |
||
2382 | public function setSelectedCell($pCoordinate) |
||
2386 | |||
2387 | /** |
||
2388 | * Select a range of cells. |
||
2389 | * |
||
2390 | * @param string $pCoordinate Cell range, examples: 'A1', 'B2:G5', 'A:C', '3:6' |
||
2391 | * |
||
2392 | * @throws Exception |
||
2393 | * |
||
2394 | * @return Worksheet |
||
2395 | */ |
||
2396 | 70 | public function setSelectedCells($pCoordinate) |
|
2423 | |||
2424 | /** |
||
2425 | * Selected cell by using numeric cell coordinates. |
||
2426 | * |
||
2427 | * @param int $pColumn Numeric column coordinate of the cell (A = 0) |
||
2428 | * @param int $pRow Numeric row coordinate of the cell |
||
2429 | * |
||
2430 | * @throws Exception |
||
2431 | * |
||
2432 | * @return Worksheet |
||
2433 | */ |
||
2434 | public function setSelectedCellByColumnAndRow($pColumn, $pRow) |
||
2438 | |||
2439 | /** |
||
2440 | * Get right-to-left. |
||
2441 | * |
||
2442 | * @return bool |
||
2443 | */ |
||
2444 | 58 | public function getRightToLeft() |
|
2448 | |||
2449 | /** |
||
2450 | * Set right-to-left. |
||
2451 | * |
||
2452 | * @param bool $value Right-to-left true/false |
||
2453 | * |
||
2454 | * @return Worksheet |
||
2455 | */ |
||
2456 | 18 | public function setRightToLeft($value) |
|
2462 | |||
2463 | /** |
||
2464 | * Fill worksheet from values in array. |
||
2465 | * |
||
2466 | * @param array $source Source array |
||
2467 | * @param mixed $nullValue Value in source array that stands for blank cell |
||
2468 | * @param string $startCell Insert array starting from this cell address as the top left coordinate |
||
2469 | * @param bool $strictNullComparison Apply strict comparison when testing for null values in the array |
||
2470 | * |
||
2471 | * @throws Exception |
||
2472 | * |
||
2473 | * @return Worksheet |
||
2474 | */ |
||
2475 | 30 | public function fromArray(array $source, $nullValue = null, $startCell = 'A1', $strictNullComparison = false) |
|
2507 | |||
2508 | /** |
||
2509 | * Create array from a range of cells. |
||
2510 | * |
||
2511 | * @param string $pRange Range of cells (i.e. "A1:B10"), or just one cell (i.e. "A1") |
||
2512 | * @param mixed $nullValue Value returned in the array entry if a cell doesn't exist |
||
2513 | * @param bool $calculateFormulas Should formulas be calculated? |
||
2514 | * @param bool $formatData Should formatting be applied to cell values? |
||
2515 | * @param bool $returnCellRef False - Return a simple array of rows and columns indexed by number counting from zero |
||
2516 | * True - Return rows and columns indexed by their actual row and column IDs |
||
2517 | * |
||
2518 | * @return array |
||
2519 | */ |
||
2520 | 25 | public function rangeToArray($pRange, $nullValue = null, $calculateFormulas = true, $formatData = true, $returnCellRef = false) |
|
2577 | |||
2578 | /** |
||
2579 | * Create array from a range of cells. |
||
2580 | * |
||
2581 | * @param string $pNamedRange Name of the Named Range |
||
2582 | * @param mixed $nullValue Value returned in the array entry if a cell doesn't exist |
||
2583 | * @param bool $calculateFormulas Should formulas be calculated? |
||
2584 | * @param bool $formatData Should formatting be applied to cell values? |
||
2585 | * @param bool $returnCellRef False - Return a simple array of rows and columns indexed by number counting from zero |
||
2586 | * True - Return rows and columns indexed by their actual row and column IDs |
||
2587 | * |
||
2588 | * @throws Exception |
||
2589 | * |
||
2590 | * @return array |
||
2591 | */ |
||
2592 | public function namedRangeToArray($pNamedRange, $nullValue = null, $calculateFormulas = true, $formatData = true, $returnCellRef = false) |
||
2604 | |||
2605 | /** |
||
2606 | * Create array from worksheet. |
||
2607 | * |
||
2608 | * @param mixed $nullValue Value returned in the array entry if a cell doesn't exist |
||
2609 | * @param bool $calculateFormulas Should formulas be calculated? |
||
2610 | * @param bool $formatData Should formatting be applied to cell values? |
||
2611 | * @param bool $returnCellRef False - Return a simple array of rows and columns indexed by number counting from zero |
||
2612 | * True - Return rows and columns indexed by their actual row and column IDs |
||
2613 | * |
||
2614 | * @return array |
||
2615 | */ |
||
2616 | 12 | public function toArray($nullValue = null, $calculateFormulas = true, $formatData = true, $returnCellRef = false) |
|
2627 | |||
2628 | /** |
||
2629 | * Get row iterator. |
||
2630 | * |
||
2631 | * @param int $startRow The row number at which to start iterating |
||
2632 | * @param int $endRow The row number at which to stop iterating |
||
2633 | * |
||
2634 | * @return RowIterator |
||
2635 | */ |
||
2636 | 4 | public function getRowIterator($startRow = 1, $endRow = null) |
|
2640 | |||
2641 | /** |
||
2642 | * Get column iterator. |
||
2643 | * |
||
2644 | * @param string $startColumn The column address at which to start iterating |
||
2645 | * @param string $endColumn The column address at which to stop iterating |
||
2646 | * |
||
2647 | * @return ColumnIterator |
||
2648 | */ |
||
2649 | public function getColumnIterator($startColumn = 'A', $endColumn = null) |
||
2653 | |||
2654 | /** |
||
2655 | * Run PhpSpreadsheet garabage collector. |
||
2656 | * |
||
2657 | * @return Worksheet |
||
2658 | */ |
||
2659 | 74 | public function garbageCollect() |
|
2690 | |||
2691 | /** |
||
2692 | * Get hash code. |
||
2693 | * |
||
2694 | * @return string Hash code |
||
2695 | */ |
||
2696 | 90 | public function getHashCode() |
|
2705 | |||
2706 | /** |
||
2707 | * Extract worksheet title from range. |
||
2708 | * |
||
2709 | * Example: extractSheetTitle("testSheet!A1") ==> 'A1' |
||
2710 | * Example: extractSheetTitle("'testSheet 1'!A1", true) ==> array('testSheet 1', 'A1'); |
||
2711 | * |
||
2712 | * @param string $pRange Range to extract title from |
||
2713 | * @param bool $returnRange Return range? (see example) |
||
2714 | * |
||
2715 | * @return mixed |
||
2716 | */ |
||
2717 | 1 | public static function extractSheetTitle($pRange, $returnRange = false) |
|
2730 | |||
2731 | /** |
||
2732 | * Get hyperlink. |
||
2733 | * |
||
2734 | * @param string $pCellCoordinate Cell coordinate to get hyperlink for, eg: 'A1' |
||
2735 | */ |
||
2736 | 21 | public function getHyperlink($pCellCoordinate) |
|
2748 | |||
2749 | /** |
||
2750 | * Set hyperlink. |
||
2751 | * |
||
2752 | * @param string $pCellCoordinate Cell coordinate to insert hyperlink, eg: 'A1' |
||
2753 | * @param null|Hyperlink $pHyperlink |
||
2754 | * |
||
2755 | * @return Worksheet |
||
2756 | */ |
||
2757 | 13 | public function setHyperlink($pCellCoordinate, Hyperlink $pHyperlink = null) |
|
2767 | |||
2768 | /** |
||
2769 | * Hyperlink at a specific coordinate exists? |
||
2770 | * |
||
2771 | * @param string $pCoordinate eg: 'A1' |
||
2772 | * |
||
2773 | * @return bool |
||
2774 | */ |
||
2775 | 6 | public function hyperlinkExists($pCoordinate) |
|
2779 | |||
2780 | /** |
||
2781 | * Get collection of hyperlinks. |
||
2782 | * |
||
2783 | * @return Hyperlink[] |
||
2784 | */ |
||
2785 | 62 | public function getHyperlinkCollection() |
|
2789 | |||
2790 | /** |
||
2791 | * Get data validation. |
||
2792 | * |
||
2793 | * @param string $pCellCoordinate Cell coordinate to get data validation for, eg: 'A1' |
||
2794 | */ |
||
2795 | 4 | public function getDataValidation($pCellCoordinate) |
|
2796 | { |
||
2797 | // return data validation if we already have one |
||
2798 | 4 | if (isset($this->dataValidationCollection[$pCellCoordinate])) { |
|
2799 | 2 | return $this->dataValidationCollection[$pCellCoordinate]; |
|
2800 | } |
||
2801 | |||
2802 | // else create data validation |
||
2803 | 4 | $this->dataValidationCollection[$pCellCoordinate] = new DataValidation(); |
|
2804 | |||
2805 | 4 | return $this->dataValidationCollection[$pCellCoordinate]; |
|
2806 | } |
||
2807 | |||
2808 | /** |
||
2809 | * Set data validation. |
||
2810 | * |
||
2811 | * @param string $pCellCoordinate Cell coordinate to insert data validation, eg: 'A1' |
||
2812 | * @param null|DataValidation $pDataValidation |
||
2813 | * |
||
2814 | * @return Worksheet |
||
2815 | */ |
||
2816 | public function setDataValidation($pCellCoordinate, DataValidation $pDataValidation = null) |
||
2826 | |||
2827 | /** |
||
2828 | * Data validation at a specific coordinate exists? |
||
2829 | * |
||
2830 | * @param string $pCoordinate eg: 'A1' |
||
2831 | * |
||
2832 | * @return bool |
||
2833 | */ |
||
2834 | 3 | public function dataValidationExists($pCoordinate) |
|
2835 | { |
||
2836 | 3 | return isset($this->dataValidationCollection[$pCoordinate]); |
|
2837 | } |
||
2838 | |||
2839 | /** |
||
2840 | * Get collection of data validations. |
||
2841 | * |
||
2842 | * @return DataValidation[] |
||
2843 | */ |
||
2844 | 62 | public function getDataValidationCollection() |
|
2848 | |||
2849 | /** |
||
2850 | * Accepts a range, returning it as a range that falls within the current highest row and column of the worksheet. |
||
2851 | * |
||
2852 | * @param string $range |
||
2853 | * |
||
2854 | * @return string Adjusted range value |
||
2855 | */ |
||
2856 | public function shrinkRangeToFit($range) |
||
2885 | |||
2886 | /** |
||
2887 | * Get tab color. |
||
2888 | * |
||
2889 | * @return Color |
||
2890 | */ |
||
2891 | 12 | public function getTabColor() |
|
2899 | |||
2900 | /** |
||
2901 | * Reset tab color. |
||
2902 | * |
||
2903 | * @return Worksheet |
||
2904 | */ |
||
2905 | public function resetTabColor() |
||
2912 | |||
2913 | /** |
||
2914 | * Tab color set? |
||
2915 | * |
||
2916 | * @return bool |
||
2917 | */ |
||
2918 | 67 | public function isTabColorSet() |
|
2922 | |||
2923 | /** |
||
2924 | * Copy worksheet (!= clone!). |
||
2925 | * |
||
2926 | * @return Worksheet |
||
2927 | */ |
||
2928 | public function copy() |
||
2934 | |||
2935 | /** |
||
2936 | * Implement PHP __clone to create a deep clone, not just a shallow copy. |
||
2937 | */ |
||
2938 | 1 | public function __clone() |
|
2967 | |||
2968 | /** |
||
2969 | * Define the code name of the sheet. |
||
2970 | * |
||
2971 | * @param string $pValue Same rule as Title minus space not allowed (but, like Excel, change |
||
2972 | * silently space to underscore) |
||
2973 | * @param bool $validate False to skip validation of new title. WARNING: This should only be set |
||
2974 | * at parse time (by Readers), where titles can be assumed to be valid. |
||
2975 | * |
||
2976 | * @throws Exception |
||
2977 | * |
||
2978 | * @return Worksheet |
||
2979 | */ |
||
2980 | 153 | public function setCodeName($pValue, $validate = true) |
|
3027 | |||
3028 | /** |
||
3029 | * Return the code name of the sheet. |
||
3030 | * |
||
3031 | * @return null|string |
||
3032 | */ |
||
3033 | 153 | public function getCodeName() |
|
3037 | |||
3038 | /** |
||
3039 | * Sheet has a code name ? |
||
3040 | * |
||
3041 | * @return bool |
||
3042 | */ |
||
3043 | public function hasCodeName() |
||
3047 | } |
||
3048 |
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..