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 | * Cacheable collection of cells |
||
55 | * |
||
56 | * @var CachedObjectStorage_xxx |
||
57 | */ |
||
58 | private $cellCollection; |
||
59 | |||
60 | /** |
||
61 | * Collection of row dimensions |
||
62 | * |
||
63 | * @var Worksheet\RowDimension[] |
||
64 | */ |
||
65 | private $rowDimensions = []; |
||
66 | |||
67 | /** |
||
68 | * Default row dimension |
||
69 | * |
||
70 | * @var Worksheet\RowDimension |
||
71 | */ |
||
72 | private $defaultRowDimension; |
||
73 | |||
74 | /** |
||
75 | * Collection of column dimensions |
||
76 | * |
||
77 | * @var Worksheet\ColumnDimension[] |
||
78 | */ |
||
79 | private $columnDimensions = []; |
||
80 | |||
81 | /** |
||
82 | * Default column dimension |
||
83 | * |
||
84 | * @var Worksheet\ColumnDimension |
||
85 | */ |
||
86 | private $defaultColumnDimension = null; |
||
87 | |||
88 | /** |
||
89 | * Collection of drawings |
||
90 | * |
||
91 | * @var Worksheet\BaseDrawing[] |
||
92 | */ |
||
93 | private $drawingCollection = null; |
||
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 Worksheet\PageSetup |
||
120 | */ |
||
121 | private $pageSetup; |
||
122 | |||
123 | /** |
||
124 | * Page margins |
||
125 | * |
||
126 | * @var Worksheet\PageMargins |
||
127 | */ |
||
128 | private $pageMargins; |
||
129 | |||
130 | /** |
||
131 | * Page header/footer |
||
132 | * |
||
133 | * @var Worksheet\HeaderFooter |
||
134 | */ |
||
135 | private $headerFooter; |
||
136 | |||
137 | /** |
||
138 | * Sheet view |
||
139 | * |
||
140 | * @var Worksheet\SheetView |
||
141 | */ |
||
142 | private $sheetView; |
||
143 | |||
144 | /** |
||
145 | * Protection |
||
146 | * |
||
147 | * @var Worksheet\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 Worksheet\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 Style\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 = null; |
||
325 | |||
326 | /** |
||
327 | * Create a new worksheet |
||
328 | * |
||
329 | * @param Spreadsheet $parent |
||
330 | * @param string $pTitle |
||
331 | */ |
||
332 | public function __construct(Spreadsheet $parent = null, $pTitle = 'Worksheet') |
||
362 | 9 | ||
363 | 9 | /** |
|
364 | * Disconnect all cells from this Worksheet object, |
||
365 | * typically so that the worksheet object can be unset |
||
366 | */ |
||
367 | public function disconnectCells() |
||
376 | |||
377 | /** |
||
378 | * Code to execute when this worksheet is unset() |
||
379 | */ |
||
380 | public function __destruct() |
||
386 | |||
387 | /** |
||
388 | * Return the cache controller for the cell collection |
||
389 | * |
||
390 | * @return CachedObjectStorage_xxx |
||
391 | */ |
||
392 | public function getCellCacheController() |
||
396 | 1 | ||
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 | * @throws Exception |
||
412 | * @return string The valid string |
||
413 | */ |
||
414 | private static function checkSheetCodeName($pValue) |
||
434 | 9 | ||
435 | /** |
||
436 | * Check sheet title for valid Excel syntax |
||
437 | * |
||
438 | * @param string $pValue The string to check |
||
439 | * @throws Exception |
||
440 | * @return string The valid string |
||
441 | */ |
||
442 | private static function checkSheetTitle($pValue) |
||
456 | 9 | ||
457 | /** |
||
458 | * Get collection of cells |
||
459 | * |
||
460 | * @param bool $pSorted Also sort the cell collection? |
||
461 | * @return Cell[] |
||
462 | */ |
||
463 | public function getCellCollection($pSorted = true) |
||
475 | |||
476 | /** |
||
477 | * Sort collection of cells |
||
478 | * |
||
479 | * @return Worksheet |
||
480 | */ |
||
481 | public function sortCellCollection() |
||
489 | |||
490 | /** |
||
491 | * Get collection of row dimensions |
||
492 | * |
||
493 | * @return Worksheet\RowDimension[] |
||
494 | */ |
||
495 | public function getRowDimensions() |
||
499 | |||
500 | /** |
||
501 | * Get default row dimension |
||
502 | * |
||
503 | * @return Worksheet\RowDimension |
||
504 | */ |
||
505 | public function getDefaultRowDimension() |
||
509 | |||
510 | /** |
||
511 | * Get collection of column dimensions |
||
512 | * |
||
513 | * @return Worksheet\ColumnDimension[] |
||
514 | */ |
||
515 | public function getColumnDimensions() |
||
519 | |||
520 | /** |
||
521 | * Get default column dimension |
||
522 | * |
||
523 | * @return Worksheet\ColumnDimension |
||
524 | */ |
||
525 | public function getDefaultColumnDimension() |
||
529 | |||
530 | /** |
||
531 | * Get collection of drawings |
||
532 | * |
||
533 | * @return Worksheet\BaseDrawing[] |
||
534 | */ |
||
535 | public function getDrawingCollection() |
||
539 | |||
540 | /** |
||
541 | * Get collection of charts |
||
542 | * |
||
543 | * @return Chart[] |
||
544 | */ |
||
545 | public function getChartCollection() |
||
549 | |||
550 | /** |
||
551 | * Add chart |
||
552 | * |
||
553 | * @param Chart $pChart |
||
554 | * @param int|null $iChartIndex Index where chart should go (0,1,..., or null for last) |
||
555 | * @return Chart |
||
556 | */ |
||
557 | public function addChart(Chart $pChart = null, $iChartIndex = null) |
||
569 | |||
570 | /** |
||
571 | * Return the count of charts on this worksheet |
||
572 | * |
||
573 | * @return int The number of charts |
||
574 | */ |
||
575 | public function getChartCount() |
||
579 | |||
580 | /** |
||
581 | * Get a chart by its index position |
||
582 | * |
||
583 | * @param string $index Chart index position |
||
584 | * @throws Exception |
||
585 | * @return false|Chart |
||
586 | */ |
||
587 | public function getChartByIndex($index = null) |
||
602 | |||
603 | /** |
||
604 | * Return an array of the names of charts on this worksheet |
||
605 | * |
||
606 | * @throws Exception |
||
607 | * @return string[] The names of charts |
||
608 | */ |
||
609 | public function getChartNames() |
||
618 | |||
619 | /** |
||
620 | * Get a chart by name |
||
621 | * |
||
622 | * @param string $chartName Chart name |
||
623 | * @throws Exception |
||
624 | * @return false|Chart |
||
625 | */ |
||
626 | public function getChartByName($chartName = '') |
||
640 | |||
641 | /** |
||
642 | * Refresh column dimensions |
||
643 | * |
||
644 | * @return Worksheet |
||
645 | */ |
||
646 | public function refreshColumnDimensions() |
||
659 | |||
660 | /** |
||
661 | * Refresh row dimensions |
||
662 | * |
||
663 | * @return Worksheet |
||
664 | */ |
||
665 | public function refreshRowDimensions() |
||
678 | |||
679 | /** |
||
680 | * Calculate worksheet dimension |
||
681 | * |
||
682 | * @return string String containing the dimension of this worksheet |
||
683 | */ |
||
684 | public function calculateWorksheetDimension() |
||
689 | |||
690 | /** |
||
691 | * Calculate worksheet data dimension |
||
692 | * |
||
693 | * @return string String containing the dimension of this worksheet that actually contain data |
||
694 | */ |
||
695 | public function calculateWorksheetDataDimension() |
||
700 | |||
701 | /** |
||
702 | * Calculate widths for auto-size columns |
||
703 | * |
||
704 | * @param bool $calculateMergeCells Calculate merge cell width |
||
705 | * @return Worksheet; |
||
706 | */ |
||
707 | public function calculateColumnWidths($calculateMergeCells = false) |
||
764 | |||
765 | /** |
||
766 | * Get parent |
||
767 | * |
||
768 | * @return Spreadsheet |
||
769 | */ |
||
770 | public function getParent() |
||
774 | 9 | ||
775 | /** |
||
776 | * Re-bind parent |
||
777 | * |
||
778 | * @param Spreadsheet $parent |
||
779 | * @return Worksheet |
||
780 | */ |
||
781 | public function rebindParent(Spreadsheet $parent) |
||
797 | |||
798 | /** |
||
799 | * Get title |
||
800 | * |
||
801 | * @return string |
||
802 | */ |
||
803 | public function getTitle() |
||
807 | 9 | ||
808 | /** |
||
809 | * Set title |
||
810 | * |
||
811 | * @param string $pValue String containing the dimension of this worksheet |
||
812 | * @param string $updateFormulaCellReferences boolean Flag indicating whether cell references in formulae should |
||
813 | * be updated to reflect the new sheet name. |
||
814 | * This should be left as the default true, unless you are |
||
815 | * certain that no formula cells on any worksheet contain |
||
816 | * references to this worksheet |
||
817 | * @return Worksheet |
||
818 | */ |
||
819 | public function setTitle($pValue = 'Worksheet', $updateFormulaCellReferences = true) |
||
876 | 9 | ||
877 | /** |
||
878 | * Get sheet state |
||
879 | * |
||
880 | * @return string Sheet state (visible, hidden, veryHidden) |
||
881 | */ |
||
882 | public function getSheetState() |
||
886 | |||
887 | /** |
||
888 | * Set sheet state |
||
889 | * |
||
890 | * @param string $value Sheet state (visible, hidden, veryHidden) |
||
891 | * @return Worksheet |
||
892 | */ |
||
893 | public function setSheetState($value = self::SHEETSTATE_VISIBLE) |
||
899 | 9 | ||
900 | /** |
||
901 | * Get page setup |
||
902 | * |
||
903 | * @return Worksheet\PageSetup |
||
904 | */ |
||
905 | public function getPageSetup() |
||
909 | |||
910 | /** |
||
911 | * Set page setup |
||
912 | * |
||
913 | * @param Worksheet\PageSetup $pValue |
||
914 | * @return Worksheet |
||
915 | */ |
||
916 | public function setPageSetup(Worksheet\PageSetup $pValue) |
||
922 | |||
923 | /** |
||
924 | * Get page margins |
||
925 | * |
||
926 | * @return Worksheet\PageMargins |
||
927 | */ |
||
928 | public function getPageMargins() |
||
932 | |||
933 | /** |
||
934 | * Set page margins |
||
935 | * |
||
936 | * @param Worksheet\PageMargins $pValue |
||
937 | * @return Worksheet |
||
938 | */ |
||
939 | public function setPageMargins(Worksheet\PageMargins $pValue) |
||
945 | |||
946 | /** |
||
947 | * Get page header/footer |
||
948 | * |
||
949 | * @return Worksheet\HeaderFooter |
||
950 | */ |
||
951 | public function getHeaderFooter() |
||
955 | |||
956 | /** |
||
957 | * Set page header/footer |
||
958 | * |
||
959 | * @param Worksheet\HeaderFooter $pValue |
||
960 | * @return Worksheet |
||
961 | */ |
||
962 | public function setHeaderFooter(Worksheet\HeaderFooter $pValue) |
||
968 | |||
969 | /** |
||
970 | * Get sheet view |
||
971 | * |
||
972 | * @return Worksheet\SheetView |
||
973 | */ |
||
974 | public function getSheetView() |
||
978 | |||
979 | /** |
||
980 | * Set sheet view |
||
981 | * |
||
982 | * @param Worksheet\SheetView $pValue |
||
983 | * @return Worksheet |
||
984 | */ |
||
985 | public function setSheetView(Worksheet\SheetView $pValue) |
||
991 | |||
992 | /** |
||
993 | * Get Protection |
||
994 | * |
||
995 | * @return Worksheet\Protection |
||
996 | */ |
||
997 | public function getProtection() |
||
1001 | |||
1002 | /** |
||
1003 | * Set Protection |
||
1004 | * |
||
1005 | * @param Worksheet\Protection $pValue |
||
1006 | * @return Worksheet |
||
1007 | */ |
||
1008 | public function setProtection(Worksheet\Protection $pValue) |
||
1015 | |||
1016 | /** |
||
1017 | * Get highest worksheet column |
||
1018 | * |
||
1019 | * @param string $row Return the data highest column for the specified row, |
||
1020 | * or the highest column of any row if no row number is passed |
||
1021 | * @return string Highest column name |
||
1022 | */ |
||
1023 | public function getHighestColumn($row = null) |
||
1031 | |||
1032 | /** |
||
1033 | * Get highest worksheet column that contains data |
||
1034 | * |
||
1035 | * @param string $row Return the highest data column for the specified row, |
||
1036 | * or the highest data column of any row if no row number is passed |
||
1037 | * @return string Highest column name that contains data |
||
1038 | */ |
||
1039 | public function getHighestDataColumn($row = null) |
||
1043 | |||
1044 | /** |
||
1045 | * Get highest worksheet row |
||
1046 | * |
||
1047 | * @param string $column Return the highest data row for the specified column, |
||
1048 | * or the highest row of any column if no column letter is passed |
||
1049 | * @return int Highest row number |
||
1050 | */ |
||
1051 | public function getHighestRow($column = null) |
||
1059 | |||
1060 | /** |
||
1061 | * Get highest worksheet row that contains data |
||
1062 | * |
||
1063 | * @param string $column Return the highest data row for the specified column, |
||
1064 | * or the highest data row of any column if no column letter is passed |
||
1065 | * @return string Highest row number that contains data |
||
1066 | */ |
||
1067 | public function getHighestDataRow($column = null) |
||
1071 | |||
1072 | /** |
||
1073 | * Get highest worksheet column and highest row that have cell records |
||
1074 | * |
||
1075 | * @return array Highest column name and highest row number |
||
1076 | */ |
||
1077 | public function getHighestRowAndColumn() |
||
1081 | |||
1082 | /** |
||
1083 | * Set a cell value |
||
1084 | * |
||
1085 | * @param string $pCoordinate Coordinate of the cell |
||
1086 | * @param mixed $pValue Value of the cell |
||
1087 | * @param bool $returnCell Return the worksheet (false, default) or the cell (true) |
||
1088 | * @return Worksheet|Cell Depending on the last parameter being specified |
||
1089 | */ |
||
1090 | public function setCellValue($pCoordinate = 'A1', $pValue = null, $returnCell = false) |
||
1096 | 1 | ||
1097 | /** |
||
1098 | * Set a cell value by using numeric cell coordinates |
||
1099 | * |
||
1100 | * @param int $pColumn Numeric column coordinate of the cell (A = 0) |
||
1101 | * @param int $pRow Numeric row coordinate of the cell |
||
1102 | * @param mixed $pValue Value of the cell |
||
1103 | * @param bool $returnCell Return the worksheet (false, default) or the cell (true) |
||
1104 | * @return Worksheet|Cell Depending on the last parameter being specified |
||
1105 | */ |
||
1106 | public function setCellValueByColumnAndRow($pColumn = 0, $pRow = 1, $pValue = null, $returnCell = false) |
||
1112 | |||
1113 | /** |
||
1114 | * Set a cell value |
||
1115 | * |
||
1116 | * @param string $pCoordinate Coordinate of the cell |
||
1117 | * @param mixed $pValue Value of the cell |
||
1118 | * @param string $pDataType Explicit data type |
||
1119 | * @param bool $returnCell Return the worksheet (false, default) or the cell (true) |
||
1120 | * @return Worksheet|Cell Depending on the last parameter being specified |
||
1121 | */ |
||
1122 | public function setCellValueExplicit($pCoordinate = 'A1', $pValue = null, $pDataType = Cell\DataType::TYPE_STRING, $returnCell = false) |
||
1129 | |||
1130 | /** |
||
1131 | * Set a cell value by using numeric cell coordinates |
||
1132 | * |
||
1133 | * @param int $pColumn Numeric column coordinate of the cell |
||
1134 | * @param int $pRow Numeric row coordinate of the cell |
||
1135 | * @param mixed $pValue Value of the cell |
||
1136 | * @param string $pDataType Explicit data type |
||
1137 | * @param bool $returnCell Return the worksheet (false, default) or the cell (true) |
||
1138 | * @return Worksheet|Cell Depending on the last parameter being specified |
||
1139 | */ |
||
1140 | public function setCellValueExplicitByColumnAndRow($pColumn = 0, $pRow = 1, $pValue = null, $pDataType = Cell\DataType::TYPE_STRING, $returnCell = false) |
||
1146 | |||
1147 | /** |
||
1148 | * Get cell at a specific coordinate |
||
1149 | * |
||
1150 | * @param string $pCoordinate Coordinate of the cell |
||
1151 | * @param bool $createIfNotExists Flag indicating whether a new cell should be created if it doesn't |
||
1152 | * already exist, or a null should be returned instead |
||
1153 | * @throws Exception |
||
1154 | * @return null|Cell Cell that was found/created or null |
||
1155 | */ |
||
1156 | public function getCell($pCoordinate = 'A1', $createIfNotExists = true) |
||
1193 | 1 | ||
1194 | /** |
||
1195 | * Get cell at a specific coordinate by using numeric cell coordinates |
||
1196 | * |
||
1197 | * @param string $pColumn Numeric column coordinate of the cell |
||
1198 | * @param string $pRow Numeric row coordinate of the cell |
||
1199 | * @param bool $createIfNotExists Flag indicating whether a new cell should be created if it doesn't |
||
1200 | * already exist, or a null should be returned instead |
||
1201 | * @return null|Cell Cell that was found/created or null |
||
1202 | */ |
||
1203 | public function getCellByColumnAndRow($pColumn = 0, $pRow = 1, $createIfNotExists = true) |
||
1215 | |||
1216 | /** |
||
1217 | * Create a new cell at the specified coordinate |
||
1218 | * |
||
1219 | * @param string $pCoordinate Coordinate of the cell |
||
1220 | * @return Cell Cell that was created |
||
1221 | */ |
||
1222 | private function createNewCell($pCoordinate) |
||
1252 | 1 | ||
1253 | /** |
||
1254 | * Does the cell at a specific coordinate exist? |
||
1255 | * |
||
1256 | * @param string $pCoordinate Coordinate of the cell |
||
1257 | * @throws Exception |
||
1258 | * @return bool |
||
1259 | */ |
||
1260 | public function cellExists($pCoordinate = 'A1') |
||
1302 | |||
1303 | /** |
||
1304 | * Cell at a specific coordinate by using numeric cell coordinates exists? |
||
1305 | * |
||
1306 | * @param string $pColumn Numeric column coordinate of the cell |
||
1307 | * @param string $pRow Numeric row coordinate of the cell |
||
1308 | * @return bool |
||
1309 | */ |
||
1310 | public function cellExistsByColumnAndRow($pColumn = 0, $pRow = 1) |
||
1314 | |||
1315 | /** |
||
1316 | * Get row dimension at a specific row |
||
1317 | * |
||
1318 | * @param int $pRow Numeric index of the row |
||
1319 | * @return Worksheet\RowDimension |
||
1320 | */ |
||
1321 | public function getRowDimension($pRow = 1, $create = true) |
||
1338 | |||
1339 | /** |
||
1340 | * Get column dimension at a specific column |
||
1341 | * |
||
1342 | * @param string $pColumn String index of the column |
||
1343 | * @return Worksheet\ColumnDimension |
||
1344 | */ |
||
1345 | public function getColumnDimension($pColumn = 'A', $create = true) |
||
1364 | |||
1365 | /** |
||
1366 | * Get column dimension at a specific column by using numeric cell coordinates |
||
1367 | * |
||
1368 | * @param int $pColumn Numeric column coordinate of the cell |
||
1369 | * @return Worksheet\ColumnDimension |
||
1370 | */ |
||
1371 | public function getColumnDimensionByColumn($pColumn = 0) |
||
1375 | |||
1376 | /** |
||
1377 | * Get styles |
||
1378 | * |
||
1379 | * @return Style[] |
||
1380 | */ |
||
1381 | public function getStyles() |
||
1385 | |||
1386 | /** |
||
1387 | * Get default style of workbook. |
||
1388 | * |
||
1389 | * @deprecated |
||
1390 | * @throws Exception |
||
1391 | * @return Style |
||
1392 | */ |
||
1393 | public function getDefaultStyle() |
||
1397 | |||
1398 | /** |
||
1399 | * Set default style - should only be used by \PhpOffice\PhpSpreadsheet\IReader implementations! |
||
1400 | * |
||
1401 | * @deprecated |
||
1402 | * @param Style $pValue |
||
1403 | * @throws Exception |
||
1404 | * @return Worksheet |
||
1405 | */ |
||
1406 | public function setDefaultStyle(Style $pValue) |
||
1417 | |||
1418 | /** |
||
1419 | * Get style for cell |
||
1420 | * |
||
1421 | * @param string $pCellCoordinate Cell coordinate (or range) to get style for |
||
1422 | * @throws Exception |
||
1423 | * @return Style |
||
1424 | */ |
||
1425 | public function getStyle($pCellCoordinate = 'A1') |
||
1435 | |||
1436 | /** |
||
1437 | * Get conditional styles for a cell |
||
1438 | * |
||
1439 | * @param string $pCoordinate |
||
1440 | * @return Style\Conditional[] |
||
1441 | */ |
||
1442 | public function getConditionalStyles($pCoordinate = 'A1') |
||
1451 | |||
1452 | /** |
||
1453 | * Do conditional styles exist for this cell? |
||
1454 | * |
||
1455 | * @param string $pCoordinate |
||
1456 | * @return bool |
||
1457 | */ |
||
1458 | public function conditionalStylesExists($pCoordinate = 'A1') |
||
1466 | |||
1467 | /** |
||
1468 | * Removes conditional styles for a cell |
||
1469 | * |
||
1470 | * @param string $pCoordinate |
||
1471 | * @return Worksheet |
||
1472 | */ |
||
1473 | public function removeConditionalStyles($pCoordinate = 'A1') |
||
1479 | |||
1480 | /** |
||
1481 | * Get collection of conditional styles |
||
1482 | * |
||
1483 | * @return array |
||
1484 | */ |
||
1485 | public function getConditionalStylesCollection() |
||
1489 | |||
1490 | /** |
||
1491 | * Set conditional styles |
||
1492 | * |
||
1493 | * @param string $pCoordinate eg: 'A1' |
||
1494 | * @param $pValue Style\Conditional[] |
||
1495 | * @return Worksheet |
||
1496 | */ |
||
1497 | public function setConditionalStyles($pCoordinate, $pValue) |
||
1503 | |||
1504 | /** |
||
1505 | * Get style for cell by using numeric cell coordinates |
||
1506 | * |
||
1507 | * @param int $pColumn Numeric column coordinate of the cell |
||
1508 | * @param int $pRow Numeric row coordinate of the cell |
||
1509 | * @param int pColumn2 Numeric column coordinate of the range cell |
||
1510 | * @param int pRow2 Numeric row coordinate of the range cell |
||
1511 | * @return Style |
||
1512 | */ |
||
1513 | public function getStyleByColumnAndRow($pColumn = 0, $pRow = 1, $pColumn2 = null, $pRow2 = null) |
||
1523 | |||
1524 | /** |
||
1525 | * Set shared cell style to a range of cells |
||
1526 | * |
||
1527 | * Please note that this will overwrite existing cell styles for cells in range! |
||
1528 | * |
||
1529 | * @deprecated duplicateStyle |
||
1530 | * @param Style $pSharedCellStyle Cell style to share |
||
1531 | * @param string $pRange Range of cells (i.e. "A1:B10"), or just one cell (i.e. "A1") |
||
1532 | * @throws Exception |
||
1533 | * @return Worksheet |
||
1534 | */ |
||
1535 | public function setSharedStyle(Style $pSharedCellStyle = null, $pRange = '') |
||
1541 | |||
1542 | /** |
||
1543 | * Duplicate cell style to a range of cells |
||
1544 | * |
||
1545 | * Please note that this will overwrite existing cell styles for cells in range! |
||
1546 | * |
||
1547 | * @param Style $pCellStyle Cell style to duplicate |
||
1548 | * @param string $pRange Range of cells (i.e. "A1:B10"), or just one cell (i.e. "A1") |
||
1549 | * @throws Exception |
||
1550 | * @return Worksheet |
||
1551 | */ |
||
1552 | public function duplicateStyle(Style $pCellStyle = null, $pRange = '') |
||
1587 | |||
1588 | /** |
||
1589 | * Duplicate conditional style to a range of cells |
||
1590 | * |
||
1591 | * Please note that this will overwrite existing cell styles for cells in range! |
||
1592 | * |
||
1593 | * @param Style\Conditional[] $pCellStyle Cell style to duplicate |
||
1594 | * @param string $pRange Range of cells (i.e. "A1:B10"), or just one cell (i.e. "A1") |
||
1595 | * @throws Exception |
||
1596 | * @return Worksheet |
||
1597 | */ |
||
1598 | public function duplicateConditionalStyle(array $pCellStyle = null, $pRange = '') |
||
1625 | |||
1626 | /** |
||
1627 | * Duplicate cell style array to a range of cells |
||
1628 | * |
||
1629 | * Please note that this will overwrite existing cell styles for cells in range, |
||
1630 | * if they are in the styles array. For example, if you decide to set a range of |
||
1631 | * cells to font bold, only include font bold in the styles array. |
||
1632 | * |
||
1633 | * @deprecated |
||
1634 | * @param array $pStyles Array containing style information |
||
1635 | * @param string $pRange Range of cells (i.e. "A1:B10"), or just one cell (i.e. "A1") |
||
1636 | * @param bool $pAdvanced Advanced mode for setting borders. |
||
1637 | * @throws Exception |
||
1638 | * @return Worksheet |
||
1639 | */ |
||
1640 | public function duplicateStyleArray($pStyles = null, $pRange = '', $pAdvanced = true) |
||
1646 | |||
1647 | /** |
||
1648 | * Set break on a cell |
||
1649 | * |
||
1650 | * @param string $pCell Cell coordinate (e.g. A1) |
||
1651 | * @param int $pBreak Break type (type of Worksheet::BREAK_*) |
||
1652 | * @throws Exception |
||
1653 | * @return Worksheet |
||
1654 | */ |
||
1655 | public function setBreak($pCell = 'A1', $pBreak = self::BREAK_NONE) |
||
1674 | |||
1675 | /** |
||
1676 | * Set break on a cell by using numeric cell coordinates |
||
1677 | * |
||
1678 | * @param int $pColumn Numeric column coordinate of the cell |
||
1679 | * @param int $pRow Numeric row coordinate of the cell |
||
1680 | * @param int $pBreak Break type (type of \PhpOffice\PhpSpreadsheet\Worksheet::BREAK_*) |
||
1681 | * @return Worksheet |
||
1682 | */ |
||
1683 | public function setBreakByColumnAndRow($pColumn = 0, $pRow = 1, $pBreak = self::BREAK_NONE) |
||
1687 | |||
1688 | /** |
||
1689 | * Get breaks |
||
1690 | * |
||
1691 | * @return array[] |
||
1692 | */ |
||
1693 | public function getBreaks() |
||
1697 | |||
1698 | /** |
||
1699 | * Set merge on a cell range |
||
1700 | * |
||
1701 | * @param string $pRange Cell range (e.g. A1:E1) |
||
1702 | * @throws Exception |
||
1703 | * @return Worksheet |
||
1704 | */ |
||
1705 | public function mergeCells($pRange = 'A1:A1') |
||
1737 | |||
1738 | /** |
||
1739 | * Set merge on a cell range by using numeric cell coordinates |
||
1740 | * |
||
1741 | * @param int $pColumn1 Numeric column coordinate of the first cell |
||
1742 | * @param int $pRow1 Numeric row coordinate of the first cell |
||
1743 | * @param int $pColumn2 Numeric column coordinate of the last cell |
||
1744 | * @param int $pRow2 Numeric row coordinate of the last cell |
||
1745 | * @throws Exception |
||
1746 | * @return Worksheet |
||
1747 | */ |
||
1748 | public function mergeCellsByColumnAndRow($pColumn1 = 0, $pRow1 = 1, $pColumn2 = 0, $pRow2 = 1) |
||
1754 | |||
1755 | /** |
||
1756 | * Remove merge on a cell range |
||
1757 | * |
||
1758 | * @param string $pRange Cell range (e.g. A1:E1) |
||
1759 | * @throws Exception |
||
1760 | * @return Worksheet |
||
1761 | */ |
||
1762 | public function unmergeCells($pRange = 'A1:A1') |
||
1779 | |||
1780 | /** |
||
1781 | * Remove merge on a cell range by using numeric cell coordinates |
||
1782 | * |
||
1783 | * @param int $pColumn1 Numeric column coordinate of the first cell |
||
1784 | * @param int $pRow1 Numeric row coordinate of the first cell |
||
1785 | * @param int $pColumn2 Numeric column coordinate of the last cell |
||
1786 | * @param int $pRow2 Numeric row coordinate of the last cell |
||
1787 | * @throws Exception |
||
1788 | * @return Worksheet |
||
1789 | */ |
||
1790 | public function unmergeCellsByColumnAndRow($pColumn1 = 0, $pRow1 = 1, $pColumn2 = 0, $pRow2 = 1) |
||
1796 | |||
1797 | /** |
||
1798 | * Get merge cells array. |
||
1799 | * |
||
1800 | * @return array[] |
||
1801 | */ |
||
1802 | public function getMergeCells() |
||
1806 | |||
1807 | /** |
||
1808 | * Set merge cells array for the entire sheet. Use instead mergeCells() to merge |
||
1809 | * a single cell range. |
||
1810 | * |
||
1811 | * @param array |
||
1812 | */ |
||
1813 | public function setMergeCells($pValue = []) |
||
1819 | |||
1820 | /** |
||
1821 | * Set protection on a cell range |
||
1822 | * |
||
1823 | * @param string $pRange Cell (e.g. A1) or cell range (e.g. A1:E1) |
||
1824 | * @param string $pPassword Password to unlock the protection |
||
1825 | * @param bool $pAlreadyHashed If the password has already been hashed, set this to true |
||
1826 | * @throws Exception |
||
1827 | * @return Worksheet |
||
1828 | */ |
||
1829 | public function protectCells($pRange = 'A1', $pPassword = '', $pAlreadyHashed = false) |
||
1841 | |||
1842 | /** |
||
1843 | * Set protection on a cell range by using numeric cell coordinates |
||
1844 | * |
||
1845 | * @param int $pColumn1 Numeric column coordinate of the first cell |
||
1846 | * @param int $pRow1 Numeric row coordinate of the first cell |
||
1847 | * @param int $pColumn2 Numeric column coordinate of the last cell |
||
1848 | * @param int $pRow2 Numeric row coordinate of the last cell |
||
1849 | * @param string $pPassword Password to unlock the protection |
||
1850 | * @param bool $pAlreadyHashed If the password has already been hashed, set this to true |
||
1851 | * @throws Exception |
||
1852 | * @return Worksheet |
||
1853 | */ |
||
1854 | public function protectCellsByColumnAndRow($pColumn1 = 0, $pRow1 = 1, $pColumn2 = 0, $pRow2 = 1, $pPassword = '', $pAlreadyHashed = false) |
||
1860 | |||
1861 | /** |
||
1862 | * Remove protection on a cell range |
||
1863 | * |
||
1864 | * @param string $pRange Cell (e.g. A1) or cell range (e.g. A1:E1) |
||
1865 | * @throws Exception |
||
1866 | * @return Worksheet |
||
1867 | */ |
||
1868 | public function unprotectCells($pRange = 'A1') |
||
1881 | |||
1882 | /** |
||
1883 | * Remove protection on a cell range by using numeric cell coordinates |
||
1884 | * |
||
1885 | * @param int $pColumn1 Numeric column coordinate of the first cell |
||
1886 | * @param int $pRow1 Numeric row coordinate of the first cell |
||
1887 | * @param int $pColumn2 Numeric column coordinate of the last cell |
||
1888 | * @param int $pRow2 Numeric row coordinate of the last cell |
||
1889 | * @param string $pPassword Password to unlock the protection |
||
1890 | * @param bool $pAlreadyHashed If the password has already been hashed, set this to true |
||
1891 | * @throws Exception |
||
1892 | * @return Worksheet |
||
1893 | */ |
||
1894 | public function unprotectCellsByColumnAndRow($pColumn1 = 0, $pRow1 = 1, $pColumn2 = 0, $pRow2 = 1, $pPassword = '', $pAlreadyHashed = false) |
||
1900 | |||
1901 | /** |
||
1902 | * Get protected cells |
||
1903 | * |
||
1904 | * @return array[] |
||
1905 | */ |
||
1906 | public function getProtectedCells() |
||
1910 | |||
1911 | /** |
||
1912 | * Get Autofilter |
||
1913 | * |
||
1914 | * @return Worksheet\AutoFilter |
||
1915 | */ |
||
1916 | public function getAutoFilter() |
||
1920 | |||
1921 | /** |
||
1922 | * Set AutoFilter |
||
1923 | * |
||
1924 | * @param Worksheet\AutoFilter|string $pValue |
||
1925 | * A simple string containing a Cell range like 'A1:E10' is permitted for backward compatibility |
||
1926 | * @throws Exception |
||
1927 | * @return Worksheet |
||
1928 | */ |
||
1929 | public function setAutoFilter($pValue) |
||
1940 | |||
1941 | /** |
||
1942 | * Set Autofilter Range by using numeric cell coordinates |
||
1943 | * |
||
1944 | * @param int $pColumn1 Numeric column coordinate of the first cell |
||
1945 | * @param int $pRow1 Numeric row coordinate of the first cell |
||
1946 | * @param int $pColumn2 Numeric column coordinate of the second cell |
||
1947 | * @param int $pRow2 Numeric row coordinate of the second cell |
||
1948 | * @throws Exception |
||
1949 | * @return Worksheet |
||
1950 | */ |
||
1951 | public function setAutoFilterByColumnAndRow($pColumn1 = 0, $pRow1 = 1, $pColumn2 = 0, $pRow2 = 1) |
||
1959 | |||
1960 | /** |
||
1961 | * Remove autofilter |
||
1962 | * |
||
1963 | * @return Worksheet |
||
1964 | */ |
||
1965 | public function removeAutoFilter() |
||
1971 | |||
1972 | /** |
||
1973 | * Get Freeze Pane |
||
1974 | * |
||
1975 | * @return string |
||
1976 | */ |
||
1977 | public function getFreezePane() |
||
1981 | |||
1982 | /** |
||
1983 | * Freeze Pane |
||
1984 | * |
||
1985 | * @param string $pCell Cell (i.e. A2) |
||
1986 | * Examples: |
||
1987 | * A2 will freeze the rows above cell A2 (i.e row 1) |
||
1988 | * B1 will freeze the columns to the left of cell B1 (i.e column A) |
||
1989 | * B2 will freeze the rows above and to the left of cell A2 |
||
1990 | * (i.e row 1 and column A) |
||
1991 | * @throws Exception |
||
1992 | * @return Worksheet |
||
1993 | */ |
||
1994 | public function freezePane($pCell = '') |
||
2006 | |||
2007 | /** |
||
2008 | * Freeze Pane by using numeric cell coordinates |
||
2009 | * |
||
2010 | * @param int $pColumn Numeric column coordinate of the cell |
||
2011 | * @param int $pRow Numeric row coordinate of the cell |
||
2012 | * @throws Exception |
||
2013 | * @return Worksheet |
||
2014 | */ |
||
2015 | public function freezePaneByColumnAndRow($pColumn = 0, $pRow = 1) |
||
2019 | |||
2020 | /** |
||
2021 | * Unfreeze Pane |
||
2022 | * |
||
2023 | * @return Worksheet |
||
2024 | */ |
||
2025 | public function unfreezePane() |
||
2029 | |||
2030 | /** |
||
2031 | * Insert a new row, updating all possible related data |
||
2032 | * |
||
2033 | * @param int $pBefore Insert before this one |
||
2034 | * @param int $pNumRows Number of rows to insert |
||
2035 | * @throws Exception |
||
2036 | * @return Worksheet |
||
2037 | */ |
||
2038 | View Code Duplication | public function insertNewRowBefore($pBefore = 1, $pNumRows = 1) |
|
2049 | |||
2050 | /** |
||
2051 | * Insert a new column, updating all possible related data |
||
2052 | * |
||
2053 | * @param int $pBefore Insert before this one |
||
2054 | * @param int $pNumCols Number of columns to insert |
||
2055 | * @throws Exception |
||
2056 | * @return Worksheet |
||
2057 | */ |
||
2058 | View Code Duplication | public function insertNewColumnBefore($pBefore = 'A', $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) |
||
2074 | * @param int $pNumCols Number of columns to insert |
||
2075 | * @throws Exception |
||
2076 | * @return Worksheet |
||
2077 | */ |
||
2078 | public function insertNewColumnBeforeByIndex($pBefore = 0, $pNumCols = 1) |
||
2086 | |||
2087 | /** |
||
2088 | * Delete a row, updating all possible related data |
||
2089 | * |
||
2090 | * @param int $pRow Remove starting with this one |
||
2091 | * @param int $pNumRows Number of rows to remove |
||
2092 | * @throws Exception |
||
2093 | * @return Worksheet |
||
2094 | */ |
||
2095 | public function removeRow($pRow = 1, $pNumRows = 1) |
||
2111 | |||
2112 | /** |
||
2113 | * Remove a column, updating all possible related data |
||
2114 | * |
||
2115 | * @param string $pColumn Remove starting with this one |
||
2116 | * @param int $pNumCols Number of columns to remove |
||
2117 | * @throws Exception |
||
2118 | * @return Worksheet |
||
2119 | */ |
||
2120 | public function removeColumn($pColumn = 'A', $pNumCols = 1) |
||
2137 | |||
2138 | /** |
||
2139 | * Remove a column, updating all possible related data |
||
2140 | * |
||
2141 | * @param int $pColumn Remove starting with this one (numeric column coordinate of the cell) |
||
2142 | * @param int $pNumCols Number of columns to remove |
||
2143 | * @throws Exception |
||
2144 | * @return Worksheet |
||
2145 | */ |
||
2146 | public function removeColumnByIndex($pColumn = 0, $pNumCols = 1) |
||
2154 | |||
2155 | /** |
||
2156 | * Show gridlines? |
||
2157 | * |
||
2158 | * @return bool |
||
2159 | */ |
||
2160 | public function getShowGridlines() |
||
2164 | |||
2165 | /** |
||
2166 | * Set show gridlines |
||
2167 | * |
||
2168 | * @param bool $pValue Show gridlines (true/false) |
||
2169 | * @return Worksheet |
||
2170 | */ |
||
2171 | public function setShowGridlines($pValue = false) |
||
2177 | |||
2178 | /** |
||
2179 | * Print gridlines? |
||
2180 | * |
||
2181 | * @return bool |
||
2182 | */ |
||
2183 | public function getPrintGridlines() |
||
2187 | |||
2188 | /** |
||
2189 | * Set print gridlines |
||
2190 | * |
||
2191 | * @param bool $pValue Print gridlines (true/false) |
||
2192 | * @return Worksheet |
||
2193 | */ |
||
2194 | public function setPrintGridlines($pValue = false) |
||
2200 | |||
2201 | /** |
||
2202 | * Show row and column headers? |
||
2203 | * |
||
2204 | * @return bool |
||
2205 | */ |
||
2206 | public function getShowRowColHeaders() |
||
2210 | |||
2211 | /** |
||
2212 | * Set show row and column headers |
||
2213 | * |
||
2214 | * @param bool $pValue Show row and column headers (true/false) |
||
2215 | * @return Worksheet |
||
2216 | */ |
||
2217 | public function setShowRowColHeaders($pValue = false) |
||
2223 | |||
2224 | /** |
||
2225 | * Show summary below? (Row/Column outlining) |
||
2226 | * |
||
2227 | * @return bool |
||
2228 | */ |
||
2229 | public function getShowSummaryBelow() |
||
2233 | |||
2234 | /** |
||
2235 | * Set show summary below |
||
2236 | * |
||
2237 | * @param bool $pValue Show summary below (true/false) |
||
2238 | * @return Worksheet |
||
2239 | */ |
||
2240 | public function setShowSummaryBelow($pValue = true) |
||
2246 | |||
2247 | /** |
||
2248 | * Show summary right? (Row/Column outlining) |
||
2249 | * |
||
2250 | * @return bool |
||
2251 | */ |
||
2252 | public function getShowSummaryRight() |
||
2256 | |||
2257 | /** |
||
2258 | * Set show summary right |
||
2259 | * |
||
2260 | * @param bool $pValue Show summary right (true/false) |
||
2261 | * @return Worksheet |
||
2262 | */ |
||
2263 | public function setShowSummaryRight($pValue = true) |
||
2269 | |||
2270 | /** |
||
2271 | * Get comments |
||
2272 | * |
||
2273 | * @return Comment[] |
||
2274 | */ |
||
2275 | public function getComments() |
||
2279 | |||
2280 | /** |
||
2281 | * Set comments array for the entire sheet. |
||
2282 | * |
||
2283 | * @param array of Comment |
||
2284 | * @return Worksheet |
||
2285 | */ |
||
2286 | public function setComments($pValue = []) |
||
2292 | |||
2293 | /** |
||
2294 | * Get comment for cell |
||
2295 | * |
||
2296 | * @param string $pCellCoordinate Cell coordinate to get comment for |
||
2297 | * @throws Exception |
||
2298 | * @return Comment |
||
2299 | */ |
||
2300 | public function getComment($pCellCoordinate = 'A1') |
||
2324 | |||
2325 | /** |
||
2326 | * Get comment for cell by using numeric cell coordinates |
||
2327 | * |
||
2328 | * @param int $pColumn Numeric column coordinate of the cell |
||
2329 | * @param int $pRow Numeric row coordinate of the cell |
||
2330 | * @return Comment |
||
2331 | */ |
||
2332 | public function getCommentByColumnAndRow($pColumn = 0, $pRow = 1) |
||
2336 | |||
2337 | /** |
||
2338 | * Get selected cell |
||
2339 | * |
||
2340 | * @deprecated |
||
2341 | * @return string |
||
2342 | */ |
||
2343 | public function getSelectedCell() |
||
2347 | |||
2348 | /** |
||
2349 | * Get active cell |
||
2350 | * |
||
2351 | * @return string Example: 'A1' |
||
2352 | */ |
||
2353 | public function getActiveCell() |
||
2357 | |||
2358 | /** |
||
2359 | * Get selected cells |
||
2360 | * |
||
2361 | * @return string |
||
2362 | */ |
||
2363 | public function getSelectedCells() |
||
2367 | |||
2368 | /** |
||
2369 | * Selected cell |
||
2370 | * |
||
2371 | * @param string $pCoordinate Cell (i.e. A1) |
||
2372 | * @return Worksheet |
||
2373 | */ |
||
2374 | public function setSelectedCell($pCoordinate = 'A1') |
||
2378 | |||
2379 | /** |
||
2380 | * Select a range of cells. |
||
2381 | * |
||
2382 | * @param string $pCoordinate Cell range, examples: 'A1', 'B2:G5', 'A:C', '3:6' |
||
2383 | * @throws Exception |
||
2384 | * @return Worksheet |
||
2385 | */ |
||
2386 | public function setSelectedCells($pCoordinate = 'A1') |
||
2413 | |||
2414 | /** |
||
2415 | * Selected cell by using numeric cell coordinates |
||
2416 | * |
||
2417 | * @param int $pColumn Numeric column coordinate of the cell |
||
2418 | * @param int $pRow Numeric row coordinate of the cell |
||
2419 | * @throws Exception |
||
2420 | * @return Worksheet |
||
2421 | */ |
||
2422 | public function setSelectedCellByColumnAndRow($pColumn = 0, $pRow = 1) |
||
2426 | |||
2427 | /** |
||
2428 | * Get right-to-left |
||
2429 | * |
||
2430 | * @return bool |
||
2431 | */ |
||
2432 | public function getRightToLeft() |
||
2436 | |||
2437 | /** |
||
2438 | * Set right-to-left |
||
2439 | * |
||
2440 | * @param bool $value Right-to-left true/false |
||
2441 | * @return Worksheet |
||
2442 | */ |
||
2443 | public function setRightToLeft($value = false) |
||
2449 | |||
2450 | /** |
||
2451 | * Fill worksheet from values in array |
||
2452 | * |
||
2453 | * @param array $source Source array |
||
2454 | * @param mixed $nullValue Value in source array that stands for blank cell |
||
2455 | * @param string $startCell Insert array starting from this cell address as the top left coordinate |
||
2456 | * @param bool $strictNullComparison Apply strict comparison when testing for null values in the array |
||
2457 | * @throws Exception |
||
2458 | * @return Worksheet |
||
2459 | */ |
||
2460 | public function fromArray($source = null, $nullValue = null, $startCell = 'A1', $strictNullComparison = false) |
||
2496 | |||
2497 | /** |
||
2498 | * Create array from a range of cells |
||
2499 | * |
||
2500 | * @param string $pRange Range of cells (i.e. "A1:B10"), or just one cell (i.e. "A1") |
||
2501 | * @param mixed $nullValue Value returned in the array entry if a cell doesn't exist |
||
2502 | * @param bool $calculateFormulas Should formulas be calculated? |
||
2503 | * @param bool $formatData Should formatting be applied to cell values? |
||
2504 | * @param bool $returnCellRef False - Return a simple array of rows and columns indexed by number counting from zero |
||
2505 | * True - Return rows and columns indexed by their actual row and column IDs |
||
2506 | * @return array |
||
2507 | */ |
||
2508 | public function rangeToArray($pRange = 'A1', $nullValue = null, $calculateFormulas = true, $formatData = true, $returnCellRef = false) |
||
2565 | |||
2566 | /** |
||
2567 | * Create array from a range of cells |
||
2568 | * |
||
2569 | * @param string $pNamedRange Name of the Named Range |
||
2570 | * @param mixed $nullValue Value returned in the array entry if a cell doesn't exist |
||
2571 | * @param bool $calculateFormulas Should formulas be calculated? |
||
2572 | * @param bool $formatData Should formatting be applied to cell values? |
||
2573 | * @param bool $returnCellRef False - Return a simple array of rows and columns indexed by number counting from zero |
||
2574 | * True - Return rows and columns indexed by their actual row and column IDs |
||
2575 | * @throws Exception |
||
2576 | * @return array |
||
2577 | */ |
||
2578 | public function namedRangeToArray($pNamedRange = '', $nullValue = null, $calculateFormulas = true, $formatData = true, $returnCellRef = false) |
||
2590 | |||
2591 | /** |
||
2592 | * Create array from worksheet |
||
2593 | * |
||
2594 | * @param mixed $nullValue Value returned in the array entry if a cell doesn't exist |
||
2595 | * @param bool $calculateFormulas Should formulas be calculated? |
||
2596 | * @param bool $formatData Should formatting be applied to cell values? |
||
2597 | * @param bool $returnCellRef False - Return a simple array of rows and columns indexed by number counting from zero |
||
2598 | * True - Return rows and columns indexed by their actual row and column IDs |
||
2599 | * @return array |
||
2600 | */ |
||
2601 | public function toArray($nullValue = null, $calculateFormulas = true, $formatData = true, $returnCellRef = false) |
||
2612 | |||
2613 | /** |
||
2614 | * Get row iterator |
||
2615 | * |
||
2616 | * @param int $startRow The row number at which to start iterating |
||
2617 | * @param int $endRow The row number at which to stop iterating |
||
2618 | * |
||
2619 | * @return Worksheet\RowIterator |
||
2620 | */ |
||
2621 | public function getRowIterator($startRow = 1, $endRow = null) |
||
2625 | |||
2626 | /** |
||
2627 | * Get column iterator |
||
2628 | * |
||
2629 | * @param string $startColumn The column address at which to start iterating |
||
2630 | * @param string $endColumn The column address at which to stop iterating |
||
2631 | * |
||
2632 | * @return Worksheet\ColumnIterator |
||
2633 | */ |
||
2634 | public function getColumnIterator($startColumn = 'A', $endColumn = null) |
||
2638 | |||
2639 | /** |
||
2640 | * Run PhpSpreadsheet garabage collector. |
||
2641 | * |
||
2642 | * @return Worksheet |
||
2643 | */ |
||
2644 | public function garbageCollect() |
||
2675 | |||
2676 | /** |
||
2677 | * Get hash code |
||
2678 | * |
||
2679 | * @return string Hash code |
||
2680 | */ |
||
2681 | public function getHashCode() |
||
2690 | |||
2691 | /** |
||
2692 | * Extract worksheet title from range. |
||
2693 | * |
||
2694 | * Example: extractSheetTitle("testSheet!A1") ==> 'A1' |
||
2695 | * Example: extractSheetTitle("'testSheet 1'!A1", true) ==> array('testSheet 1', 'A1'); |
||
2696 | * |
||
2697 | * @param string $pRange Range to extract title from |
||
2698 | * @param bool $returnRange Return range? (see example) |
||
2699 | * @return mixed |
||
2700 | */ |
||
2701 | public static function extractSheetTitle($pRange, $returnRange = false) |
||
2714 | |||
2715 | /** |
||
2716 | * Get hyperlink |
||
2717 | * |
||
2718 | * @param string $pCellCoordinate Cell coordinate to get hyperlink for |
||
2719 | */ |
||
2720 | View Code Duplication | public function getHyperlink($pCellCoordinate = 'A1') |
|
2732 | |||
2733 | /** |
||
2734 | * Set hyperlnk |
||
2735 | * |
||
2736 | * @param string $pCellCoordinate Cell coordinate to insert hyperlink |
||
2737 | * @param Cell\Hyperlink $pHyperlink |
||
2738 | * @return Worksheet |
||
2739 | */ |
||
2740 | public function setHyperlink($pCellCoordinate = 'A1', Cell\Hyperlink $pHyperlink = null) |
||
2750 | |||
2751 | /** |
||
2752 | * Hyperlink at a specific coordinate exists? |
||
2753 | * |
||
2754 | * @param string $pCoordinate |
||
2755 | * @return bool |
||
2756 | */ |
||
2757 | public function hyperlinkExists($pCoordinate = 'A1') |
||
2761 | |||
2762 | /** |
||
2763 | * Get collection of hyperlinks |
||
2764 | * |
||
2765 | * @return Cell\Hyperlink[] |
||
2766 | */ |
||
2767 | public function getHyperlinkCollection() |
||
2771 | |||
2772 | /** |
||
2773 | * Get data validation |
||
2774 | * |
||
2775 | * @param string $pCellCoordinate Cell coordinate to get data validation for |
||
2776 | */ |
||
2777 | View Code Duplication | public function getDataValidation($pCellCoordinate = 'A1') |
|
2789 | |||
2790 | /** |
||
2791 | * Set data validation |
||
2792 | * |
||
2793 | * @param string $pCellCoordinate Cell coordinate to insert data validation |
||
2794 | * @param Cell\DataValidation $pDataValidation |
||
2795 | * @return Worksheet |
||
2796 | */ |
||
2797 | public function setDataValidation($pCellCoordinate = 'A1', Cell\DataValidation $pDataValidation = null) |
||
2807 | |||
2808 | /** |
||
2809 | * Data validation at a specific coordinate exists? |
||
2810 | * |
||
2811 | * @param string $pCoordinate |
||
2812 | * @return bool |
||
2813 | */ |
||
2814 | public function dataValidationExists($pCoordinate = 'A1') |
||
2818 | |||
2819 | /** |
||
2820 | * Get collection of data validations |
||
2821 | * |
||
2822 | * @return Cell\DataValidation[] |
||
2823 | */ |
||
2824 | public function getDataValidationCollection() |
||
2828 | |||
2829 | /** |
||
2830 | * Accepts a range, returning it as a range that falls within the current highest row and column of the worksheet |
||
2831 | * |
||
2832 | * @param string $range |
||
2833 | * @return string Adjusted range value |
||
2834 | */ |
||
2835 | public function shrinkRangeToFit($range) |
||
2864 | |||
2865 | /** |
||
2866 | * Get tab color |
||
2867 | * |
||
2868 | * @return Style\Color |
||
2869 | */ |
||
2870 | public function getTabColor() |
||
2878 | |||
2879 | /** |
||
2880 | * Reset tab color |
||
2881 | * |
||
2882 | * @return Worksheet |
||
2883 | */ |
||
2884 | public function resetTabColor() |
||
2891 | |||
2892 | /** |
||
2893 | * Tab color set? |
||
2894 | * |
||
2895 | * @return bool |
||
2896 | */ |
||
2897 | public function isTabColorSet() |
||
2901 | |||
2902 | /** |
||
2903 | * Copy worksheet (!= clone!) |
||
2904 | * |
||
2905 | * @return Worksheet |
||
2906 | */ |
||
2907 | public function copy() |
||
2913 | |||
2914 | /** |
||
2915 | * Implement PHP __clone to create a deep clone, not just a shallow copy. |
||
2916 | */ |
||
2917 | public function __clone() |
||
2942 | /** |
||
2943 | * Define the code name of the sheet |
||
2944 | * |
||
2945 | * @param null|string Same rule as Title minus space not allowed (but, like Excel, change silently space to underscore) |
||
2946 | * @throws Exception |
||
2947 | * @return objWorksheet |
||
2948 | */ |
||
2949 | public function setCodeName($pValue = null) |
||
2994 | 9 | /** |
|
2995 | * Return the code name of the sheet |
||
2996 | * |
||
2997 | * @return null|string |
||
2998 | */ |
||
2999 | public function getCodeName() |
||
3003 | 9 | /** |
|
3004 | * Sheet has a code name ? |
||
3005 | * @return bool |
||
3006 | */ |
||
3007 | public function hasCodeName() |
||
3011 | } |
||
3012 |
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..