1 | <?php |
||
14 | class Writer |
||
15 | { |
||
16 | /** |
||
17 | * @var SheetFile |
||
18 | */ |
||
19 | private $sheetFile; |
||
20 | |||
21 | /** |
||
22 | * @var Styler |
||
23 | */ |
||
24 | private $styler; |
||
25 | |||
26 | /** |
||
27 | * @var Sheet |
||
28 | */ |
||
29 | private $sheet; |
||
30 | |||
31 | /** |
||
32 | * @var resource |
||
33 | */ |
||
34 | private $output; |
||
35 | |||
36 | /** |
||
37 | * If no $fontsDirectory is supplied, the operating systems default |
||
38 | * will be used (e.g. /usr/share/fonts or C:/Windows/Fonts). |
||
39 | * |
||
40 | * @param string|null $fontsDirectory |
||
41 | */ |
||
42 | 7 | public function __construct($fontsDirectory = null) |
|
49 | |||
50 | /** |
||
51 | * All cells _above_ this cell will be frozen/fixed. |
||
52 | * |
||
53 | * @param string $cellId |
||
54 | */ |
||
55 | 1 | public function setFreezePaneCellId($cellId) |
|
59 | |||
60 | /** |
||
61 | * Set fixed column widths per cell (no ranges) and array index |
||
62 | * 0 being the first column. |
||
63 | * If used alongside cell autosizing, these should be set |
||
64 | * after the last row has been added. |
||
65 | * |
||
66 | * @param array $columnWidths |
||
67 | * @throws \InvalidArgumentException |
||
68 | */ |
||
69 | 1 | public function setFixedColumnWidths(array $columnWidths) |
|
73 | |||
74 | /** |
||
75 | * Set lower and/or upper limits for column widths. |
||
76 | * |
||
77 | * @param float|null $minWidth |
||
78 | * @param float|null $maxWidth |
||
79 | */ |
||
80 | 1 | public function setColumnWidthLimits($minWidth = null, $maxWidth = null) |
|
84 | |||
85 | /** |
||
86 | * Start recording row specs for column autosizing. |
||
87 | * |
||
88 | * @return Writer |
||
89 | */ |
||
90 | 3 | public function enableCellAutosizing() |
|
95 | |||
96 | /** |
||
97 | * Stop recording row specs for column autosizing. |
||
98 | * |
||
99 | * @return Writer |
||
100 | */ |
||
101 | 1 | public function disableCellAutosizing() |
|
106 | |||
107 | /** |
||
108 | * Add multiple rows at once. |
||
109 | * |
||
110 | * @param array $rows |
||
111 | * @param Style $style |
||
112 | * @throws \InvalidArgumentException |
||
113 | */ |
||
114 | 2 | public function addRows(array $rows, Style $style = null) |
|
124 | |||
125 | /** |
||
126 | * Add a single new row to the sheet and supply an optional style. |
||
127 | * |
||
128 | * @param array $row |
||
129 | * @param Style $style |
||
130 | */ |
||
131 | 1 | public function addRow(array $row, Style $style = null) |
|
139 | |||
140 | /** |
||
141 | * Wrap things up and write xlsx. |
||
142 | * |
||
143 | * @param string $fileName |
||
144 | */ |
||
145 | 1 | public function writeToFile($fileName = 'report.xlsx') |
|
151 | |||
152 | /** |
||
153 | * Wrap things up and send xlsx to browser. |
||
154 | * |
||
155 | * @param string $fileName |
||
156 | */ |
||
157 | public function writeToBrowser($fileName = 'report.xlsx') |
||
164 | |||
165 | /** |
||
166 | * Send headers for browser output. |
||
167 | * |
||
168 | * @param string $fileName |
||
169 | */ |
||
170 | private function sendHeaders($fileName) |
||
177 | |||
178 | /** |
||
179 | * Return array of available fonts & paths as key value pairs. |
||
180 | * |
||
181 | * @return array |
||
182 | */ |
||
183 | public function getFonts() |
||
187 | } |
||
188 |