1 | <?php |
||
15 | class Sheet |
||
16 | { |
||
17 | /** |
||
18 | * @var CellBuilder |
||
19 | */ |
||
20 | private $cellBuilder; |
||
21 | |||
22 | /** |
||
23 | * @var WidthCalculator |
||
24 | */ |
||
25 | private $widthCalculator; |
||
26 | |||
27 | /** |
||
28 | * @var bool |
||
29 | */ |
||
30 | private $useCellAutosizing = false; |
||
31 | |||
32 | /** |
||
33 | * @var int |
||
34 | */ |
||
35 | private $freezePaneId; |
||
36 | |||
37 | /** |
||
38 | * Track next row index. |
||
39 | * |
||
40 | * @var int |
||
41 | */ |
||
42 | private $rowIndex = 1; |
||
43 | |||
44 | /** |
||
45 | * Holds width/column count of the widest row. |
||
46 | * |
||
47 | * @var int |
||
48 | */ |
||
49 | private $maxRowWidth; |
||
50 | |||
51 | /** |
||
52 | * Holds widths of the widest cells for column sizing. |
||
53 | * |
||
54 | * @var array |
||
55 | */ |
||
56 | private $columnWidths = array(); |
||
57 | |||
58 | /** |
||
59 | * Sheet constructor. |
||
60 | */ |
||
61 | 9 | public function __construct() |
|
66 | |||
67 | /** |
||
68 | * Enable cell autosizing (~30% performance hit!). |
||
69 | */ |
||
70 | 3 | public function enableCellAutosizing() |
|
74 | |||
75 | /** |
||
76 | * Disable cell autosizing (default). |
||
77 | */ |
||
78 | 1 | public function disableCellAutosizing() |
|
82 | |||
83 | /** |
||
84 | * Set custom column widths with 0 beeing the the first. |
||
85 | * |
||
86 | * @param array $columnWidths |
||
87 | * @throws \InvalidArgumentException |
||
88 | */ |
||
89 | 3 | public function setFixedColumnWidths(array $columnWidths) |
|
99 | |||
100 | /** |
||
101 | * Return array containing all column widths. |
||
102 | * |
||
103 | * @return array |
||
104 | */ |
||
105 | 4 | public function getColumnWidths() |
|
109 | |||
110 | /** |
||
111 | * Return cellId for dimensions. |
||
112 | * |
||
113 | * @return string |
||
114 | */ |
||
115 | 1 | public function getDimensionUpperBound() |
|
119 | |||
120 | /** |
||
121 | * Add single row and style to sheet. |
||
122 | * |
||
123 | * @param array $row |
||
124 | * @param Style $style |
||
125 | * |
||
126 | * @return string |
||
127 | */ |
||
128 | 4 | public function addRow(array $row, Style $style) |
|
143 | |||
144 | /** |
||
145 | * @param int $cellId |
||
146 | */ |
||
147 | 1 | public function setFreezePaneId($cellId) |
|
151 | |||
152 | /** |
||
153 | * Track widest row for dimensions xml (e.g. A1:K123). |
||
154 | * |
||
155 | * @param int $rowWidth |
||
156 | */ |
||
157 | 4 | private function updateMaxRowWidth($rowWidth) |
|
163 | |||
164 | /** |
||
165 | * Get xml string for single cell and update cell widths. |
||
166 | * |
||
167 | * @param array $row |
||
168 | * @param Style $style |
||
169 | * @return string |
||
170 | */ |
||
171 | 4 | private function getCellXml(array $row, Style $style) |
|
183 | |||
184 | /** |
||
185 | * Track cell width for column width sizing if its enabled. |
||
186 | * |
||
187 | * @param mixed $value |
||
188 | * @param int $cellIndex |
||
189 | * @param Style $style |
||
190 | */ |
||
191 | 4 | private function updateColumnWidths($value, $cellIndex, Style $style) |
|
202 | |||
203 | /** |
||
204 | * Return freeze pane xml string for sheetView. |
||
205 | * |
||
206 | * @return string |
||
207 | */ |
||
208 | 2 | public function getFreezePaneXml() |
|
217 | } |
||
218 |