1 | <?php |
||
21 | class WorksheetManager implements WorksheetManagerInterface |
||
22 | { |
||
23 | /** @var \Box\Spout\Common\Helper\Escaper\ODS Strings escaper */ |
||
24 | private $stringsEscaper; |
||
25 | |||
26 | /** @var StringHelper String helper */ |
||
27 | private $stringHelper; |
||
28 | |||
29 | /** @var StyleManager Manages styles */ |
||
30 | private $styleManager; |
||
31 | |||
32 | /** @var StyleMerger Helper to merge styles together */ |
||
33 | private $styleMerger; |
||
34 | |||
35 | /** |
||
36 | * WorksheetManager constructor. |
||
37 | * |
||
38 | * @param StyleManager $styleManager |
||
39 | * @param StyleMerger $styleMerger |
||
40 | * @param ODSEscaper $stringsEscaper |
||
41 | * @param StringHelper $stringHelper |
||
42 | */ |
||
43 | 38 | public function __construct( |
|
54 | |||
55 | /** |
||
56 | * Prepares the worksheet to accept data |
||
57 | * |
||
58 | * @param Worksheet $worksheet The worksheet to start |
||
59 | * @throws \Box\Spout\Common\Exception\IOException If the sheet data file cannot be opened for writing |
||
60 | * @return void |
||
61 | */ |
||
62 | 38 | public function startSheet(Worksheet $worksheet) |
|
69 | |||
70 | /** |
||
71 | * Checks if the sheet has been sucessfully created. Throws an exception if not. |
||
72 | * |
||
73 | * @param bool|resource $sheetFilePointer Pointer to the sheet data file or FALSE if unable to open the file |
||
74 | * @throws IOException If the sheet data file cannot be opened for writing |
||
75 | * @return void |
||
76 | */ |
||
77 | 38 | private function throwIfSheetFilePointerIsNotAvailable($sheetFilePointer) |
|
83 | |||
84 | /** |
||
85 | * Returns the table XML root node as string. |
||
86 | * |
||
87 | * @param Worksheet $worksheet |
||
88 | * @return string <table> node as string |
||
89 | */ |
||
90 | 35 | public function getTableElementStartAsString(Worksheet $worksheet) |
|
101 | |||
102 | /** |
||
103 | * Adds a row to the given worksheet. |
||
104 | * |
||
105 | * @param Worksheet $worksheet The worksheet to add the row to |
||
106 | * @param Row $row The row to be added |
||
107 | * @throws IOException If the data cannot be written |
||
108 | * @throws InvalidArgumentException If a cell value's type is not supported |
||
109 | * @return void |
||
110 | */ |
||
111 | 33 | public function addRow(Worksheet $worksheet, Row $row) |
|
146 | |||
147 | /** |
||
148 | * Applies styles to the given style, merging the cell's style with its row's style |
||
149 | * Then builds and returns xml for the cell. |
||
150 | * |
||
151 | * @param Cell $cell |
||
152 | * @param Style $rowStyle |
||
153 | * @param int $currentCellIndex |
||
154 | * @param int $nextCellIndex |
||
155 | * @throws InvalidArgumentException If a cell value's type is not supported |
||
156 | * @return string |
||
157 | */ |
||
158 | 33 | private function applyStyleAndGetCellXML(Cell $cell, Style $rowStyle, $currentCellIndex, $nextCellIndex) |
|
172 | |||
173 | /** |
||
174 | * Returns the cell XML content, given its value. |
||
175 | * |
||
176 | * @param Cell $cell The cell to be written |
||
177 | * @param int $styleIndex Index of the used style |
||
178 | * @param int $numTimesValueRepeated Number of times the value is consecutively repeated |
||
179 | * @throws InvalidArgumentException If a cell value's type is not supported |
||
180 | * @return string The cell XML content |
||
181 | */ |
||
182 | 33 | private function getCellXML(Cell $cell, $styleIndex, $numTimesValueRepeated) |
|
220 | |||
221 | /** |
||
222 | * Closes the worksheet |
||
223 | * |
||
224 | * @param Worksheet $worksheet |
||
225 | * @return void |
||
226 | */ |
||
227 | 35 | public function close(Worksheet $worksheet) |
|
237 | } |
||
238 |