1 | <?php |
||
14 | class Sheet |
||
15 | { |
||
16 | /** |
||
17 | * @var CellBuilder |
||
18 | */ |
||
19 | private $cellBuilder; |
||
20 | |||
21 | /** |
||
22 | * @var WidthCalculator |
||
23 | */ |
||
24 | private $widthCalculator; |
||
25 | |||
26 | /** |
||
27 | * @var bool |
||
28 | */ |
||
29 | private $useCellAutosizing = false; |
||
30 | |||
31 | /** |
||
32 | * Track next row index. |
||
33 | * |
||
34 | * @var int |
||
35 | */ |
||
36 | private $rowIndex = 1; |
||
37 | |||
38 | /** |
||
39 | * Holds width/column count of the widest row. |
||
40 | * |
||
41 | * @var int |
||
42 | */ |
||
43 | private $maxRowWidth; |
||
44 | |||
45 | /** |
||
46 | * Holds widths of the widest cells for column sizing. |
||
47 | * |
||
48 | * @var array |
||
49 | */ |
||
50 | private $columnWidths; |
||
51 | |||
52 | /** |
||
53 | * Sheet constructor. |
||
54 | */ |
||
55 | 5 | public function __construct() |
|
60 | |||
61 | /** |
||
62 | * Enable cell autosizing (~30% performance hit!). |
||
63 | */ |
||
64 | 3 | public function enableCellAutosizing() |
|
68 | |||
69 | /** |
||
70 | * Disable cell autosizing (default). |
||
71 | */ |
||
72 | 1 | public function disableCellAutosizing() |
|
76 | |||
77 | /** |
||
78 | * @return bool |
||
79 | */ |
||
80 | 2 | public function isCellAutosizingEnabled() |
|
84 | |||
85 | /** |
||
86 | * Return array containing all column widths. |
||
87 | * |
||
88 | * @return array |
||
89 | */ |
||
90 | 1 | public function getColumnWidths() |
|
94 | |||
95 | /** |
||
96 | * Return cellId for dimensions. |
||
97 | * |
||
98 | * @return string |
||
99 | */ |
||
100 | 1 | public function getDimensionUpperBound() |
|
104 | |||
105 | /** |
||
106 | * Add single row and style to sheet. |
||
107 | * |
||
108 | * @param array $row |
||
109 | * @param Style $style |
||
110 | * |
||
111 | * @return string |
||
112 | */ |
||
113 | 2 | public function addRow(array $row, Style $style) |
|
128 | |||
129 | /** |
||
130 | * Track widest row for dimensions xml (e.g. A1:K123). |
||
131 | * |
||
132 | * @param int $rowWidth |
||
133 | */ |
||
134 | 2 | private function updateMaxRowWidth($rowWidth) |
|
140 | |||
141 | /** |
||
142 | * Get xml string for single cell and update cell widths. |
||
143 | * |
||
144 | * @param array $row |
||
145 | * @param Style $style |
||
146 | * @return string |
||
147 | */ |
||
148 | 2 | private function getCellXml(array $row, Style $style) |
|
162 | |||
163 | /** |
||
164 | * Track cell width for column width sizing. |
||
165 | * |
||
166 | * @param mixed $value |
||
167 | * @param int $cellIndex |
||
168 | * @param Style $style |
||
169 | */ |
||
170 | 2 | private function updateColumnWidths($value, $cellIndex, Style $style) |
|
180 | } |
||
181 |