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 |
||
5 | class Worksheet extends BIFFwriter |
||
6 | { |
||
7 | const BOF_TYPE = 0x0010; |
||
8 | |||
9 | const STATE_VISIBLE = 0x00; |
||
10 | const STATE_HIDDEN = 0x01; |
||
11 | const STATE_VERYHIDDEN = 0x02; |
||
12 | |||
13 | const TYPE_SHEET = 0x00; |
||
14 | |||
15 | /** |
||
16 | * Name of the Worksheet |
||
17 | * @var string |
||
18 | */ |
||
19 | protected $name; |
||
20 | |||
21 | /** |
||
22 | * Index for the Worksheet |
||
23 | * @var integer |
||
24 | */ |
||
25 | protected $index; |
||
26 | |||
27 | /** |
||
28 | * Reference to the (default) Format object for URLs |
||
29 | * @var Format |
||
30 | */ |
||
31 | protected $urlFormat; |
||
32 | |||
33 | /** |
||
34 | * Reference to the parser used for parsing formulas |
||
35 | * @var FormulaParser |
||
36 | */ |
||
37 | protected $formulaParser; |
||
38 | |||
39 | /** |
||
40 | * @var Range |
||
41 | */ |
||
42 | protected $dimensions; |
||
43 | |||
44 | /** |
||
45 | * Array containing format information for columns |
||
46 | * @var array |
||
47 | */ |
||
48 | protected $colInfo = array(); |
||
49 | |||
50 | /** |
||
51 | * Array containing format information for rows |
||
52 | * @var array |
||
53 | */ |
||
54 | protected $rowInfo = array(); |
||
55 | |||
56 | /** |
||
57 | * Range containing the selected area for the worksheet |
||
58 | * @var Range |
||
59 | */ |
||
60 | protected $selection = null; |
||
61 | |||
62 | /** |
||
63 | * Array containing the panes for the worksheet |
||
64 | * @var array |
||
65 | */ |
||
66 | protected $panes = array(); |
||
67 | |||
68 | /** |
||
69 | * The active pane for the worksheet |
||
70 | * @var integer |
||
71 | */ |
||
72 | protected $activePane = 3; |
||
73 | |||
74 | /** |
||
75 | * Bit specifying if panes are frozen |
||
76 | * @var integer |
||
77 | */ |
||
78 | protected $frozen = 0; |
||
79 | |||
80 | /** |
||
81 | * Bit specifying if the worksheet is selected |
||
82 | * @var integer |
||
83 | */ |
||
84 | protected $selected = 0; |
||
85 | |||
86 | /** |
||
87 | * Whether to display RightToLeft. |
||
88 | * @var integer |
||
89 | */ |
||
90 | protected $rtl = 0; |
||
91 | |||
92 | /** |
||
93 | * Whether to use outline. |
||
94 | * @var bool |
||
95 | */ |
||
96 | protected $outlineOn = true; |
||
97 | |||
98 | /** |
||
99 | * Auto outline styles. |
||
100 | * @var bool |
||
101 | */ |
||
102 | protected $outlineStyle = false; |
||
103 | |||
104 | /** |
||
105 | * Whether to have outline summary below. |
||
106 | * @var bool |
||
107 | */ |
||
108 | protected $outlineBelow = true; |
||
109 | |||
110 | /** |
||
111 | * Whether to have outline summary at the right. |
||
112 | * @var bool |
||
113 | */ |
||
114 | protected $outlineRight = true; |
||
115 | |||
116 | /** |
||
117 | * Outline row level. |
||
118 | * @var integer |
||
119 | */ |
||
120 | protected $outlineRowLevel = 0; |
||
121 | |||
122 | /** |
||
123 | * @var SharedStringsTable |
||
124 | */ |
||
125 | protected $sst; |
||
126 | |||
127 | /** |
||
128 | * @var Workbook |
||
129 | */ |
||
130 | protected $workbook; |
||
131 | |||
132 | /** |
||
133 | * Merged cell ranges |
||
134 | * @var array |
||
135 | */ |
||
136 | protected $mergedRanges = array(); |
||
137 | |||
138 | protected $protect = 0; |
||
139 | protected $password = null; |
||
140 | |||
141 | protected $validations = array(); |
||
142 | |||
143 | /** |
||
144 | * Holds last OBJ record id |
||
145 | * @var int |
||
146 | */ |
||
147 | protected $lastObjectId = 0; |
||
148 | |||
149 | protected $drawings = array(); |
||
150 | |||
151 | /** |
||
152 | * @var PrintSetup |
||
153 | */ |
||
154 | protected $printSetup; |
||
155 | |||
156 | protected $screenGridLines = true; |
||
157 | |||
158 | /** |
||
159 | * @var float |
||
160 | */ |
||
161 | protected $zoom = 100; |
||
162 | |||
163 | /** |
||
164 | * Constructor |
||
165 | * |
||
166 | * @param string $name The name of the new worksheet |
||
167 | * @param integer $index The index of the new worksheet |
||
168 | * @param Workbook $workbook Parent workbook |
||
169 | * @param SharedStringsTable $sst Workbook's shared strings table |
||
170 | * @param Format $urlFormat The default format for hyperlinks |
||
171 | * @param FormulaParser $formulaParser The formula parser created for the Workbook |
||
172 | */ |
||
173 | public function __construct( |
||
192 | |||
193 | /** |
||
194 | * Add data to the beginning of the workbook (note the reverse order) |
||
195 | * and to the end of the workbook. |
||
196 | * |
||
197 | * @see Workbook::save() |
||
198 | * |
||
199 | */ |
||
200 | public function close() |
||
231 | |||
232 | /** |
||
233 | * Retrieve the worksheet name. |
||
234 | * This is usefull when creating worksheets without a name. |
||
235 | * |
||
236 | * @return string The worksheet's name |
||
237 | */ |
||
238 | public function getName() |
||
242 | |||
243 | /** |
||
244 | * Retrieves data from memory in one chunk |
||
245 | * |
||
246 | * @return string The data |
||
247 | */ |
||
248 | public function getData() |
||
252 | |||
253 | /** |
||
254 | * Set this worksheet as a selected worksheet, |
||
255 | * i.e. the worksheet has its tab highlighted. |
||
256 | * |
||
257 | */ |
||
258 | public function select() |
||
262 | |||
263 | /** |
||
264 | * |
||
265 | */ |
||
266 | public function unselect() |
||
270 | |||
271 | /** |
||
272 | * Set this worksheet as the active worksheet, |
||
273 | * i.e. the worksheet that is displayed when the workbook is opened. |
||
274 | * Also set it as selected. |
||
275 | * |
||
276 | */ |
||
277 | public function activate() |
||
281 | |||
282 | /** |
||
283 | * Set this worksheet as the first visible sheet. |
||
284 | * This is necessary when there are a large number of worksheets and the |
||
285 | * activated worksheet is not visible on the screen. |
||
286 | * |
||
287 | */ |
||
288 | public function setFirstSheet() |
||
292 | |||
293 | /** |
||
294 | * Set the worksheet protection flag |
||
295 | * to prevent accidental modification and to |
||
296 | * hide formulas if the locked and hidden format properties have been set. |
||
297 | * |
||
298 | * @param string $password The password to use for protecting the sheet. |
||
299 | */ |
||
300 | public function protect($password) |
||
305 | |||
306 | /** |
||
307 | * Set the width of a single column |
||
308 | * |
||
309 | * @param integer $col Column index |
||
310 | * @param integer $width width to set |
||
311 | * @param mixed $format The optional XF format to apply to the columns |
||
312 | */ |
||
313 | public function setColumnWidth($col, $width, $format = null) |
||
324 | |||
325 | /** |
||
326 | * This method is used to set the height and format for a row. |
||
327 | * @param integer $row The row to set |
||
328 | * @param integer $height Height we are giving to the row. |
||
329 | * Use null to set XF without setting height |
||
330 | * @param mixed $format XF format we are giving to the row |
||
331 | */ |
||
332 | public function setRowHeight($row, $height, $format = null) |
||
342 | |||
343 | /** |
||
344 | * Set which cell or cells are selected in a worksheet |
||
345 | * |
||
346 | * @param integer $firstRow first row in the selected quadrant |
||
347 | * @param integer $firstColumn first column in the selected quadrant |
||
348 | * @param integer $lastRow last row in the selected quadrant |
||
349 | * @param integer $lastColumn last column in the selected quadrant |
||
350 | */ |
||
351 | public function setSelection($firstRow, $firstColumn, $lastRow = null, $lastColumn = null) |
||
355 | |||
356 | /** |
||
357 | * Set panes and mark them as frozen. |
||
358 | * |
||
359 | * @param array $panes This is the only parameter received and is composed of the following: |
||
360 | * 0 => Vertical split position, |
||
361 | * 1 => Horizontal split position |
||
362 | * 2 => Top row visible |
||
363 | * 3 => Leftmost column visible |
||
364 | * 4 => Active pane |
||
365 | */ |
||
366 | public function freezePanes($panes) |
||
380 | |||
381 | /** |
||
382 | * Set panes and mark them as unfrozen. |
||
383 | * |
||
384 | * @param array $panes This is the only parameter received and is composed of the following: |
||
385 | * 0 => Vertical split position, |
||
386 | * 1 => Horizontal split position |
||
387 | * 2 => Top row visible |
||
388 | * 3 => Leftmost column visible |
||
389 | * 4 => Active pane |
||
390 | */ |
||
391 | public function thawPanes($panes) |
||
412 | |||
413 | protected function setPanes($panes) |
||
423 | |||
424 | /** |
||
425 | * Writes the Excel BIFF PANE record. |
||
426 | * The panes can either be frozen or thawed (unfrozen). |
||
427 | * Frozen panes are specified in terms of an integer number of rows and columns. |
||
428 | * Thawed panes are specified in terms of Excel's units for rows and columns. |
||
429 | */ |
||
430 | protected function storePanes() |
||
438 | |||
439 | /** |
||
440 | * Determine which pane should be active. There is also the undocumented |
||
441 | * option to override this should it be necessary: may be removed later. |
||
442 | * @param $x |
||
443 | * @param $y |
||
444 | * |
||
445 | * @return int|null |
||
446 | */ |
||
447 | protected function calculateActivePane($x, $y) |
||
461 | |||
462 | /** |
||
463 | * Write value to cell |
||
464 | * |
||
465 | * @param integer $row The row of the cell we are writing to |
||
466 | * @param integer $col The column of the cell we are writing to |
||
467 | * @param mixed $value What we are writing |
||
468 | * @param mixed $format The optional format to apply to the cell |
||
469 | * |
||
470 | */ |
||
471 | public function write($row, $col, $value, $format = null) |
||
483 | |||
484 | /** |
||
485 | * @param $value |
||
486 | * |
||
487 | * @return bool |
||
488 | */ |
||
489 | protected function looksLikeNumber($value) |
||
493 | |||
494 | /** |
||
495 | * @param $value |
||
496 | * |
||
497 | * @return bool |
||
498 | */ |
||
499 | protected function looksLikeFormula($value) |
||
503 | |||
504 | /** |
||
505 | * @param $value |
||
506 | * |
||
507 | * @return bool |
||
508 | */ |
||
509 | protected function looksLikeUrl($value) |
||
515 | |||
516 | /** |
||
517 | * Write an array of values as a row |
||
518 | * @param integer $row The row we are writing to |
||
519 | * @param integer $col The first col (leftmost col) we are writing to |
||
520 | * @param array $val The array of values to write |
||
521 | * @param mixed $format The optional format to apply to the cell |
||
522 | * @throws \Exception |
||
523 | */ |
||
524 | public function writeRow($row, $col, $val, $format = null) |
||
539 | |||
540 | /** |
||
541 | * Write an array of values as a column |
||
542 | * @param integer $row The first row (uppermost row) we are writing to |
||
543 | * @param integer $col The col we are writing to |
||
544 | * @param array $val The array of values to write |
||
545 | * @param mixed $format The optional format to apply to the cell |
||
546 | * @throws \Exception |
||
547 | */ |
||
548 | public function writeCol($row, $col, $val, $format = null) |
||
559 | |||
560 | /** |
||
561 | * This method sets the properties for outlining and grouping. The defaults |
||
562 | * correspond to Excel's defaults. |
||
563 | * |
||
564 | * @param bool $visible |
||
565 | * @param bool $symbolsBelow |
||
566 | * @param bool $symbolsRight |
||
567 | * @param bool $autoStyle |
||
568 | */ |
||
569 | public function setOutline( |
||
580 | |||
581 | /** |
||
582 | * This method sets the worksheet direction to right-to-left (RTL) |
||
583 | * |
||
584 | * @param bool $rtl |
||
585 | */ |
||
586 | public function setRTL($rtl = true) |
||
590 | |||
591 | /** |
||
592 | * Write a double to the specified row and column (zero indexed). |
||
593 | * An integer can be written as a double. Excel will display an |
||
594 | * integer. $format is optional. |
||
595 | * |
||
596 | * @param integer $row Zero indexed row |
||
597 | * @param integer $col Zero indexed column |
||
598 | * @param float $num The number to write |
||
599 | * @param mixed $format The optional XF format |
||
600 | */ |
||
601 | public function writeNumber($row, $col, $num, $format = null) |
||
607 | |||
608 | /** |
||
609 | * Write a string to the specified row and column (zero indexed). |
||
610 | * NOTE: there is an Excel 5 defined limit of 255 characters. |
||
611 | * $format is optional. |
||
612 | * @param integer $row Zero indexed row |
||
613 | * @param integer $col Zero indexed column |
||
614 | * @param string $str The string to write |
||
615 | * @param mixed $format The XF format for the cell |
||
616 | */ |
||
617 | public function writeString($row, $col, $str, $format = null) |
||
628 | |||
629 | /** |
||
630 | * Write a string to the specified row and column (zero indexed). |
||
631 | * @param integer $row Zero indexed row |
||
632 | * @param integer $col Zero indexed column |
||
633 | * @param string $str The string to write |
||
634 | * @param mixed $format The XF format for the cell |
||
635 | */ |
||
636 | protected function writeStringSST($row, $col, $str, $format = null) |
||
650 | |||
651 | /** |
||
652 | * Check row and col before writing to a cell, and update the sheet's |
||
653 | * dimensions accordingly |
||
654 | * @param integer $row Zero indexed row |
||
655 | * @param integer $col Zero indexed column |
||
656 | * @return Cell |
||
657 | */ |
||
658 | protected function addCell($row, $col) |
||
666 | |||
667 | /** |
||
668 | * Writes a note associated with the cell given by the row and column. |
||
669 | * NOTE records don't have a length limit. |
||
670 | * @param integer $row Zero indexed row |
||
671 | * @param integer $col Zero indexed column |
||
672 | * @param string $note The note to write |
||
673 | * @param string $guid comment guid (only for tests) |
||
674 | */ |
||
675 | public function writeNote($row, $col, $note, $guid = null) |
||
696 | |||
697 | /** |
||
698 | * Write a blank cell to the specified row and column (zero indexed). |
||
699 | * A blank cell is used to specify formatting without adding a string |
||
700 | * or a number. |
||
701 | * |
||
702 | * A blank cell without a format serves no purpose. Therefore, we don't write |
||
703 | * a BLANK record unless a format is specified. |
||
704 | * |
||
705 | * @param integer $row Zero indexed row |
||
706 | * @param integer $col Zero indexed column |
||
707 | * @param mixed $format The XF format |
||
708 | * @throws \Exception |
||
709 | */ |
||
710 | public function writeBlank($row, $col, $format = null) |
||
721 | |||
722 | /** |
||
723 | * Write a formula to the specified row and column (zero indexed). |
||
724 | * The textual representation of the formula is passed to the formula parser |
||
725 | * which returns a packed binary string. |
||
726 | * |
||
727 | * @param integer $row Zero indexed row |
||
728 | * @param integer $col Zero indexed column |
||
729 | * @param string $formula The formula text string |
||
730 | * @param mixed $format The optional XF format |
||
731 | * @throws \Exception |
||
732 | */ |
||
733 | public function writeFormula($row, $col, $formula, $format = null) |
||
748 | |||
749 | /** |
||
750 | * Write a hyperlink. |
||
751 | * This is comprised of two elements: the visible label and |
||
752 | * the invisible link. The visible label is the same as the link unless an |
||
753 | * alternative string is specified. The label is written using the |
||
754 | * writeString() method. Therefore the 255 characters string limit applies. |
||
755 | * $string and $format are optional. |
||
756 | * |
||
757 | * The hyperlink can be to a http, ftp, mail, internal sheet (not yet), or external |
||
758 | * directory url. |
||
759 | * |
||
760 | * @param integer $row Row |
||
761 | * @param integer $col Column |
||
762 | * @param string $url URL string |
||
763 | * @param string $label Alternative label |
||
764 | * @param mixed $format The cell format |
||
765 | */ |
||
766 | public function writeUrl($row, $col, $url, $label = '', $format = null) |
||
786 | |||
787 | /** |
||
788 | * Used to write http, ftp and mailto hyperlinks. |
||
789 | * @param Range $range Cell range |
||
790 | * @param string $url URL string |
||
791 | * @param string $str Alternative label |
||
792 | * @param mixed $format The cell format |
||
793 | */ |
||
794 | protected function writeUrlWeb(Range $range, $url, $str, $format = null) |
||
799 | |||
800 | /** |
||
801 | * Used to write internal reference hyperlinks such as "Sheet1!A1". |
||
802 | * |
||
803 | * @param Range $range Cell range |
||
804 | * @param string $url URL string |
||
805 | * @param string $label Alternative label |
||
806 | * @param mixed $format The cell format |
||
807 | */ |
||
808 | View Code Duplication | protected function writeUrlInternal(Range $range, $url, $label, $format = null) |
|
820 | |||
821 | /** |
||
822 | * Write links to external directory names such as 'c:\foo.xls', |
||
823 | * c:\foo.xls#Sheet1!A1', '../../foo.xls'. and '../../foo.xls#Sheet1!A1'. |
||
824 | * |
||
825 | * @param Range $range Cell range |
||
826 | * @param string $url URL string |
||
827 | * @param string $label Alternative label |
||
828 | * @param mixed $format The cell format |
||
829 | */ |
||
830 | View Code Duplication | protected function writeUrlExternal(Range $range, $url, $label, $format = null) |
|
839 | |||
840 | /** |
||
841 | * @param Cell $cell |
||
842 | * @param string $url |
||
843 | * @param string $str |
||
844 | * @param null $format |
||
845 | */ |
||
846 | protected function writeUrlLabel(Cell $cell, $url, $str, $format = null) |
||
858 | |||
859 | /** |
||
860 | * Writes Excel DIMENSIONS to define the area in which there is data. |
||
861 | * @throw \Exception |
||
862 | */ |
||
863 | protected function storeDimensions() |
||
867 | |||
868 | /** |
||
869 | * Append the COLINFO and ROW records if they exist |
||
870 | */ |
||
871 | protected function storeColsAndRowsInfo() |
||
883 | |||
884 | /** |
||
885 | * Store the MERGECELLS record for all ranges of merged cells |
||
886 | */ |
||
887 | protected function storeMergedCells() |
||
893 | |||
894 | /** |
||
895 | * Store the margins records |
||
896 | */ |
||
897 | protected function storeMargins() |
||
906 | |||
907 | protected function storeHeaderAndFooter() |
||
914 | |||
915 | /** |
||
916 | * |
||
917 | */ |
||
918 | protected function storeCentering() |
||
925 | |||
926 | /** |
||
927 | * Merges the area given by its arguments. |
||
928 | * @param integer $firstRow First row of the area to merge |
||
929 | * @param integer $firstCol First column of the area to merge |
||
930 | * @param integer $lastRow Last row of the area to merge |
||
931 | * @param integer $lastCol Last column of the area to merge |
||
932 | */ |
||
933 | public function mergeCells($firstRow, $firstCol, $lastRow, $lastCol) |
||
938 | |||
939 | /** |
||
940 | * Write the PRINTHEADERS BIFF record. |
||
941 | */ |
||
942 | protected function storePrintHeaders() |
||
947 | |||
948 | /** |
||
949 | * Write the PRINTGRIDLINES BIFF record. Must be used in conjunction with the |
||
950 | * GRIDSET record. |
||
951 | */ |
||
952 | protected function storeGrid() |
||
958 | |||
959 | /** |
||
960 | * |
||
961 | */ |
||
962 | protected function storePageBreaks() |
||
976 | |||
977 | /** |
||
978 | * Write sheet protection |
||
979 | */ |
||
980 | protected function storeProtection() |
||
992 | |||
993 | /** |
||
994 | * Insert a 24bit bitmap image in a worksheet. |
||
995 | * |
||
996 | * @param integer $row The row we are going to insert the bitmap into |
||
997 | * @param integer $col The column we are going to insert the bitmap into |
||
998 | * @param string $path The bitmap filename |
||
999 | * @param integer $x The horizontal position (offset) of the image inside the cell. |
||
1000 | * @param integer $y The vertical position (offset) of the image inside the cell. |
||
1001 | * @param integer $scaleX The horizontal scale |
||
1002 | * @param integer $scaleY The vertical scale |
||
1003 | */ |
||
1004 | public function insertBitmap($row, $col, $path, $x = 0, $y = 0, $scaleX = 1, $scaleY = 1) |
||
1023 | |||
1024 | /** |
||
1025 | * Calculate the vertices that define the position of the image as required by |
||
1026 | * the OBJ record. |
||
1027 | * |
||
1028 | * +------------+------------+ |
||
1029 | * | A | B | |
||
1030 | * +-----+------------+------------+ |
||
1031 | * | |(x1,y1) | | |
||
1032 | * | 1 |(A1)._______|______ | |
||
1033 | * | | | | | |
||
1034 | * | | | | | |
||
1035 | * +-----+----| BITMAP |-----+ |
||
1036 | * | | | | | |
||
1037 | * | 2 | |______________. | |
||
1038 | * | | | (B2)| |
||
1039 | * | | | (x2,y2)| |
||
1040 | * +---- +------------+------------+ |
||
1041 | * |
||
1042 | * Example of a bitmap that covers some of the area from cell A1 to cell B2. |
||
1043 | * |
||
1044 | * Based on the width and height of the bitmap we need to calculate 8 vars: |
||
1045 | * $col_start, $row_start, $col_end, $row_end, $x1, $y1, $x2, $y2. |
||
1046 | * The width and height of the cells are also variable and have to be taken into |
||
1047 | * account. |
||
1048 | * The values of $col_start and $row_start are passed in from the calling |
||
1049 | * function. The values of $col_end and $row_end are calculated by subtracting |
||
1050 | * the width and height of the bitmap from the width and height of the |
||
1051 | * underlying cells. |
||
1052 | * The vertices are expressed as a percentage of the underlying cell width as |
||
1053 | * follows (rhs values are in pixels): |
||
1054 | * |
||
1055 | * x1 = X / W *1024 |
||
1056 | * y1 = Y / H *256 |
||
1057 | * x2 = (X-1) / W *1024 |
||
1058 | * y2 = (Y-1) / H *256 |
||
1059 | * |
||
1060 | * Where: X is distance from the left side of the underlying cell |
||
1061 | * Y is distance from the top of the underlying cell |
||
1062 | * W is the width of the cell |
||
1063 | * H is the height of the cell |
||
1064 | * |
||
1065 | * |
||
1066 | * @note the SDK incorrectly states that the height should be expressed as a |
||
1067 | * percentage of 1024. |
||
1068 | * |
||
1069 | * @param integer $colStart Col containing upper left corner of object |
||
1070 | * @param integer $rowStart Row containing top left corner of object |
||
1071 | * @param integer $x1 Distance to left side of object |
||
1072 | * @param integer $y1 Distance to top of object |
||
1073 | * @param integer $width Width of image frame |
||
1074 | * @param integer $height Height of image frame |
||
1075 | * @throws \Exception |
||
1076 | */ |
||
1077 | protected function positionImage($colStart, $rowStart, $x1, $y1, $width, $height) |
||
1135 | |||
1136 | /** |
||
1137 | * Convert the width of a cell from user's units to pixels. By interpolation |
||
1138 | * the relationship is: y = 7x +5. If the width hasn't been set by the user we |
||
1139 | * use the default value. If the col is hidden we use a value of zero. |
||
1140 | * |
||
1141 | * |
||
1142 | * @param integer $col The column |
||
1143 | * @return integer The width in pixels |
||
1144 | */ |
||
1145 | protected function getColWidth($col) |
||
1159 | |||
1160 | /** |
||
1161 | * Convert the height of a cell from user's units to pixels. By interpolation |
||
1162 | * the relationship is: y = 4/3x. If the height hasn't been set by the user we |
||
1163 | * use the default value. If the row is hidden we use a value of zero. (Not |
||
1164 | * possible to hide row yet). |
||
1165 | * |
||
1166 | * |
||
1167 | * @param integer $row The row |
||
1168 | * @return integer The width in pixels |
||
1169 | */ |
||
1170 | protected function getRowHeight($row) |
||
1184 | |||
1185 | /** |
||
1186 | * Store the window zoom factor. This should be a reduced fraction but for |
||
1187 | * simplicity we will store all fractions with a numerator of 100. |
||
1188 | */ |
||
1189 | protected function storeZoom() |
||
1199 | |||
1200 | /** |
||
1201 | * @param $row1 |
||
1202 | * @param $col1 |
||
1203 | * @param $row2 |
||
1204 | * @param $col2 |
||
1205 | * @param Validator $validator |
||
1206 | */ |
||
1207 | public function setValidation($row1, $col1, $row2, $col2, $validator) |
||
1212 | |||
1213 | /** |
||
1214 | * Store the DVAL and DV records. |
||
1215 | */ |
||
1216 | protected function storeDataValidity() |
||
1228 | |||
1229 | /** |
||
1230 | * @return bool |
||
1231 | */ |
||
1232 | public function isSelected() |
||
1236 | |||
1237 | /** |
||
1238 | * @return bool |
||
1239 | */ |
||
1240 | public function isFrozen() |
||
1244 | |||
1245 | /** |
||
1246 | * @return bool |
||
1247 | */ |
||
1248 | public function isRtl() |
||
1252 | |||
1253 | /** |
||
1254 | * @return int |
||
1255 | */ |
||
1256 | public function getIndex() |
||
1260 | |||
1261 | /** |
||
1262 | * @return integer |
||
1263 | */ |
||
1264 | protected function getNewObjectId() |
||
1270 | |||
1271 | /** |
||
1272 | * @return array |
||
1273 | */ |
||
1274 | public function getDrawings() |
||
1278 | |||
1279 | /** |
||
1280 | * @return bool |
||
1281 | */ |
||
1282 | public function isOutlineOn() |
||
1286 | |||
1287 | /** |
||
1288 | * @return boolean |
||
1289 | */ |
||
1290 | public function getOutlineStyle() |
||
1294 | |||
1295 | /** |
||
1296 | * @return boolean |
||
1297 | */ |
||
1298 | public function getOutlineBelow() |
||
1302 | |||
1303 | /** |
||
1304 | * @return boolean |
||
1305 | */ |
||
1306 | public function getOutlineRight() |
||
1310 | |||
1311 | /** |
||
1312 | * @return PrintSetup |
||
1313 | */ |
||
1314 | public function getPrintSetup() |
||
1318 | |||
1319 | /** |
||
1320 | * Set the option to hide gridlines on the worksheet (as seen on the screen). |
||
1321 | * |
||
1322 | * @param bool $visible |
||
1323 | * |
||
1324 | * @return Worksheet |
||
1325 | */ |
||
1326 | public function showGridlines($visible = true) |
||
1332 | |||
1333 | /** |
||
1334 | * Set the worksheet zoom factor. |
||
1335 | * |
||
1336 | * @param integer $percents The zoom factor |
||
1337 | * |
||
1338 | * @throws \Exception |
||
1339 | * @return Worksheet |
||
1340 | */ |
||
1341 | public function setZoom($percents = 100) |
||
1352 | |||
1353 | /** |
||
1354 | * @return bool |
||
1355 | */ |
||
1356 | public function areGridLinesVisible() |
||
1360 | |||
1361 | /** |
||
1362 | * @return float |
||
1363 | */ |
||
1364 | public function getZoom() |
||
1368 | } |
||
1369 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.