1 | <?php |
||
15 | class Writer |
||
16 | { |
||
17 | /** |
||
18 | * @var SheetFile |
||
19 | */ |
||
20 | private $sheetFile; |
||
21 | |||
22 | /** |
||
23 | * @var Styler |
||
24 | */ |
||
25 | private $styler; |
||
26 | |||
27 | /** |
||
28 | * @var Sheet |
||
29 | */ |
||
30 | private $sheet; |
||
31 | |||
32 | /** |
||
33 | * @var |
||
34 | */ |
||
35 | private $output; |
||
36 | |||
37 | /** |
||
38 | * Writer constructor. |
||
39 | */ |
||
40 | 7 | public function __construct() |
|
44 | |||
45 | /** |
||
46 | * All cells _above_ this cell will be frozen/fixed. |
||
47 | * |
||
48 | * @param int $cellId |
||
49 | */ |
||
50 | 1 | public function setFreezePaneCellId($cellId) |
|
54 | |||
55 | /** |
||
56 | * Set fixed column widths per cell (no ranges) and array index |
||
57 | * 0 being the first column. |
||
58 | * If used alongside cell autosizing, these should be set |
||
59 | * after the last row has been added. |
||
60 | * |
||
61 | * @param array $columnWidths |
||
62 | * @throws \InvalidArgumentException |
||
63 | */ |
||
64 | 1 | public function setFixedColumnWidths(array $columnWidths) |
|
68 | |||
69 | /** |
||
70 | * Set lower and/or upper limits for column widths. |
||
71 | * |
||
72 | * @param float|null $minWidth |
||
73 | * @param float|null $maxWidth |
||
74 | */ |
||
75 | 1 | public function setColumnWidthLimits($minWidth = null, $maxWidth = null) |
|
79 | |||
80 | /** |
||
81 | * Start recording row specs for column autosizing. |
||
82 | * |
||
83 | * @return Writer |
||
84 | */ |
||
85 | 3 | public function enableCellAutosizing() |
|
90 | |||
91 | /** |
||
92 | * Stop recording row specs for column autosizing. |
||
93 | * |
||
94 | * @return Writer |
||
95 | */ |
||
96 | 1 | public function disableCellAutosizing() |
|
101 | |||
102 | /** |
||
103 | * Initialize writer defaults. |
||
104 | */ |
||
105 | 7 | private function initialize() |
|
112 | |||
113 | /** |
||
114 | * @param array $rows |
||
115 | * @param Style $style |
||
116 | * @throws \InvalidArgumentException |
||
117 | */ |
||
118 | 2 | public function addRows(array $rows, Style $style = null) |
|
128 | |||
129 | /** |
||
130 | * @param array $row |
||
131 | * @param Style $style |
||
132 | */ |
||
133 | 1 | public function addRow(array $row, Style $style = null) |
|
141 | |||
142 | /** |
||
143 | * Wrap things up and send xlsx to browser. |
||
144 | * |
||
145 | * @param string $fileName |
||
146 | */ |
||
147 | public function writeToBrowser($fileName = 'report.xlsx') |
||
154 | |||
155 | /** |
||
156 | * Wrap things up and write xlsx. |
||
157 | * |
||
158 | * @param string $fileName |
||
159 | */ |
||
160 | 1 | public function writeToFile($fileName = 'report.xlsx') |
|
166 | |||
167 | /** |
||
168 | * Output headers & content and unlink the xlsx file eventually. |
||
169 | * |
||
170 | * @param string $fileName |
||
171 | */ |
||
172 | private function sendHeaders($fileName) |
||
179 | } |
||
180 |