1 | <?php |
||
9 | class Writer |
||
10 | { |
||
11 | /** |
||
12 | * @var SheetFile |
||
13 | */ |
||
14 | private $sheetFile; |
||
15 | |||
16 | /** |
||
17 | * @var Styler |
||
18 | */ |
||
19 | private $styler; |
||
20 | |||
21 | /** |
||
22 | * @var Sheet |
||
23 | */ |
||
24 | private $sheet; |
||
25 | |||
26 | /** |
||
27 | * @var Workbook |
||
28 | */ |
||
29 | private $workbook; |
||
30 | |||
31 | /** |
||
32 | * @var resource |
||
33 | */ |
||
34 | private $output; |
||
35 | |||
36 | /** |
||
37 | * If a $fontsDirectory is supplied it will be scanned for usable ttf/otf fonts |
||
38 | * to be used for cell auto-sizing. Keep in mind though - viewers of an excel |
||
39 | 11 | * file have to have that font on their machine. XLSX does not embed fonts! |
|
40 | * |
||
41 | 11 | * @param string|null $fontsDirectory |
|
42 | 11 | * @throws \Exception |
|
43 | 11 | */ |
|
44 | 11 | public function __construct($fontsDirectory = null) |
|
52 | 1 | ||
53 | /** |
||
54 | 1 | * All cells _above_ this cell (e.g. A2) will be frozen/fixed. |
|
55 | 1 | * |
|
56 | * @param string $cellId |
||
57 | */ |
||
58 | public function setFreezePaneCellId($cellId) |
||
62 | |||
63 | /** |
||
64 | * Set the range of rows to repeat at the top of each page when printing the |
||
65 | * excel file. $startRow=1 and $endRow=1 will repeat the first row only. |
||
66 | 1 | * |
|
67 | * @param int $startRow |
||
68 | 1 | * @param int $endRow |
|
69 | 1 | */ |
|
70 | public function setPrintTitleRange($startRow, $endRow) |
||
74 | |||
75 | /** |
||
76 | * Set fixed column widths per cell (no ranges) and array index |
||
77 | 1 | * 0 being the first column. |
|
78 | * If used alongside cell autosizing, these should be set |
||
79 | 1 | * after the last row has been added. |
|
80 | 1 | * |
|
81 | * @param array $columnWidths |
||
82 | * @throws \InvalidArgumentException |
||
83 | */ |
||
84 | public function setFixedColumnWidths(array $columnWidths) |
||
88 | |||
89 | 3 | /** |
|
90 | 3 | * Set lower and/or upper limits for column widths. |
|
91 | * |
||
92 | * @param float|null $minWidth |
||
93 | * @param float|null $maxWidth |
||
94 | */ |
||
95 | public function setColumnWidthLimits($minWidth = null, $maxWidth = null) |
||
99 | |||
100 | 1 | /** |
|
101 | 1 | * Start recording row specs for column auto-sizing. |
|
102 | * |
||
103 | * @return Writer |
||
104 | */ |
||
105 | public function enableCellAutosizing() |
||
110 | |||
111 | 4 | /** |
|
112 | * Stop recording row specs for column autosizing. |
||
113 | 4 | * |
|
114 | 1 | * @return Writer |
|
115 | */ |
||
116 | public function disableCellAutosizing() |
||
121 | |||
122 | /** |
||
123 | * Add multiple rows at once. |
||
124 | * |
||
125 | * @param array|\Traversable $rows |
||
126 | * @param Style $style |
||
127 | * @throws \InvalidArgumentException |
||
128 | 4 | */ |
|
129 | public function addRows($rows, Style $style = null) |
||
139 | |||
140 | /** |
||
141 | * Add a single new row to the sheet and supply an optional style. |
||
142 | 3 | * |
|
143 | * @param array $row |
||
144 | 3 | * @param Style $style |
|
145 | 3 | */ |
|
146 | 3 | public function addRow(array $row, Style $style = null) |
|
154 | 1 | ||
155 | /** |
||
156 | 1 | * Wrap things up and write xlsx. |
|
157 | 1 | * |
|
158 | 1 | * @param string $fileName |
|
159 | 1 | */ |
|
160 | 1 | public function writeToFile($fileName = 'report.xlsx') |
|
166 | |||
167 | 1 | /** |
|
168 | * Wrap things up and send xlsx to browser. |
||
169 | 1 | * |
|
170 | * @param string $fileName |
||
171 | */ |
||
172 | public function writeToBrowser($fileName = 'report.xlsx') |
||
179 | |||
180 | /** |
||
181 | * Send headers for browser output. |
||
182 | 1 | * |
|
183 | * @param string $fileName |
||
184 | 1 | */ |
|
185 | private function sendHeaders($fileName) |
||
194 | |||
195 | /** |
||
196 | * Return array of available fonts & paths as key value pairs. |
||
197 | * |
||
198 | * @return array |
||
199 | */ |
||
200 | public function getFonts() |
||
204 | } |
||
205 |